diff --git a/app/code/core/Mage/Adminhtml/Block/Cms/Page/Edit/Tab/Design.php b/app/code/core/Mage/Adminhtml/Block/Cms/Page/Edit/Tab/Design.php index f59601a8449..c85370eb909 100644 --- a/app/code/core/Mage/Adminhtml/Block/Cms/Page/Edit/Tab/Design.php +++ b/app/code/core/Mage/Adminhtml/Block/Cms/Page/Edit/Tab/Design.php @@ -7,6 +7,8 @@ * @package Mage_Adminhtml */ +use Mage_Cms_Api_Data_PageInterface as PageInterface; + /** * @package Mage_Adminhtml */ @@ -23,6 +25,7 @@ public function __construct() /** * @inheritDoc + * @throws Exception */ protected function _prepareForm() { @@ -47,8 +50,8 @@ protected function _prepareForm() 'disabled' => $isElementDisabled, ]); - $layoutFieldset->addField('root_template', 'select', [ - 'name' => 'root_template', + $layoutFieldset->addField(PageInterface::DATA_ROOT_TEMPLATE, 'select', [ + 'name' => PageInterface::DATA_ROOT_TEMPLATE, 'label' => Mage::helper('cms')->__('Layout'), 'required' => true, 'values' => Mage::getSingleton('page/source_layout')->toOptionArray(), @@ -58,8 +61,8 @@ protected function _prepareForm() $model->setRootTemplate(Mage::getSingleton('page/source_layout')->getDefaultValue()); } - $layoutFieldset->addField('layout_update_xml', 'textarea', [ - 'name' => 'layout_update_xml', + $layoutFieldset->addField(PageInterface::DATA_LAYOUT_UPDATE_XML, 'textarea', [ + 'name' => PageInterface::DATA_LAYOUT_UPDATE_XML, 'label' => Mage::helper('cms')->__('Layout Update XML'), 'style' => 'height:24em;', 'disabled' => $isElementDisabled, @@ -75,8 +78,8 @@ protected function _prepareForm() Mage_Core_Model_Locale::FORMAT_TYPE_SHORT, ); - $designFieldset->addField('custom_theme_from', 'date', [ - 'name' => 'custom_theme_from', + $designFieldset->addField(PageInterface::DATA_CUSTOM_THEME_FROM, 'date', [ + 'name' => PageInterface::DATA_CUSTOM_THEME_FROM, 'label' => Mage::helper('cms')->__('Custom Design From'), 'image' => $this->getSkinUrl('images/grid-cal.gif'), 'format' => $dateFormatIso, @@ -84,8 +87,8 @@ protected function _prepareForm() 'class' => 'validate-date validate-date-range date-range-custom_theme-from', ]); - $designFieldset->addField('custom_theme_to', 'date', [ - 'name' => 'custom_theme_to', + $designFieldset->addField(PageInterface::DATA_CUSTOM_THEME_TO, 'date', [ + 'name' => PageInterface::DATA_CUSTOM_THEME_TO, 'label' => Mage::helper('cms')->__('Custom Design To'), 'image' => $this->getSkinUrl('images/grid-cal.gif'), 'format' => $dateFormatIso, @@ -93,22 +96,22 @@ protected function _prepareForm() 'class' => 'validate-date validate-date-range date-range-custom_theme-to', ]); - $designFieldset->addField('custom_theme', 'select', [ - 'name' => 'custom_theme', + $designFieldset->addField(PageInterface::DATA_CUSTOM_THEME, 'select', [ + 'name' => PageInterface::DATA_CUSTOM_THEME, 'label' => Mage::helper('cms')->__('Custom Theme'), 'values' => Mage::getModel('core/design_source_design')->getAllOptions(), 'disabled' => $isElementDisabled, ]); - $designFieldset->addField('custom_root_template', 'select', [ - 'name' => 'custom_root_template', + $designFieldset->addField(PageInterface::DATA_CUSTOM_ROOT_TEMPLATE, 'select', [ + 'name' => PageInterface::DATA_CUSTOM_ROOT_TEMPLATE, 'label' => Mage::helper('cms')->__('Custom Layout'), 'values' => Mage::getSingleton('page/source_layout')->toOptionArray(true), 'disabled' => $isElementDisabled, ]); - $designFieldset->addField('custom_layout_update_xml', 'textarea', [ - 'name' => 'custom_layout_update_xml', + $designFieldset->addField(PageInterface::DATA_CUSTOM_LAYOUT_UPDATE_XML, 'textarea', [ + 'name' => PageInterface::DATA_CUSTOM_LAYOUT_UPDATE_XML, 'label' => Mage::helper('cms')->__('Custom Layout Update XML'), 'style' => 'height:24em;', 'disabled' => $isElementDisabled, diff --git a/app/code/core/Mage/Adminhtml/controllers/Cms/BlockController.php b/app/code/core/Mage/Adminhtml/controllers/Cms/BlockController.php index ce77ee38f0f..ebfa57d9bcf 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Cms/BlockController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Cms/BlockController.php @@ -7,6 +7,8 @@ * @package Mage_Adminhtml */ +use Mage_Cms_Api_Data_BlockInterface as BlockInterface; + /** * Cms manage blocks controller * @@ -49,6 +51,8 @@ protected function _initAction() /** * Index action + * + * @throws Mage_Core_Exception */ public function indexAction() { @@ -69,18 +73,20 @@ public function newAction() /** * Edit CMS block + * + * @throws Mage_Core_Exception */ public function editAction() { $this->_title($this->__('CMS'))->_title($this->__('Static Blocks')); // 1. Get ID and create model - $id = $this->getRequest()->getParam('block_id'); + $blockId = $this->getRequest()->getParam(BlockInterface::DATA_ID); $model = Mage::getModel('cms/block'); // 2. Initial checking - if ($id) { - $model->load($id); + if ($blockId) { + $model->load($blockId); if (!$model->getId()) { Mage::getSingleton('adminhtml/session')->addError(Mage::helper('cms')->__('This block no longer exists.')); $this->_redirect('*/*/'); @@ -101,20 +107,22 @@ public function editAction() // 5. Build edit form $this->_initAction() - ->_addBreadcrumb($id ? Mage::helper('cms')->__('Edit Block') : Mage::helper('cms')->__('New Block'), $id ? Mage::helper('cms')->__('Edit Block') : Mage::helper('cms')->__('New Block')) + ->_addBreadcrumb($blockId ? Mage::helper('cms')->__('Edit Block') : Mage::helper('cms')->__('New Block'), $blockId ? Mage::helper('cms')->__('Edit Block') : Mage::helper('cms')->__('New Block')) ->renderLayout(); } /** * Save action + * + * @throws Mage_Core_Exception */ public function saveAction() { // check if data sent if ($data = $this->getRequest()->getPost()) { - $id = $this->getRequest()->getParam('block_id'); - $model = Mage::getModel('cms/block')->load($id); - if (!$model->getId() && $id) { + $blockId = $this->getRequest()->getParam(BlockInterface::DATA_ID); + $model = Mage::getModel('cms/block')->load($blockId); + if (!$model->getId() && $blockId) { Mage::getSingleton('adminhtml/session')->addError(Mage::helper('cms')->__('This block no longer exists.')); $this->_redirect('*/*/'); return; @@ -135,20 +143,20 @@ public function saveAction() // check if 'Save and Continue' if ($this->getRequest()->getParam('back')) { - $this->_redirect('*/*/edit', ['block_id' => $model->getId()]); + $this->_redirect('*/*/edit', [BlockInterface::DATA_ID => $model->getId()]); return; } // go to grid $this->_redirect('*/*/'); return; - } catch (Exception $e) { + } catch (Exception $exception) { // display error message - Mage::getSingleton('adminhtml/session')->addError($e->getMessage()); + Mage::getSingleton('adminhtml/session')->addError($exception->getMessage()); // save data in session Mage::getSingleton('adminhtml/session')->setFormData($data); // redirect to edit form - $this->_redirect('*/*/edit', ['block_id' => $this->getRequest()->getParam('block_id')]); + $this->_redirect('*/*/edit', [BlockInterface::DATA_ID => $this->getRequest()->getParam(BlockInterface::DATA_ID)]); return; } } @@ -162,24 +170,22 @@ public function saveAction() public function deleteAction() { // check if we know what should be deleted - if ($id = $this->getRequest()->getParam('block_id')) { - $title = ''; + if ($blockId = $this->getRequest()->getParam(BlockInterface::DATA_ID)) { try { // init model and delete $model = Mage::getModel('cms/block'); - $model->load($id); - $title = $model->getTitle(); + $model->load($blockId); $model->delete(); // display success message Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('cms')->__('The block has been deleted.')); // go to grid $this->_redirect('*/*/'); return; - } catch (Exception $e) { + } catch (Exception $exception) { // display error message - Mage::getSingleton('adminhtml/session')->addError($e->getMessage()); + Mage::getSingleton('adminhtml/session')->addError($exception->getMessage()); // go back to edit form - $this->_redirect('*/*/edit', ['block_id' => $id]); + $this->_redirect('*/*/edit', [BlockInterface::DATA_ID => $blockId]); return; } } diff --git a/app/code/core/Mage/Adminhtml/controllers/Cms/PageController.php b/app/code/core/Mage/Adminhtml/controllers/Cms/PageController.php index e4f89e83f89..68dc94948e9 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Cms/PageController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Cms/PageController.php @@ -7,6 +7,8 @@ * @package Mage_Adminhtml */ +use Mage_Cms_Api_Data_PageInterface as PageInterface; + /** * Cms manage pages controller * @@ -32,6 +34,8 @@ protected function _initAction() /** * Index action + * + * @throws Mage_Core_Exception */ public function indexAction() { @@ -54,6 +58,8 @@ public function newAction() /** * Edit CMS page + * + * @throws Mage_Core_Exception */ public function editAction() { @@ -62,12 +68,12 @@ public function editAction() ->_title($this->__('Manage Content')); // 1. Get ID and create model - $id = $this->getRequest()->getParam('page_id'); + $pageId = $this->getRequest()->getParam(PageInterface::DATA_ID); $model = Mage::getModel('cms/page'); // 2. Initial checking - if ($id) { - $model->load($id); + if ($pageId) { + $model->load($pageId); if (!$model->getId()) { Mage::getSingleton('adminhtml/session')->addError( Mage::helper('cms')->__('This page no longer exists.'), @@ -92,9 +98,9 @@ public function editAction() // 5. Build edit form $this->_initAction() ->_addBreadcrumb( - $id ? Mage::helper('cms')->__('Edit Page') + $pageId ? Mage::helper('cms')->__('Edit Page') : Mage::helper('cms')->__('New Page'), - $id ? Mage::helper('cms')->__('Edit Page') + $pageId ? Mage::helper('cms')->__('Edit Page') : Mage::helper('cms')->__('New Page'), ); @@ -103,6 +109,10 @@ public function editAction() /** * Save action + * + * @throws Exception + * @throws Mage_Core_Exception + * @throws Zend_Locale_Exception */ public function saveAction() { @@ -112,8 +122,8 @@ public function saveAction() //init model and set data $model = Mage::getModel('cms/page'); - if ($id = $this->getRequest()->getParam('page_id')) { - $model->load($id); + if ($pageId = $this->getRequest()->getParam(PageInterface::DATA_ID)) { + $model->load($pageId); } $model->setData($data); @@ -122,7 +132,7 @@ public function saveAction() //validating if (!$this->_validatePostData($data)) { - $this->_redirect('*/*/edit', ['page_id' => $model->getId(), '_current' => true]); + $this->_redirect('*/*/edit', [PageInterface::DATA_ID => $model->getId(), '_current' => true]); return; } @@ -139,24 +149,24 @@ public function saveAction() Mage::getSingleton('adminhtml/session')->setFormData(false); // check if 'Save and Continue' if ($this->getRequest()->getParam('back')) { - $this->_redirect('*/*/edit', ['page_id' => $model->getId(), '_current' => true]); + $this->_redirect('*/*/edit', [PageInterface::DATA_ID => $model->getId(), '_current' => true]); return; } // go to grid $this->_redirect('*/*/'); return; - } catch (Mage_Core_Exception $e) { - $this->_getSession()->addError($e->getMessage()); - } catch (Exception $e) { + } catch (Mage_Core_Exception $mageCoreException) { + $this->_getSession()->addError($mageCoreException->getMessage()); + } catch (Exception $exception) { $this->_getSession()->addException( - $e, + $exception, Mage::helper('cms')->__('An error occurred while saving the page.'), ); } $this->_getSession()->setFormData($data); - $this->_redirect('*/*/edit', ['page_id' => $this->getRequest()->getParam('page_id')]); + $this->_redirect('*/*/edit', [PageInterface::DATA_ID => $this->getRequest()->getParam(PageInterface::DATA_ID)]); return; } @@ -169,12 +179,12 @@ public function saveAction() public function deleteAction() { // check if we know what should be deleted - if ($id = $this->getRequest()->getParam('page_id')) { + if ($pageId = $this->getRequest()->getParam(PageInterface::DATA_ID)) { $title = ''; try { // init model and delete $model = Mage::getModel('cms/page'); - $model->load($id); + $model->load($pageId); $title = $model->getTitle(); $model->delete(); // display success message @@ -185,12 +195,12 @@ public function deleteAction() Mage::dispatchEvent('adminhtml_cmspage_on_delete', ['title' => $title, 'status' => 'success']); $this->_redirect('*/*/'); return; - } catch (Exception $e) { + } catch (Exception $exception) { Mage::dispatchEvent('adminhtml_cmspage_on_delete', ['title' => $title, 'status' => 'fail']); // display error message - Mage::getSingleton('adminhtml/session')->addError($e->getMessage()); + Mage::getSingleton('adminhtml/session')->addError($exception->getMessage()); // go back to edit form - $this->_redirect('*/*/edit', ['page_id' => $id]); + $this->_redirect('*/*/edit', [PageInterface::DATA_ID => $pageId]); return; } } @@ -232,30 +242,36 @@ protected function _isAllowed() * * @param array $data * @return array + * @throws Zend_Locale_Exception */ protected function _filterPostData($data) { - return $this->_filterDates($data, ['custom_theme_from', 'custom_theme_to']); + return $this->_filterDates($data, [PageInterface::DATA_CUSTOM_THEME_FROM, PageInterface::DATA_CUSTOM_THEME_TO]); } /** * Validate post data * * @param array $data - * @return bool Return FALSE if someone item is invalid + * @return bool Return FALSE if someone item is invalid + * @throws Exception */ protected function _validatePostData($data) { $errorNo = true; - if (!empty($data['layout_update_xml']) || !empty($data['custom_layout_update_xml'])) { + if (!empty($data[PageInterface::DATA_LAYOUT_UPDATE_XML]) + || !empty($data[PageInterface::DATA_CUSTOM_LAYOUT_UPDATE_XML]) + ) { /** @var Mage_Adminhtml_Model_LayoutUpdate_Validator $validatorCustomLayout */ $validatorCustomLayout = Mage::getModel('adminhtml/layoutUpdate_validator'); - if (!empty($data['layout_update_xml']) && !$validatorCustomLayout->isValid($data['layout_update_xml'])) { + if (!empty($data[PageInterface::DATA_LAYOUT_UPDATE_XML]) + && !$validatorCustomLayout->isValid($data[PageInterface::DATA_LAYOUT_UPDATE_XML]) + ) { $errorNo = false; } - if (!empty($data['custom_layout_update_xml']) - && !$validatorCustomLayout->isValid($data['custom_layout_update_xml']) + if (!empty($data[PageInterface::DATA_CUSTOM_LAYOUT_UPDATE_XML]) + && !$validatorCustomLayout->isValid($data[PageInterface::DATA_CUSTOM_LAYOUT_UPDATE_XML]) ) { $errorNo = false; } 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 @@ +getPageId()) { $page = Mage::getModel('cms/page') ->setStoreId(Mage::app()->getStore()->getId()) - ->load($this->getPageId(), 'identifier'); + ->load($this->getPageId(), PageInterface::DATA_IDENTIFIER); } else { $page = Mage::getSingleton('cms/page'); } @@ -42,19 +45,19 @@ public function getPage() /** * @inheritDoc + * @throws Mage_Core_Exception * @throws Mage_Core_Model_Store_Exception */ protected function _prepareLayout() { $page = $this->getPage(); $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')) + && ($page->getIdentifier() !== Mage::getStoreConfig(Mage_Cms_Helper_Page::XML_PATH_HOME_PAGE)) + && ($page->getIdentifier() !== Mage::getStoreConfig(Mage_Cms_Helper_Page::XML_PATH_NO_ROUTE_PAGE)) ) { $breadcrumbsArray[] = [ 'crumbName' => 'home', @@ -126,6 +129,8 @@ protected function _toHtml() /** * Get canonical URL for CMS page + * + * @throws Mage_Core_Exception */ protected function getCanonicalUrl(Mage_Cms_Model_Page $page): ?string { @@ -142,9 +147,9 @@ protected function getCanonicalUrl(Mage_Cms_Model_Page $page): ?string $identifier = $page->getIdentifier(); // Handle special pages differently - $homePageId = Mage::getStoreConfig('web/default/cms_home_page'); - $noRoutePageId = Mage::getStoreConfig('web/default/cms_no_route'); - $noCookiesPageId = Mage::getStoreConfig('web/default/cms_no_cookies'); + $homePageId = Mage::getStoreConfig(Mage_Cms_Helper_Page::XML_PATH_HOME_PAGE); + $noRoutePageId = Mage::getStoreConfig(Mage_Cms_Helper_Page::XML_PATH_NO_ROUTE_PAGE); + $noCookiesPageId = Mage::getStoreConfig(Mage_Cms_Helper_Page::XML_PATH_NO_COOKIES_PAGE); // For homepage, use base URL if ($identifier === $homePageId) { diff --git a/app/code/core/Mage/Cms/Block/Widget/Block.php b/app/code/core/Mage/Cms/Block/Widget/Block.php index 71b600041ef..7a8e1de9e26 100644 --- a/app/code/core/Mage/Cms/Block/Widget/Block.php +++ b/app/code/core/Mage/Cms/Block/Widget/Block.php @@ -7,6 +7,8 @@ * @package Mage_Cms */ +use Mage_Cms_Api_Data_BlockInterface as BlockInterface; + /** * Cms Static Block Widget * @@ -43,11 +45,13 @@ protected function _construct() * Prevent blocks recursion if needed * * @return $this + * @throws Exception + * @throws Mage_Core_Exception */ protected function _beforeToHtml() { parent::_beforeToHtml(); - $blockId = $this->getData('block_id'); + $blockId = $this->getData(BlockInterface::DATA_ID); $blockHash = static::class . $blockId; if (isset(self::$_widgetUsageMap[$blockHash])) { @@ -99,6 +103,7 @@ public function getCacheKeyInfo() * Check is request goes from admin area * * @return bool + * @throws Exception */ public function isRequestFromAdminArea() { 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 856962cfaa2..fa12e427ce0 100644 --- a/app/code/core/Mage/Cms/Block/Widget/Page/Link.php +++ b/app/code/core/Mage/Cms/Block/Widget/Page/Link.php @@ -7,6 +7,8 @@ * @package Mage_Cms */ +use Mage_Cms_Api_Data_PageInterface as PageInterface; + /** * Widget to display link to CMS page * @@ -40,6 +42,7 @@ class Mage_Cms_Block_Widget_Page_Link extends Mage_Core_Block_Html_Link implemen * or retrieve such using passed page id. * * @return string + * @throws Mage_Core_Model_Store_Exception */ public function getHref() { @@ -47,8 +50,8 @@ public function getHref() $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')); + } elseif ($this->getData(PageInterface::DATA_ID)) { + $this->_href = Mage::helper('cms/page')->getPageUrl($this->getData(PageInterface::DATA_ID)); } } @@ -60,17 +63,18 @@ public function getHref() * as parameter or retrieve page title from DB using passed identifier or page id. * * @return string + * @throws Mage_Core_Exception * @throws Mage_Core_Model_Store_Exception */ public function getTitle() { if (!$this->_title) { $this->_title = ''; - if ($this->getData('title') !== null) { + if ($this->getData(PageInterface::DATA_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')); + $this->_title = $this->getData(PageInterface::DATA_TITLE); + } elseif ($this->getData(PageInterface::DATA_ID)) { + $this->_title = $this->getCmsPageTitleById($this->getData(PageInterface::DATA_ID)); } elseif ($this->getData('href')) { $this->_title = $this->getCmsPageTitleByIdentifier($this->getData('href')); } @@ -85,6 +89,7 @@ public function getTitle() * if title will be blank string, page identifier will be used. * * @return string + * @throws Mage_Core_Exception * @throws Mage_Core_Model_Store_Exception */ public function getAnchorText() @@ -95,8 +100,8 @@ public function getAnchorText() $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->getData(PageInterface::DATA_ID)) { + $this->_anchorText = $this->getCmsPageTitleById($this->getData(PageInterface::DATA_ID)); } else { $this->_anchorText = $this->getData('href'); } @@ -110,6 +115,7 @@ protected function getCmsPageTitleById(int|string $pageId): string } /** + * @throws Mage_Core_Exception * @throws Mage_Core_Model_Store_Exception */ protected function getCmsPageTitleByIdentifier(int|string $identifier): string diff --git a/app/code/core/Mage/Cms/Controller/Router.php b/app/code/core/Mage/Cms/Controller/Router.php index da84cb0759f..d5f482ff47b 100644 --- a/app/code/core/Mage/Cms/Controller/Router.php +++ b/app/code/core/Mage/Cms/Controller/Router.php @@ -7,6 +7,8 @@ * @package Mage_Cms */ +use Mage_Cms_Api_Data_PageInterface as PageInterface; + /** * Cms Controller Router * @@ -32,6 +34,7 @@ public function initControllerRouters($observer) * * @return bool * @SuppressWarnings("PHPMD.ExitExpression") + * @throws Mage_Core_Exception */ public function match(Zend_Controller_Request_Http $request) { @@ -75,7 +78,7 @@ public function match(Zend_Controller_Request_Http $request) $request->setModuleName('cms') ->setControllerName('page') ->setActionName('view') - ->setParam('page_id', $pageId); + ->setParam(PageInterface::DATA_ID, $pageId); $request->setAlias( Mage_Core_Model_Url_Rewrite::REWRITE_REQUEST_PATH_ALIAS, $identifier, diff --git a/app/code/core/Mage/Cms/Helper/Page.php b/app/code/core/Mage/Cms/Helper/Page.php index 3b0620e6e76..c5a7d346c10 100644 --- a/app/code/core/Mage/Cms/Helper/Page.php +++ b/app/code/core/Mage/Cms/Helper/Page.php @@ -145,6 +145,7 @@ public function renderPageExtended(Mage_Core_Controller_Varien_Action $action, $ * * @param string $pageId * @return null|string + * @throws Mage_Core_Exception * @throws Mage_Core_Model_Store_Exception */ public function getPageUrl($pageId = null) @@ -216,6 +217,7 @@ public static function getScopeInfoFromConfigScope(string $scope, string $scopeI /** * @throws Mage_Core_Exception + * @throws Zend_Db_Select_Exception */ public static function getValidateConfigErrorMessage(Mage_Core_Model_Resource_Db_Collection_Abstract $isUsedInConfig): string { diff --git a/app/code/core/Mage/Cms/Model/Block.php b/app/code/core/Mage/Cms/Model/Block.php index ab41176897c..04e9c2b8ffd 100644 --- a/app/code/core/Mage/Cms/Model/Block.php +++ b/app/code/core/Mage/Cms/Model/Block.php @@ -13,26 +13,11 @@ * @package Mage_Cms * * @method Mage_Cms_Model_Resource_Block _getResource() - * @method int getBlockId() * @method Mage_Cms_Model_Resource_Block_Collection getCollection() - * @method string getContent() - * @method string getCreationTime() - * @method string getIdentifier() - * @method int getIsActive() * @method Mage_Cms_Model_Resource_Block getResource() * @method Mage_Cms_Model_Resource_Block_Collection getResourceCollection() - * @method int getStoreId() - * @method string getTitle() - * @method string getUpdateTime() - * @method $this setContent(string $value) - * @method $this setCreationTime(string $value) - * @method $this setIdentifier(string $value) - * @method $this setIsActive(int $value) - * @method $this setStoreId(int $storeId) - * @method $this setTitle(string $value) - * @method $this setUpdateTime(string $value) */ -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'; @@ -60,4 +45,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 ebf800f2675..22568dfef18 100644 --- a/app/code/core/Mage/Cms/Model/Page.php +++ b/app/code/core/Mage/Cms/Model/Page.php @@ -14,51 +14,12 @@ * * @method Mage_Cms_Model_Resource_Page _getResource() * @method Mage_Cms_Model_Resource_Page_Collection getCollection() - * @method string getContent() - * @method string getContentHeading() - * @method string getCreationTime() - * @method string getCustomLayoutUpdateXml() - * @method string getCustomRootTemplate() - * @method string getCustomTheme() - * @method string getCustomThemeFrom() - * @method string getCustomThemeTo() - * @method string getIdentifier() - * @method int getIsActive() - * @method string getLayoutUpdateXml() - * @method string getMetaDescription() - * @method string getMetaKeywords() * @method string getPreviewUrl() * @method Mage_Cms_Model_Resource_Page getResource() * @method Mage_Cms_Model_Resource_Page_Collection getResourceCollection() - * @method string getRootTemplate() - * @method int getSortOrder() - * @method string getStoreCode() - * @method string getStoreId() - * @method array getStores() - * @method string getTitle() - * @method string getUpdateTime() - * @method bool hasCreationTime() * @method bool hasStores() - * @method $this setContent(string $value) - * @method $this setContentHeading(string $value) - * @method $this setCreationTime(string $value) - * @method $this setCustomLayoutUpdateXml(string $value) - * @method $this setCustomRootTemplate(string $value) - * @method $this setCustomTheme(string $value) - * @method $this setCustomThemeFrom(string $value) - * @method $this setCustomThemeTo(string $value) - * @method $this setIdentifier(string $value) - * @method $this setIsActive(int $value) - * @method $this setLayoutUpdateXml(string $value) - * @method $this setMetaDescription(string $value) - * @method $this setMetaKeywords(string $value) - * @method $this setRootTemplate(string $value) - * @method $this setSortOrder(int $value) - * @method $this setStoreId(int $value) - * @method $this setTitle(string $value) - * @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'; @@ -101,6 +62,7 @@ public function load($id, $field = null) * Load No-Route Page * * @return $this + * @throws Mage_Core_Exception */ public function noRoutePage() { @@ -114,6 +76,7 @@ public function noRoutePage() * @param string $identifier * @param int $storeId * @return string + * @throws Mage_Core_Exception */ public function checkIdentifier($identifier, $storeId) { @@ -122,6 +85,9 @@ public function checkIdentifier($identifier, $storeId) /** * Retrieves cms page title from DB by passed identifier. + * + * @throws Mage_Core_Exception + * @throws Mage_Core_Model_Store_Exception */ public function getCmsPageTitleByIdentifier(string $identifier): string { @@ -132,6 +98,7 @@ public function getCmsPageTitleByIdentifier(string $identifier): string * Retrieves cms page title from DB by passed id. * * @param int|string $id + * @throws Mage_Core_Exception */ public function getCmsPageTitleById($id): string { @@ -142,6 +109,7 @@ public function getCmsPageTitleById($id): string * Retrieves cms page identifier from DB by passed id. * * @param int|string $id + * @throws Mage_Core_Exception */ public function getCmsPageIdentifierById($id): string { @@ -166,13 +134,344 @@ public function getAvailableStatuses() return $statuses->getData(); } + /** + * @throws Mage_Core_Exception + */ public function getUsedInStoreConfigCollection(?array $paths = []): Mage_Core_Model_Resource_Db_Collection_Abstract { return $this->_getResource()->getUsedInStoreConfigCollection($this, $paths); } + /** + * @throws Mage_Core_Exception + */ 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/Page.php b/app/code/core/Mage/Cms/Model/Resource/Page.php index 84c89123a95..7ec1835434d 100644 --- a/app/code/core/Mage/Cms/Model/Resource/Page.php +++ b/app/code/core/Mage/Cms/Model/Resource/Page.php @@ -7,6 +7,8 @@ * @package Mage_Cms */ +use Mage_Cms_Api_Data_PageInterface as PageInterface; + /** * Cms page mysql resource * @@ -23,12 +25,14 @@ class Mage_Cms_Model_Resource_Page extends Mage_Core_Model_Resource_Db_Abstract protected function _construct() { - $this->_init('cms/page', 'page_id'); + $this->_init('cms/page', PageInterface::DATA_ID); } /** * @inheritDoc + * @param Mage_Cms_Model_Page $object * @throws Mage_Core_Exception + * @throws Zend_Db_Select_Exception */ protected function _beforeDelete(Mage_Core_Model_Abstract $object) { @@ -48,7 +52,7 @@ protected function _beforeDelete(Mage_Core_Model_Abstract $object) } $condition = [ - 'page_id = ?' => (int) $object->getId(), + PageInterface::DATA_ID . ' = ?' => (int) $object->getId(), ]; $this->_getWriteAdapter()->delete($this->getTable('cms/page_store'), $condition); @@ -60,6 +64,7 @@ protected function _beforeDelete(Mage_Core_Model_Abstract $object) * @param Mage_Cms_Model_Page $object * @inheritDoc * @throws Mage_Core_Exception + * @throws Zend_Db_Select_Exception */ protected function _beforeSave(Mage_Core_Model_Abstract $object) { @@ -69,7 +74,7 @@ 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) { + foreach ([PageInterface::DATA_CUSTOM_THEME_FROM, PageInterface::DATA_CUSTOM_THEME_TO] as $field) { $value = !$object->getData($field) ? null : $object->getData($field); $object->setData($field, $this->formatDate($value)); } @@ -113,6 +118,7 @@ protected function _beforeSave(Mage_Core_Model_Abstract $object) /** * @param Mage_Cms_Model_Page $object * @inheritDoc + * @throws Mage_Core_Exception * @throws Zend_Db_Exception */ protected function _afterSave(Mage_Core_Model_Abstract $object) @@ -129,8 +135,8 @@ protected function _afterSave(Mage_Core_Model_Abstract $object) if ($delete) { $where = [ - 'page_id = ?' => (int) $object->getId(), - 'store_id IN (?)' => $delete, + PageInterface::DATA_ID . ' = ?' => (int) $object->getId(), + PageInterface::DATA_STORE_ID . ' IN (?)' => $delete, ]; $this->_getWriteAdapter()->delete($table, $where); @@ -141,8 +147,8 @@ protected function _afterSave(Mage_Core_Model_Abstract $object) foreach ($insert as $storeId) { $data[] = [ - 'page_id' => (int) $object->getId(), - 'store_id' => (int) $storeId, + PageInterface::DATA_ID => (int) $object->getId(), + PageInterface::DATA_STORE_ID => (int) $storeId, ]; } @@ -161,7 +167,7 @@ protected function _afterSave(Mage_Core_Model_Abstract $object) public function load(Mage_Core_Model_Abstract $object, $value, $field = null) { if (!is_numeric($value) && is_null($field)) { - $field = 'identifier'; + $field = PageInterface::DATA_IDENTIFIER; } return parent::load($object, $value, $field); @@ -169,6 +175,7 @@ public function load(Mage_Core_Model_Abstract $object, $value, $field = null) /** * @inheritDoc + * @throws Mage_Core_Exception */ protected function _afterLoad(Mage_Core_Model_Abstract $object) { @@ -217,6 +224,7 @@ protected function _getLoadSelect($field, $value, $object) * @param array|int $store * @param int $isActive * @return Varien_Db_Select + * @throws Mage_Core_Exception */ protected function _getLoadByIdentifierSelect($identifier, $store, $isActive = null) { @@ -242,6 +250,7 @@ protected function _getLoadByIdentifierSelect($identifier, $store, $isActive = n * * @param Mage_Cms_Model_Page $object * @return bool + * @throws Mage_Core_Exception */ public function getIsUniquePageToStores(Mage_Core_Model_Abstract $object) { @@ -314,6 +323,7 @@ public function isUsedInStoreConfig(?Mage_Cms_Model_Page $page = null, ?array $p * @param string $identifier * @param int $storeId * @return string + * @throws Mage_Core_Exception */ public function checkIdentifier($identifier, $storeId) { @@ -332,6 +342,7 @@ public function checkIdentifier($identifier, $storeId) * * @param int|string $identifier * @return string + * @throws Mage_Core_Exception * @throws Mage_Core_Model_Store_Exception */ public function getCmsPageTitleByIdentifier($identifier) @@ -355,17 +366,18 @@ public function getCmsPageTitleByIdentifier($identifier) * * @param int|string $id * @return string + * @throws Mage_Core_Exception */ public function getCmsPageTitleById($id) { $adapter = $this->_getReadAdapter(); $select = $adapter->select() - ->from($this->getMainTable(), 'title') + ->from($this->getMainTable(), PageInterface::DATA_TITLE) ->where('page_id = :page_id'); $binds = [ - 'page_id' => (int) $id, + PageInterface::DATA_ID => (int) $id, ]; return $adapter->fetchOne($select, $binds); @@ -376,17 +388,18 @@ public function getCmsPageTitleById($id) * * @param string $id * @return false|string + * @throws Mage_Core_Exception */ public function getCmsPageIdentifierById($id) { $adapter = $this->_getReadAdapter(); $select = $adapter->select() - ->from($this->getMainTable(), 'identifier') + ->from($this->getMainTable(), PageInterface::DATA_IDENTIFIER) ->where('page_id = :page_id'); $binds = [ - 'page_id' => (int) $id, + PageInterface::DATA_ID => (int) $id, ]; return $adapter->fetchOne($select, $binds); @@ -403,8 +416,8 @@ public function lookupStoreIds($pageId) $adapter = $this->_getReadAdapter(); $select = $adapter->select() - ->from($this->getTable('cms/page_store'), 'store_id') - ->where('page_id = ?', (int) $pageId); + ->from($this->getTable('cms/page_store'), PageInterface::DATA_STORE_ID) + ->where(PageInterface::DATA_ID . ' = ?', (int) $pageId); return $adapter->fetchCol($select); } @@ -425,6 +438,7 @@ public function setStore($store) * Retrieve store model * * @return Mage_Core_Model_Store + * @throws Mage_Core_Exception * @throws Mage_Core_Model_Store_Exception */ public function getStore() diff --git a/app/code/core/Mage/Cms/controllers/IndexController.php b/app/code/core/Mage/Cms/controllers/IndexController.php index 0becca15239..defebd5e2f5 100644 --- a/app/code/core/Mage/Cms/controllers/IndexController.php +++ b/app/code/core/Mage/Cms/controllers/IndexController.php @@ -18,6 +18,7 @@ class Mage_Cms_IndexController extends Mage_Core_Controller_Front_Action * Renders CMS Home page * * @param string $coreRoute + * @throws Mage_Core_Exception */ public function indexAction($coreRoute = null) { @@ -30,6 +31,8 @@ public function indexAction($coreRoute = null) /** * Default index action (with 404 Not Found headers) * Used if default page don't configure or available + * + * @throws Mage_Core_Exception */ public function defaultIndexAction() { @@ -44,6 +47,7 @@ public function defaultIndexAction() * Render CMS 404 Not found page * * @param string $coreRoute + * @throws Mage_Core_Exception */ public function noRouteAction($coreRoute = null) { @@ -59,6 +63,8 @@ public function noRouteAction($coreRoute = null) /** * Default no route page action * Used if no route page don't configure or available + * + * @throws Mage_Core_Exception */ public function defaultNoRouteAction() { @@ -71,6 +77,8 @@ public function defaultNoRouteAction() /** * Render Disable cookies page + * + * @throws Mage_Core_Exception */ public function noCookiesAction() { @@ -83,6 +91,8 @@ public function noCookiesAction() /** * Default no cookies page action * Used if no cookies page don't configure or available + * + * @throws Mage_Core_Exception */ public function defaultNoCookiesAction() { diff --git a/app/code/core/Mage/Cms/controllers/PageController.php b/app/code/core/Mage/Cms/controllers/PageController.php index bf6978bfe53..ea903d5045b 100644 --- a/app/code/core/Mage/Cms/controllers/PageController.php +++ b/app/code/core/Mage/Cms/controllers/PageController.php @@ -7,6 +7,8 @@ * @package Mage_Cms */ +use Mage_Cms_Api_Data_PageInterface as PageInterface; + /** * CMS Page controller * @@ -16,11 +18,13 @@ class Mage_Cms_PageController extends Mage_Core_Controller_Front_Action { /** * View CMS page action + * + * @throws Mage_Core_Exception */ public function viewAction() { $pageId = $this->getRequest() - ->getParam('page_id', $this->getRequest()->getParam('id', false)); + ->getParam(PageInterface::DATA_ID, $this->getRequest()->getParam('id', false)); if (!Mage::helper('cms/page')->renderPage($this, $pageId)) { $this->_forward('noRoute'); } diff --git a/app/code/core/Mage/Cms/sql/cms_setup/install-1.6.0.0.php b/app/code/core/Mage/Cms/sql/cms_setup/install-1.6.0.0.php index 11948da3155..d9d49c2097b 100644 --- a/app/code/core/Mage/Cms/sql/cms_setup/install-1.6.0.0.php +++ b/app/code/core/Mage/Cms/sql/cms_setup/install-1.6.0.0.php @@ -7,6 +7,9 @@ * @package Mage_Cms */ +use Mage_Cms_Api_Data_BlockInterface as BlockInterface; +use Mage_Cms_Api_Data_PageInterface as PageInterface; + /** @var Mage_Core_Model_Resource_Setup $this */ $installer = $this; $installer->startSetup(); @@ -16,24 +19,24 @@ */ $table = $installer->getConnection() ->newTable($installer->getTable('cms/block')) - ->addColumn('block_id', Varien_Db_Ddl_Table::TYPE_SMALLINT, null, [ + ->addColumn(BlockInterface::DATA_ID, Varien_Db_Ddl_Table::TYPE_SMALLINT, null, [ 'identity' => true, 'nullable' => false, 'primary' => true, ], 'Block ID') - ->addColumn('title', Varien_Db_Ddl_Table::TYPE_TEXT, 255, [ + ->addColumn(BlockInterface::DATA_TITLE, Varien_Db_Ddl_Table::TYPE_TEXT, 255, [ 'nullable' => false, ], 'Block Title') - ->addColumn('identifier', Varien_Db_Ddl_Table::TYPE_TEXT, 255, [ + ->addColumn(BlockInterface::DATA_IDENTIFIER, Varien_Db_Ddl_Table::TYPE_TEXT, 255, [ 'nullable' => false, ], 'Block String Identifier') - ->addColumn('content', Varien_Db_Ddl_Table::TYPE_TEXT, '2M', [ + ->addColumn(BlockInterface::DATA_CONTENT, Varien_Db_Ddl_Table::TYPE_TEXT, '2M', [ ], 'Block Content') - ->addColumn('creation_time', Varien_Db_Ddl_Table::TYPE_TIMESTAMP, null, [ + ->addColumn(BlockInterface::DATA_CREATION_TIME, Varien_Db_Ddl_Table::TYPE_TIMESTAMP, null, [ ], 'Block Creation Time') - ->addColumn('update_time', Varien_Db_Ddl_Table::TYPE_TIMESTAMP, null, [ + ->addColumn(BlockInterface::DATA_UPDATE_TIME, Varien_Db_Ddl_Table::TYPE_TIMESTAMP, null, [ ], 'Block Modification Time') - ->addColumn('is_active', Varien_Db_Ddl_Table::TYPE_SMALLINT, null, [ + ->addColumn(BlockInterface::DATA_IS_ACTIVE, Varien_Db_Ddl_Table::TYPE_SMALLINT, null, [ 'nullable' => false, 'default' => '1', ], 'Is Block Active') @@ -45,32 +48,42 @@ */ $table = $installer->getConnection() ->newTable($installer->getTable('cms/block_store')) - ->addColumn('block_id', Varien_Db_Ddl_Table::TYPE_SMALLINT, null, [ + ->addColumn(BlockInterface::DATA_ID, Varien_Db_Ddl_Table::TYPE_SMALLINT, null, [ 'nullable' => false, 'primary' => true, ], 'Block ID') - ->addColumn('store_id', Varien_Db_Ddl_Table::TYPE_SMALLINT, null, [ + ->addColumn(BlockInterface::DATA_STORE_ID, Varien_Db_Ddl_Table::TYPE_SMALLINT, null, [ 'unsigned' => true, 'nullable' => false, 'primary' => true, ], 'Store ID') ->addIndex( - $installer->getIdxName('cms/block_store', ['store_id']), - ['store_id'], + $installer->getIdxName('cms/block_store', [BlockInterface::DATA_STORE_ID]), + [BlockInterface::DATA_STORE_ID], ) ->addForeignKey( - $installer->getFkName('cms/block_store', 'block_id', 'cms/block', 'block_id'), - 'block_id', + $installer->getFkName( + 'cms/block_store', + BlockInterface::DATA_ID, + 'cms/block', + BlockInterface::DATA_ID, + ), + BlockInterface::DATA_ID, $installer->getTable('cms/block'), - 'block_id', + BlockInterface::DATA_ID, Varien_Db_Ddl_Table::ACTION_CASCADE, Varien_Db_Ddl_Table::ACTION_CASCADE, ) ->addForeignKey( - $installer->getFkName('cms/block_store', 'store_id', 'core/store', 'store_id'), - 'store_id', + $installer->getFkName( + 'cms/block_store', + BlockInterface::DATA_STORE_ID, + 'core/store', + BlockInterface::DATA_STORE_ID, + ), + BlockInterface::DATA_STORE_ID, $installer->getTable('core/store'), - 'store_id', + BlockInterface::DATA_STORE_ID, Varien_Db_Ddl_Table::ACTION_CASCADE, Varien_Db_Ddl_Table::ACTION_CASCADE, ) @@ -82,65 +95,65 @@ */ $table = $installer->getConnection() ->newTable($installer->getTable('cms/page')) - ->addColumn('page_id', Varien_Db_Ddl_Table::TYPE_SMALLINT, null, [ + ->addColumn(PageInterface::DATA_ID, Varien_Db_Ddl_Table::TYPE_SMALLINT, null, [ 'identity' => true, 'nullable' => false, 'primary' => true, ], 'Page ID') - ->addColumn('title', Varien_Db_Ddl_Table::TYPE_TEXT, 255, [ + ->addColumn(PageInterface::DATA_TITLE, Varien_Db_Ddl_Table::TYPE_TEXT, 255, [ 'nullable' => true, ], 'Page Title') - ->addColumn('root_template', Varien_Db_Ddl_Table::TYPE_TEXT, 255, [ + ->addColumn(PageInterface::DATA_ROOT_TEMPLATE, Varien_Db_Ddl_Table::TYPE_TEXT, 255, [ 'nullable' => true, ], 'Page Template') - ->addColumn('meta_keywords', Varien_Db_Ddl_Table::TYPE_TEXT, '64k', [ + ->addColumn(PageInterface::DATA_META_KEYWORDS, Varien_Db_Ddl_Table::TYPE_TEXT, '64k', [ 'nullable' => true, ], 'Page Meta Keywords') - ->addColumn('meta_description', Varien_Db_Ddl_Table::TYPE_TEXT, '64k', [ + ->addColumn(PageInterface::DATA_META_DESCRIPTION, Varien_Db_Ddl_Table::TYPE_TEXT, '64k', [ 'nullable' => true, ], 'Page Meta Description') - ->addColumn('identifier', Varien_Db_Ddl_Table::TYPE_TEXT, 100, [ + ->addColumn(PageInterface::DATA_IDENTIFIER, Varien_Db_Ddl_Table::TYPE_TEXT, 100, [ 'nullable' => true, 'default' => null, ], 'Page String Identifier') - ->addColumn('content_heading', Varien_Db_Ddl_Table::TYPE_TEXT, 255, [ + ->addColumn(PageInterface::DATA_CONTENT_HEADING, Varien_Db_Ddl_Table::TYPE_TEXT, 255, [ 'nullable' => true, ], 'Page Content Heading') - ->addColumn('content', Varien_Db_Ddl_Table::TYPE_TEXT, '2M', [ + ->addColumn(PageInterface::DATA_CONTENT, Varien_Db_Ddl_Table::TYPE_TEXT, '2M', [ ], 'Page Content') - ->addColumn('creation_time', Varien_Db_Ddl_Table::TYPE_TIMESTAMP, null, [ + ->addColumn(PageInterface::DATA_CREATION_TIME, Varien_Db_Ddl_Table::TYPE_TIMESTAMP, null, [ ], 'Page Creation Time') - ->addColumn('update_time', Varien_Db_Ddl_Table::TYPE_TIMESTAMP, null, [ + ->addColumn(PageInterface::DATA_UPDATE_TIME, Varien_Db_Ddl_Table::TYPE_TIMESTAMP, null, [ ], 'Page Modification Time') - ->addColumn('is_active', Varien_Db_Ddl_Table::TYPE_SMALLINT, null, [ + ->addColumn(PageInterface::DATA_IS_ACTIVE, Varien_Db_Ddl_Table::TYPE_SMALLINT, null, [ 'nullable' => false, 'default' => '1', ], 'Is Page Active') - ->addColumn('sort_order', Varien_Db_Ddl_Table::TYPE_SMALLINT, null, [ + ->addColumn(PageInterface::DATA_SORT_ORDER, Varien_Db_Ddl_Table::TYPE_SMALLINT, null, [ 'nullable' => false, 'default' => '0', ], 'Page Sort Order') - ->addColumn('layout_update_xml', Varien_Db_Ddl_Table::TYPE_TEXT, '64k', [ + ->addColumn(PageInterface::DATA_LAYOUT_UPDATE_XML, Varien_Db_Ddl_Table::TYPE_TEXT, '64k', [ 'nullable' => true, ], 'Page Layout Update Content') - ->addColumn('custom_theme', Varien_Db_Ddl_Table::TYPE_TEXT, 100, [ + ->addColumn(PageInterface::DATA_CUSTOM_THEME, Varien_Db_Ddl_Table::TYPE_TEXT, 100, [ 'nullable' => true, ], 'Page Custom Theme') - ->addColumn('custom_root_template', Varien_Db_Ddl_Table::TYPE_TEXT, 255, [ + ->addColumn(PageInterface::DATA_CUSTOM_ROOT_TEMPLATE, Varien_Db_Ddl_Table::TYPE_TEXT, 255, [ 'nullable' => true, ], 'Page Custom Template') - ->addColumn('custom_layout_update_xml', Varien_Db_Ddl_Table::TYPE_TEXT, '64k', [ + ->addColumn(PageInterface::DATA_CUSTOM_LAYOUT_UPDATE_XML, Varien_Db_Ddl_Table::TYPE_TEXT, '64k', [ 'nullable' => true, ], 'Page Custom Layout Update Content') - ->addColumn('custom_theme_from', Varien_Db_Ddl_Table::TYPE_DATE, null, [ + ->addColumn(PageInterface::DATA_CUSTOM_THEME_FROM, Varien_Db_Ddl_Table::TYPE_DATE, null, [ 'nullable' => true, ], 'Page Custom Theme Active From Date') - ->addColumn('custom_theme_to', Varien_Db_Ddl_Table::TYPE_DATE, null, [ + ->addColumn(PageInterface::DATA_CUSTOM_THEME_TO, Varien_Db_Ddl_Table::TYPE_DATE, null, [ 'nullable' => true, ], 'Page Custom Theme Active To Date') ->addIndex( - $installer->getIdxName('cms/page', ['identifier']), - ['identifier'], + $installer->getIdxName('cms/page', [PageInterface::DATA_IDENTIFIER]), + [PageInterface::DATA_IDENTIFIER], ) ->setComment('CMS Page Table'); $installer->getConnection()->createTable($table); @@ -150,32 +163,32 @@ */ $table = $installer->getConnection() ->newTable($installer->getTable('cms/page_store')) - ->addColumn('page_id', Varien_Db_Ddl_Table::TYPE_SMALLINT, null, [ + ->addColumn(PageInterface::DATA_ID, Varien_Db_Ddl_Table::TYPE_SMALLINT, null, [ 'nullable' => false, 'primary' => true, ], 'Page ID') - ->addColumn('store_id', Varien_Db_Ddl_Table::TYPE_SMALLINT, null, [ + ->addColumn(PageInterface::DATA_STORE_ID, Varien_Db_Ddl_Table::TYPE_SMALLINT, null, [ 'unsigned' => true, 'nullable' => false, 'primary' => true, ], 'Store ID') ->addIndex( - $installer->getIdxName('cms/page_store', ['store_id']), - ['store_id'], + $installer->getIdxName('cms/page_store', [PageInterface::DATA_STORE_ID]), + [PageInterface::DATA_STORE_ID], ) ->addForeignKey( - $installer->getFkName('cms/page_store', 'page_id', 'cms/page', 'page_id'), - 'page_id', + $installer->getFkName('cms/page_store', PageInterface::DATA_ID, 'cms/page', PageInterface::DATA_ID), + PageInterface::DATA_ID, $installer->getTable('cms/page'), - 'page_id', + PageInterface::DATA_ID, Varien_Db_Ddl_Table::ACTION_CASCADE, Varien_Db_Ddl_Table::ACTION_CASCADE, ) ->addForeignKey( - $installer->getFkName('cms/page_store', 'store_id', 'core/store', 'store_id'), - 'store_id', + $installer->getFkName('cms/page_store', PageInterface::DATA_STORE_ID, 'core/store', PageInterface::DATA_STORE_ID), + PageInterface::DATA_STORE_ID, $installer->getTable('core/store'), - 'store_id', + PageInterface::DATA_STORE_ID, Varien_Db_Ddl_Table::ACTION_CASCADE, Varien_Db_Ddl_Table::ACTION_CASCADE, )