ElggEntity::getIconURL PHP Method

getIconURL() public method

Plugins can register for the 'entity:icon:url', plugin hook to customize the icon for an entity.
Since: 1.8.0
public getIconURL ( mixed $params = [] ) : string
$params mixed A string defining the size of the icon (e.g. tiny, small, medium, large) or an array of parameters including 'size'
return string The URL
    public function getIconURL($params = array())
    {
        return _elgg_services()->iconService->getIconURL($this, $params);
    }

Usage Example

Example #1
0
 /**
  * Map column headers to a proper representation in the row cell
  * @param ElggEntity $entity
  * @param boolean $csv
  * @return array
  */
 public function getRowCells($entity)
 {
     $row = array();
     $headers = $this->getColumnHeaders();
     foreach ($headers as $header => $label) {
         $value = '';
         switch ($header) {
             default:
                 $value = $entity->{$header};
                 if (is_array($value)) {
                     $value = implode('; ', $value);
                 }
                 break;
             case 'guid':
                 $value = $entity->guid;
                 break;
             case 'icon':
                 $value = $entity->getIconURL();
                 if (!elgg_in_context('plaintext')) {
                     $value = elgg_view_entity_icon($entity, 'small');
                 }
                 break;
             case 'title':
                 $value = elgg_instanceof($entity, 'object') ? $entity->title : $entity->name;
                 if (!elgg_in_context('plaintext')) {
                     $value = elgg_view('output/url', array('text' => $value, 'href' => $entity->getURL()));
                 }
                 break;
             case 'time_created':
                 $value = date('M d, Y H:i', $entity->time_created);
                 break;
             case 'owner_guid':
                 $value = '';
                 $owner = $entity->getOwnerEntity();
                 if (elgg_instanceof($owner)) {
                     $value = $owner->guid;
                     if (!elgg_in_context('plaintext')) {
                         $value = elgg_view('output/url', array('text' => elgg_instanceof($owner, 'object') ? $owner->title : $owner->name, 'href' => $owner->getURL()));
                     }
                 }
                 break;
             case 'container_guid':
                 $value = '';
                 $container = $entity->getContainerEntity();
                 if (elgg_instanceof($container)) {
                     $value = $container->guid;
                     if (!elgg_in_context('plaintext')) {
                         $value = elgg_view('output/url', array('text' => elgg_instanceof($container, 'object') ? $container->title : $container->name, 'href' => $container->getURL()));
                     }
                 }
                 break;
         }
         $row[$header] = $value;
     }
     return elgg_trigger_plugin_hook('export:entity', 'table', array('headers' => $this->getColumnHeaders(), 'entity' => $entity), $row);
 }