Elgg
Version master
|
Public Member Functions | |
__construct (protected Config $config, protected EventsService $events, protected EntityTable $entities, protected UploadService $uploads, protected ImageService $images, protected MimeTypeService $mimetype, protected HttpRequest $request) | |
Constructor. More... | |
saveIconFromUploadedFile (\ElggEntity $entity, string $input_name, string $type= 'icon', array $coords=[]) | |
Saves icons using an uploaded file as the source. More... | |
saveIconFromLocalFile (\ElggEntity $entity, string $filename, string $type= 'icon', array $coords=[]) | |
Saves icons using a local file as the source. More... | |
saveIconFromElggFile (\ElggEntity $entity,\ElggFile $file, string $type= 'icon', array $coords=[]) | |
Saves icons using a file located in the data store as the source. More... | |
saveIcon (\ElggEntity $entity,\ElggFile $file, string $type= 'icon', array $coords=[]) | |
Saves icons using a created temporary file. More... | |
getIcon (\ElggEntity $entity, string $size, string $type= 'icon', bool $generate=true) | |
Returns entity icon as an ElggIcon object The icon file may or may not exist on filestore. More... | |
deleteIcon (\ElggEntity $entity, string $type= 'icon', bool $retain_master=false) | |
Removes all icon files and metadata for the passed type of icon. More... | |
getIconURL (\ElggEntity $entity, string|array $params=[]) | |
Get the URL for this entity's icon. More... | |
getFallbackIconUrl (\ElggEntity $entity, array $params=[]) | |
Returns default/fallback icon. More... | |
getIconLastChange (\ElggEntity $entity, string $size, string $type= 'icon') | |
Returns the timestamp of when the icon was changed. More... | |
hasIcon (\ElggEntity $entity, string $size, string $type= 'icon') | |
Returns if the entity has an icon of the passed type. More... | |
getSizes (string $entity_type=null, string $entity_subtype=null, $type= 'icon') | |
Returns a configuration array of icon sizes. More... | |
Protected Member Functions | |
prepareIcon (string $filename) | |
Prepares an icon. More... | |
generateIcon (\ElggEntity $entity,\ElggFile $file, string $type= 'icon', array $coords=[], string $icon_size= '') | |
Generate an icon for the given entity. More... | |
detectCroppingCoordinates (string $input_name) | |
Automagicly detect cropping coordinates. More... | |
hasWebPSupport () | |
Checks if browser has WebP support and if the webserver is able to generate. More... | |
Entity icon service.
Definition at line 20 of file EntityIconService.php.
Elgg\EntityIconService::__construct | ( | protected Config | $config, |
protected EventsService | $events, | ||
protected EntityTable | $entities, | ||
protected UploadService | $uploads, | ||
protected ImageService | $images, | ||
protected MimeTypeService | $mimetype, | ||
protected HttpRequest | $request | ||
) |
Constructor.
Config | $config | Config |
EventsService | $events | Events service |
EntityTable | $entities | Entity table |
UploadService | $uploads | Upload service |
ImageService | $images | Image service |
MimeTypeService | $mimetype | MimeType service |
Request | $request | Http Request service |
Definition at line 36 of file EntityIconService.php.
Elgg\EntityIconService::deleteIcon | ( | \ElggEntity | $entity, |
string | $type = 'icon' , |
||
bool | $retain_master = false |
||
) |
Removes all icon files and metadata for the passed type of icon.
\ElggEntity | $entity | Entity that owns icons |
string | $type | The name of the icon. e.g., 'icon', 'cover_photo' |
bool | $retain_master | Keep the master icon (default: false) |
Definition at line 435 of file EntityIconService.php.
|
protected |
Automagicly detect cropping coordinates.
Based in the input names x1, x2, y1 and y2
string | $input_name | the file input name which is the prefix for the cropping coordinates |
Definition at line 658 of file EntityIconService.php.
|
protected |
Generate an icon for the given entity.
\ElggEntity | $entity | Temporary ElggFile instance |
\ElggFile | $file | Temporary ElggFile instance |
string | $type | The name of the icon. e.g., 'icon', 'cover_photo' |
array | $coords | An array of cropping coordinates x1, y1, x2, y2 |
string | $icon_size | The icon size to generate (leave empty to generate all supported sizes) |
Definition at line 286 of file EntityIconService.php.
Elgg\EntityIconService::getFallbackIconUrl | ( | \ElggEntity | $entity, |
array | $params = [] |
||
) |
Returns default/fallback icon.
\ElggEntity | $entity | Entity |
array | $params | Icon params |
Definition at line 540 of file EntityIconService.php.
Elgg\EntityIconService::getIcon | ( | \ElggEntity | $entity, |
string | $size, | ||
string | $type = 'icon' , |
||
bool | $generate = true |
||
) |
Returns entity icon as an ElggIcon object The icon file may or may not exist on filestore.
\ElggEntity | $entity | Entity that owns the icon |
string | $size | Size of the icon |
string | $type | The name of the icon. e.g., 'icon', 'cover_photo' |
bool | $generate | Try to generate an icon based on master if size doesn't exists |
UnexpectedValueException |
Definition at line 374 of file EntityIconService.php.
Elgg\EntityIconService::getIconLastChange | ( | \ElggEntity | $entity, |
string | $size, | ||
string | $type = 'icon' |
||
) |
Returns the timestamp of when the icon was changed.
\ElggEntity | $entity | Entity that owns the icon |
string | $size | The size of the icon |
string | $type | The name of the icon. e.g., 'icon', 'cover_photo' |
Definition at line 577 of file EntityIconService.php.
Elgg\EntityIconService::getIconURL | ( | \ElggEntity | $entity, |
string|array | $params = [] |
||
) |
Get the URL for this entity's icon.
Plugins can register for the 'entity:icon:url', <type> event to customize the icon for an entity.
\ElggEntity | $entity | Entity that owns the icon |
mixed | $params | A string defining the size of the icon (e.g. tiny, small, medium, large) or an array of parameters including 'size' |
Definition at line 498 of file EntityIconService.php.
Elgg\EntityIconService::getSizes | ( | string | $entity_type = null , |
string | $entity_subtype = null , |
||
$type = 'icon' |
|||
) |
Returns a configuration array of icon sizes.
string | $entity_type | Entity type |
string | $entity_subtype | Entity subtype |
string | $type | The name of the icon. e.g., 'icon', 'cover_photo' |
InvalidArgumentException |
Definition at line 610 of file EntityIconService.php.
Elgg\EntityIconService::hasIcon | ( | \ElggEntity | $entity, |
string | $size, | ||
string | $type = 'icon' |
||
) |
Returns if the entity has an icon of the passed type.
\ElggEntity | $entity | Entity that owns the icon |
string | $size | The size of the icon |
string | $type | The name of the icon. e.g., 'icon', 'cover_photo' |
Definition at line 595 of file EntityIconService.php.
|
protected |
Checks if browser has WebP support and if the webserver is able to generate.
Definition at line 692 of file EntityIconService.php.
|
protected |
Prepares an icon.
string | $filename | the file to prepare |
Definition at line 259 of file EntityIconService.php.
Elgg\EntityIconService::saveIcon | ( | \ElggEntity | $entity, |
\ElggFile | $file, | ||
string | $type = 'icon' , |
||
array | $coords = [] |
||
) |
Saves icons using a created temporary file.
\ElggEntity | $entity | Temporary ElggFile instance |
\ElggFile | $file | Temporary ElggFile instance |
string | $type | The name of the icon. e.g., 'icon', 'cover_photo' |
array | $coords | An array of cropping coordinates x1, y1, x2, y2 |
Definition at line 164 of file EntityIconService.php.
Elgg\EntityIconService::saveIconFromElggFile | ( | \ElggEntity | $entity, |
\ElggFile | $file, | ||
string | $type = 'icon' , |
||
array | $coords = [] |
||
) |
Saves icons using a file located in the data store as the source.
\ElggEntity | $entity | Entity to own the icons |
\ElggFile | $file | An ElggFile instance |
string | $type | The name of the icon. e.g., 'icon', 'cover_photo' |
array | $coords | An array of cropping coordinates x1, y1, x2, y2 |
InvalidArgumentException |
Definition at line 132 of file EntityIconService.php.
Elgg\EntityIconService::saveIconFromLocalFile | ( | \ElggEntity | $entity, |
string | $filename, | ||
string | $type = 'icon' , |
||
array | $coords = [] |
||
) |
Saves icons using a local file as the source.
\ElggEntity | $entity | Entity to own the icons |
string | $filename | The full path to the local file |
string | $type | The name of the icon. e.g., 'icon', 'cover_photo' |
array | $coords | An array of cropping coordinates x1, y1, x2, y2 |
InvalidArgumentException |
Definition at line 99 of file EntityIconService.php.
Elgg\EntityIconService::saveIconFromUploadedFile | ( | \ElggEntity | $entity, |
string | $input_name, | ||
string | $type = 'icon' , |
||
array | $coords = [] |
||
) |
Saves icons using an uploaded file as the source.
\ElggEntity | $entity | Entity to own the icons |
string | $input_name | Form input name |
string | $type | The name of the icon. e.g., 'icon', 'cover_photo' |
array | $coords | An array of cropping coordinates x1, y1, x2, y2 |
Definition at line 57 of file EntityIconService.php.