Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Protected Member Functions | Protected Attributes
Link Class Reference
Inheritance diagram for Link:
AbstractRenderer AbstractBlock RendererInterface AbstractBlock DataObject BlockInterface Activate

Public Member Functions

 __construct (\Magento\Backend\Block\Context $context, \Magento\Framework\Json\Helper\Data $jsonHelper, array $data=[])
 
 render (DataObject $row)
 
 isVisible ()
 
 isDisabled ()
 
 getUrlPattern ()
 
 getCaption ()
 
- Public Member Functions inherited from AbstractRenderer
 setColumn ($column)
 
 getColumn ()
 
 render (DataObject $row)
 
 renderExport (DataObject $row)
 
 _getInputValueElement (DataObject $row)
 
 renderHeader ()
 
 renderProperty ()
 
 renderCss ()
 
- Public Member Functions inherited from AbstractBlock
 __construct (\Magento\Backend\Block\Context $context, array $data=[])
 
- Public Member Functions inherited from AbstractBlock
 __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 ()
 
- Public Member Functions inherited from DataObject
 __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)
 
- Public Member Functions inherited from BlockInterface
 toHtml ()
 
- Public Member Functions inherited from RendererInterface
 render (\Magento\Framework\DataObject $row)
 

Protected Member Functions

 _getAttributesHtml ()
 
 _getDataAttributes ()
 
 _getUrl (DataObject $row)
 
- Protected Member Functions inherited from AbstractRenderer
 _getValue (DataObject $row)
 
 _getInputValue (DataObject $row)
 
- Protected Member Functions inherited from AbstractBlock
 _construct ()
 
 _prepareLayout ()
 
 _beforeToHtml ()
 
 _afterToHtml ($html)
 
 _toHtml ()
 
 _getNotFoundUrl ($route='', $params=['_direct'=> 'core/index/notFound'])
 
 getCacheTags ()
 
 getCacheLifetime ()
 
 _loadCache ()
 
 _saveCache ($data)
 
 _getSidPlaceholder ($cacheKey=null)
 
- Protected Member Functions inherited from DataObject
 _getData ($key)
 
 _underscore ($name)
 

Protected Attributes

 $_row
 
 $jsonHelper
 
- Protected Attributes inherited from AbstractRenderer
 $_defaultWidth
 
 $_column
 
- Protected Attributes inherited from AbstractBlock
 $_authorization
 
- Protected Attributes inherited from AbstractBlock
 $_design
 
 $_session
 
 $_sidResolver
 
 $_nameInLayout
 
 $_layout
 
 $jsLayout = []
 
 $_request
 
 $_urlBuilder
 
 $_eventManager
 
 $_frontController
 
 $_assetRepo
 
 $_viewConfig
 
 $_cacheState
 
 $_logger
 
 $_escaper
 
 $filterManager
 
 $_localeDate
 
 $inlineTranslation
 
 $_isScopePrivate = false
 
 $_scopeConfig
 
 $_cache
 
- Protected Attributes inherited from DataObject
 $_data = []
 

Additional Inherited Members

- Static Public Member Functions inherited from AbstractBlock
static extractModuleName ($className)
 
- Data Fields inherited from AbstractBlock
const CACHE_GROUP = \Magento\Framework\App\Cache\Type\Block::TYPE_IDENTIFIER
 
const CACHE_KEY_PREFIX = 'BLOCK_'
 
- Static Protected Attributes inherited from DataObject
static $_underscoreCache = []
 

Detailed Description

Definition at line 13 of file Link.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( \Magento\Backend\Block\Context  $context,
\Magento\Framework\Json\Helper\Data  $jsonHelper,
array  $data = [] 
)
Parameters
\Magento\Backend\Block\Context$context
\Magento\Framework\Json\Helper\Data$jsonHelper
array$data

Definition at line 30 of file Link.php.

34  {
35  $this->jsonHelper = $jsonHelper;
36  parent::__construct($context, $data);
37  }

Member Function Documentation

◆ _getAttributesHtml()

_getAttributesHtml ( )
protected

Return additional HTML parameters for tag, e.g. 'style'

Returns
string

Definition at line 115 of file Link.php.

116  {
117  $html = [];
118 
119  foreach ($this->_getAttributes() as $key => $value) {
120  if ($value === null || $value == '') {
121  continue;
122  }
123  $html[] = sprintf('%s="%s"', $key, $this->escapeHtmlAttr($value, false));
124  }
125 
126  return join(' ', $html);
127  }
$value
Definition: gender.phtml:16
escapeHtmlAttr($string, $escapeSingleQuote=true)

◆ _getDataAttributes()

_getDataAttributes ( )
protected

Return HTML data attributes, which treated in special manner:

  • prepended by "data-"
  • JSON-encoded if necessary
Returns
array

Definition at line 154 of file Link.php.

155  {
156  return [];
157  }

◆ _getUrl()

_getUrl ( DataObject  $row)
protected

Render URL for current item.

Parameters
\Magento\Framework\DataObject$row
Returns
string

Definition at line 165 of file Link.php.

◆ getCaption()

getCaption ( )

Caption for the link.

Returns
string

Definition at line 99 of file Link.php.

100  {
101  return $this->isDisabled() ? $this
102  ->getColumn()
103  ->getDisabledCaption() ?: $this
104  ->getColumn()
105  ->getCaption() : $this
106  ->getColumn()
107  ->getCaption();
108  }

◆ getUrlPattern()

getUrlPattern ( )

Return URL pattern for action associated with the link e.g. "(star)(slash)(star)(slash)activate" -> will be translated to http://.../admin/integration/activate/id/X

Returns
string

Definition at line 89 of file Link.php.

90  {
91  return $this->getColumn()->getUrlPattern();
92  }

◆ isDisabled()

isDisabled ( )

Decide whether action associated with the link is not available.

Returns
bool

Definition at line 78 of file Link.php.

79  {
80  return false;
81  }

◆ isVisible()

isVisible ( )

Decide whether anything should be rendered.

Returns
bool

Definition at line 68 of file Link.php.

69  {
70  return true;
71  }

◆ render()

render ( DataObject  $row)

Render grid row

Parameters
\Magento\Framework\DataObject$row
Returns
string

Prepare link to display in grid

Parameters
\Magento\Framework\DataObject$row
Returns
string

Definition at line 45 of file Link.php.

46  {
47  $this->_row = $row;
48 
49  if (!$this->isVisible()) {
50  return '';
51  }
52 
53  $html = sprintf(
54  '<a href="%s" %s>%s</a>',
55  $this->_getUrl($row),
56  $this->_getAttributesHtml(),
57  $this->getCaption()
58  );
59 
60  return $html;
61  }

Field Documentation

◆ $_row

$_row
protected

Definition at line 18 of file Link.php.

◆ $jsonHelper

$jsonHelper
protected

Definition at line 23 of file Link.php.


The documentation for this class was generated from the following file: