diff --git a/app/code/core/Mage/Adminhtml/Block/Cms/Page/Edit/Tab/Content.php b/app/code/core/Mage/Adminhtml/Block/Cms/Page/Edit/Tab/Content.php index 32d667b4baf..d2dea206d7c 100644 --- a/app/code/core/Mage/Adminhtml/Block/Cms/Page/Edit/Tab/Content.php +++ b/app/code/core/Mage/Adminhtml/Block/Cms/Page/Edit/Tab/Content.php @@ -70,6 +70,7 @@ protected function _prepareForm() ]); // Setting custom renderer for content field to remove label column + /** @var Mage_Adminhtml_Block_Widget_Form_Renderer_Fieldset_Element $renderer */ $renderer = $this->getLayout()->createBlock('adminhtml/widget_form_renderer_fieldset_element') ->setTemplate('cms/page/edit/form/renderer/content.phtml'); $contentField->setRenderer($renderer); diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Items/Abstract.php b/app/code/core/Mage/Adminhtml/Block/Sales/Items/Abstract.php index 7024e1af1f6..8344c4e632a 100644 --- a/app/code/core/Mage/Adminhtml/Block/Sales/Items/Abstract.php +++ b/app/code/core/Mage/Adminhtml/Block/Sales/Items/Abstract.php @@ -105,9 +105,11 @@ public function getItemRenderer($type) } if (is_null($this->_itemRenders[$type]['renderer'])) { - $this->_itemRenders[$type]['renderer'] = $this->getLayout() + /** @var Mage_Adminhtml_Block_Sales_Items_Abstract $renderer */ + $renderer = $this->getLayout() ->createBlock($this->_itemRenders[$type]['block']) ->setTemplate($this->_itemRenders[$type]['template']); + $this->_itemRenders[$type]['renderer'] = $renderer; foreach ($this->_columnRenders as $columnType => $renderer) { $this->_itemRenders[$type]['renderer']->addColumnRender($columnType, $renderer['block'], $renderer['template']); } diff --git a/app/code/core/Mage/Adminhtml/Block/System/Store/Tree.php b/app/code/core/Mage/Adminhtml/Block/System/Store/Tree.php index f711559420a..e88fe412bb8 100644 --- a/app/code/core/Mage/Adminhtml/Block/System/Store/Tree.php +++ b/app/code/core/Mage/Adminhtml/Block/System/Store/Tree.php @@ -33,13 +33,13 @@ public function _construct() /** * Prepare block layout * - * @return Mage_Core_Block_Abstract + * @return Mage_Adminhtml_Block_Template */ protected function _prepareLayout() { - $this->_cellTemplate = $this->getLayout() - ->createBlock('adminhtml/template') - ->setTemplate('system/store/cell.phtml'); + /** @var Mage_Adminhtml_Block_Template $block */ + $block = $this->getLayout()->createBlock('adminhtml/template'); + $this->_cellTemplate = $block->setTemplate('system/store/cell.phtml'); return parent::_prepareLayout(); } diff --git a/app/code/core/Mage/Adminhtml/controllers/IndexController.php b/app/code/core/Mage/Adminhtml/controllers/IndexController.php index ab997c7d819..8ca8fc25975 100644 --- a/app/code/core/Mage/Adminhtml/controllers/IndexController.php +++ b/app/code/core/Mage/Adminhtml/controllers/IndexController.php @@ -23,7 +23,9 @@ class Mage_Adminhtml_IndexController extends Mage_Adminhtml_Controller_Action protected function _outTemplate($tplName, $data = []) { $this->_initLayoutMessages('adminhtml/session'); - $block = $this->getLayout()->createBlock('adminhtml/template')->setTemplate("$tplName.phtml"); + /** @var Mage_Adminhtml_Block_Template $block */ + $block = $this->getLayout()->createBlock('adminhtml/template'); + $block->setTemplate("$tplName.phtml"); foreach ($data as $index => $value) { $block->assign($index, $value); } @@ -131,9 +133,9 @@ public function globalSearchAction() $totalCount = count($items); } - $block = $this->getLayout()->createBlock('adminhtml/template') - ->setTemplate('system/autocomplete.phtml') - ->assign('items', $items); + /** @var Mage_Adminhtml_Block_Template $block */ + $block = $this->getLayout()->createBlock('adminhtml/template'); + $block->setTemplate('system/autocomplete.phtml')->assign('items', $items); $this->getResponse()->setBody($block->toHtml()); } diff --git a/app/code/core/Mage/Cms/Api/Data/BlockInterface.php b/app/code/core/Mage/Cms/Api/Data/BlockInterface.php new file mode 100644 index 00000000000..a5dbb508706 --- /dev/null +++ b/app/code/core/Mage/Cms/Api/Data/BlockInterface.php @@ -0,0 +1,68 @@ +hasData('page')) { - if ($this->getPageId()) { + $pageId = $this->getPageId(); + if ($pageId) { $page = Mage::getModel('cms/page') ->setStoreId(Mage::app()->getStore()->getId()) - ->load($this->getPageId(), 'identifier'); + ->load($pageId, 'identifier'); } else { $page = Mage::getSingleton('cms/page'); } @@ -37,7 +36,12 @@ public function getPage() $this->setData('page', $page); } - return $this->getData('page'); + return $this->getDataByKey('page'); + } + + public function getPageId(): ?string + { + return $this->getDataByKey('page_id'); } /** @@ -46,15 +50,17 @@ public function getPage() */ protected function _prepareLayout() { - $page = $this->getPage(); + $page = $this->getPage(); + $pageTitle = $page->getTitle(); + $identifier = $page->getIdentifier(); + $breadcrumbsArray = []; - $breadcrumbs = null; // show breadcrumbs if (Mage::getStoreConfig('web/default/show_cms_breadcrumbs') && ($breadcrumbs = $this->getLayout()->getBlock('breadcrumbs')) - && ($page->getIdentifier() !== Mage::getStoreConfig('web/default/cms_home_page')) - && ($page->getIdentifier() !== Mage::getStoreConfig('web/default/cms_no_route')) + && ($identifier !== Mage::getStoreConfig('web/default/cms_home_page')) + && ($identifier !== Mage::getStoreConfig('web/default/cms_no_route')) ) { $breadcrumbsArray[] = [ 'crumbName' => 'home', @@ -67,17 +73,17 @@ protected function _prepareLayout() $breadcrumbsArray[] = [ 'crumbName' => 'cms_page', 'crumbInfo' => [ - 'label' => $page->getTitle(), - 'title' => $page->getTitle(), + 'label' => $pageTitle, + 'title' => $pageTitle, ], ]; $breadcrumbsObject = new Varien_Object(); - $breadcrumbsObject->setCrumbs($breadcrumbsArray); + $breadcrumbsObject->setData('crumbs', $breadcrumbsArray); Mage::dispatchEvent('cms_generate_breadcrumbs', ['breadcrumbs' => $breadcrumbsObject]); if ($breadcrumbs instanceof Mage_Page_Block_Html_Breadcrumbs) { - foreach ($breadcrumbsObject->getCrumbs() as $breadcrumbsItem) { + foreach ($breadcrumbsObject->getDataByKey('crumbs') as $breadcrumbsItem) { $breadcrumbs->addCrumb($breadcrumbsItem['crumbName'], $breadcrumbsItem['crumbInfo']); } } @@ -86,13 +92,13 @@ protected function _prepareLayout() /** @var Mage_Page_Block_Html $root */ $root = $this->getLayout()->getBlock('root'); if ($root) { - $root->addBodyClass('cms-' . $page->getIdentifier()); + $root->addBodyClass('cms-' . $identifier); } /** @var Mage_Page_Block_Html_Head $head */ $head = $this->getLayout()->getBlock('head'); if ($head) { - $head->setTitle($page->getTitle()); + $head->setTitle($pageTitle); $head->setKeywords($page->getMetaKeywords()); $head->setDescription($page->getMetaDescription()); diff --git a/app/code/core/Mage/Cms/Block/Widget/Block.php b/app/code/core/Mage/Cms/Block/Widget/Block.php index a9eb747bf38..f7d72b3542f 100644 --- a/app/code/core/Mage/Cms/Block/Widget/Block.php +++ b/app/code/core/Mage/Cms/Block/Widget/Block.php @@ -46,7 +46,7 @@ protected function _construct() protected function _beforeToHtml() { parent::_beforeToHtml(); - $blockId = $this->getData('block_id'); + $blockId = $this->getDataByKey('block_id'); $blockHash = static::class . $blockId; if (isset(self::$_widgetUsageMap[$blockHash])) { diff --git a/app/code/core/Mage/Cms/Block/Widget/Page/Link.php b/app/code/core/Mage/Cms/Block/Widget/Page/Link.php index 8dcf11e19aa..223ed400829 100644 --- a/app/code/core/Mage/Cms/Block/Widget/Page/Link.php +++ b/app/code/core/Mage/Cms/Block/Widget/Page/Link.php @@ -45,10 +45,10 @@ public function getHref() { if (!$this->_href) { $this->_href = ''; - if ($this->getData('href')) { - $this->_href = $this->getData('href'); - } elseif ($this->getData('page_id')) { - $this->_href = Mage::helper('cms/page')->getPageUrl($this->getData('page_id')); + if ($this->getDataByKey('href')) { + $this->_href = $this->getDataByKey('href'); + } elseif ($this->getDataByKey('page_id')) { + $this->_href = Mage::helper('cms/page')->getPageUrl($this->getDataByKey('page_id')); } } @@ -66,13 +66,13 @@ public function getTitle() { if (!$this->_title) { $this->_title = ''; - if ($this->getData('title') !== null) { + if ($this->getDataByKey('title') !== null) { // compare to null used here bc user can specify blank title - $this->_title = $this->getData('title'); - } elseif ($this->getData('page_id')) { - $this->_title = $this->getCmsPageTitleById($this->getData('page_id')); - } elseif ($this->getData('href')) { - $this->_title = $this->getCmsPageTitleByIdentifier($this->getData('href')); + $this->_title = $this->getDataByKey('title'); + } elseif ($this->getDataByKey('page_id')) { + $this->_title = $this->getCmsPageTitleById($this->getDataByKey('page_id')); + } elseif ($this->getDataByKey('href')) { + $this->_title = $this->getCmsPageTitleByIdentifier($this->getDataByKey('href')); } } @@ -89,16 +89,16 @@ public function getTitle() */ public function getAnchorText() { - if ($this->getData('anchor_text')) { - $this->_anchorText = $this->getData('anchor_text'); + if ($this->getDataByKey('anchor_text')) { + $this->_anchorText = $this->getDataByKey('anchor_text'); } elseif ($this->getTitle()) { $this->_anchorText = $this->getTitle(); - } elseif ($this->getData('href')) { - $this->_anchorText = $this->getCmsPageTitleByIdentifier($this->getData('href')); - } elseif ($this->getData('page_id')) { - $this->_anchorText = $this->getCmsPageTitleById($this->getData('page_id')); + } elseif ($this->getDataByKey('href')) { + $this->_anchorText = $this->getCmsPageTitleByIdentifier($this->getDataByKey('href')); + } elseif ($this->getDataByKey('page_id')) { + $this->_anchorText = $this->getCmsPageTitleById($this->getDataByKey('page_id')); } else { - $this->_anchorText = $this->getData('href'); + $this->_anchorText = $this->getDataByKey('href'); } return $this->_anchorText; diff --git a/app/code/core/Mage/Cms/Helper/Page.php b/app/code/core/Mage/Cms/Helper/Page.php index 3de4d300260..d79a5310326 100644 --- a/app/code/core/Mage/Cms/Helper/Page.php +++ b/app/code/core/Mage/Cms/Helper/Page.php @@ -79,9 +79,10 @@ protected function _renderPage(Mage_Core_Controller_Varien_Action $action, $pag $action->addActionLayoutHandles(); if ($page->getRootTemplate()) { - $handle = ($page->getCustomRootTemplate() - && $page->getCustomRootTemplate() != 'empty' - && $inRange) ? $page->getCustomRootTemplate() : $page->getRootTemplate(); + $customRootTemplate = $page->getCustomRootTemplate(); + $handle = ($customRootTemplate + && $customRootTemplate != 'empty' + && $inRange) ? $customRootTemplate : $page->getRootTemplate(); $action->getLayout()->helper('page/layout')->applyHandle($handle); } diff --git a/app/code/core/Mage/Cms/Model/Block.php b/app/code/core/Mage/Cms/Model/Block.php index 5a1efab9004..d4c8f79446a 100644 --- a/app/code/core/Mage/Cms/Model/Block.php +++ b/app/code/core/Mage/Cms/Model/Block.php @@ -15,28 +15,12 @@ * @method Mage_Cms_Model_Resource_Block _getResource() * @method Mage_Cms_Model_Resource_Block getResource() * @method Mage_Cms_Model_Resource_Block_Collection getCollection() - * - * @method string getTitle() - * @method $this setTitle(string $value) - * @method string getIdentifier() - * @method $this setIdentifier(string $value) - * @method string getContent() - * @method $this setContent(string $value) - * @method string getCreationTime() - * @method $this setCreationTime(string $value) - * @method string getUpdateTime() - * @method $this setUpdateTime(string $value) - * @method int getIsActive() - * @method $this setIsActive(int $value) - * @method $this setStoreId(int $storeId) - * @method int getStoreId() - * @method int getBlockId() */ -class Mage_Cms_Model_Block extends Mage_Core_Model_Abstract +class Mage_Cms_Model_Block extends Mage_Core_Model_Abstract implements Mage_Cms_Api_Data_BlockInterface { - public const CACHE_TAG = 'cms_block'; + public const CACHE_TAG = 'cms_block'; - protected $_cacheTag = 'cms_block'; + protected $_cacheTag = 'cms_block'; protected function _construct() { @@ -60,4 +44,141 @@ protected function _beforeSave() Mage::helper('cms')->__('The static block content cannot contain directive with its self.'), ); } + + /** + * @api + */ + public function getBlockId(): ?int + { + $blockId = $this->getDataByKey(self::DATA_ID); + return is_null($blockId) ? null : (int) $blockId; + } + + /** + * @api + * @return $this + */ + public function setBlockId(?int $blockId) + { + return $this->setData(self::DATA_ID, $blockId); + } + + /** + * @api + */ + public function getContent(): ?string + { + return $this->getDataByKey(self::DATA_CONTENT); + } + + /** + * @api + * @return $this + */ + public function setContent(?string $content) + { + return $this->setData(self::DATA_CONTENT, $content); + } + + /** + * @api + */ + public function getCreationTime(): ?string + { + return $this->getDataByKey(self::DATA_CREATION_TIME); + } + + /** + * @api + * @return $this + */ + public function setCreationTime(?string $time) + { + return $this->setData(self::DATA_CREATION_TIME, $time); + } + + /** + * @api + */ + public function getIsActive(): int + { + return $this->getDataByKey(self::DATA_IS_ACTIVE); + } + + /** + * @api + * @return $this + */ + public function setIsActive(int $value) + { + return $this->setData(self::DATA_IS_ACTIVE, $value); + } + + /** + * @api + */ + public function getIdentifier(): string + { + return $this->getDataByKey(self::DATA_IDENTIFIER); + } + + /** + * @api + * @return $this + */ + public function setIdentifier(string $identifier) + { + return $this->setData(self::DATA_IDENTIFIER, $identifier); + } + + /** + * @api + */ + public function getTitle(): string + { + return $this->getDataByKey(self::DATA_TITLE); + } + + /** + * @api + * @return $this + */ + public function setTitle(string $title) + { + return $this->setData(self::DATA_TITLE, $title); + } + + /** + * @api + */ + public function getStoreId(): ?int + { + return $this->getDataByKey(self::DATA_STORE_ID); + } + + /** + * @api + * @return $this + */ + public function setStoreId(int $storeId) + { + return $this->setData(self::DATA_STORE_ID, $storeId); + } + + /** + * @api + */ + public function getUpdateTime(): ?string + { + return $this->getDataByKey(self::DATA_UPDATE_TIME); + } + + /** + * @api + * @return $this + */ + public function setUpdateTime(?string $time) + { + return $this->setData(self::DATA_UPDATE_TIME, $time); + } } diff --git a/app/code/core/Mage/Cms/Model/Page.php b/app/code/core/Mage/Cms/Model/Page.php index 0bb7e76f12c..4b2c7924fd3 100644 --- a/app/code/core/Mage/Cms/Model/Page.php +++ b/app/code/core/Mage/Cms/Model/Page.php @@ -16,49 +16,12 @@ * @method Mage_Cms_Model_Resource_Page getResource() * @method Mage_Cms_Model_Resource_Page_Collection getCollection() * - * @method string getContentHeading() - * @method $this setContentHeading(string $value) - * @method string getContent() - * @method $this setContent(string $value) - * @method string getCreationTime() - * @method $this setCreationTime(string $value) - * @method int getIsActive() - * @method $this setIsActive(int $value) - * @method string getLayoutUpdateXml() - * @method $this setLayoutUpdateXml(string $value) - * @method bool hasCreationTime() - * @method string getCustomTheme() - * @method $this setCustomTheme(string $value) - * @method string getCustomRootTemplate() - * @method $this setCustomRootTemplate(string $value) - * @method string getCustomLayoutUpdateXml() - * @method $this setCustomLayoutUpdateXml(string $value) - * @method string getCustomThemeFrom() - * @method $this setCustomThemeFrom(string $value) - * @method string getCustomThemeTo() - * @method $this setCustomThemeTo(string $value) - * @method string getIdentifier() - * @method $this setIdentifier(string $value) - * @method string getMetaDescription() - * @method $this setMetaDescription(string $value) - * @method string getMetaKeywords() - * @method $this setMetaKeywords(string $value) * @method string getPreviewUrl() - * @method string getRootTemplate() - * @method $this setRootTemplate(string $value) - * @method $this setStoreId(int $value) - * @method int getSortOrder() - * @method $this setSortOrder(int $value) * @method bool hasStores() * @method array getStores() * @method string getStoreCode() - * @method string getStoreId() - * @method string getTitle() - * @method $this setTitle(string $value) - * @method string getUpdateTime() - * @method $this setUpdateTime(string $value) */ -class Mage_Cms_Model_Page extends Mage_Core_Model_Abstract +class Mage_Cms_Model_Page extends Mage_Core_Model_Abstract implements Mage_Cms_Api_Data_PageInterface { public const NOROUTE_PAGE_ID = 'no-route'; @@ -175,4 +138,329 @@ public function isUsedInStoreConfig(?array $paths = []): bool { return $this->_getResource()->isUsedInStoreConfig($this, $paths); } + + public function hasCreationTime(): bool + { + return $this->hasData(self::DATA_CREATION_TIME); + } + + /** + * @api + */ + public function getPageId(): ?int + { + $pageId = $this->getDataByKey(self::DATA_ID); + return is_null($pageId) ? null : (int) $pageId; + } + + /** + * @api + * @return $this + */ + public function setPageId(?int $pageId) + { + return $this->setData(self::DATA_ID, $pageId); + } + + /** + * @api + */ + public function getContent(): ?string + { + return $this->getDataByKey(self::DATA_CONTENT); + } + + /** + * @api + * @return $this + */ + public function setContent(?string $content) + { + return $this->setData(self::DATA_CONTENT, $content); + } + + /** + * @api + */ + public function getContentHeading(): ?string + { + return $this->getDataByKey(self::DATA_CONTENT_HEADING); + } + + /** + * @api + * @return $this + */ + public function setContentHeading(?string $heading) + { + return $this->setData(self::DATA_CONTENT_HEADING, $heading); + } + + /** + * @api + */ + public function getCreationTime(): ?string + { + return $this->getDataByKey(self::DATA_CREATION_TIME); + } + + /** + * @api + * @return $this + */ + public function setCreationTime(?string $value) + { + return $this->setData(self::DATA_CREATION_TIME, $value); + } + + /** + * @api + */ + public function getCustomLayoutUpdateXml(): ?string + { + return $this->getDataByKey(self::DATA_CUSTOM_LAYOUT_UPDATE_XML); + } + + /** + * @api + * @return $this + */ + public function setCustomLayoutUpdateXml(?string $xml) + { + return $this->setData(self::DATA_CUSTOM_LAYOUT_UPDATE_XML, $xml); + } + + /** + * @api + */ + public function getCustomRootTemplate(): ?string + { + return $this->getDataByKey(self::DATA_CUSTOM_ROOT_TEMPLATE); + } + + /** + * @api + * @return $this + */ + public function setCustomRootTemplate(?string $template) + { + return $this->setData(self::DATA_CUSTOM_ROOT_TEMPLATE, $template); + } + + /** + * @api + */ + public function getCustomTheme(): ?string + { + return $this->getDataByKey(self::DATA_CUSTOM_THEME); + } + + /** + * @api + * @return $this + */ + public function setCustomTheme(?string $from) + { + return $this->setData(self::DATA_CUSTOM_THEME, $from); + } + + /** + * @api + */ + public function getCustomThemeFrom(): ?string + { + return $this->getDataByKey(self::DATA_CUSTOM_THEME_FROM); + } + + /** + * @api + * @return $this + */ + public function setCustomThemeFrom(?string $from) + { + return $this->setData(self::DATA_CUSTOM_THEME_FROM, $from); + } + + /** + * @api + */ + public function getCustomThemeTo(): ?string + { + return $this->getDataByKey(self::DATA_CUSTOM_THEME_TO); + } + + /** + * @api + * @return $this + */ + public function setCustomThemeTo(?string $to) + { + return $this->setData(self::DATA_CUSTOM_THEME_TO, $to); + } + + /** + * @api + */ + public function getIdentifier(): ?string + { + return $this->getDataByKey(self::DATA_IDENTIFIER); + } + + /** + * @api + * @return $this + */ + public function setIdentifier(?string $identifier) + { + return $this->setData(self::DATA_IDENTIFIER, $identifier); + } + + /** + * @api + */ + public function getIsActive(): int + { + return (int) $this->getDataByKey(self::DATA_IS_ACTIVE); + } + + /** + * @api + * @return $this + */ + public function setIsActive(int $value) + { + return $this->setData(self::DATA_IS_ACTIVE, $value); + } + + /** + * @api + */ + public function getLayoutUpdateXml(): ?string + { + return $this->getDataByKey(self::DATA_LAYOUT_UPDATE_XML); + } + + /** + * @api + * @return $this + */ + public function setLayoutUpdateXml(?string $xml) + { + return $this->setData(self::DATA_LAYOUT_UPDATE_XML, $xml); + } + + /** + * @api + */ + public function getMetaDescription(): ?string + { + return $this->getDataByKey(self::DATA_META_DESCRIPTION); + } + + /** + * @api + * @return $this + */ + public function setMetaDescription(?string $description) + { + return $this->setData(self::DATA_META_DESCRIPTION, $description); + } + + /** + * @api + */ + public function getMetaKeywords(): ?string + { + return $this->getDataByKey(self::DATA_META_KEYWORDS); + } + + /** + * @api + * @return $this + */ + public function setMetaKeywords(?string $keywords) + { + return $this->setData(self::DATA_META_KEYWORDS, $keywords); + } + + /** + * @api + */ + public function getRootTemplate(): ?string + { + return $this->getDataByKey(self::DATA_ROOT_TEMPLATE); + } + + /** + * @api + * @return $this + */ + public function setRootTemplate(?string $template) + { + return $this->setData(self::DATA_ROOT_TEMPLATE, $template); + } + + /** + * @api + */ + public function getSortOrder(): int + { + return (int) $this->getDataByKey(self::DATA_SORT_ORDER); + } + + /** + * @api + * @return $this + */ + public function setSortOrder(int $position) + { + return $this->setData(self::DATA_SORT_ORDER, $position); + } + + /** + * @api + */ + public function getStoreId(): ?int + { + return (int) $this->getDataByKey(self::DATA_STORE_ID); + } + + /** + * @api + * @return $this + */ + public function setStoreId(int $storeId) + { + return $this->setData(self::DATA_STORE_ID, $storeId); + } + + public function getTitle(): ?string + { + return $this->getDataByKey(self::DATA_TITLE); + } + + /** + * @return $this + */ + public function setTitle(?string $title) + { + return $this->setData(self::DATA_TITLE, $title); + } + + /** + * @api + */ + public function getUpdateTime(): ?string + { + return $this->getDataByKey(self::DATA_UPDATE_TIME); + } + + /** + * @api + * @return $this + */ + public function setUpdateTime(?string $time) + { + return $this->setData(self::DATA_UPDATE_TIME, $time); + } } diff --git a/app/code/core/Mage/Cms/Model/Resource/Block.php b/app/code/core/Mage/Cms/Model/Resource/Block.php index 8d4c0fa69f2..7ee8cba19cf 100644 --- a/app/code/core/Mage/Cms/Model/Resource/Block.php +++ b/app/code/core/Mage/Cms/Model/Resource/Block.php @@ -20,6 +20,7 @@ protected function _construct() } /** + * @param Mage_Cms_Model_Block $object * @inheritDoc */ protected function _beforeDelete(Mage_Core_Model_Abstract $object) @@ -36,6 +37,7 @@ protected function _beforeDelete(Mage_Core_Model_Abstract $object) /** * Perform operations before object save * + * @param Mage_Cms_Model_Block $object * @return $this * @throws Mage_Core_Exception */ @@ -54,6 +56,7 @@ protected function _beforeSave(Mage_Core_Model_Abstract $object) } /** + * @param Mage_Cms_Model_Block $object * @inheritDoc */ protected function _afterSave(Mage_Core_Model_Abstract $object) @@ -91,6 +94,7 @@ protected function _afterSave(Mage_Core_Model_Abstract $object) } /** + * @param Mage_Cms_Model_Block $object * @inheritDoc */ public function load(Mage_Core_Model_Abstract $object, $value, $field = null) @@ -103,6 +107,7 @@ public function load(Mage_Core_Model_Abstract $object, $value, $field = null) } /** + * @param Mage_Cms_Model_Block $object * @inheritDoc */ protected function _afterLoad(Mage_Core_Model_Abstract $object) @@ -150,6 +155,7 @@ protected function _getLoadSelect($field, $value, $object) /** * Check for unique of identifier of block to selected store(s). * + * @param Mage_Cms_Model_Block $object * @return bool */ public function getIsUniqueBlockToStores(Mage_Core_Model_Abstract $object) @@ -157,7 +163,7 @@ public function getIsUniqueBlockToStores(Mage_Core_Model_Abstract $object) if (Mage::app()->isSingleStoreMode()) { $stores = [Mage_Core_Model_App::ADMIN_STORE_ID]; } else { - $stores = (array) $object->getData('stores'); + $stores = (array) $object->getDataByKey('stores'); } $select = $this->_getReadAdapter()->select() @@ -166,7 +172,7 @@ public function getIsUniqueBlockToStores(Mage_Core_Model_Abstract $object) ['cbs' => $this->getTable('cms/block_store')], 'cb.block_id = cbs.block_id', [], - )->where('cb.identifier = ?', $object->getData('identifier')) + )->where('cb.identifier = ?', $object->getDataByKey('identifier')) ->where('cbs.store_id IN (?)', $stores); if ($object->getId()) { diff --git a/app/code/core/Mage/Cms/Model/Resource/Block/Collection.php b/app/code/core/Mage/Cms/Model/Resource/Block/Collection.php index b7de5f9da73..aad38ad21a3 100644 --- a/app/code/core/Mage/Cms/Model/Resource/Block/Collection.php +++ b/app/code/core/Mage/Cms/Model/Resource/Block/Collection.php @@ -16,7 +16,6 @@ class Mage_Cms_Model_Resource_Block_Collection extends Mage_Core_Model_Resource_ { /** * Define resource model - * */ protected function _construct() { diff --git a/app/code/core/Mage/Cms/Model/Resource/Page.php b/app/code/core/Mage/Cms/Model/Resource/Page.php index f03ece47c59..98f8f3a798f 100644 --- a/app/code/core/Mage/Cms/Model/Resource/Page.php +++ b/app/code/core/Mage/Cms/Model/Resource/Page.php @@ -68,7 +68,11 @@ protected function _beforeSave(Mage_Core_Model_Abstract $object) * If they are empty we need to convert them into DB * type NULL so in DB they will be empty and not some default value */ - foreach (['custom_theme_from', 'custom_theme_to'] as $field) { + $dates = [ + Mage_Cms_Api_Data_PageInterface::DATA_CUSTOM_THEME_FROM, + Mage_Cms_Api_Data_PageInterface::DATA_CUSTOM_THEME_TO, + ]; + foreach ($dates as $field) { $value = !$object->getData($field) ? null : $object->getData($field); $object->setData($field, $this->formatDate($value)); } @@ -76,7 +80,7 @@ protected function _beforeSave(Mage_Core_Model_Abstract $object) if (!$object->getIsActive()) { $isUsedInConfig = $this->getUsedInStoreConfigCollection($object); if ($isUsedInConfig->count()) { - $object->setIsActive(true); + $object->setIsActive(1); Mage::getSingleton('adminhtml/session')->addWarning( Mage::helper('cms')->__( 'Cannot disable page, it is used in configuration "%s".', @@ -243,10 +247,10 @@ public function getIsUniquePageToStores(Mage_Core_Model_Abstract $object) if (!$object->hasStores()) { $stores = [Mage_Core_Model_App::ADMIN_STORE_ID]; } else { - $stores = (array) $object->getData('stores'); + $stores = (array) $object->getDataByKey('stores'); } - $select = $this->_getLoadByIdentifierSelect($object->getData('identifier'), $stores); + $select = $this->_getLoadByIdentifierSelect($object->getDataByKey('identifier'), $stores); if ($object->getId()) { $select->where('cps.page_id <> ?', $object->getId()); @@ -266,18 +270,17 @@ public function getIsUniquePageToStores(Mage_Core_Model_Abstract $object) */ protected function isNumericPageIdentifier(Mage_Core_Model_Abstract $object) { - return preg_match('/^\d+$/', $object->getData('identifier')); + return preg_match('/^\d+$/', $object->getDataByKey('identifier')); } /** * Check whether page identifier is valid * - * * @return int|false */ protected function isValidPageIdentifier(Mage_Core_Model_Abstract $object) { - return preg_match('/^[a-z0-9][a-z0-9_\/-]+(\.[a-z0-9_-]+)?$/', $object->getData('identifier')); + return preg_match('/^[a-z0-9][a-z0-9_\/-]+(\.[a-z0-9_-]+)?$/', $object->getDataByKey('identifier')); } public function getUsedInStoreConfigCollection(Mage_Cms_Model_Page $page, ?array $paths = []): Mage_Core_Model_Resource_Db_Collection_Abstract diff --git a/app/code/core/Mage/Cms/Model/Resource/Page/Collection.php b/app/code/core/Mage/Cms/Model/Resource/Page/Collection.php index ecd5978345e..e3c6de54a6c 100644 --- a/app/code/core/Mage/Cms/Model/Resource/Page/Collection.php +++ b/app/code/core/Mage/Cms/Model/Resource/Page/Collection.php @@ -23,7 +23,6 @@ class Mage_Cms_Model_Resource_Page_Collection extends Mage_Core_Model_Resource_D /** * Define resource model - * */ protected function _construct() { @@ -53,13 +52,13 @@ public function toOptionIdArray() $res = []; $existingIdentifiers = []; foreach ($this as $item) { - $identifier = $item->getData('identifier'); + $identifier = $item->getDataByKey('identifier'); $data['value'] = $identifier; - $data['label'] = $item->getData('title'); + $data['label'] = $item->getDataByKey('title'); if (in_array($identifier, $existingIdentifiers)) { - $data['value'] .= '|' . $item->getData('page_id'); + $data['value'] .= '|' . $item->getDataByKey('page_id'); } else { $existingIdentifiers[] = $identifier; } @@ -97,16 +96,16 @@ protected function _afterLoad() if ($result = $connection->fetchPairs($select)) { foreach ($this as $item) { - if (!isset($result[$item->getData('page_id')])) { + if (!isset($result[$item->getDataByKey('page_id')])) { continue; } - if ($result[$item->getData('page_id')] == 0) { + if ($result[$item->getDataByKey('page_id')] == 0) { $stores = Mage::app()->getStores(false, true); $storeId = current($stores)->getId(); $storeCode = key($stores); } else { - $storeId = $result[$item->getData('page_id')]; + $storeId = $result[$item->getDataByKey('page_id')]; $storeCode = Mage::app()->getStore($storeId)->getCode(); } diff --git a/app/code/core/Mage/Cms/Model/Wysiwyg/Config.php b/app/code/core/Mage/Cms/Model/Wysiwyg/Config.php index 4578efadb76..e63dd5b209d 100644 --- a/app/code/core/Mage/Cms/Model/Wysiwyg/Config.php +++ b/app/code/core/Mage/Cms/Model/Wysiwyg/Config.php @@ -88,16 +88,15 @@ public function getConfig($data = []) 'plugins' => [], 'lang' => $lang, ]); - $config->setData('directives_url_quoted', preg_quote($config->getData('directives_url'))); + $config->setData('directives_url_quoted', preg_quote($config->getDataByKey('directives_url'))); if (Mage::getSingleton('admin/session')->isAllowed('cms/media_gallery')) { + $configNode = Mage::getConfig()->getNode('adminhtml/cms/browser'); $config->addData([ - 'add_images' => true, - 'files_browser_window_url' => Mage::getSingleton('adminhtml/url')->getUrl('*/cms_wysiwyg_images/index'), - 'files_browser_window_width' - => (int) Mage::getConfig()->getNode('adminhtml/cms/browser/window_width'), - 'files_browser_window_height' - => (int) Mage::getConfig()->getNode('adminhtml/cms/browser/window_height'), + 'add_images' => true, + 'files_browser_window_url' => Mage::getSingleton('adminhtml/url')->getUrl('*/cms_wysiwyg_images/index'), + 'files_browser_window_width' => (int) $configNode->window_width, + 'files_browser_window_height' => (int) $configNode->window_height, ]); } diff --git a/app/code/core/Mage/Core/Api/Data/WebsiteInterface.php b/app/code/core/Mage/Core/Api/Data/WebsiteInterface.php new file mode 100644 index 00000000000..0e8fc58a46d --- /dev/null +++ b/app/code/core/Mage/Core/Api/Data/WebsiteInterface.php @@ -0,0 +1,55 @@ +setData('cache_key', $cacheKey); + } + + /** + * Get tags array for saving cached * * @return array */ @@ -1440,6 +1443,14 @@ public function getCacheTags() return array_unique($tags); } + /** + * @return $this + */ + public function setCacheTags(array $cacheTags) + { + return $this->setData('cache_tags', $cacheTags); + } + /** * Add tag to block * @@ -1484,6 +1495,14 @@ public function getCacheLifetime() return $this->getData('cache_lifetime'); } + /** + * @return $this + */ + public function setCacheLifetime($lifetime) + { + return $this->setData('cache_lifetime', $lifetime); + } + /** * Retrieve Session Form Key * @@ -1613,6 +1632,23 @@ protected function _isSecure() return $this->_getApp()->getFrontController()->getRequest()->isSecure(); } + /** + * @return string|null + */ + public function getTemplate() + { + return $this->getDataByKey('template'); + } + + /** + * @param string $template + * @return $this + */ + public function setTemplate($template) + { + return $this->setData('template', $template); + } + public function isModuleEnabled(?string $moduleName = null, string $helperAlias = 'core'): bool { if ($moduleName === null) { diff --git a/app/code/core/Mage/Core/Block/Text.php b/app/code/core/Mage/Core/Block/Text.php index 3f7cf97efc0..14e2d33bb6e 100644 --- a/app/code/core/Mage/Core/Block/Text.php +++ b/app/code/core/Mage/Core/Block/Text.php @@ -11,26 +11,33 @@ * Base html block * * @package Mage_Core - * - * @method array getLiParams() - * @method $this setLiParams(array $value) - * @method array getAParams() - * @method $this setAParams(array $value) - * @method string getInnerText() - * @method $this setInnerText(string $value) - * @method string getAfterText() - * @method $this setAfterText(string $value) */ class Mage_Core_Block_Text extends Mage_Core_Block_Abstract { + public function getAfterText(): ?string + { + return $this->getData('after_text'); + } + /** - * @param string $text * @return $this */ - public function setText($text) + public function setAfterText(?string $text) { - $this->setData('text', $text); - return $this; + return $this->setData('after_text', $text); + } + + public function getInnerText(): ?string + { + return $this->getData('inner_text'); + } + + /** + * @return $this + */ + public function setInnerText(?string $text) + { + return $this->setData('inner_text', $text); } /** @@ -41,6 +48,16 @@ public function getText() return $this->getData('text'); } + /** + * @param string $text + * @return $this + */ + public function setText($text) + { + $this->setData('text', $text); + return $this; + } + /** * @param string $text * @param bool $before @@ -54,6 +71,40 @@ public function addText($text, $before = false) } } + /** + * @return string|array + */ + public function getAParams() + { + return $this->getData('a_params'); + } + + /** + * @param string|array $params + * @return $this + */ + public function setAParams($params) + { + return $this->setData('a_params', $params); + } + + /** + * @return string|array + */ + public function getLiParams() + { + return $this->getData('li_params'); + } + + /** + * @param string|array $params + * @return $this + */ + public function setLiParams($params) + { + return $this->setData('li_params', $params); + } + /** * @return string */ diff --git a/app/code/core/Mage/Core/Block/Text/List/Item.php b/app/code/core/Mage/Core/Block/Text/List/Item.php index fd38cb98e30..2f4c4ee237a 100644 --- a/app/code/core/Mage/Core/Block/Text/List/Item.php +++ b/app/code/core/Mage/Core/Block/Text/List/Item.php @@ -16,7 +16,7 @@ class Mage_Core_Block_Text_List_Item extends Mage_Core_Block_Text { /** * @param array $liParams - * @param array $innerText + * @param string $innerText * @return $this */ public function setLink($liParams, $innerText) diff --git a/app/code/core/Mage/Core/Block/Text/List/Link.php b/app/code/core/Mage/Core/Block/Text/List/Link.php index 4fe29c47b21..5e505e079ed 100644 --- a/app/code/core/Mage/Core/Block/Text/List/Link.php +++ b/app/code/core/Mage/Core/Block/Text/List/Link.php @@ -15,8 +15,8 @@ class Mage_Core_Block_Text_List_Link extends Mage_Core_Block_Text { /** - * @param array $liParams - * @param array $aParams + * @param string|array $liParams + * @param string|array $aParams * @param string $innerText * @param string $afterText * @return $this diff --git a/app/code/core/Mage/Core/Helper/String.php b/app/code/core/Mage/Core/Helper/String.php index 2213e01397d..0eb118a8984 100644 --- a/app/code/core/Mage/Core/Helper/String.php +++ b/app/code/core/Mage/Core/Helper/String.php @@ -281,7 +281,7 @@ public function splitWords($str, $uniqueOnly = false, $maxWordLength = 0, $wordS /** * Clean non UTF-8 characters * - * @param string $string + * @param string|null $string * @return string */ public function cleanString($string) diff --git a/app/code/core/Mage/Core/Model/Domainpolicy.php b/app/code/core/Mage/Core/Model/Domainpolicy.php index 7185f8336d4..a2c87fc4e18 100644 --- a/app/code/core/Mage/Core/Model/Domainpolicy.php +++ b/app/code/core/Mage/Core/Model/Domainpolicy.php @@ -56,7 +56,7 @@ public function __construct($options = []) */ public function addDomainPolicyHeader(Varien_Event_Observer $observer) { - $action = $observer->getControllerAction(); + $action = $observer->getDataByKey('controller_action'); $policy = null; if ($action->getLayout()->getArea() == 'adminhtml') { diff --git a/app/code/core/Mage/Core/Model/Layout.php b/app/code/core/Mage/Core/Model/Layout.php index 5bf0dc3b061..01bffda3996 100644 --- a/app/code/core/Mage/Core/Model/Layout.php +++ b/app/code/core/Mage/Core/Model/Layout.php @@ -593,6 +593,7 @@ public function getOutput() */ public function getMessagesBlock() { + /** @var Mage_Core_Block_Messages $block */ $block = $this->getBlock('messages'); if ($block instanceof Mage_Core_Block_Messages) { return $block; diff --git a/app/code/core/Mage/Core/Model/Session.php b/app/code/core/Mage/Core/Model/Session.php index 3fc1051db80..0c48f1767e1 100644 --- a/app/code/core/Mage/Core/Model/Session.php +++ b/app/code/core/Mage/Core/Model/Session.php @@ -22,7 +22,6 @@ * @method int getJustVotedPoll() * @method $this setOrderIds(array $value) * @method $this setJustVotedPoll(int $value) - * @method $this setLastUrl(string $value) */ class Mage_Core_Model_Session extends Mage_Core_Model_Session_Abstract { @@ -72,4 +71,30 @@ public function getOrderIds(bool $clear = false): array { return $this->getData('order_ids', $clear) ?? []; } + + public function getLastUrl(): ?string + { + return $this->getDataByKey('last_url'); + } + + /** + * @return $this + */ + public function setLastUrl(?string $storeId) + { + return $this->setData('last_url', $storeId); + } + + public function getVisitorData(): ?array + { + return $this->getDataByKey('visitor_data'); + } + + /** + * @return $this + */ + public function setVisitorData(?array $data) + { + return $this->setData('visitor_data', $data); + } } diff --git a/app/code/core/Mage/Core/Model/Store.php b/app/code/core/Mage/Core/Model/Store.php index cef474600e5..ad09081f8bc 100644 --- a/app/code/core/Mage/Core/Model/Store.php +++ b/app/code/core/Mage/Core/Model/Store.php @@ -19,12 +19,8 @@ * * @method $this setCode(string $value) * @method $this setGroupId(int $value) - * @method string getHomeUrl() - * @method $this setHomeUrl(string $value) * @method $this setIsActive(int $value) - * @method $this setLocaleCode(string $value) * @method string getLanguageCode() - * @method string getLocaleCode() * @method $this setName(string $value) * @method $this setRootCategory(Mage_Catalog_Model_Category $value) * @method $this setRootCategoryPath(string $value) @@ -1293,4 +1289,30 @@ public function getFrontendName() return $this->_frontendName; } + + public function getHomeUrl(): ?string + { + return $this->getDataByKey('home_url'); + } + + /** + * @return $this + */ + public function setHomeUrl(?string $localeCode) + { + return $this->setData('home_url', $localeCode); + } + + public function getLocaleCode(): ?string + { + return $this->getDataByKey('locale_code'); + } + + /** + * @return $this + */ + public function setLocaleCode(?string $localeCode) + { + return $this->setData('locale_code', $localeCode); + } } diff --git a/app/code/core/Mage/Core/Model/Url.php b/app/code/core/Mage/Core/Model/Url.php index b5d05fafe9e..aea36ceebdf 100644 --- a/app/code/core/Mage/Core/Model/Url.php +++ b/app/code/core/Mage/Core/Model/Url.php @@ -323,17 +323,18 @@ public function getSecure() } $store = $this->getStore(); + $isAdmin = $store->isAdmin(); - if ($store->isAdmin() && !$store->isAdminUrlSecure()) { + if ($isAdmin && !$store->isAdminUrlSecure()) { return false; } - if (!$store->isAdmin() && !$store->isFrontUrlSecure()) { + if (!$isAdmin && !$store->isFrontUrlSecure()) { return false; } if (!$this->hasData('secure')) { - if ($this->getType() == Mage_Core_Model_Store::URL_TYPE_LINK && !$store->isAdmin()) { + if ($this->getType() == Mage_Core_Model_Store::URL_TYPE_LINK && !$isAdmin) { $pathSecure = Mage::getConfig()->shouldUrlBeSecure('/' . $this->getActionPath()); $this->setData('secure', $pathSecure); } else { @@ -341,7 +342,7 @@ public function getSecure() } } - return $this->getData('secure'); + return $this->getDataByKey('secure'); } /** diff --git a/app/code/core/Mage/Core/Model/Website.php b/app/code/core/Mage/Core/Model/Website.php index 3b31c1eccb4..7c41c53770c 100644 --- a/app/code/core/Mage/Core/Model/Website.php +++ b/app/code/core/Mage/Core/Model/Website.php @@ -17,23 +17,13 @@ * @method Mage_Core_Model_Resource_Website_Collection getCollection() * @method Mage_Core_Model_Resource_Website_Collection getResourceCollection() * - * @method $this setCode(string $value) - * @method string getName() - * @method $this setName(string $value) - * @method int getSortOrder() - * @method $this setSortOrder(int $value) - * @method $this setDefaultGroupId(int $value) - * @method int getIsDefault() - * @method $this setIsDefault(int $value) * @method int getGroupId() * @method int getStoreId() * @method $this setStoreId(int $value) * @method array getStoresIds() * @method bool hasWebsiteId() - * @method int getWebsiteId() - * @method bool hasDefaultGroupId() */ -class Mage_Core_Model_Website extends Mage_Core_Model_Abstract +class Mage_Core_Model_Website extends Mage_Core_Model_Abstract implements Mage_Core_Api_Data_WebsiteInterface { public const ENTITY = 'core_website'; @@ -323,7 +313,7 @@ public function getGroupsCount() */ public function getDefaultGroup() { - if (!$this->hasDefaultGroupId()) { + if (!$this->hasData('default_group_id')) { return false; } @@ -474,22 +464,6 @@ public function getWebsiteGroupStore() return implode('-', [$this->getWebsiteId(), $this->getGroupId(), $this->getStoreId()]); } - /** - * @return int - */ - public function getDefaultGroupId() - { - return $this->_getData('default_group_id'); - } - - /** - * @return string - */ - public function getCode() - { - return $this->_getData('code'); - } - /** * @inheritDoc */ @@ -583,4 +557,109 @@ public function isReadOnly($value = null) return $this->_isReadOnly; } + + /** + * @api + */ + public function getWebsiteId(): ?int + { + $websiteId = $this->getDataByKey(self::DATA_ID); + return is_null($websiteId) ? null : (int) $websiteId; + } + + /** + * @api + * @return $this + */ + public function setWebsiteId(?int $value) + { + return $this->setData(self::DATA_ID, $value); + } + + /** + * @api + * @return string + */ + public function getCode() + { + return $this->_getData(self::DATA_CODE); + } + + /** + * @api + * @return $this + */ + public function setCode(?string $code) + { + return $this->setData(self::DATA_CODE, $code); + } + + /** + * @api + * @return int + */ + public function getDefaultGroupId() + { + return (int) $this->_getData(self::DATA_DEFAULT_GROUP_ID); + } + + /** + * @api + * @return $this + */ + public function setDefaultGroupId(int $value) + { + return $this->setData(self::DATA_DEFAULT_GROUP_ID, $value); + } + + /** + * @api + */ + public function getIsDefault(): ?int + { + return (int) $this->_getData(self::DATA_IS_DEFAULT); + } + + /** + * @api + * @return $this + */ + public function setIsDefault(?int $value) + { + return $this->setData(self::DATA_IS_DEFAULT, $value); + } + + /** + * @api + */ + public function getName(): ?string + { + return $this->_getData(self::DATA_NAME); + } + + /** + * @api + * @return $this + */ + public function setName(?string $name) + { + return $this->setData(self::DATA_NAME, $name); + } + + /** + * @api + */ + public function getSortOrder(): int + { + return (int) $this->_getData(self::DATA_SORT_ORDER); + } + + /** + * @api + * @return $this + */ + public function setSortOrder(int $position) + { + return $this->setData(self::DATA_SORT_ORDER, $position); + } } diff --git a/app/code/core/Mage/Log/Api/Data/VisitorInterface.php b/app/code/core/Mage/Log/Api/Data/VisitorInterface.php new file mode 100644 index 00000000000..3e3a8e9eecf --- /dev/null +++ b/app/code/core/Mage/Log/Api/Data/VisitorInterface.php @@ -0,0 +1,55 @@ +insert($this->getTable('log/url_info_table'), $bind); - $visitor->setLastUrlId($adapter->lastInsertId($this->getTable('log/url_info_table'))); + $visitor->setLastUrlId((int) $adapter->lastInsertId($this->getTable('log/url_info_table'))); return $this; } @@ -76,6 +77,7 @@ protected function _saveUrlInfo($visitor) /** * Save url info before save * + * @param Mage_Log_Model_Visitor $visitor * @return $this */ protected function _beforeSave(Mage_Core_Model_Abstract $visitor) @@ -94,6 +96,7 @@ protected function _beforeSave(Mage_Core_Model_Abstract $visitor) /** * Actions after save * + * @param Mage_Log_Model_Visitor $visitor * @return $this */ protected function _afterSave(Mage_Core_Model_Abstract $visitor) @@ -128,6 +131,7 @@ protected function _afterSave(Mage_Core_Model_Abstract $visitor) /** * Perform actions after object load * + * @param Mage_Log_Model_Visitor $object * @return $this */ protected function _afterLoad(Mage_Core_Model_Abstract $object) @@ -152,8 +156,8 @@ protected function _afterLoad(Mage_Core_Model_Abstract $object) /** * Saving visitor information * - * @param Mage_Core_Model_Abstract|Mage_Log_Model_Visitor $visitor - * @return $this + * @param Mage_Log_Model_Visitor $visitor + * @return $this */ protected function _saveVisitorInfo($visitor) { diff --git a/app/code/core/Mage/Log/Model/Visitor.php b/app/code/core/Mage/Log/Model/Visitor.php index e4f460a2c70..a85fd09f324 100644 --- a/app/code/core/Mage/Log/Model/Visitor.php +++ b/app/code/core/Mage/Log/Model/Visitor.php @@ -11,42 +11,8 @@ * @package Mage_Log * * @method Mage_Log_Model_Resource_Visitor getResource() - * @method int getCustomerId() - * @method $this setCustomerId(int $value) - * @method int getCustomerLogId() - * @method $this setCustomerLogId(int $value) - * @method bool getDoCustomerLogin() - * @method $this setDoCustomerLogin(bool $value) - * @method bool getDoCustomerLogout() - * @method $this setDoCustomerLogout(bool $value) - * @method bool getDoQuoteCreate() - * @method $this setDoQuoteCreate(bool $value) - * @method bool getDoQuoteDestroy() - * @method $this setDoQuoteDestroy(bool $value) - * @method $this setFirstVisitAt(string $value) - * @method string getHttpAcceptCharset() - * @method string getHttpAcceptLanguage() - * @method string getHttpHost() - * @method string getHttpReferer() - * @method string getHttpSecure() - * @method string getHttpUserAgent() - * @method bool getIsNewVisitor() - * @method $this setIsNewVisitor(bool $value) - * @method $this setLastVisitAt(string $value) - * @method int getLastUrlId() - * @method $this setLastUrlId(int $value) - * @method int getQuoteId() - * @method $this setQuoteId(int $value) - * @method string getRemoteAddr() - * @method string getRequestUri() - * @method string getServerAddr() - * @method string getSessionId() - * @method $this setSessionId(string $value) - * @method int getStoreId() - * @method $this setStoreId(int $value) - * @method int getVisitorId() */ -class Mage_Log_Model_Visitor extends Mage_Core_Model_Abstract +class Mage_Log_Model_Visitor extends Mage_Core_Model_Abstract implements Mage_Log_Api_Data_VisitorInterface { public const DEFAULT_ONLINE_MINUTES_INTERVAL = 15; @@ -133,7 +99,7 @@ public function initServerData() $this->addData([ 'server_addr' => $this->_httpHelper->getServerAddr(true), 'remote_addr' => $this->_httpHelper->getRemoteAddr(true), - 'http_secure' => Mage::app()->getStore()->isCurrentlySecure(), + 'http_secure' => Mage::app()->isCurrentlySecure(), 'http_host' => $this->_httpHelper->getHttpHost(true), 'http_user_agent' => $this->_httpHelper->getHttpUserAgent(true), 'http_accept_language' => $this->_httpHelper->getHttpAcceptLanguage(true), @@ -171,27 +137,47 @@ public function getUrl() } /** + * @api * @return string */ public function getFirstVisitAt() { - if (!$this->hasData('first_visit_at')) { - $this->setData('first_visit_at', Varien_Date::now()); + if (!$this->hasData(self::DATA_FIRST_VISIT_AT)) { + $this->setData(self::DATA_FIRST_VISIT_AT, Varien_Date::now()); } - return $this->getData('first_visit_at'); + return $this->getDataByKey(self::DATA_FIRST_VISIT_AT); } /** + * @api + * @return $this + */ + public function setFirstVisitAt(?string $value) + { + return $this->setData(self::DATA_FIRST_VISIT_AT, $value); + } + + /** + * @api * @return string */ public function getLastVisitAt() { - if (!$this->hasData('last_visit_at')) { - $this->setData('last_visit_at', Varien_Date::now()); + if (!$this->hasData(self::DATA_LAST_VISIT_AT)) { + $this->setData(self::DATA_LAST_VISIT_AT, Varien_Date::now()); } - return $this->getData('last_visit_at'); + return $this->getDataByKey(self::DATA_LAST_VISIT_AT); + } + + /** + * @api + * @return $this + */ + public function setLastVisitAt(string $value) + { + return $this->setData(self::DATA_LAST_VISIT_AT, $value); } /** @@ -278,7 +264,7 @@ public function saveByRequest($observer) public function bindCustomerLogin($observer) { /** @var Mage_Customer_Model_Customer $customer */ - $customer = $observer->getEvent()->getCustomer(); + $customer = $observer->getEvent()->getDataByKey('customer'); if ($customer) { $this->setDoCustomerLogin(true); $this->setCustomerId($customer->getId()); @@ -297,7 +283,7 @@ public function bindCustomerLogin($observer) */ public function bindCustomerLogout($observer) { - if ($this->getCustomerId() && $customer = $observer->getEvent()->getCustomer()) { + if ($this->getCustomerId() && $observer->getEvent()->getDataByKey('customer')) { $this->setDoCustomerLogout(true); } @@ -311,7 +297,7 @@ public function bindCustomerLogout($observer) public function bindQuoteCreate($observer) { /** @var Mage_Sales_Model_Quote $quote */ - $quote = $observer->getEvent()->getQuote(); + $quote = $observer->getEvent()->getDataByKey('quote'); if ($quote) { if ($quote->getIsCheckoutCart()) { $this->setQuoteId($quote->getId()); @@ -329,7 +315,7 @@ public function bindQuoteCreate($observer) public function bindQuoteDestroy($observer) { /** @var Mage_Sales_Model_Quote $quote */ - $quote = $observer->getEvent()->getQuote(); + $quote = $observer->getEvent()->getDataByKey('quote'); if ($quote) { $this->setDoQuoteDestroy(true); } @@ -394,7 +380,7 @@ public function isModuleIgnored($observer) $ignores = $this->_config->getNode('global/ignoredModules/entities')->asArray(); if (is_array($ignores) && $observer) { - $curModule = $observer->getEvent()->getControllerAction()->getRequest()->getRouteName(); + $curModule = $observer->getEvent()->getDataByKey('controller_action')->getRequest()->getRouteName(); if (isset($ignores[$curModule])) { return true; } @@ -402,4 +388,294 @@ public function isModuleIgnored($observer) return false; } + + public function getCustomerId(): ?int + { + return $this->getDataByKey('customer_id'); + } + + /** + * @return $this + */ + public function setCustomerId(?int $value) + { + return $this->setData('customer_id', $value); + } + + public function getCustomerLogId(): ?int + { + return $this->getDataByKey('customer_log_id'); + } + + /** + * @return $this + */ + public function setCustomerLogId(?int $value) + { + return $this->setData('customer_log_id', $value); + } + + public function getDoCustomerLogin(): int + { + return $this->getDataByKey('do_customer_login'); + } + + /** + * @return $this + */ + public function setDoCustomerLogin(?bool $value) + { + return $this->setData('do_customer_login', $value); + } + + public function getDoCustomerLogout(): ?bool + { + return $this->getDataByKey('do_customer_logout'); + } + + /** + * @return $this + */ + public function setDoCustomerLogout(?bool $value) + { + return $this->setData('do_customer_logout', $value); + } + + public function getDoQuoteCreate(): ?bool + { + return $this->getDataByKey('do_quote_create'); + } + + /** + * @return $this + */ + public function setDoQuoteCreate(?bool $value) + { + return $this->setData('do_quote_create', $value); + } + + public function getIsNewVisitor(): bool + { + return $this->getDataByKey('is_new_visitor'); + } + + /** + * @return $this + */ + public function setIsNewVisitor(bool $value) + { + return $this->setData('is_new_visitor', $value); + } + + public function getDoQuoteDestroy(): ?bool + { + return $this->getDataByKey('do_quote_destroy'); + } + + /** + * @return $this + */ + public function setDoQuoteDestroy(?bool $value) + { + return $this->setData('do_quote_destroy', $value); + } + + public function getHttpAcceptCharset(): ?string + { + return $this->getDataByKey('http_accept_charset'); + } + + /** + * @return $this + */ + public function setHttpAcceptCharset(?string $value) + { + return $this->setData('http_accept_charset', $value); + } + + public function getHttpAcceptLanguage(): ?string + { + return $this->getDataByKey('http_accept_language'); + } + + /** + * @return $this + */ + public function setHttpAcceptLanguage(?string $value) + { + return $this->setData('http_accept_language', $value); + } + + public function getHttpHost(): ?string + { + return $this->getDataByKey('http_host'); + } + + /** + * @return $this + */ + public function setHttpHost(?string $value) + { + return $this->setData('http_host', $value); + } + + public function getHttpReferer(): ?string + { + return $this->getDataByKey('http_referer'); + } + + /** + * @return $this + */ + public function setHttpReferer(?string $value) + { + return $this->setData('http_referer', $value); + } + + public function getHttpSecure(): ?string + { + return $this->getDataByKey('http_secure'); + } + + /** + * @return $this + */ + public function setHttpSecure(?string $value) + { + return $this->setData('http_secure', $value); + } + + public function getHttpUserAgent(): ?string + { + return $this->getDataByKey('http_user_agent'); + } + + /** + * @return $this + */ + public function setHttpUserAgent(?string $value) + { + return $this->setData('http_user_agent', $value); + } + + public function getQuoteId(): ?int + { + return $this->getDataByKey('quote_id'); + } + + /** + * @return $this + */ + public function setQuoteId(?int $value) + { + return $this->setData('quote_id', $value); + } + + public function getRemoteAddr(): ?string + { + return $this->getDataByKey('remote_addr'); + } + + /** + * @return $this + */ + public function setRemoteAddr(?string $value) + { + return $this->setData('remote_addr', $value); + } + + public function getRequestUri(): ?string + { + return $this->getDataByKey('request_uri'); + } + + /** + * @return $this + */ + public function setRequestUri(?string $value) + { + return $this->setData('request_uri', $value); + } + + public function getServerAddr(): ?string + { + return $this->getDataByKey('server_addr'); + } + + /** + * @return $this + */ + public function setServerAddr(?string $value) + { + return $this->setData('server_addr', $value); + } + + /** + * @api + */ + public function getVisitorId(): ?int + { + $visitorId = $this->getDataByKey(self::DATA_ID); + return is_null($visitorId) ? null : (int) $visitorId; + } + + /** + * @api + * @return $this + */ + public function setVisitorId(?int $value) + { + return $this->setData(self::DATA_ID, $value); + } + + /** + * @api + */ + public function getLastUrlId(): int + { + return (int) $this->getDataByKey(self::DATA_LAST_URL_ID); + } + + /** + * @api + * @return $this + */ + public function setLastUrlId(int $value) + { + return $this->setData(self::DATA_LAST_URL_ID, $value); + } + + /** + * @api + */ + public function getSessionId(): ?string + { + return $this->getDataByKey(self::DATA_SESSION_ID); + } + + /** + * @api + * @return $this + */ + public function setSessionId(?string $value) + { + return $this->setData(self::DATA_SESSION_ID, $value); + } + + /** + * @api + */ + public function getStoreId(): int + { + return (int) $this->getDataByKey(self::DATA_STORE_ID); + } + + /** + * @api + * @return $this + */ + public function setStoreId(int $storeId) + { + return $this->setData(self::DATA_STORE_ID, $storeId); + } }