Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Data Fields | Protected Member Functions | Protected Attributes
Extend Class Reference
Inheritance diagram for Extend:
Element Element Template RendererInterface Template AbstractBlock DataObject BlockInterface

Public Member Functions

 __construct (\Magento\Backend\Block\Template\Context $context, \Magento\Framework\Registry $registry, \Magento\Framework\Data\FormFactory $formFactory, array $data=[])
 
 getElementHtml ()
 
 getParentElementHtml ()
 
 getOptions ()
 
 isDisabledField ()
 
 getProduct ()
 
 getExtendedElement ($switchAttributeCode)
 
- Public Member Functions inherited from Element
 getDataObject ()
 
 getAttribute ()
 
 getAttributeCode ()
 
 canDisplayUseDefault ()
 
 usedDefault ()
 
 checkFieldDisable ()
 
 getScopeLabel ()
 
 getElementLabelHtml ()
 
 getElementHtml ()
 
- Public Member Functions inherited from Element
 getElement ()
 
 render (AbstractElement $element)
 
- Public Member Functions inherited from Template
 __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 ()
 
- Public Member Functions inherited from RendererInterface
 render (\Magento\Framework\Data\Form\Element\AbstractElement $element)
 

Data Fields

const DYNAMIC = 0
 
const FIXED = 1
 
- 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_'
 

Protected Member Functions

 _construct ()
 
- Protected Member Functions inherited from Element
 _getDefaultStoreId ()
 
- Protected Member Functions inherited from Template
 _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

 $_coreRegistry = null
 
- Protected Attributes inherited from Element
 $_template = 'Magento_Catalog::catalog/form/renderer/fieldset/element.phtml'
 
- Protected Attributes inherited from Element
 $_element
 
 $_template = 'Magento_Backend::widget/form/renderer/fieldset/element.phtml'
 
- Protected Attributes inherited from Template
 $_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)
 
- Static Protected Attributes inherited from DataObject
static $_underscoreCache = []
 

Detailed Description

Definition at line 14 of file Extend.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( \Magento\Backend\Block\Template\Context  $context,
\Magento\Framework\Registry  $registry,
\Magento\Framework\Data\FormFactory  $formFactory,
array  $data = [] 
)
Parameters
\Magento\Backend\Block\Template\Context$context
\Magento\Framework\Registry$registry
\Magento\Framework\Data\FormFactory$formFactory
array$data

Definition at line 43 of file Extend.php.

48  {
49  $this->_coreRegistry = $registry;
50  parent::__construct($context, $data);
51  $this->formFactory = $formFactory;
52  }

Member Function Documentation

◆ _construct()

_construct ( )
protected

Class constructor

Returns
void

Definition at line 59 of file Extend.php.

60  {
61  parent::_construct();
62  $this->setCanEditPrice(true);
63  $this->setCanReadPrice(true);
64  }

◆ getElementHtml()

getElementHtml ( )

Get Element Html

Returns
string

Definition at line 71 of file Extend.php.

72  {
73  $templateFile = $this->getTemplateFile($this->template);
74  return $this->fetchView($templateFile);
75  }

◆ getExtendedElement()

getExtendedElement (   $switchAttributeCode)
Parameters
string$switchAttributeCode
Returns
\Magento\Framework\Data\Form\Element\Select
Exceptions

Definition at line 136 of file Extend.php.

137  {
138  $form = $this->formFactory->create();
139  return $form->addField(
141  'select',
142  [
143  'name' => "product[{$switchAttributeCode}]",
144  'values' => $this->getOptions(),
145  'class' => 'required-entry next-toinput',
146  'no_span' => true,
147  'disabled' => $this->isDisabledField(),
148  'value' => $this->getProduct()->getData($switchAttributeCode),
149  ]
150  );
151  }
getData($key='', $index=null)
Definition: DataObject.php:119
$switchAttributeCode
Definition: extend.phtml:15

◆ getOptions()

getOptions ( )
Returns
array

Definition at line 90 of file Extend.php.

91  {
92  return [
93  [
94  'value' => '',
95  'label' => __('-- Select --')
96  ],
97  [
98  'value' => self::DYNAMIC,
99  'label' => __('Dynamic')
100  ],
101  [
102  'value' => self::FIXED,
103  'label' => __('Fixed')
104  ]
105  ];
106  }
__()
Definition: __.php:13

◆ getParentElementHtml()

getParentElementHtml ( )

Execute method getElementHtml from parrent class

Returns
string

Definition at line 82 of file Extend.php.

83  {
84  return parent::getElementHtml();
85  }

◆ getProduct()

getProduct ( )
Returns
mixed

Definition at line 123 of file Extend.php.

124  {
125  if (!$this->getData('product')) {
126  $this->setData('product', $this->_coreRegistry->registry('product'));
127  }
128  return $this->getData('product');
129  }
getData($key='', $index=null)
Definition: DataObject.php:119
setData($key, $value=null)
Definition: DataObject.php:72

◆ isDisabledField()

isDisabledField ( )
Returns
bool

Definition at line 111 of file Extend.php.

112  {
113  return $this->_getData('is_disabled_field')
114  || ($this->getProduct()->getId()
115  && $this->getAttribute()->getAttributeCode() === 'price'
116  )
117  || $this->getElement()->getReadonly();
118  }

Field Documentation

◆ $_coreRegistry

$_coreRegistry = null
protected

Definition at line 30 of file Extend.php.

◆ DYNAMIC

const DYNAMIC = 0

Definition at line 21 of file Extend.php.

◆ FIXED

const FIXED = 1

Definition at line 23 of file Extend.php.


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