Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Protected Member Functions | Protected Attributes
Edit Class Reference
Inheritance diagram for Edit:
Container Template ContainerInterface Template ContextInterface AbstractBlock DataObject BlockInterface Edit Edit Edit

Public Member Functions

 __construct (\Magento\Backend\Block\Widget\Context $context, \Magento\UrlRewrite\Model\UrlRewriteFactory $rewriteFactory, \Magento\Backend\Helper\Data $adminhtmlData, array $data=[])
 
 getButtonsHtml ($area=null)
 
- Public Member Functions inherited from Container
 __construct (\Magento\Backend\Block\Widget\Context $context, array $data=[])
 
 addButton ($buttonId, $data, $level=0, $sortOrder=0, $region='toolbar')
 
 removeButton ($buttonId)
 
 updateButton ($buttonId, $key, $data)
 
 getHeaderText ()
 
 getHeaderCssClass ()
 
 getHeaderHtml ()
 
 hasFooterButtons ()
 
 canRender (Button\Item $item)
 
- 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 ContextInterface
 canRender (\Magento\Backend\Block\Widget\Button\Item $item)
 

Protected Member Functions

 _prepareLayout ()
 
 _prepareLayoutFeatures ()
 
 _addEditFormBlock ()
 
 _addResetButton ()
 
 _addBackButton ()
 
 _updateBackButtonLink ($link)
 
 _addDeleteButton ()
 
 _addSaveButton ()
 
 _createEditFormBlock ()
 
 _addUrlRewriteSelectorBlock ()
 
 _getUrlRewrite ()
 
- Protected Member Functions inherited from Container
 _construct ()
 
 _prepareLayout ()
 
- 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

 $_controller = 'url_rewrite'
 
 $_buttonsHtml
 
 $_adminhtmlData = null
 
 $_rewriteFactory
 
- Protected Attributes inherited from Container
 $_controller = 'empty'
 
 $_headerText = 'Container Widget Header'
 
 $buttonList
 
 $toolbar
 
- 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)
 
- Data Fields inherited from Container
const PARAM_CONTROLLER = 'controller'
 
const PARAM_HEADER_TEXT = 'header_text'
 
- 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

Block for URL rewrites edit page

Definition at line 11 of file Edit.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( \Magento\Backend\Block\Widget\Context  $context,
\Magento\UrlRewrite\Model\UrlRewriteFactory  $rewriteFactory,
\Magento\Backend\Helper\Data  $adminhtmlData,
array  $data = [] 
)
Parameters
\Magento\Backend\Block\Widget\Context$context
\Magento\UrlRewrite\Model\UrlRewriteFactory$rewriteFactory
\Magento\Backend\Helper\Data$adminhtmlData
array$data

Definition at line 50 of file Edit.php.

55  {
56  $this->_rewriteFactory = $rewriteFactory;
57  $this->_adminhtmlData = $adminhtmlData;
58  parent::__construct($context, $data);
59  }

Member Function Documentation

◆ _addBackButton()

_addBackButton ( )
protected

Add back button

Returns
void

Definition at line 133 of file Edit.php.

134  {
135  $this->addButton(
136  'back',
137  [
138  'label' => __('Back'),
139  'onclick' => 'setLocation(\'' . $this->_adminhtmlData->getUrl('adminhtml/*/') . '\')',
140  'class' => 'back',
141  'level' => -1
142  ]
143  );
144  }
__()
Definition: __.php:13
addButton($buttonId, $data, $level=0, $sortOrder=0, $region='toolbar')
Definition: Container.php:85

◆ _addDeleteButton()

_addDeleteButton ( )
protected

Add delete button

Returns
void

Definition at line 162 of file Edit.php.

163  {
164  $this->addButton(
165  'delete',
166  [
167  'label' => __('Delete'),
168  'onclick' => 'deleteConfirm(' . json_encode(__('Are you sure you want to do this?'))
169  . ','
170  . json_encode(
171  $this->_adminhtmlData->getUrl(
172  'adminhtml/*/delete',
173  ['id' => $this->getUrlRewrite()->getId()]
174  )
175  )
176  . ', {data: {}})',
177  'class' => 'scalable delete',
178  'level' => -1
179  ]
180  );
181  }
__()
Definition: __.php:13
addButton($buttonId, $data, $level=0, $sortOrder=0, $region='toolbar')
Definition: Container.php:85

◆ _addEditFormBlock()

_addEditFormBlock ( )
protected

Add child edit form block

Returns
void

Definition at line 98 of file Edit.php.

99  {
100  $this->setChild('form', $this->_createEditFormBlock());
101 
102  if ($this->_getUrlRewrite()->getId()) {
103  $this->_addResetButton();
104  $this->_addDeleteButton();
105  }
106 
107  $this->_addSaveButton();
108  }

◆ _addResetButton()

_addResetButton ( )
protected

Add reset button

Returns
void

Definition at line 115 of file Edit.php.

116  {
117  $this->addButton(
118  'reset',
119  [
120  'label' => __('Reset'),
121  'onclick' => 'location.reload();',
122  'class' => 'scalable',
123  'level' => -1
124  ]
125  );
126  }
__()
Definition: __.php:13
addButton($buttonId, $data, $level=0, $sortOrder=0, $region='toolbar')
Definition: Container.php:85

◆ _addSaveButton()

_addSaveButton ( )
protected

Add save button

Returns
void

Definition at line 188 of file Edit.php.

189  {
190  $this->addButton(
191  'save',
192  [
193  'label' => __('Save'),
194  'class' => 'save primary save-url-rewrite',
195  'level' => -1,
196  'data_attribute' => [
197  'mage-init' => ['button' => ['event' => 'save', 'target' => '#edit_form']],
198  ]
199  ]
200  );
201  }
__()
Definition: __.php:13
addButton($buttonId, $data, $level=0, $sortOrder=0, $region='toolbar')
Definition: Container.php:85

◆ _addUrlRewriteSelectorBlock()

_addUrlRewriteSelectorBlock ( )
protected

Add child URL rewrite selector block

Returns
void

Definition at line 222 of file Edit.php.

223  {
224  $this->setChild('selector', $this->_getSelectorBlock());
225  }

◆ _createEditFormBlock()

_createEditFormBlock ( )
protected

Creates edit form block

Returns
\Magento\UrlRewrite\Block\Edit\Form

Definition at line 208 of file Edit.php.

209  {
210  return $this->getLayout()->createBlock(
211  \Magento\UrlRewrite\Block\Edit\Form::class,
212  '',
213  ['data' => ['url_rewrite' => $this->_getUrlRewrite()]]
214  );
215  }

◆ _getUrlRewrite()

_getUrlRewrite ( )
protected

Get or create new instance of URL rewrite

Returns
\Magento\UrlRewrite\Model\UrlRewrite

Definition at line 270 of file Edit.php.

271  {
272  if (!$this->hasData('url_rewrite')) {
273  $this->setUrlRewrite($this->_rewriteFactory->create());
274  }
275  return $this->getUrlRewrite();
276  }

◆ _prepareLayout()

_prepareLayout ( )
protected

Prepare URL rewrite editing layout

Returns
$this

Definition at line 66 of file Edit.php.

67  {
68  $this->setTemplate('Magento_UrlRewrite::edit.phtml');
69 
70  $this->_addBackButton();
71  $this->_prepareLayoutFeatures();
72 
73  return parent::_prepareLayout();
74  }

◆ _prepareLayoutFeatures()

_prepareLayoutFeatures ( )
protected

Prepare featured blocks for layout of URL rewrite editing

Returns
void

Definition at line 81 of file Edit.php.

82  {
83  if ($this->_getUrlRewrite()->getId()) {
84  $this->_headerText = __('Edit URL Rewrite');
85  } else {
86  $this->_headerText = __('Add New URL Rewrite');
87  }
88 
90  $this->_addEditFormBlock();
91  }
__()
Definition: __.php:13

◆ _updateBackButtonLink()

_updateBackButtonLink (   $link)
protected

Update Back button location link

Parameters
string$link
Returns
void

Definition at line 152 of file Edit.php.

153  {
154  $this->updateButton('back', 'onclick', 'setLocation(\'' . $link . '\')');
155  }
updateButton($buttonId, $key, $data)
Definition: Container.php:111

◆ getButtonsHtml()

getButtonsHtml (   $area = null)

Get container buttons HTML

Since buttons are set as children, we remove them as children after generating them not to duplicate them in future

Parameters
string | null$area
Returns
string @SuppressWarnings(PHPMD.UnusedFormalParameter)

Definition at line 250 of file Edit.php.

251  {
252  if (null === $this->_buttonsHtml) {
253  $this->_buttonsHtml = parent::getButtonsHtml();
254  $layout = $this->getLayout();
255  foreach ($this->getChildNames() as $name) {
256  $alias = $layout->getElementAlias($name);
257  if (false !== strpos($alias, '_button')) {
258  $layout->unsetChild($this->getNameInLayout(), $alias);
259  }
260  }
261  }
262  return $this->_buttonsHtml;
263  }
if(!trim($html)) $alias
Definition: details.phtml:20
if(!isset($_GET['name'])) $name
Definition: log.php:14

Field Documentation

◆ $_adminhtmlData

$_adminhtmlData = null
protected

Definition at line 37 of file Edit.php.

◆ $_buttonsHtml

$_buttonsHtml
protected

Definition at line 30 of file Edit.php.

◆ $_controller

$_controller = 'url_rewrite'
protected

Definition at line 23 of file Edit.php.

◆ $_rewriteFactory

$_rewriteFactory
protected

Definition at line 42 of file Edit.php.


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