Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Protected Member Functions | Protected Attributes
Template Class Reference
Inheritance diagram for Template:
Template AbstractBlock DataObject BlockInterface Messages UnreadMessagePopup ToolbarEntry Window FraudDetails Formkey Additional Container Dashboard Denied GlobalSearch Menu Page Copyright Footer Header Notices Switcher Fieldset Design Group Website Widget Breadcrumbs Container Element Gallery Element Fieldset Element Tab Backup Dialogs AbstractCategory AssignProducts Main Attribute Group Add Main Js ChildTab Conditions Files Newfolder Tree Field Matrix AttributeSelector Currency Matrix Services Carts View PersonalInfo Sales Links Js Labels Options Template Form Giftoptions Items Form Giftoptions Items GiftOptions Googleoptimizer ListAssociatedProducts After Before Result Inventory Index Partners Problem Edit Subscriber Template Form Info Hint ResolutionRules Wishlist Detailed Summary AbstractItems View Table Adjustments Payment Form History History Activity Packaging Grid Tracking Renderer Add Save Scope Files Tree CarrierConfig Selector Buttons Chooser Layout

Public Member Functions

 __construct (\Magento\Backend\Block\Template\Context $context, array $data=[])
 
 getFormKey ()
 
 isOutputEnabled ($moduleName=null)
 
 getAuthorization ()
 
 getToolbar ()
 
- Public Member Functions inherited from Template
 __construct (Template\Context $context, array $data=[])
 
 setTemplateContext ($templateContext)
 
 getTemplate ()
 
 setTemplate ($template)
 
 getTemplateFile ($template=null)
 
 getArea ()
 
 assign ($key, $value=null)
 
 fetchView ($fileName)
 
 getBaseUrl ()
 
 getObjectData (\Magento\Framework\DataObject $object, $key)
 
 getCacheKeyInfo ()
 
- 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 ()
 

Protected Member Functions

 _toHtml ()
 
- Protected Member Functions inherited from Template
 _construct ()
 
 _toHtml ()
 
 getRootDirectory ()
 
 getMediaDirectory ()
 
- 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

 $_authorization
 
 $mathRandom
 
 $_backendSession
 
 $formKey
 
 $nameBuilder
 
- Protected Attributes inherited from Template
 $_viewVars = []
 
 $_baseUrl
 
 $_jsUrl
 
 $_allowSymlinks
 
 $_filesystem
 
 $_template
 
 $templateEnginePool
 
 $_storeManager
 
 $_appState
 
 $directory
 
 $templateContext
 
 $pageConfig
 
 $resolver
 
 $validator
 
- 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 Template
const XML_PATH_TEMPLATE_ALLOW_SYMLINK = 'dev/template/allow_symlink'
 
- 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

Standard admin block. Adds admin-specific behavior and event. Should be used when you declare a block in admin layout handle.

Avoid extending this class if possible.

If you need custom presentation logic in your blocks, use this class as block, and declare custom view models in block arguments in layout handle file.

Example: <block name="my.block" class="Magento\Backend\Block\Template" template="My_Module::template.phtml"> <arguments> <argument name="view_model" xsi:type="object">My\Module\ViewModel\Custom</argument> </arguments> </block>

Your class object can then be accessed by doing $block->getViewModel()

@api @SuppressWarnings(PHPMD.NumberOfChildren)

Since
100.0.2

Definition at line 33 of file Template.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( \Magento\Backend\Block\Template\Context  $context,
array  $data = [] 
)
Parameters
\Magento\Backend\Block\Template\Context$context
array$data

Definition at line 64 of file Template.php.

65  {
66  $this->_localeDate = $context->getLocaleDate();
67  $this->_authorization = $context->getAuthorization();
68  $this->mathRandom = $context->getMathRandom();
69  $this->_backendSession = $context->getBackendSession();
70  $this->formKey = $context->getFormKey();
71  $this->nameBuilder = $context->getNameBuilder();
72  parent::__construct($context, $data);
73  }

Member Function Documentation

◆ _toHtml()

_toHtml ( )
protected

Prepare html output

Returns
string

Definition at line 126 of file Template.php.

127  {
128  $this->_eventManager->dispatch('adminhtml_block_html_before', ['block' => $this]);
129  return parent::_toHtml();
130  }

◆ getAuthorization()

getAuthorization ( )

Make this public so that templates can use it properly with template engine

Returns
\Magento\Framework\AuthorizationInterface

Definition at line 116 of file Template.php.

117  {
118  return $this->_authorization;
119  }

◆ getFormKey()

getFormKey ( )

Retrieve Session Form Key

Returns
string

Definition at line 80 of file Template.php.

81  {
82  return $this->formKey->getFormKey();
83  }

◆ getToolbar()

getToolbar ( )

Return toolbar block instance

Returns
bool|\Magento\Framework\View\Element\BlockInterface

Definition at line 137 of file Template.php.

138  {
139  return $this->getLayout()->getBlock('page.actions.toolbar');
140  }

◆ isOutputEnabled()

isOutputEnabled (   $moduleName = null)

Check whether or not the module output is enabled.

Because many module blocks belong to Backend module, the feature "Disable module output" doesn't cover Admin area.

Parameters
string$moduleNameFull module name
Returns
boolean
Deprecated:
100.2.0 Magento does not support disabling/enabling modules output from the Admin Panel since 2.2.0 version. Module output can still be enabled/disabled in configuration files. However, this functionality should not be used in future development. Module design should explicitly state dependencies to avoid requiring output disabling. This functionality will temporarily be kept in Magento core, as there are unresolved modularity issues that will be addressed in future releases.

Definition at line 99 of file Template.php.

100  {
101  if ($moduleName === null) {
102  $moduleName = $this->getModuleName();
103  }
104 
105  return !$this->_scopeConfig->isSetFlag(
106  'advanced/modules_disable_output/' . $moduleName,
107  \Magento\Store\Model\ScopeInterface::SCOPE_STORE
108  );
109  }

Field Documentation

◆ $_authorization

$_authorization
protected

Definition at line 38 of file Template.php.

◆ $_backendSession

$_backendSession
protected

Definition at line 48 of file Template.php.

◆ $formKey

$formKey
protected

Definition at line 53 of file Template.php.

◆ $mathRandom

$mathRandom
protected

Definition at line 43 of file Template.php.

◆ $nameBuilder

$nameBuilder
protected

Definition at line 58 of file Template.php.


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