Icon class is used to create icon objects which can be rendered as svg. Output will be html. Optionally, the icon can be rendered as a css background.
- Author
- Jan-Hendrik Willms tleil.nosp@m.ax+s.nosp@m.tudip.nosp@m.@gma.nosp@m.il.co.nosp@m.m
- Copyright
- Stud.IP Core Group GPL2 or any later version
- Since
- 3.2
◆ __construct()
Constructor of the object.
- Parameters
-
String | $shape | Shape of the icon, may contain a mixed definition like 'seminar' |
String | $role | Role of the icon, defaults to Icon::DEFAULT_ROLE |
Array | $attributes | Additional attributes like 'title'; only use semantic ones describing this icon regardless of its later rendering in a view |
◆ __toString()
Function to be called whenever the object is converted to string. Internally the same as calling Icon::asImg
- Returns
- String representation
◆ asCSS()
Renders the icon as a set of css background rules.
- Parameters
-
int | $size | Optional; Defines the size in px of the rendered icon |
- Returns
- String containing the html representation for css backgrounds
◆ asImagePath()
Returns a path to the SVG matching the icon.
- Returns
- String containing the html representation for css backgrounds
◆ asImg()
asImg |
( |
|
$size = null , |
|
|
|
$view_attributes = [] |
|
) |
| |
Renders the icon inside an img html tag.
- Parameters
-
int | $size | Optional; Defines the dimension in px of the rendered icon; FALSE prevents any width or height attributes |
Array | $view_attributes | Optional; Additional attributes to pass into the rendered output |
- Returns
- String containing the html representation for the icon.
◆ asInput()
asInput |
( |
|
$size = null , |
|
|
|
$view_attributes = [] |
|
) |
| |
Renders the icon inside an input html tag.
- Parameters
-
int | $size | Optional; Defines the dimension in px of the rendered icon; FALSE prevents any width or height attributes |
Array | $view_attributes | Optional; Additional attributes to pass into the rendered output |
- Returns
- String containing the html representation for the icon.
◆ colorToRoles()
static colorToRoles |
( |
|
$color | ) |
|
|
static |
◆ copyWithAttributes()
copyWithAttributes |
( |
|
$attributes | ) |
|
Returns a new Icon with new attributes
- Parameters
-
mixed | $attributes | New value of attributes |
- Returns
- Icon A new Icon with a new
attributes
◆ copyWithRole()
Returns a new Icon with a changed role
- Parameters
-
mixed | $role | New value of role |
- Returns
- Icon A new Icon with a new
role
◆ copyWithShape()
Returns a new Icon with a changed shape
- Parameters
-
mixed | $shape | New value of shape |
- Returns
- Icon A new Icon with a new
shape
◆ create()
Create a new Icon object.
This is just a factory method. You could easily just call the constructor instead.
- Parameters
-
String | $shape | Shape of the icon, may contain a mixed definition like 'seminar' |
String | $role | Role of the icon, defaults to Icon::DEFAULT_ROLE |
Array | $attributes | Additional attributes like 'title'; only use semantic ones describing this icon regardless of its later rendering in a view |
- Returns
- Icon object
◆ get_asset_svg()
Get the correct asset for an SVG icon.
- Returns
- String containing the url of the corresponding asset
◆ get_size()
Get the size of the icon. If a size was passed as a parameter and inside the attributes array during icon construction, the size from the attributes will be used.
- Parameters
-
- Returns
- int Size of the icon in pixels
◆ getAttributes()
Returns the semantic attributes
of this instance, e.g. the title of this Icon
- Returns
- Array the semantic attribiutes of the Icon
◆ getRole()
Returns the role
– the string describing the role of this instance.
- Returns
- String the role of this Icon
◆ getShape()
Returns the shape
– the string describing the shape of this instance.
- Returns
- String the shape of this Icon
◆ signalsAttention()
Returns whether this icon intends to signal attention.
- Returns
- bool
- Since
- Stud.IP 5.0
◆ $attributes
◆ $role
◆ $shape
◆ CSS_BACKGROUND
◆ DEFAULT_COLOR
const DEFAULT_COLOR = 'blue' |
◆ DEFAULT_ROLE
const DEFAULT_ROLE = 'clickable' |
◆ DEFAULT_SIZE
◆ INPUT
◆ ROLE_ACCEPT
const ROLE_ACCEPT = 'accept' |
◆ ROLE_ATTENTION
const ROLE_ATTENTION = 'attention' |
◆ ROLE_CLICKABLE
else ROLE_CLICKABLE = 'clickable' |
◆ ROLE_INACTIVE
else ROLE_INACTIVE = 'inactive' |
◆ ROLE_INFO
◆ ROLE_INFO_ALT
const ROLE_INFO_ALT = 'info_alt' |
◆ ROLE_NAVIGATION
const ROLE_NAVIGATION = 'navigation' |
◆ ROLE_NEW
◆ ROLE_SORT
◆ ROLE_STATUS_GREEN
default ROLE_STATUS_GREEN = 'status-green' |
◆ ROLE_STATUS_RED
case ROLE_STATUS_RED = 'status-red' |
◆ ROLE_STATUS_YELLOW
const ROLE_STATUS_YELLOW = 'status-yellow' |
◆ SVG
The documentation for this class was generated from the following files: