Magento 2 Documentation
2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
|
Public Member Functions | |
__construct (\Magento\Framework\View\Element\Context $context, array $data=[]) | |
getJsLayout () | |
getRequest () | |
getParentBlock () | |
setLayout (\Magento\Framework\View\LayoutInterface $layout) | |
getLayout () | |
setNameInLayout ($name) | |
getChildNames () | |
setAttribute ($name, $value=null) | |
setChild ($alias, $block) | |
addChild ($alias, $block, $data=[]) | |
unsetChild ($alias) | |
unsetCallChild ($alias, $callback, $result, $params) | |
unsetChildren () | |
getChildBlock ($alias) | |
getChildHtml ($alias='', $useCache=true) | |
getChildChildHtml ($alias, $childChildAlias='', $useCache=true) | |
getBlockHtml ($name) | |
insert ($element, $siblingName=0, $after=true, $alias='') | |
append ($element, $alias='') | |
getGroupChildNames ($groupName) | |
getChildData ($alias, $key='') | |
getUiId ($arg1=null, $arg2=null, $arg3=null, $arg4=null, $arg5=null) | |
getJsId ($arg1=null, $arg2=null, $arg3=null, $arg4=null, $arg5=null) | |
getUrl ($route='', $params=[]) | |
getViewFileUrl ($fileId, array $params=[]) | |
formatDate ( $date=null, $format=\IntlDateFormatter::SHORT, $showTime=false, $timezone=null) | |
formatTime ( $time=null, $format=\IntlDateFormatter::SHORT, $showDate=false) | |
getModuleName () | |
escapeHtml ($data, $allowedTags=null) | |
escapeJs ($string) | |
escapeHtmlAttr ($string, $escapeSingleQuote=true) | |
escapeCss ($string) | |
stripTags ($data, $allowableTags=null, $allowHtmlEntities=false) | |
escapeUrl ($string) | |
escapeXssInUrl ($data) | |
escapeQuote ($data, $addSlashes=false) | |
escapeJsQuote ($data, $quote='\'') | |
getNameInLayout () | |
getCacheKeyInfo () | |
getCacheKey () | |
getVar ($name, $module=null) | |
isScopePrivate () | |
![]() | |
__construct (array $data=[]) | |
addData (array $arr) | |
setData ($key, $value=null) | |
unsetData ($key=null) | |
getData ($key='', $index=null) | |
getDataByPath ($path) | |
getDataByKey ($key) | |
setDataUsingMethod ($key, $args=[]) | |
getDataUsingMethod ($key, $args=null) | |
hasData ($key='') | |
toArray (array $keys=[]) | |
convertToArray (array $keys=[]) | |
toXml (array $keys=[], $rootName='item', $addOpenTag=false, $addCdata=true) | |
convertToXml (array $arrAttributes=[], $rootName='item', $addOpenTag=false, $addCdata=true) | |
toJson (array $keys=[]) | |
convertToJson (array $keys=[]) | |
toString ($format='') | |
__call ($method, $args) | |
isEmpty () | |
serialize ($keys=[], $valueSeparator='=', $fieldSeparator=' ', $quote='"') | |
debug ($data=null, &$objects=[]) | |
offsetSet ($offset, $value) | |
offsetExists ($offset) | |
offsetUnset ($offset) | |
offsetGet ($offset) | |
![]() | |
toHtml () | |
Static Public Member Functions | |
static | extractModuleName ($className) |
Data Fields | |
const | CACHE_GROUP = \Magento\Framework\App\Cache\Type\Block::TYPE_IDENTIFIER |
const | CACHE_KEY_PREFIX = 'BLOCK_' |
Protected Member Functions | |
_construct () | |
_prepareLayout () | |
_beforeToHtml () | |
_afterToHtml ($html) | |
_toHtml () | |
_getNotFoundUrl ($route='', $params=['_direct'=> 'core/index/notFound']) | |
getCacheTags () | |
getCacheLifetime () | |
_loadCache () | |
_saveCache ($data) | |
_getSidPlaceholder ($cacheKey=null) | |
![]() | |
_getData ($key) | |
_underscore ($name) | |
Protected Attributes | |
$_design | |
$_session | |
$_sidResolver | |
$_nameInLayout | |
$_layout | |
$jsLayout = [] | |
$_request | |
$_urlBuilder | |
$_eventManager | |
$_frontController | |
$_assetRepo | |
$_viewConfig | |
$_cacheState | |
$_logger | |
$_escaper | |
$filterManager | |
$_localeDate | |
$inlineTranslation | |
$_isScopePrivate = false | |
$_scopeConfig | |
$_cache | |
![]() | |
$_data = [] | |
Additional Inherited Members | |
![]() | |
static | $_underscoreCache = [] |
Base class for all blocks.
Avoid inheriting from this class. Will be deprecated.
Marked as public API because it is actively used now.
@api @SuppressWarnings(PHPMD.ExcessivePublicCount) @SuppressWarnings(PHPMD.ExcessiveClassComplexity) @SuppressWarnings(PHPMD.CouplingBetweenObjects) @SuppressWarnings(PHPMD.TooManyFields) @SuppressWarnings(PHPMD.NumberOfChildren)
Definition at line 25 of file AbstractBlock.php.
__construct | ( | \Magento\Framework\View\Element\Context | $context, |
array | $data = [] |
||
) |
Constructor
\Magento\Framework\View\Element\Context | $context | |
array | $data |
Definition at line 185 of file AbstractBlock.php.
|
protected |
Processing block html after rendering
string | $html |
Definition at line 698 of file AbstractBlock.php.
|
protected |
Before rendering html, but after trying to load cache
Definition at line 639 of file AbstractBlock.php.
|
protected |
Internal constructor, that is called from real constructor
Please override this one instead of overriding real __construct constructor
Please override this one instead of overriding real __construct constructor
Definition at line 239 of file AbstractBlock.php.
|
protected |
Get 404 file not found url
string | $route | |
array | $params |
Definition at line 803 of file AbstractBlock.php.
|
protected |
Get SID placeholder for cache
null | string | $cacheKey |
Definition at line 1134 of file AbstractBlock.php.
|
protected |
Load block html from cache storage
Definition at line 1089 of file AbstractBlock.php.
|
protected |
Preparing global layout
You can redefine this method in child classes for changing layout
Definition at line 284 of file AbstractBlock.php.
|
protected |
Save block content to cache storage
string | $data |
Definition at line 1112 of file AbstractBlock.php.
|
protected |
Override this method in descendants to produce html
Definition at line 708 of file AbstractBlock.php.
addChild | ( | $alias, | |
$block, | |||
$data = [] |
|||
) |
Create block with name: {parent}.{alias} and set as child
string | $alias | |
string | $block | |
array | $data |
Definition at line 385 of file AbstractBlock.php.
append | ( | $element, | |
$alias = '' |
|||
) |
Append element to the end of children list
\Magento\Framework\View\Element\AbstractBlock | string | $element | |
string | $alias |
Definition at line 598 of file AbstractBlock.php.
escapeCss | ( | $string | ) |
Escape string for the CSS context
string | $string |
Definition at line 927 of file AbstractBlock.php.
escapeHtml | ( | $data, | |
$allowedTags = null |
|||
) |
Escape HTML entities
string | array | $data | |
array | null | $allowedTags |
Definition at line 890 of file AbstractBlock.php.
escapeHtmlAttr | ( | $string, | |
$escapeSingleQuote = true |
|||
) |
Escape a string for the HTML attribute context
string | $string | |
boolean | $escapeSingleQuote |
Definition at line 915 of file AbstractBlock.php.
escapeJs | ( | $string | ) |
Escape string for the JavaScript context
string | $string |
Definition at line 902 of file AbstractBlock.php.
escapeJsQuote | ( | $data, | |
$quote = '\'' |
|||
) |
Escape quotes in java scripts
string | array | $data | |
string | $quote |
Definition at line 994 of file AbstractBlock.php.
escapeQuote | ( | $data, | |
$addSlashes = false |
|||
) |
Escape quotes inside html attributes
Use $addSlashes = false for escaping js that inside html attribute (onClick, onSubmit etc)
string | $data | |
bool | $addSlashes |
Definition at line 981 of file AbstractBlock.php.
escapeUrl | ( | $string | ) |
escapeXssInUrl | ( | $data | ) |
Escape xss in urls
string | $data |
Definition at line 966 of file AbstractBlock.php.
|
static |
Extract module name from specified block class name
string | $className |
Definition at line 873 of file AbstractBlock.php.
formatDate | ( | $date = null , |
|
$format = \IntlDateFormatter::SHORT , |
|||
$showTime = false , |
|||
$timezone = null |
|||
) |
Retrieve formatting date
null | string | \DateTimeInterface | $date | |
int | $format | |
bool | $showTime | |
null | string | $timezone |
Definition at line 817 of file AbstractBlock.php.
formatTime | ( | $time = null , |
|
$format = \IntlDateFormatter::SHORT , |
|||
$showDate = false |
|||
) |
Retrieve formatting time
\DateTime | string | null | $time | |
int | $format | |
bool | $showDate |
Definition at line 841 of file AbstractBlock.php.
getBlockHtml | ( | $name | ) |
Retrieve block html
string | $name |
Definition at line 555 of file AbstractBlock.php.
getCacheKey | ( | ) |
Get Key for caching block content
don't prevent recalculation by saving generated cache key because of ability to render single block instance with different data
Definition at line 1026 of file AbstractBlock.php.
getCacheKeyInfo | ( | ) |
Get cache key informative items
Provide string array key to share specific info item with FPC placeholder
Definition at line 1016 of file AbstractBlock.php.
|
protected |
|
protected |
Get tags array for saving cache
Definition at line 1050 of file AbstractBlock.php.
getChildBlock | ( | $alias | ) |
Retrieve child block by name
string | $alias |
Definition at line 477 of file AbstractBlock.php.
getChildChildHtml | ( | $alias, | |
$childChildAlias = '' , |
|||
$useCache = true |
|||
) |
Render output of child child element
string | $alias | |
string | $childChildAlias | |
bool | $useCache |
Definition at line 527 of file AbstractBlock.php.
getChildData | ( | $alias, | |
$key = '' |
|||
) |
Get a value from child block by specified key
string | $alias | |
string | $key |
Definition at line 625 of file AbstractBlock.php.
getChildHtml | ( | $alias = '' , |
|
$useCache = true |
|||
) |
Retrieve child block HTML
string | $alias | |
boolean | $useCache |
Definition at line 497 of file AbstractBlock.php.
getChildNames | ( | ) |
Retrieves sorted list of child names
Definition at line 328 of file AbstractBlock.php.
getGroupChildNames | ( | $groupName | ) |
Get a group of child blocks
Returns an array of <alias> => <block> or an array of <alias> => <callback_result> The callback currently supports only $this methods and passes the alias as parameter
string | $groupName |
Definition at line 613 of file AbstractBlock.php.
getJsId | ( | $arg1 = null , |
|
$arg2 = null , |
|||
$arg3 = null , |
|||
$arg4 = null , |
|||
$arg5 = null |
|||
) |
Generate id for using in JavaScript UI
Function takes an arbitrary amount of parameters
string | null | $arg1 | |
string | null | $arg2 | |
string | null | $arg3 | |
string | null | $arg4 | |
string | null | $arg5 |
Definition at line 744 of file AbstractBlock.php.
getJsLayout | ( | ) |
Retrieve serialized JS layout configuration ready to use in template
Definition at line 217 of file AbstractBlock.php.
getLayout | ( | ) |
Retrieve layout object
Definition at line 295 of file AbstractBlock.php.
getModuleName | ( | ) |
getNameInLayout | ( | ) |
Get block name
Definition at line 1004 of file AbstractBlock.php.
getParentBlock | ( | ) |
Retrieve parent block
Definition at line 251 of file AbstractBlock.php.
getRequest | ( | ) |
Get request
Definition at line 227 of file AbstractBlock.php.
getUiId | ( | $arg1 = null , |
|
$arg2 = null , |
|||
$arg3 = null , |
|||
$arg4 = null , |
|||
$arg5 = null |
|||
) |
Retrieve data-ui-id attribute
Retrieve data-ui-id attribute which will distinguish link/input/container/anything else in template among others. Function takes an arbitrary amount of parameters.
string | null | $arg1 | |
string | null | $arg2 | |
string | null | $arg3 | |
string | null | $arg4 | |
string | null | $arg5 |
Definition at line 727 of file AbstractBlock.php.
getUrl | ( | $route = '' , |
|
$params = [] |
|||
) |
Generate url by route and parameters
string | $route | |
array | $params |
Definition at line 773 of file AbstractBlock.php.
getVar | ( | $name, | |
$module = null |
|||
) |
Get variable value from view configuration
Module name can be omitted. If omitted, it will be determined automatically.
string | $name | variable name |
string | null | $module | optional module name |
Definition at line 1152 of file AbstractBlock.php.
getViewFileUrl | ( | $fileId, | |
array | $params = [] |
||
) |
Retrieve url of a view file
string | $fileId | |
array | $params |
Definition at line 785 of file AbstractBlock.php.
insert | ( | $element, | |
$siblingName = 0 , |
|||
$after = true , |
|||
$alias = '' |
|||
) |
Insert child element into specified position
By default inserts as first element into children list
\Magento\Framework\View\Element\AbstractBlock | string | $element | |
string | int | null | $siblingName | |
bool | $after | |
string | $alias |
Definition at line 575 of file AbstractBlock.php.
isScopePrivate | ( | ) |
Determine if the block scope is private or public.
Returns true if scope is private, false otherwise
Definition at line 1165 of file AbstractBlock.php.
setAttribute | ( | $name, | |
$value = null |
|||
) |
Set block attribute value
Wrapper for method "setData"
string | $name | |
mixed | $value |
Definition at line 346 of file AbstractBlock.php.
setChild | ( | $alias, | |
$block | |||
) |
Set child block
string | $alias | |
\Magento\Framework\View\Element\AbstractBlock | string | $block |
Definition at line 358 of file AbstractBlock.php.
setLayout | ( | \Magento\Framework\View\LayoutInterface | $layout | ) |
Set layout object
\Magento\Framework\View\LayoutInterface | $layout |
Definition at line 270 of file AbstractBlock.php.
setNameInLayout | ( | $name | ) |
Sets/changes name of a block in layout
string | $name |
Definition at line 311 of file AbstractBlock.php.
stripTags | ( | $data, | |
$allowableTags = null , |
|||
$allowHtmlEntities = false |
|||
) |
Wrapper for standard strip_tags() function with extra functionality for html entities
string | $data | |
string | null | $allowableTags | |
bool | $allowHtmlEntities |
Definition at line 940 of file AbstractBlock.php.
unsetCallChild | ( | $alias, | |
$callback, | |||
$result, | |||
$params | |||
) |
Call a child and unset it, if callback matched result
Variable $params will pass to child callback $params may be array, if called from layout with elements with same name, for example: ...<foo>value_1</foo><foo>value_2</foo><foo>value_3</foo>
Or, if called like this: ...<foo>value_1</foo><bar>value_2</bar><baz>value_3</baz>
It is no difference anyway, because they will be transformed in appropriate way.
string | $alias | |
string | $callback | |
mixed | $result | |
array | $params |
Definition at line 431 of file AbstractBlock.php.
unsetChild | ( | $alias | ) |
Unset child block
string | $alias |
Definition at line 402 of file AbstractBlock.php.
unsetChildren | ( | ) |
Unset all children blocks
Definition at line 457 of file AbstractBlock.php.
|
protected |
Definition at line 113 of file AbstractBlock.php.
|
protected |
Definition at line 177 of file AbstractBlock.php.
|
protected |
Definition at line 127 of file AbstractBlock.php.
|
protected |
Definition at line 42 of file AbstractBlock.php.
|
protected |
Definition at line 141 of file AbstractBlock.php.
|
protected |
Definition at line 99 of file AbstractBlock.php.
|
protected |
Definition at line 106 of file AbstractBlock.php.
|
protected |
Definition at line 166 of file AbstractBlock.php.
|
protected |
Definition at line 70 of file AbstractBlock.php.
|
protected |
Definition at line 153 of file AbstractBlock.php.
|
protected |
Definition at line 134 of file AbstractBlock.php.
|
protected |
Definition at line 63 of file AbstractBlock.php.
|
protected |
Definition at line 84 of file AbstractBlock.php.
|
protected |
Definition at line 171 of file AbstractBlock.php.
|
protected |
Definition at line 49 of file AbstractBlock.php.
|
protected |
Definition at line 56 of file AbstractBlock.php.
|
protected |
Definition at line 91 of file AbstractBlock.php.
|
protected |
Definition at line 120 of file AbstractBlock.php.
|
protected |
Definition at line 148 of file AbstractBlock.php.
|
protected |
Definition at line 158 of file AbstractBlock.php.
|
protected |
Definition at line 77 of file AbstractBlock.php.
const CACHE_GROUP = \Magento\Framework\App\Cache\Type\Block::TYPE_IDENTIFIER |
Cache group Tag
Definition at line 30 of file AbstractBlock.php.
const CACHE_KEY_PREFIX = 'BLOCK_' |
Prefix for cache key of block
Definition at line 35 of file AbstractBlock.php.