diff --git a/CHANGELOG.md b/CHANGELOG.md index 8837cd299ee9062f01f44f35e209de4e1f28ffa2..34e9246bff5008a6b90df8ef0e845175453f1e7f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,23 @@ +2.0.0.0-dev64 +============= +* Modularity improvements: + * Moved abstract shopping cart logic from the Paypal module to the Payments module +* Caching improvements: + * Added a new mechanism to uniquely identify page content (a hash-key for cache storage) + * Replaced the "magentoZoom" plugin with two widgets: the "gallery" and "zoom" +* Fixed bugs: + * Fixed an issue with inserting an image in WYSIWYG editor where the selected folder was stored in session + * Fixed an issue with CMS Page Links not being shown because of the empty text in the link + * Fixed an issue where zooming functionality was not disabled for the responsive design + * Fixed an issue with zooming on a configurable product page where the main product image was shown instead of the selected option images +* Updated various PHPDoc with parameter and return types +* Moved quote-related multishipping logic to the Multishipping module +* Resolved dependencies between the Payment and Multishipping modules +* Moved the framework part of the Translate functionality from modules to the library +* Created the architecture for the email template library +* Introduced a consistent approach for using the Config scope +* Fixed an issue with the dependency static test + 2.0.0.0-dev63 ============= * Modularity improvements: diff --git a/app/code/Magento/Authorizenet/Model/Authorizenet.php b/app/code/Magento/Authorizenet/Model/Authorizenet.php index e161544d1639709c193a9209c2f0403324dbf5da..4e764cb0b4a23ddae5ede488fcefb050ef4b42cd 100644 --- a/app/code/Magento/Authorizenet/Model/Authorizenet.php +++ b/app/code/Magento/Authorizenet/Model/Authorizenet.php @@ -105,7 +105,6 @@ class Authorizenet extends \Magento\Payment\Model\Method\Cc protected $_canVoid = true; protected $_canUseInternal = true; protected $_canUseCheckout = true; - protected $_canUseForMultishipping = true; protected $_canSaveCc = false; protected $_canFetchTransactionInfo = true; diff --git a/app/code/Magento/Authorizenet/Model/Directpost.php b/app/code/Magento/Authorizenet/Model/Directpost.php index 89c476bbed699fe30f992750447a82581f076a37..aa33c676955fb68638f8028c190fd2cc7318a89a 100644 --- a/app/code/Magento/Authorizenet/Model/Directpost.php +++ b/app/code/Magento/Authorizenet/Model/Directpost.php @@ -44,7 +44,6 @@ class Directpost extends \Magento\Authorizenet\Model\Authorizenet protected $_canVoid = true; protected $_canUseInternal = true; protected $_canUseCheckout = true; - protected $_canUseForMultishipping = false; protected $_canSaveCc = false; protected $_isInitializeNeeded = true; diff --git a/dev/tests/unit/testsuite/Magento/Core/Model/Config/TestReaderClass.php b/app/code/Magento/Authorizenet/etc/payment.xml similarity index 50% rename from dev/tests/unit/testsuite/Magento/Core/Model/Config/TestReaderClass.php rename to app/code/Magento/Authorizenet/etc/payment.xml index ef70c4ab2b842328111534be23b244cdd2a8b3a8..d2bf5a20106e25ef6d551385863790d6dd7419ee 100644 --- a/dev/tests/unit/testsuite/Magento/Core/Model/Config/TestReaderClass.php +++ b/app/code/Magento/Authorizenet/etc/payment.xml @@ -1,13 +1,14 @@ -<?php +<?xml version="1.0"?> +<!-- /** * Magento * * NOTICE OF LICENSE * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.txt. + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/osl-3.0.php + * http://opensource.org/licenses/afl-3.0.php * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@magentocommerce.com so we can send you a copy immediately. @@ -19,14 +20,15 @@ * needs please refer to http://www.magentocommerce.com for more information. * * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */ -namespace Magento\Core\Model\Config; - -class TestReaderClass -{ - public function read($scope = 'primary') - { - return $scope; - } -} \ No newline at end of file +--> +<payment xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="../../../Magento/Payment/etc/payment.xsd"> + <methods> + <method name="authorizenet"> + <allow_multiple_address>1</allow_multiple_address> + <allow_multiple_with_3dsecure>1</allow_multiple_with_3dsecure> + </method> + </methods> +</payment> diff --git a/app/code/Magento/Backend/App/Config.php b/app/code/Magento/Backend/App/Config.php index 10bfd964180100b16d3970058094d099c49d0f65..2a6fba19fa2cca2e1ec31188e6ffcfe9b1735025 100644 --- a/app/code/Magento/Backend/App/Config.php +++ b/app/code/Magento/Backend/App/Config.php @@ -31,16 +31,16 @@ namespace Magento\Backend\App; class Config implements ConfigInterface { /** - * @var \Magento\Core\Model\Config\SectionPool + * @var \Magento\App\Config\ScopePool */ - protected $_sectionPool; + protected $_scopePool; /** - * @param \Magento\Core\Model\Config\SectionPool $sectionPool + * @param \Magento\App\Config\ScopePool $scopePool */ - public function __construct(\Magento\Core\Model\Config\SectionPool $sectionPool) + public function __construct(\Magento\App\Config\ScopePool $scopePool) { - $this->_sectionPool = $sectionPool; + $this->_scopePool = $scopePool; } /** @@ -51,7 +51,7 @@ class Config implements ConfigInterface */ public function getValue($path) { - return $this->_sectionPool->getSection('default', null)->getValue($path); + return $this->_scopePool->getScope('default', null)->getValue($path); } /** @@ -62,7 +62,7 @@ class Config implements ConfigInterface */ public function setValue($path, $value) { - $this->_sectionPool->getSection('default', null)->setValue($path, $value); + $this->_scopePool->getScope('default', null)->setValue($path, $value); } /** @@ -70,7 +70,7 @@ class Config implements ConfigInterface */ public function reinit() { - $this->_sectionPool->clean(); + $this->_scopePool->clean(); } /** @@ -81,6 +81,6 @@ class Config implements ConfigInterface */ public function isSetFlag($path) { - return !!$this->_sectionPool->getSection('default', null)->getValue($path); + return !!$this->_scopePool->getScope('default', null)->getValue($path); } } diff --git a/app/code/Magento/Backend/Block/Template/Context.php b/app/code/Magento/Backend/Block/Template/Context.php index 175726a7634f84bc0b35ed8e3dbfb08ff7fbbfac..02a4259018653e00c68bda0456062b5549a29d1c 100644 --- a/app/code/Magento/Backend/Block/Template/Context.php +++ b/app/code/Magento/Backend/Block/Template/Context.php @@ -55,7 +55,7 @@ class Context extends \Magento\View\Element\Template\Context * @param \Magento\View\LayoutInterface $layout * @param \Magento\Event\ManagerInterface $eventManager * @param \Magento\UrlInterface $urlBuilder - * @param \Magento\Core\Model\Translate $translator + * @param \Magento\TranslateInterface $translator * @param \Magento\App\CacheInterface $cache * @param \Magento\View\DesignInterface $design * @param \Magento\Core\Model\Session $session @@ -88,7 +88,7 @@ class Context extends \Magento\View\Element\Template\Context \Magento\View\LayoutInterface $layout, \Magento\Event\ManagerInterface $eventManager, \Magento\UrlInterface $urlBuilder, - \Magento\Core\Model\Translate $translator, + \Magento\TranslateInterface $translator, \Magento\App\CacheInterface $cache, \Magento\View\DesignInterface $design, \Magento\Core\Model\Session $session, diff --git a/app/code/Magento/Backend/Block/Widget/Button/SplitButton.php b/app/code/Magento/Backend/Block/Widget/Button/SplitButton.php index 67497a525635e9a6f0f361f3162ab2704ace7684..17937637564fe3c50f2fc1c864e08fd9221e971a 100644 --- a/app/code/Magento/Backend/Block/Widget/Button/SplitButton.php +++ b/app/code/Magento/Backend/Block/Widget/Button/SplitButton.php @@ -32,7 +32,7 @@ * @method string getClass() * @method string getLabel() * @method string getTitle() - * @method string getDisabled() + * @method bool getDisabled() * @method string getStyle() * @method array getDataAttribute() */ diff --git a/app/code/Magento/Backend/Model/Config/Backend/Admin/Custom.php b/app/code/Magento/Backend/Model/Config/Backend/Admin/Custom.php index 2b5d4201d503e5db30a8a8a6acaaf273405bf80d..d284a612d21627a51c8f9570a9d71b2dded19592 100644 --- a/app/code/Magento/Backend/Model/Config/Backend/Admin/Custom.php +++ b/app/code/Magento/Backend/Model/Config/Backend/Admin/Custom.php @@ -47,7 +47,7 @@ class Custom extends \Magento\Core\Model\Config\Value /** * Writer of configuration storage * - * @var \Magento\Core\Model\Config\Storage\WriterInterface + * @var \Magento\App\Config\Storage\WriterInterface */ protected $_configWriter; @@ -56,7 +56,7 @@ class Custom extends \Magento\Core\Model\Config\Value * @param \Magento\Core\Model\Registry $registry * @param \Magento\Core\Model\StoreManagerInterface $storeManager * @param \Magento\App\ConfigInterface $config - * @param \Magento\Core\Model\Config\Storage\WriterInterface $configWriter + * @param \Magento\App\Config\Storage\WriterInterface $configWriter * @param \Magento\Core\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data @@ -66,7 +66,7 @@ class Custom extends \Magento\Core\Model\Config\Value \Magento\Core\Model\Registry $registry, \Magento\Core\Model\StoreManagerInterface $storeManager, \Magento\App\ConfigInterface $config, - \Magento\Core\Model\Config\Storage\WriterInterface $configWriter, + \Magento\App\Config\Storage\WriterInterface $configWriter, \Magento\Core\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() diff --git a/app/code/Magento/Backend/Model/Config/Backend/Admin/Usecustom.php b/app/code/Magento/Backend/Model/Config/Backend/Admin/Usecustom.php index 65d2a3397125c0197a64625ab5ca79933f7d90b4..8dedcf8643a40be6e0e20908e7d6d1d27273ca4a 100644 --- a/app/code/Magento/Backend/Model/Config/Backend/Admin/Usecustom.php +++ b/app/code/Magento/Backend/Model/Config/Backend/Admin/Usecustom.php @@ -35,7 +35,7 @@ class Usecustom extends \Magento\Core\Model\Config\Value /** * Writer of configuration storage * - * @var \Magento\Core\Model\Config\Storage\WriterInterface + * @var \Magento\App\Config\Storage\WriterInterface */ protected $_configWriter; @@ -44,7 +44,7 @@ class Usecustom extends \Magento\Core\Model\Config\Value * @param \Magento\Core\Model\Registry $registry * @param \Magento\Core\Model\StoreManagerInterface $storeManager * @param \Magento\App\ConfigInterface $config - * @param \Magento\Core\Model\Config\Storage\WriterInterface $configWriter + * @param \Magento\App\Config\Storage\WriterInterface $configWriter * @param \Magento\Core\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data @@ -54,7 +54,7 @@ class Usecustom extends \Magento\Core\Model\Config\Value \Magento\Core\Model\Registry $registry, \Magento\Core\Model\StoreManagerInterface $storeManager, \Magento\App\ConfigInterface $config, - \Magento\Core\Model\Config\Storage\WriterInterface $configWriter, + \Magento\App\Config\Storage\WriterInterface $configWriter, \Magento\Core\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() diff --git a/app/code/Magento/Backend/Model/Config/Backend/Encrypted.php b/app/code/Magento/Backend/Model/Config/Backend/Encrypted.php index 12917d0d44595b5f3bf2c26ab00a307eb9461452..a0dd946444fdbfa5a923319859d157b29cb843eb 100644 --- a/app/code/Magento/Backend/Model/Config/Backend/Encrypted.php +++ b/app/code/Magento/Backend/Model/Config/Backend/Encrypted.php @@ -29,7 +29,7 @@ namespace Magento\Backend\Model\Config\Backend; class Encrypted extends \Magento\Core\Model\Config\Value - implements \Magento\Core\Model\Config\Data\BackendModelInterface + implements \Magento\App\Config\Data\ProcessorInterface { /** * @var \Magento\Encryption\EncryptorInterface diff --git a/app/code/Magento/Backend/Model/Locale/Manager.php b/app/code/Magento/Backend/Model/Locale/Manager.php index c44b006cd0318c08be8295289ac842bb47277a6c..1351119ee63dd79b9e912f8a090cc6ca74874892 100644 --- a/app/code/Magento/Backend/Model/Locale/Manager.php +++ b/app/code/Magento/Backend/Model/Locale/Manager.php @@ -46,7 +46,7 @@ class Manager protected $_authSession; /** - * @var \Magento\Core\Model\Translate + * @var \Magento\TranslateInterface */ protected $_translator; @@ -55,12 +55,12 @@ class Manager * * @param \Magento\Backend\Model\Session $session * @param \Magento\Backend\Model\Auth\Session $authSession - * @param \Magento\Core\Model\Translate $translator + * @param \Magento\TranslateInterface $translator */ public function __construct( \Magento\Backend\Model\Session $session, \Magento\Backend\Model\Auth\Session $authSession, - \Magento\Core\Model\Translate $translator + \Magento\TranslateInterface $translator ) { $this->_session = $session; $this->_authSession = $authSession; diff --git a/lib/Magento/App/Config/LoaderInterface.php b/app/code/Magento/Backend/Model/Translate.php similarity index 59% rename from lib/Magento/App/Config/LoaderInterface.php rename to app/code/Magento/Backend/Model/Translate.php index 80c9c79a929008c667bdab698d5a43e0e9e017d0..f7fb517bf5fc43637107f33c83d4c458d16e9a18 100644 --- a/lib/Magento/App/Config/LoaderInterface.php +++ b/app/code/Magento/Backend/Model/Translate.php @@ -1,7 +1,5 @@ <?php /** - * Loader interface - * * Magento * * NOTICE OF LICENSE @@ -20,16 +18,27 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * + * @category Magento + * @package Magento_Backend * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Backend\Model; -namespace Magento\App\Config; - -interface LoaderInterface +class Translate extends \Magento\Translate implements \Magento\TranslateInterface { /** - * Load configuration for current scope + * @inheritdoc */ - public function load(); + public function init($area = null, $initParams = null, $forceReload = false) + { + parent::init($area, $initParams, $forceReload); + $scope = null; + if ($this->getConfig(self::CONFIG_KEY_AREA) == \Magento\Backend\App\Area\FrontNameResolver::AREA_CODE) { + $scope = 'admin'; + } + $this->_translateInline = $this->getInlineObject($initParams)->isAllowed($scope); + return $this; + } + } diff --git a/app/code/Magento/Backend/Model/Translate/Inline.php b/app/code/Magento/Backend/Model/Translate/Inline.php index c1901eb186b70ec08fb26d5523623f605bda1447..38749aeb07294292f57bc814ba492a05a5230ea2 100644 --- a/app/code/Magento/Backend/Model/Translate/Inline.php +++ b/app/code/Magento/Backend/Model/Translate/Inline.php @@ -29,7 +29,7 @@ */ namespace Magento\Backend\Model\Translate; -class Inline extends \Magento\Core\Model\Translate\Inline +class Inline extends \Magento\Translate\Inline { /** * Return URL for ajax requests @@ -40,4 +40,20 @@ class Inline extends \Magento\Core\Model\Translate\Inline { return $this->_url->getUrl(\Magento\Backend\App\Area\FrontNameResolver::AREA_CODE . '/ajax/translate'); } + + /** + * Replace translation templates with HTML fragments + * + * @param array|string $body + * @param bool $isJson + * @return $this + */ + public function processResponseBody(&$body, $isJson = false) + { + if (!$this->isAllowed()) { + $this->_stripInlineTranslations($body); + return $this; + } + return parent::processResponseBody($body, $isJson); + } } diff --git a/app/code/Magento/Backend/Model/Translate/Inline/Config.php b/app/code/Magento/Backend/Model/Translate/Inline/Config.php index fa701b4b06b444278831134a9881748cbc75d58f..2b8f33ccdda462ab9e411641024590d5024c3aaf 100644 --- a/app/code/Magento/Backend/Model/Translate/Inline/Config.php +++ b/app/code/Magento/Backend/Model/Translate/Inline/Config.php @@ -29,29 +29,43 @@ */ namespace Magento\Backend\Model\Translate\Inline; -class Config implements \Magento\Core\Model\Translate\Inline\ConfigInterface +class Config implements \Magento\Translate\Inline\ConfigInterface { /** * @var \Magento\Backend\App\ConfigInterface */ protected $_config; + /** + * @var \Magento\Core\Helper\Data + */ + protected $_helper; + /** * @param \Magento\Backend\App\ConfigInterface $config + * @param \Magento\Core\Helper\Data $helper */ - public function __construct(\Magento\Backend\App\ConfigInterface $config) - { + public function __construct( + \Magento\Backend\App\ConfigInterface $config, + \Magento\Core\Helper\Data $helper + ) { $this->_config = $config; + $this->_helper = $helper; } /** - * Check whether inline translation is enabled - * - * @param int|null $store - * @return bool + * @inheritdoc */ - public function isActive($store = null) + public function isActive($scope = null) { return $this->_config->isSetFlag('dev/translate_inline/active_admin'); } + + /** + * @inheritdoc + */ + public function isDevAllowed($scope = null) + { + return $this->_helper->isDevAllowed($scope); + } } diff --git a/app/code/Magento/Backend/Model/Translate/Inline/ConfigFactory.php b/app/code/Magento/Backend/Model/Translate/Inline/ConfigFactory.php index 93c96497ddb84401a68e264985863d6a3756d84b..0ad93428b490a78d633dfca7ff99ca4a5c05d434 100644 --- a/app/code/Magento/Backend/Model/Translate/Inline/ConfigFactory.php +++ b/app/code/Magento/Backend/Model/Translate/Inline/ConfigFactory.php @@ -29,15 +29,15 @@ */ namespace Magento\Backend\Model\Translate\Inline; -class ConfigFactory extends \Magento\Core\Model\Translate\Inline\ConfigFactory +class ConfigFactory extends \Magento\Translate\Inline\ConfigFactory { /** - * Create instance of inline translate config + * Get instance of inline translate config * - * @return \Magento\Core\Model\Translate\Inline\ConfigInterface + * @return \Magento\Translate\Inline\ConfigFactory */ - public function create() + public function get() { - return $this->_objectManager->create('Magento\Backend\Model\Translate\Inline\Config'); + return $this->_objectManager->get('Magento\Backend\Model\Translate\Inline\Config'); } } diff --git a/app/code/Magento/Backend/Model/View.php b/app/code/Magento/Backend/Model/View.php index 0ffe30cf6f7bed40547ce93c814bf9d944e79808..8be9b1ad29a893d7679995d3adb90fb6e3225c17 100644 --- a/app/code/Magento/Backend/Model/View.php +++ b/app/code/Magento/Backend/Model/View.php @@ -37,7 +37,7 @@ class View extends \Magento\App\View * @param \Magento\App\ResponseInterface $response * @param \Magento\Config\ScopeInterface $configScope * @param \Magento\Event\ManagerInterface $eventManager - * @param \Magento\Core\Model\Translate $translator + * @param \Magento\Translate\InlineInterface $translateInline * @param \Magento\App\ActionFlag $actionFlag * @param \Magento\Core\Model\Layout\Filter\Acl $aclFilter */ @@ -47,12 +47,12 @@ class View extends \Magento\App\View \Magento\App\ResponseInterface $response, \Magento\Config\ScopeInterface $configScope, \Magento\Event\ManagerInterface $eventManager, - \Magento\Core\Model\Translate $translator, + \Magento\Translate\InlineInterface $translateInline, \Magento\App\ActionFlag $actionFlag, \Magento\Core\Model\Layout\Filter\Acl $aclFilter ) { $this->_aclFilter = $aclFilter; - parent::__construct($layout, $request, $response, $configScope, $eventManager, $translator, $actionFlag); + parent::__construct($layout, $request, $response, $configScope, $eventManager, $translateInline, $actionFlag); } @@ -71,4 +71,4 @@ class View extends \Magento\App\View return $this; } -} +} diff --git a/app/code/Magento/Backend/etc/adminhtml/di.xml b/app/code/Magento/Backend/etc/adminhtml/di.xml index df67d5802826ac9612a7f5dab5e60dd8f6f9e5f0..14edd9815b914e8252dcaa031adffba6fc1746ca 100644 --- a/app/code/Magento/Backend/etc/adminhtml/di.xml +++ b/app/code/Magento/Backend/etc/adminhtml/di.xml @@ -33,8 +33,8 @@ <preference for="Magento\Backend\Model\Config\Backend\File\RequestData\RequestDataInterface" type="Magento\Backend\Model\Config\Backend\File\RequestData" /> <preference for="Magento\App\DefaultPathInterface" type="Magento\Backend\App\DefaultPath" /> <preference for="Magento\Backend\App\ConfigInterface" type="Magento\Backend\App\Config" /> - <preference for="Magento\Core\Model\Translate\Inline\ConfigFactory" type="Magento\Backend\Model\Translate\Inline\ConfigFactory" /> - <preference for="Magento\Core\Model\Translate\InlineInterface" type="Magento\Backend\Model\Translate\Inline" /> + <preference for="Magento\Translate\Inline\ConfigFactory" type="Magento\Backend\Model\Translate\Inline\ConfigFactory" /> + <preference for="Magento\Translate\InlineInterface" type="Magento\Backend\Model\Translate\Inline" /> <preference for="Magento\Core\Model\Resource\Translate\String" type="Magento\Backend\Model\Resource\Translate\String" /> <preference for="Magento\Core\Model\Resource\Translate" type="Magento\Backend\Model\Resource\Translate" /> <preference for="Magento\App\Response\Http\FileFactory" type="Magento\Backend\App\Response\Http\FileFactory" /> @@ -43,6 +43,9 @@ <param name="url"> <instance type="Magento\Backend\Model\UrlInterface" /> </param> + <param name="templateFileName"> + <value>Magento_Core::translate_inline.phtml</value> + </param> </type> <type name="Magento\Backend\App\Action\Context"> <param name="helper"> diff --git a/app/code/Magento/Backend/etc/di.xml b/app/code/Magento/Backend/etc/di.xml index 3c53c7aa790eee877eab431227a9f045e9396c93..c022bc7c8433b8e157451479f33cb9f07e22bb71 100644 --- a/app/code/Magento/Backend/etc/di.xml +++ b/app/code/Magento/Backend/etc/di.xml @@ -24,7 +24,7 @@ */ --> <config> - <preference for="Magento\Core\Model\Config\Storage\WriterInterface" type="Magento\Core\Model\Config\Storage\Writer\Db" /> + <preference for="Magento\App\Config\Storage\WriterInterface" type="Magento\Core\Model\Config\Storage\Db" /> <preference for="Magento\App\Request\PathInfoProcessorInterface" type="Magento\Backend\App\Request\PathInfoProcessor" /> <preference for="Magento\Backend\Model\Auth\StorageInterface" type="Magento\Backend\Model\Auth\Session" /> <preference for="Magento\Backend\Model\Config\Structure\SearchInterface" type="Magento\Backend\Model\Config\Structure" /> diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tabs.php b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tabs.php index 07cf853b47e38be1472d79889db2e44cbb67625f..b1b42b2a6cf115da315bfbb7c8c8e8a322d7c9c3 100644 --- a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tabs.php +++ b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tabs.php @@ -46,7 +46,7 @@ class Tabs extends \Magento\Backend\Block\Widget\Tabs * @var \Magento\Core\Model\Registry */ protected $_coreRegistry = null; - + /** * Catalog data * @@ -71,6 +71,11 @@ class Tabs extends \Magento\Backend\Block\Widget\Tabs */ protected $_moduleManager; + /** + * @var \Magento\Translate\InlineInterface + */ + protected $_translateInline; + /** * @param \Magento\Module\Manager $moduleManager * @param \Magento\Backend\Block\Template\Context $context @@ -80,6 +85,7 @@ class Tabs extends \Magento\Backend\Block\Widget\Tabs * @param \Magento\Catalog\Helper\Catalog $helperCatalog * @param \Magento\Catalog\Helper\Data $catalogData * @param \Magento\Core\Model\Registry $registry + * @param \Magento\Translate\InlineInterface $translateInline, * @param array $data */ public function __construct( @@ -91,6 +97,7 @@ class Tabs extends \Magento\Backend\Block\Widget\Tabs \Magento\Catalog\Helper\Catalog $helperCatalog, \Magento\Catalog\Helper\Data $catalogData, \Magento\Core\Model\Registry $registry, + \Magento\Translate\InlineInterface $translateInline, array $data = array() ) { $this->_moduleManager = $moduleManager; @@ -98,6 +105,7 @@ class Tabs extends \Magento\Backend\Block\Widget\Tabs $this->_helperCatalog = $helperCatalog; $this->_catalogData = $catalogData; $this->_coreRegistry = $registry; + $this->_translateInline = $translateInline; parent::__construct($context, $jsonEncoder, $authSession, $data); } @@ -304,7 +312,7 @@ class Tabs extends \Magento\Backend\Block\Widget\Tabs */ protected function _translateHtml($html) { - $this->_translator->processResponseBody($html); + $this->_translateInline->processResponseBody($html); return $html; } } diff --git a/app/code/Magento/Catalog/Block/Product/View/Gallery.php b/app/code/Magento/Catalog/Block/Product/View/Gallery.php index f36b0128d7f63395c9d4b01668c037b0c67f978a..a086b8f442f2452264638b6e0435434c19236b89 100644 --- a/app/code/Magento/Catalog/Block/Product/View/Gallery.php +++ b/app/code/Magento/Catalog/Block/Product/View/Gallery.php @@ -59,4 +59,39 @@ class Gallery extends \Magento\Catalog\Block\Product\View\AbstractView } return $this->getUrl('catalog/product/gallery', $params); } + + /** + * Get gallery image url + * + * @param \Magento\Object $image + * @param string $type + * @param boolean $whiteBorders + * @param null|number $width + * @param null|number $height + * @return string + */ + public function getImageUrl($image, $type, $whiteBorders = false, $width = null, $height = null) + { + $product = $this->getProduct(); + $img = $this->_imageHelper->init($product, $type, $image->getFile()); + if ($whiteBorders) { + $img->constrainOnly(TRUE)->keepAspectRatio(TRUE)->keepFrame(FALSE); + } + if ($width || $height) { + $img->resize($width, $height); + } + return (string)$img; + } + + /** + * Is product main image + * + * @param \Magento\Object $image + * @return bool + */ + public function isMainImage($image) + { + $product = $this->getProduct(); + return $product->getImage() == $image->getFile(); + } } diff --git a/app/code/Magento/Catalog/view/frontend/js/configurable.js b/app/code/Magento/Catalog/view/frontend/js/configurable.js index f68b24ba33cb3789307c8e42e95d1f9f74369dee..3b7f566f9c902a3cf5a4d4be56c5ff2075debd65 100644 --- a/app/code/Magento/Catalog/view/frontend/js/configurable.js +++ b/app/code/Magento/Catalog/view/frontend/js/configurable.js @@ -28,7 +28,8 @@ $.widget('mage.configurable', { options: { superSelector: '.super-attribute-select', - state: {} + state: {}, + mediaGallerySelector: '[data-role=media-gallery]' }, _create: function() { @@ -210,7 +211,8 @@ */ _changeProductImage: function () { var images = this.options.spConfig.images, - imagesArray = null; + imagesArray = null, + galleryElement = $(this.options.mediaGallerySelector); $.each(this.options.settings, function (k, v) { var selectValue = parseInt(v.value, 10), attributeId = v.id.replace(/[a-z]*/, ''); @@ -231,39 +233,21 @@ var result = []; $.each(imagesArray || {}, function (k, v) { - result.push(v); + result.push({ + small: v, + medium: v, + large: v + }); }); - var baseImage = $('[data-role=base-image-container] img'); - if (result.length === 1) { - baseImage.attr('src', result[0]).trigger('imageChanged', result[0]); - } else { - baseImage.attr('src', this.options.parentImage).trigger('loadOriginalImage', this.options.parentImage); - } - this._fitImageToContainer(); - }, - /** - * Fit image to container when changing displayed product image according to chosen options - * @private - */ - _fitImageToContainer: function () { - var image = $('[data-role=base-image-container] img'), - imageContainer = image.closest('[data-role=base-image-container]'), - width = image.width(), - height = image.height(), - parentWidth = imageContainer.width(), - parentHeight = imageContainer.height(); - // Image is not larger than parent container, no need to see full picture or zoom slider - if (width <= parentWidth && height <= parentHeight) { - return; + if (galleryElement.length && galleryElement.data('gallery')) { + if (result.length === 1) { + this.initialGalleryImages = this.initialGalleryImages || galleryElement.gallery('option', 'images'); + galleryElement.gallery('option', 'images', result); + } else { + galleryElement.gallery('option', 'images', this.initialGalleryImages); + } } - // Resize Image to fit parent container - image.css({ - width: width > height ? parentWidth : '', - height: width > height ? '' : parentHeight, - top: width > height ? ((parentHeight - height) / 2) + 'px' : '', - left: width > height ? '' : ((parentWidth - width) / 2) + 'px' - }); }, /** diff --git a/app/code/Magento/Catalog/view/frontend/product/view/base-image.phtml b/app/code/Magento/Catalog/view/frontend/product/view/base-image.phtml index 069efd9a670e67299c5e2e40f9a3a9a624baf95e..a435f11557b064120721ff13901abd59653870dc 100644 --- a/app/code/Magento/Catalog/view/frontend/product/view/base-image.phtml +++ b/app/code/Magento/Catalog/view/frontend/product/view/base-image.phtml @@ -25,7 +25,7 @@ /** * Product media data template * - * @var $this \Magento\Catalog\Block\Product\View\BaseImage + * @var $this \Magento\Catalog\Block\Product\View\Gallery */ ?> <?php @@ -39,102 +39,143 @@ $_resizedHeight = $this->getVar("{$image}:height") ?: $_resizedWidth ; $_hasImage = ($_product->getImage() && $_product->getImage() != "no_selection") ? true : false; -$_isOldDisplayMode = 0; $whiteBorders = $this->getVar("product_image_white_borders"); +$thumbWidth = $this->getVar("product_page_more_views:width"); +$thumbHeight = $this->getVar("product_page_more_views:height") ? : $thumbWidth; ?> -<div class="product photo main" data-role="base-image-container"> - <a class="product photo magento-zoom<?php echo (!$_hasImage) ? ' isPlaceholder' : ''; ?>" - id="base-image" data-role="base-image-zoom" - href="<?php echo $this->helper('Magento\Catalog\Helper\Image')->init($_product, 'image'); ?>"> - <?php echo $this->getChildBlock('product.image.main')->setAddAttribute('itemprop="image"')->init($_product, $image)->toHtml() ?> - </a> - <script type="text/javascript"> - jQuery('[data-role=base-image-zoom]').attr('rel', '<?php echo $this->helper('Magento\Catalog\Helper\Image')->init($_product, 'image'); ?>'); - </script> - <p class="notice"></p> - <script type="text/javascript"> - jQuery(function(){ - <?php if ($_isOldDisplayMode): ?> - jQuery('.magento-zoom').magentoZoom({ - useGallery: false, - swapNotices: false, - isOldMode: <?php print $_isOldDisplayMode; ?>, - messages: { - noticeDefault: '<?php echo $this->escapeJsQuote(__("Click on image to zoom")) ?>', - loadingMessage: '<?php echo $this->escapeJsQuote(__("Loading...")) ?>' - } - }); - <?php else: ?> - jQuery('.magento-zoom').magentoZoom({ - useLens: true, - enlarged: { - adjustment: 20, - width: 500, - height: <?php echo $_resizedHeight ?> - }, - useGallery: true, - swapNotices: true, - isOldMode: <?php print $_isOldDisplayMode; ?>, - messages: { - noticeDefault: '<?php echo $this->escapeJsQuote(__("Click on image to zoom")) ?>', - noticeLightBox: '<?php echo $this->escapeJsQuote(__("Click on image to view it full sized")) ?>', loadingMessage: '<?php echo $this->escapeJsQuote(__("Loading...")) ?>' - } - }); - <?php endif; ?> - }); - </script> - <?php ?> -</div> -<?php if (count($this->getGalleryImages()) > 0): ?> - <?php - $thumbWidth = $this->getVar("product_page_more_views:width"); - $thumbHeight = $this->getVar("product_page_more_views:height") ? : $thumbWidth; - ?> - <div class="product photo thumbs"> - <strong class="title"><?php echo __('More Views') ?></strong> - <ul class="items thumbs"> - <?php foreach ($this->getGalleryImages() as $_image): ?> - <?php if ($_isOldDisplayMode) { - $attributes = ' href="#" data-mage-init="{popupWindow: {windowURL:' - . $this->getGalleryUrl($_image) - . ',windowName:\'gallery\',width:300,height:300,status:1,scrollbars:1,resizable:1}"'; - } else { - $attributes = ' href="' - . $this->helper('Magento\Catalog\Helper\Image')->init($_product, 'image', $_image->getFile()) - . '" rel="'; - if ($whiteBorders) { - $attributes .= $this->helper('Magento\Catalog\Helper\Image')->init($_product, 'image', $_image->getFile())->resize($_resizedWidth,$_resizedHeight) . '"'; - } else { - $attributes .= $this->helper('Magento\Catalog\Helper\Image')->init($_product, 'image', $_image->getFile())->constrainOnly(TRUE)->keepAspectRatio(TRUE)->keepFrame(FALSE)->resize($_resizedWidth,$_resizedHeight) . '"'; - } - };?> +<div data-role="media-gallery"> + <div class="product photo main"> + <div data-role="gallery-base-image-container"> + <a href="#" class="product photo magento-zoom<?php echo (!$_hasImage) ? ' isPlaceholder' : ''; ?>" + id="base-image" data-role="zoom-image" + data-large="<?php echo $this->helper('Magento\Catalog\Helper\Image')->init($_product, 'image'); ?>"> + <?php echo $this->getChildBlock('product.image.main')->setAddAttribute('itemprop="image"')->init($_product, $image)->toHtml() ?> + </a> + </div> + <div data-role="gallery-notice-container"> + <p class="notice" data-role="notice"></p> + </div> + </div> + <?php if (count($this->getGalleryImages()) > 0): ?> + + <div class="product photo thumbs"> + <strong class="title"><?php echo __('More Views') ?></strong> + <ul class="items thumbs"> + <?php foreach ($this->getGalleryImages() as $_image): ?> + <?php + $imageSmall = $this->getImageUrl($_image, 'thumbnail', $whiteBorders, $thumbWidth, $thumbHeight); + $imageMedium = $this->getImageUrl($_image, 'image', $whiteBorders, $_resizedWidth, $_resizedHeight); + $imageLarge = $this->getImageUrl($_image, 'image'); + ?> <li class="item thumb"> - <a<?php echo $attributes; ?> class="magento-zoom" title="<?php echo $this->escapeHtml($_image->getLabel()) ?>"> - <?php if ($whiteBorders): ?> - <span class="img" - style="position:relative; z-index:1; display:block; width:<?php echo $thumbHeight; ?>px; height:<?php echo $thumbHeight; ?>px;"> - <img itemprop="image" - src="<?php echo $this->helper('Magento\Catalog\Helper\Image')->init($_product, 'thumbnail', $_image->getFile())->resize($thumbWidth, $thumbHeight); ?>" - alt="<?php echo $this->escapeHtml($_image->getLabel()) ?>"/> - </span> - <?php else: ?> - <span class="img" - style="position:relative; z-index:1; display:block; width:<?php echo $thumbHeight; ?>px; height:<?php echo $thumbHeight; ?>px;"> - <img itemprop="image" - src="<?php echo $this->helper('Magento\Catalog\Helper\Image')->init($_product, 'thumbnail', $_image->getFile())->constrainOnly(TRUE)->keepAspectRatio(TRUE)->keepFrame(FALSE)->resize($thumbWidth, $thumbHeight); ?>" - alt="<?php echo $this->escapeHtml($_image->getLabel()) ?>"/> - </span> + <a class="magento-zoom" data-role="gallery-thumb" + href ="<?php echo $imageLarge ?>" + data-image-small="<?php echo $imageSmall; ?>" + data-image-medium="<?php echo $imageMedium; ?>" + data-image-large="<?php echo $imageLarge; ?>" + <?php if ($this->isMainImage($_image)): ?> + data-image-selected="true" <?php endif; ?> + title="<?php echo $this->escapeHtml($_image->getLabel()) ?>"> + <span class="img" + style="position:relative; z-index:1; display:block; width:<?php echo $thumbHeight; ?>px; height:<?php echo $thumbHeight; ?>px;"> + <img itemprop="image" + src="<?php echo $imageSmall; ?>" + alt="<?php echo $this->escapeHtml($_image->getLabel()) ?>"/> + </span> </a> </li> - <?php endforeach; ?> - </ul> - </div> - <?php if ($_isOldDisplayMode): ?> - <script type="text/javascript"> - (function($) { - head.js("<?php echo $this->getViewFileUrl('mage/popup-window.js')?>"); - })(jQuery); - </script> + <?php endforeach; ?> + </ul> + </div> <?php endif; ?> +</div> +<?php if ($_hasImage): ?> + <script data-template="gallery-wrapper" type="text/x-jQuery-tmpl"> + <div class="product photo main"> + <div data-role="gallery-base-image-container"></div> + <div data-role="gallery-notice-container"></div> + </div> + <div class="product photo thumbs" data-role="gallery-thumbs-container"> + </div> + <div class="product photo buttons" data-role="gallery-buttons-container"> + </div> + </script> + <script data-template="gallery-buttons" type="text/x-jQuery-tmpl"> + <a class="gallery control prev" data-role="gallery-prev" href="#"></a> + <a class="gallery control next" data-role="gallery-next" href="#"></a> + </script> + <script data-template="gallery-base-image" type="text/x-jQuery-tmpl"> + <a class="product photo{{if typeof hasImg !== 'undefined'}} isPlaceholder{{/if}}" href="#"> + <span class="img photo container" style="width:${width}px; height:${height}px; display: block; position: relative; overflow: hidden"> + <img data-role="zoom-image" class="photo image" width="${width}" itemprop="image" {{if !fullSizeMode}}data-large="${large}" src="${medium}"{{else}}src="${large}"{{/if}} alt="${title}"/> + </span> + </a> + </script> + <script data-template="gallery-thumbs" type="text/x-jQuery-tmpl"> + <strong class="title">${tumbsTitle}</strong> + <ul class="items thumbs"> + {{each(index, img) images}} + <li class="item thumb"> + <a title="${img.title}" data-index="${index}" data-role="gallery-thumb" href="#"> + <span style="position:relative; z-index:1; display:block; width:${size.width}px; height:${size.height}px;" class="img"> + <img alt="${img.title}" src="${img.small}" itemprop="image" width="${size.width}"> + </span> + </a> + </li> + {{/each}} + </ul> + </script> + <script data-template="zoom-display" type="text/x-jQuery-tmpl"> + <div class="magento-zoom-enlarged" data-role="zoom-container"> + <div data-role="zoom-inner"></div> + </div> + </script> + <script data-template="zoom-enlarged-image" type="text/x-jQuery-tmpl"> + <img data-role="enlarged-image" src="${img}" /> + </script> + <script data-template="zoom-track" type="text/z-jQuery-tmpl"> + <div data-role="zoom-track"></div> + </script> + <script data-template="zoom-lens" type="text/z-jQuery-tmpl"> + <div data-role="zoom-lens"></div> + </script> + <script data-template="notice" type="text/x-jQuery-tmpl"> + <p class="notice" data-role="notice">${text}</p> + </script> + <script type="text/javascript"> + (function($) { + head.js("<?php echo $this->getViewFileUrl('mage/zoom.js')?>", + "<?php echo $this->getViewFileUrl('mage/gallery.js')?>", + "<?php echo $this->getViewFileUrl('mage/gallery-fullscreen.js')?>", + function() { + $('[data-role=media-gallery]') + .gallery({ + sizes: { + small: { + width: <?php echo $thumbWidth ?>, + height: <?php echo $thumbHeight ?> + }, + medium: { + width: <?php echo $_resizedWidth ?>, + height: <?php echo $_resizedHeight ?> + } + }, + controls: { + notice: { + text: '<?php echo $this->escapeJsQuote(__("Click on image to view it full sized")) ?>' + } + } + }) + .zoom({ + controls: { + notice: { + text: '<?php echo $this->escapeJsQuote(__("Click on image to zoom")) ?>' + } + } + }) + .galleryFullScreen(); + }); + })(jQuery); + </script> <?php endif; ?> diff --git a/app/code/Magento/CatalogInventory/Block/Adminhtml/Form/Field/Customergroup.php b/app/code/Magento/CatalogInventory/Block/Adminhtml/Form/Field/Customergroup.php index 6135d9921565ee66cffac9f81346147ca62171a1..93a805df467c817c28d97cfbcd7ff67ed8a76e43 100644 --- a/app/code/Magento/CatalogInventory/Block/Adminhtml/Form/Field/Customergroup.php +++ b/app/code/Magento/CatalogInventory/Block/Adminhtml/Form/Field/Customergroup.php @@ -71,7 +71,7 @@ class Customergroup extends \Magento\View\Element\Html\Select /** * Retrieve allowed customer groups * - * @param int $groupId return name by customer group id + * @param int $groupId return name by customer group id * @return array|string */ protected function _getCustomerGroups($groupId = null) @@ -89,6 +89,10 @@ class Customergroup extends \Magento\View\Element\Html\Select return $this->_customerGroups; } + /** + * @param string $value + * @return $this + */ public function setInputName($value) { return $this->setName($value); diff --git a/app/code/Magento/CatalogInventory/Block/Adminhtml/Form/Field/Minsaleqty.php b/app/code/Magento/CatalogInventory/Block/Adminhtml/Form/Field/Minsaleqty.php index c5f170549352270cb3571575043c045604c16346..1303db611919e2b1216ee6d1d8d5b3b864383e3e 100644 --- a/app/code/Magento/CatalogInventory/Block/Adminhtml/Form/Field/Minsaleqty.php +++ b/app/code/Magento/CatalogInventory/Block/Adminhtml/Form/Field/Minsaleqty.php @@ -37,14 +37,14 @@ class Minsaleqty extends \Magento\Backend\Block\System\Config\Form\Field\FieldArray\AbstractFieldArray { /** - * @var \Magento\CatalogInventory\Block\Adminhtml\Form\Field\Customergroup + * @var Customergroup */ protected $_groupRenderer; /** * Retrieve group column renderer * - * @return \Magento\CatalogInventory\Block\Adminhtml\Form\Field\Customergroup + * @return Customergroup */ protected function _getGroupRenderer() { @@ -60,6 +60,8 @@ class Minsaleqty /** * Prepare to render + * + * @return void */ protected function _prepareToRender() { @@ -77,7 +79,8 @@ class Minsaleqty /** * Prepare existing row data object * - * @param \Magento\Object + * @param \Magento\Object $row + * @return void */ protected function _prepareArrayRow(\Magento\Object $row) { diff --git a/app/code/Magento/CatalogInventory/Block/Adminhtml/Form/Field/Stock.php b/app/code/Magento/CatalogInventory/Block/Adminhtml/Form/Field/Stock.php index a8ba20428a5fb02f3a015a7205c4595678a6e7eb..03fd8ec3b37493ec97f8050af76dd5e581c410e9 100644 --- a/app/code/Magento/CatalogInventory/Block/Adminhtml/Form/Field/Stock.php +++ b/app/code/Magento/CatalogInventory/Block/Adminhtml/Form/Field/Stock.php @@ -29,6 +29,8 @@ */ namespace Magento\CatalogInventory\Block\Adminhtml\Form\Field; +use Magento\Data\Form; + class Stock extends \Magento\Data\Form\Element\Select { const QUANTITY_FIELD_HTML_ID = 'qty'; @@ -114,8 +116,8 @@ class Stock extends \Magento\Data\Form\Element\Select /** * Set form to quantity element in addition to current element * - * @param $form - * @return \Magento\Data\Form + * @param Form $form + * @return Form */ public function setForm($form) { @@ -126,8 +128,8 @@ class Stock extends \Magento\Data\Form\Element\Select /** * Set value to quantity element in addition to current element * - * @param $value - * @return \Magento\Data\Form\Element\Select + * @param array|string $value + * @return $this */ public function setValue($value) { @@ -142,6 +144,7 @@ class Stock extends \Magento\Data\Form\Element\Select * Set name to quantity element in addition to current element * * @param string $name + * @return void */ public function setName($name) { @@ -165,7 +168,7 @@ class Stock extends \Magento\Data\Form\Element\Select /** * Disable fields depending on product type * - * @return \Magento\CatalogInventory\Block\Adminhtml\Form\Field\Stock + * @return $this */ protected function _disableFields() { @@ -184,8 +187,8 @@ class Stock extends \Magento\Data\Form\Element\Select /** * Get js for quantity and in stock synchronisation * - * @param $quantityFieldId - * @param $inStockFieldId + * @param string $quantityFieldId + * @param string $inStockFieldId * @return string */ protected function _getJs($quantityFieldId, $inStockFieldId) diff --git a/app/code/Magento/CatalogInventory/Block/Stockqty/Composite.php b/app/code/Magento/CatalogInventory/Block/Stockqty/Composite.php index 1b3ca00256f4703d2570f8f1a645af58869b3738..58e72f914f79fb4c1475ad469bdbfb849235f758 100644 --- a/app/code/Magento/CatalogInventory/Block/Stockqty/Composite.php +++ b/app/code/Magento/CatalogInventory/Block/Stockqty/Composite.php @@ -34,26 +34,28 @@ */ namespace Magento\CatalogInventory\Block\Stockqty; -abstract class Composite extends \Magento\CatalogInventory\Block\Stockqty\DefaultStockqty +use Magento\Catalog\Model\Product; + +abstract class Composite extends DefaultStockqty { /** * Child products cache * - * @var array + * @var Product[] */ private $_childProducts; /** * Retrieve child products * - * @return array + * @return Product[] */ abstract protected function _getChildProducts(); /** * Retrieve child products (using cache) * - * @return array + * @return Product[] */ public function getChildProducts() { @@ -66,6 +68,7 @@ abstract class Composite extends \Magento\CatalogInventory\Block\Stockqty\Defaul /** * Retrieve product stock qty * + * @param Product $product * @return float */ public function getProductStockQty($product) diff --git a/app/code/Magento/CatalogInventory/Block/Stockqty/DefaultStockqty.php b/app/code/Magento/CatalogInventory/Block/Stockqty/DefaultStockqty.php index 2a6972b3297c3d1f072e7938d05d1b75699957a0..bb14075acff2ac12a482dff5db7dcd8dde5d11d2 100644 --- a/app/code/Magento/CatalogInventory/Block/Stockqty/DefaultStockqty.php +++ b/app/code/Magento/CatalogInventory/Block/Stockqty/DefaultStockqty.php @@ -34,7 +34,7 @@ */ namespace Magento\CatalogInventory\Block\Stockqty; -class DefaultStockqty extends \Magento\CatalogInventory\Block\Stockqty\AbstractStockqty +class DefaultStockqty extends AbstractStockqty { /** * Render block HTML diff --git a/app/code/Magento/CatalogInventory/Block/Stockqty/Type/Configurable.php b/app/code/Magento/CatalogInventory/Block/Stockqty/Type/Configurable.php index 79590e0dda3595a082e9d25dc7dd0c7318fa20e2..e564e1281e046e2785930f0d2c6ea369e54c893d 100644 --- a/app/code/Magento/CatalogInventory/Block/Stockqty/Type/Configurable.php +++ b/app/code/Magento/CatalogInventory/Block/Stockqty/Type/Configurable.php @@ -34,12 +34,14 @@ */ namespace Magento\CatalogInventory\Block\Stockqty\Type; +use Magento\Catalog\Model\Product; + class Configurable extends \Magento\CatalogInventory\Block\Stockqty\Composite { /** * Retrieve child products * - * @return array + * @return Product[] */ protected function _getChildProducts() { diff --git a/app/code/Magento/CatalogInventory/Block/Stockqty/Type/Grouped.php b/app/code/Magento/CatalogInventory/Block/Stockqty/Type/Grouped.php new file mode 100644 index 0000000000000000000000000000000000000000..02770142527b1e913329648a9ec44d2abd461eb1 --- /dev/null +++ b/app/code/Magento/CatalogInventory/Block/Stockqty/Type/Grouped.php @@ -0,0 +1,51 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @category Magento + * @package Magento_CatalogInventory + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + + +/** + * Product stock qty block for grouped product type + * + * @category Magento + * @package Magento_CatalogInventory + * @author Magento Core Team <core@magentocommerce.com> + */ +namespace Magento\CatalogInventory\Block\Stockqty\Type; + +use Magento\Catalog\Model\Product; + +class Grouped extends \Magento\CatalogInventory\Block\Stockqty\Composite +{ + /** + * Retrieve child products + * + * @return Product[] + */ + protected function _getChildProducts() + { + return $this->getProduct()->getTypeInstance() + ->getAssociatedProducts($this->getProduct()); + } +} diff --git a/app/code/Magento/CatalogInventory/Helper/Data.php b/app/code/Magento/CatalogInventory/Helper/Data.php index fa179715e15ddd78091a26d0b35836b9bbf18a0f..1497cf3b45ad5da58a7f58d3cba70d125a9420b8 100644 --- a/app/code/Magento/CatalogInventory/Helper/Data.php +++ b/app/code/Magento/CatalogInventory/Helper/Data.php @@ -123,7 +123,7 @@ class Data extends \Magento\App\Helper\AbstractHelper /** * Retrieve inventory item options (used in config) * - * @return array + * @return string[] */ public function getConfigItemOptions() { @@ -152,6 +152,7 @@ class Data extends \Magento\App\Helper\AbstractHelper /** * Check if creditmemo items auto return option is enabled + * * @return bool */ public function isAutoReturnEnabled() diff --git a/app/code/Magento/CatalogInventory/Helper/Minsaleqty.php b/app/code/Magento/CatalogInventory/Helper/Minsaleqty.php index fc8b8fdcf702cf4b25ddeb6efd5d5efe66394618..9a419da8d60d441176ad00c799b4e29595cbf395 100644 --- a/app/code/Magento/CatalogInventory/Helper/Minsaleqty.php +++ b/app/code/Magento/CatalogInventory/Helper/Minsaleqty.php @@ -29,6 +29,8 @@ */ namespace Magento\CatalogInventory\Helper; +use Magento\Core\Model\Store; + class Minsaleqty { /** @@ -58,7 +60,7 @@ class Minsaleqty /** * Retrieve fixed qty value * - * @param mixed $qty + * @param int|float|string|null $qty * @return float|null */ protected function _fixQty($qty) @@ -69,7 +71,7 @@ class Minsaleqty /** * Generate a storable representation of a value * - * @param mixed $value + * @param int|float|string|array $value * @return string */ protected function _serializeValue($value) @@ -96,7 +98,7 @@ class Minsaleqty /** * Create a value from a storable representation * - * @param mixed $value + * @param int|float|string $value * @return array */ protected function _unserializeValue($value) @@ -115,7 +117,7 @@ class Minsaleqty /** * Check whether value is in form retrieved by _encodeArrayFieldValue() * - * @param mixed + * @param string|array $value * @return bool */ protected function _isEncodedArrayFieldValue($value) @@ -135,7 +137,7 @@ class Minsaleqty /** * Encode value to be used in \Magento\Backend\Block\System\Config\Form\Field\FieldArray\AbstractFieldArray * - * @param array + * @param array $value * @return array */ protected function _encodeArrayFieldValue(array $value) @@ -154,7 +156,7 @@ class Minsaleqty /** * Decode value from used in \Magento\Backend\Block\System\Config\Form\Field\FieldArray\AbstractFieldArray * - * @param array + * @param array $value * @return array */ protected function _decodeArrayFieldValue(array $value) @@ -176,7 +178,7 @@ class Minsaleqty * Retrieve min_sale_qty value from config * * @param int $customerGroupId - * @param mixed $store + * @param null|string|bool|int|Store $store * @return float|null */ public function getConfigValue($customerGroupId, $store = null) @@ -201,7 +203,7 @@ class Minsaleqty /** * Make value readable by \Magento\Backend\Block\System\Config\Form\Field\FieldArray\AbstractFieldArray * - * @param mixed $value + * @param string|array $value * @return array */ public function makeArrayFieldValue($value) @@ -216,7 +218,7 @@ class Minsaleqty /** * Make value ready for store * - * @param mixed $value + * @param string|array $value * @return string */ public function makeStorableArrayFieldValue($value) diff --git a/app/code/Magento/CatalogInventory/Model/Config/Backend/Managestock.php b/app/code/Magento/CatalogInventory/Model/Config/Backend/Managestock.php index fcdfb222d30507be7cfd58a3bf51a9ee2707bedd..a20391225a94d876d886af544f7a96ca0e31e659 100644 --- a/app/code/Magento/CatalogInventory/Model/Config/Backend/Managestock.php +++ b/app/code/Magento/CatalogInventory/Model/Config/Backend/Managestock.php @@ -69,7 +69,7 @@ class Managestock /** * After change Catalog Inventory Manage value process * - * @return \Magento\CatalogInventory\Model\Config\Backend\Managestock + * @return $this */ protected function _afterSave() { diff --git a/app/code/Magento/CatalogInventory/Model/Indexer/Stock.php b/app/code/Magento/CatalogInventory/Model/Indexer/Stock.php index f04f585d554441863664d28e674ce2f1b73fc605..cfeb7dcdcec58454ee4739dab69e606ee300065b 100644 --- a/app/code/Magento/CatalogInventory/Model/Indexer/Stock.php +++ b/app/code/Magento/CatalogInventory/Model/Indexer/Stock.php @@ -23,7 +23,7 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ - +namespace Magento\CatalogInventory\Model\Indexer; /** * CatalogInventory Stock Status Indexer Model @@ -44,7 +44,6 @@ * @package Magento_CatalogInventory * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\CatalogInventory\Model\Indexer; class Stock extends \Magento\Index\Model\Indexer\AbstractIndexer { @@ -79,7 +78,7 @@ class Stock extends \Magento\Index\Model\Indexer\AbstractIndexer /** * Related config settings * - * @var array + * @var string[] */ protected $_relatedConfigSettings = array( \Magento\CatalogInventory\Model\Stock\Item::XML_PATH_MANAGE_STOCK, @@ -125,6 +124,7 @@ class Stock extends \Magento\Index\Model\Indexer\AbstractIndexer /** * Initialize resource model * + * @return void */ protected function _construct() { @@ -212,6 +212,7 @@ class Stock extends \Magento\Index\Model\Indexer\AbstractIndexer * Register data required by process in event object * * @param \Magento\Index\Model\Event $event + * @return void */ protected function _registerEvent(\Magento\Index\Model\Event $event) { @@ -249,6 +250,7 @@ class Stock extends \Magento\Index\Model\Indexer\AbstractIndexer * Register data required by catalog product processes in event object * * @param \Magento\Index\Model\Event $event + * @return void */ protected function _registerCatalogProductEvent(\Magento\Index\Model\Event $event) { @@ -273,6 +275,7 @@ class Stock extends \Magento\Index\Model\Indexer\AbstractIndexer * Register data required by cataloginventory stock item processes in event object * * @param \Magento\Index\Model\Event $event + * @return void */ protected function _registerCatalogInventoryStockItemEvent(\Magento\Index\Model\Event $event) { @@ -287,7 +290,7 @@ class Stock extends \Magento\Index\Model\Indexer\AbstractIndexer * Register data required by stock item save process in event object * * @param \Magento\Index\Model\Event $event - * @return \Magento\CatalogInventory\Model\Indexer\Stock + * @return $this */ protected function _registerStockItemSaveEvent(\Magento\Index\Model\Event $event) { @@ -315,7 +318,7 @@ class Stock extends \Magento\Index\Model\Indexer\AbstractIndexer * Register data required by product delete process in event object * * @param \Magento\Index\Model\Event $event - * @return \Magento\CatalogInventory\Model\Indexer\Stock + * @return $this */ protected function _registerCatalogProductDeleteEvent(\Magento\Index\Model\Event $event) { @@ -334,7 +337,7 @@ class Stock extends \Magento\Index\Model\Indexer\AbstractIndexer * Register data required by product mass action process in event object * * @param \Magento\Index\Model\Event $event - * @return \Magento\CatalogInventory\Model\Indexer\Stock + * @return $this */ protected function _registerCatalogProductMassActionEvent(\Magento\Index\Model\Event $event) { @@ -373,6 +376,7 @@ class Stock extends \Magento\Index\Model\Indexer\AbstractIndexer * Process event * * @param \Magento\Index\Model\Event $event + * @return void */ protected function _processEvent(\Magento\Index\Model\Event $event) { diff --git a/app/code/Magento/CatalogInventory/Model/Observer.php b/app/code/Magento/CatalogInventory/Model/Observer.php index 19c618d5bd4cebdbf3b7671d2ce754fac236ec8a..e1f351df0048a34ed427f044e58b21bbbffbbdb7 100644 --- a/app/code/Magento/CatalogInventory/Model/Observer.php +++ b/app/code/Magento/CatalogInventory/Model/Observer.php @@ -29,6 +29,10 @@ */ namespace Magento\CatalogInventory\Model; +use Magento\CatalogInventory\Model\Stock\Item; +use Magento\Event\Observer as EventObserver; +use Magento\Sales\Model\Quote\Item as QuoteItem; + class Observer { /** @@ -39,6 +43,9 @@ class Observer */ protected $_checkedQuoteItems = array(); + /** + * @var Item[] + */ protected $_itemsForReindex = array(); /** @@ -66,7 +73,7 @@ class Observer /** * Stock model factory * - * @var \Magento\CatalogInventory\Model\StockFactory + * @var StockFactory */ protected $_stockFactory; @@ -85,7 +92,7 @@ class Observer protected $_indexer; /** - * @var \Magento\CatalogInventory\Model\Stock + * @var Stock */ protected $_stock; @@ -119,11 +126,11 @@ class Observer * @param \Magento\CatalogInventory\Model\Resource\Indexer\Stock $resourceIndexerStock * @param \Magento\CatalogInventory\Model\Resource\Stock $resourceStock * @param \Magento\Index\Model\Indexer $indexer - * @param \Magento\CatalogInventory\Model\Stock $stock + * @param Stock $stock * @param \Magento\CatalogInventory\Model\Stock\Status $stockStatus * @param \Magento\CatalogInventory\Helper\Data $catalogInventoryData * @param \Magento\CatalogInventory\Model\Stock\ItemFactory $stockItemFactory - * @param \Magento\CatalogInventory\Model\StockFactory $stockFactory + * @param StockFactory $stockFactory * @param \Magento\CatalogInventory\Model\Stock\StatusFactory $stockStatusFactory * @param \Magento\Catalog\Model\ProductTypes\ConfigInterface $typeConfig */ @@ -132,11 +139,11 @@ class Observer \Magento\CatalogInventory\Model\Resource\Indexer\Stock $resourceIndexerStock, \Magento\CatalogInventory\Model\Resource\Stock $resourceStock, \Magento\Index\Model\Indexer $indexer, - \Magento\CatalogInventory\Model\Stock $stock, + Stock $stock, \Magento\CatalogInventory\Model\Stock\Status $stockStatus, \Magento\CatalogInventory\Helper\Data $catalogInventoryData, \Magento\CatalogInventory\Model\Stock\ItemFactory $stockItemFactory, - \Magento\CatalogInventory\Model\StockFactory $stockFactory, + StockFactory $stockFactory, \Magento\CatalogInventory\Model\Stock\StatusFactory $stockStatusFactory, \Magento\Catalog\Model\ProductTypes\ConfigInterface $typeConfig ) { @@ -156,8 +163,8 @@ class Observer /** * Add stock information to product * - * @param \Magento\Event\Observer $observer - * @return \Magento\CatalogInventory\Model\Observer + * @param EventObserver $observer + * @return $this */ public function addInventoryData($observer) { @@ -176,8 +183,8 @@ class Observer /** * Remove stock information from static variable * - * @param \Magento\Event\Observer $observer - * @return \Magento\CatalogInventory\Model\Observer + * @param EventObserver $observer + * @return $this */ public function removeInventoryData($observer) { @@ -194,8 +201,8 @@ class Observer * Add information about producs stock status to collection * Used in for product collection after load * - * @param \Magento\Event\Observer $observer - * @return \Magento\CatalogInventory\Model\Observer + * @param EventObserver $observer + * @return $this */ public function addStockStatusToCollection($observer) { @@ -211,8 +218,8 @@ class Observer /** * Add Stock items to product collection * - * @param \Magento\Event\Observer $observer - * @return \Magento\CatalogInventory\Model\Observer + * @param EventObserver $observer + * @return $this */ public function addInventoryDataToCollection($observer) { @@ -224,8 +231,8 @@ class Observer /** * Saving product inventory data. Product qty calculated dynamically. * - * @param \Magento\Event\Observer $observer - * @return \Magento\CatalogInventory\Model\Observer + * @param EventObserver $observer + * @return $this */ public function saveInventoryData($observer) { @@ -250,9 +257,9 @@ class Observer /** * Prepare stock item data for save * - * @param \Magento\CatalogInventory\Model\Stock\Item $item + * @param Item $item * @param \Magento\Catalog\Model\Product $product - * @return \Magento\CatalogInventory\Model\Observer + * @return $this */ protected function _prepareItemForSave($item, $product) { @@ -299,9 +306,9 @@ class Observer /** * Removes error statuses from quote and item, set by this observer * - * @param \Magento\Sales\Model\Quote\Item $item + * @param QuoteItem $item * @param int $code - * @return \Magento\CatalogInventory\Model\Observer + * @return $this */ protected function _removeErrorsFromQuoteAndItem($item, $code) { @@ -349,14 +356,14 @@ class Observer /** * Check product inventory data when quote item quantity declaring * - * @param \Magento\Event\Observer $observer - * @return \Magento\CatalogInventory\Model\Observer + * @param EventObserver $observer + * @return $this * @throws \Magento\Core\Exception */ public function checkQuoteItemQty($observer) { $quoteItem = $observer->getEvent()->getItem(); - /* @var $quoteItem \Magento\Sales\Model\Quote\Item */ + /* @var $quoteItem QuoteItem */ if (!$quoteItem || !$quoteItem->getProductId() || !$quoteItem->getQuote() || $quoteItem->getQuote()->getIsSuperMode()) { return $this; @@ -438,8 +445,8 @@ class Observer $stockItem->setProductName($quoteItem->getName()); } - /* @var $stockItem \Magento\CatalogInventory\Model\Stock\Item */ - if (!$stockItem instanceof \Magento\CatalogInventory\Model\Stock\Item) { + /* @var Item $stockItem */ + if (!$stockItem instanceof Item) { throw new \Magento\Core\Exception(__('The stock item for Product in option is not valid.')); } @@ -504,8 +511,8 @@ class Observer $stockItem->unsIsChildItem(); } } else { - /* @var $stockItem \Magento\CatalogInventory\Model\Stock\Item */ - if (!$stockItem instanceof \Magento\CatalogInventory\Model\Stock\Item) { + /* @var Item $stockItem */ + if (!$stockItem instanceof Item) { throw new \Magento\Core\Exception(__('The stock item for Product is not valid.')); } @@ -605,8 +612,8 @@ class Observer * Get product qty includes information from all quote items * Need be used only in sungleton mode * - * @param int $productId - * @param int $quoteItemId + * @param int $productId + * @param int $quoteItemId * @param float $itemQty * @return int */ @@ -627,10 +634,10 @@ class Observer /** * Subtract qtys of quote item products after multishipping checkout * - * @param \Magento\Event\Observer $observer - * @return \Magento\CatalogInventory\Model\Observer + * @param EventObserver $observer + * @return $this */ - public function checkoutAllSubmitAfter(\Magento\Event\Observer $observer) + public function checkoutAllSubmitAfter(EventObserver $observer) { $quote = $observer->getEvent()->getQuote(); if (!$quote->getInventoryProcessed()) { @@ -646,9 +653,10 @@ class Observer * Used before order placing to make order save/place transaction smaller * Also called after every successful order placement to ensure subtraction of inventory * - * @param \Magento\Event\Observer $observer + * @param EventObserver $observer + * @return $this|void */ - public function subtractQuoteInventory(\Magento\Event\Observer $observer) + public function subtractQuoteInventory(EventObserver $observer) { $quote = $observer->getEvent()->getQuote(); @@ -670,7 +678,9 @@ class Observer /** * Revert quote items inventory data (cover not success order place case) - * @param $observer + * + * @param EventObserver $observer + * @return void */ public function revertQuoteInventory($observer) { @@ -692,14 +702,16 @@ class Observer * ) * ) * - * @param \Magento\Sales\Model\Quote\Item $quoteItem + * @param QuoteItem $quoteItem * @param array &$items + * @return void */ protected function _addItemToQtyArray($quoteItem, &$items) { $productId = $quoteItem->getProductId(); - if (!$productId) + if (!$productId) { return; + } if (isset($items[$productId])) { $items[$productId]['qty'] += $quoteItem->getTotalQty(); } else { @@ -749,7 +761,8 @@ class Observer /** * Refresh stock index for specific stock items after successful order placement * - * @param $observer + * @param EventObserver $observer + * @return $this */ public function reindexQuoteInventory($observer) { @@ -787,7 +800,8 @@ class Observer /** * Return creditmemo items qty to stock * - * @param \Magento\Event\Observer $observer + * @param EventObserver $observer + * @return void */ public function refundOrderInventory($observer) { @@ -825,8 +839,8 @@ class Observer /** * Cancel order item * - * @param \Magento\Event\Observer $observer - * @return \Magento\CatalogInventory\Model\Observer + * @param EventObserver $observer + * @return $this */ public function cancelOrderItem($observer) { @@ -845,8 +859,8 @@ class Observer /** * Update items stock status and low stock date. * - * @param \Magento\Event\Observer $observer - * @return \Magento\CatalogInventory\Model\Observer + * @param EventObserver $observer + * @return $this */ public function updateItemsStockUponConfigChange($observer) { @@ -859,10 +873,10 @@ class Observer /** * Update Only product status observer * - * @param \Magento\Event\Observer $observer - * @return \Magento\CatalogInventory\Model\Observer + * @param EventObserver $observer + * @return $this */ - public function productStatusUpdate(\Magento\Event\Observer $observer) + public function productStatusUpdate(EventObserver $observer) { $productId = $observer->getEvent()->getProductId(); $this->_stockStatus->updateStatus($productId); @@ -872,10 +886,10 @@ class Observer /** * Catalog Product website update * - * @param \Magento\Event\Observer $observer - * @return \Magento\CatalogInventory\Model\Observer + * @param EventObserver $observer + * @return $this */ - public function catalogProductWebsiteUpdate(\Magento\Event\Observer $observer) + public function catalogProductWebsiteUpdate(EventObserver $observer) { $websiteIds = $observer->getEvent()->getWebsiteIds(); $productIds = $observer->getEvent()->getProductIds(); @@ -892,10 +906,10 @@ class Observer /** * Add stock status to prepare index select * - * @param \Magento\Event\Observer $observer - * @return \Magento\CatalogInventory\Model\Observer + * @param EventObserver $observer + * @return $this */ - public function addStockStatusToPrepareIndexSelect(\Magento\Event\Observer $observer) + public function addStockStatusToPrepareIndexSelect(EventObserver $observer) { $website = $observer->getEvent()->getWebsite(); $select = $observer->getEvent()->getSelect(); @@ -908,10 +922,10 @@ class Observer /** * Add stock status limitation to catalog product price index select object * - * @param \Magento\Event\Observer $observer - * @return \Magento\CatalogInventory\Model\Observer + * @param EventObserver $observer + * @return $this */ - public function prepareCatalogProductIndexSelect(\Magento\Event\Observer $observer) + public function prepareCatalogProductIndexSelect(EventObserver $observer) { $select = $observer->getEvent()->getSelect(); $entity = $observer->getEvent()->getEntityField(); @@ -925,7 +939,8 @@ class Observer /** * Reindex all events of product-massAction type * - * @param \Magento\Event\Observer $observer + * @param EventObserver $observer + * @return void */ public function reindexProductsMassAction($observer) { @@ -937,8 +952,8 @@ class Observer /** * Detects whether product status should be shown * - * @param \Magento\Event\Observer $observer - * @return \Magento\CatalogInventory\Model\Observer + * @param EventObserver $observer + * @return $this */ public function displayProductStatusInfo($observer) { diff --git a/app/code/Magento/CatalogInventory/Model/Product/CopyConstructor/CatalogInventory.php b/app/code/Magento/CatalogInventory/Model/Product/CopyConstructor/CatalogInventory.php index bd8ec669bfb23dbb953bf74cf703b2096794870c..0367abd00d21497ab92399872e5493ddb535d8b3 100644 --- a/app/code/Magento/CatalogInventory/Model/Product/CopyConstructor/CatalogInventory.php +++ b/app/code/Magento/CatalogInventory/Model/Product/CopyConstructor/CatalogInventory.php @@ -31,6 +31,7 @@ class CatalogInventory implements \Magento\Catalog\Model\Product\CopyConstructor * * @param \Magento\Catalog\Model\Product $product * @param \Magento\Catalog\Model\Product $duplicate + * @return void */ public function build(\Magento\Catalog\Model\Product $product, \Magento\Catalog\Model\Product $duplicate) { diff --git a/app/code/Magento/CatalogInventory/Model/Resource/Indexer/Stock.php b/app/code/Magento/CatalogInventory/Model/Resource/Indexer/Stock.php index ac2ea1e314bf9e247c2d03efee22e4734e40f373..4e493f5863d3ddaa4de18f441e4b80613f2a321b 100644 --- a/app/code/Magento/CatalogInventory/Model/Resource/Indexer/Stock.php +++ b/app/code/Magento/CatalogInventory/Model/Resource/Indexer/Stock.php @@ -45,7 +45,7 @@ class Stock extends \Magento\Catalog\Model\Resource\Product\Indexer\AbstractInde protected $_indexers = array(); /** - * @var \Magento\CatalogInventory\Model\Resource\Indexer\StockFactory + * @var StockFactory */ protected $_indexerFactory; @@ -57,13 +57,13 @@ class Stock extends \Magento\Catalog\Model\Resource\Product\Indexer\AbstractInde /** * @param \Magento\App\Resource $resource * @param \Magento\Eav\Model\Config $eavConfig - * @param \Magento\CatalogInventory\Model\Resource\Indexer\StockFactory $indexerFactory + * @param StockFactory $indexerFactory * @param \Magento\Catalog\Model\Product\Type $productType */ public function __construct( \Magento\App\Resource $resource, \Magento\Eav\Model\Config $eavConfig, - \Magento\CatalogInventory\Model\Resource\Indexer\StockFactory $indexerFactory, + StockFactory $indexerFactory, \Magento\Catalog\Model\Product\Type $productType ) { $this->_indexerFactory = $indexerFactory; @@ -74,6 +74,7 @@ class Stock extends \Magento\Catalog\Model\Resource\Product\Indexer\AbstractInde /** * Initialize connection and define main table * + * @return void */ protected function _construct() { @@ -84,7 +85,7 @@ class Stock extends \Magento\Catalog\Model\Resource\Product\Indexer\AbstractInde * Process stock item save action * * @param \Magento\Index\Model\Event $event - * @return \Magento\CatalogInventory\Model\Resource\Indexer\Stock + * @return $this */ public function cataloginventoryStockItemSave(\Magento\Index\Model\Event $event) { @@ -102,9 +103,9 @@ class Stock extends \Magento\Catalog\Model\Resource\Product\Indexer\AbstractInde /** * Refresh stock index for specific product ids * - * @param array $productIds + * @param int|array $productIds * @throws \Exception - * @return \Magento\CatalogInventory\Model\Resource\Indexer\Stock + * @return $this */ public function reindexProducts($productIds) { @@ -152,7 +153,7 @@ class Stock extends \Magento\Catalog\Model\Resource\Product\Indexer\AbstractInde * * @param \Magento\Index\Model\Event $event * @throws \Exception - * @return \Magento\CatalogInventory\Model\Resource\Indexer\Stock + * @return $this */ public function catalogProductDelete(\Magento\Index\Model\Event $event) { @@ -188,7 +189,7 @@ class Stock extends \Magento\Catalog\Model\Resource\Product\Indexer\AbstractInde * * @param \Magento\Index\Model\Event $event * @throws \Exception - * @return \Magento\CatalogInventory\Model\Resource\Indexer\Stock + * @return $this */ public function catalogProductMassAction(\Magento\Index\Model\Event $event) { @@ -261,7 +262,7 @@ class Stock extends \Magento\Catalog\Model\Resource\Product\Indexer\AbstractInde * Rebuild all index data * * @throws \Exception - * @return \Magento\CatalogInventory\Model\Resource\Indexer\Stock + * @return $this */ public function reindexAll() { diff --git a/app/code/Magento/CatalogInventory/Model/Resource/Indexer/Stock/Configurable.php b/app/code/Magento/CatalogInventory/Model/Resource/Indexer/Stock/Configurable.php index 4baa64b3d04e6cbaa95a821b13f9b18156589088..1f27f282bdc3c29f94e5a5a34e58487c1d3421e3 100644 --- a/app/code/Magento/CatalogInventory/Model/Resource/Indexer/Stock/Configurable.php +++ b/app/code/Magento/CatalogInventory/Model/Resource/Indexer/Stock/Configurable.php @@ -34,14 +34,13 @@ */ namespace Magento\CatalogInventory\Model\Resource\Indexer\Stock; -class Configurable - extends \Magento\CatalogInventory\Model\Resource\Indexer\Stock\DefaultStock +class Configurable extends DefaultStock { /** * Reindex stock data for defined configurable product ids * * @param int|array $entityIds - * @return \Magento\CatalogInventory\Model\Resource\Indexer\Stock\Configurable + * @return $this */ public function reindexEntity($entityIds) { diff --git a/app/code/Magento/CatalogInventory/Model/Resource/Indexer/Stock/DefaultStock.php b/app/code/Magento/CatalogInventory/Model/Resource/Indexer/Stock/DefaultStock.php index dc718aed029f4fbcae7c8cdb4a39d4300c0c4dde..e2ba9da30517887dfef428be93f5f9317c9fdf79 100644 --- a/app/code/Magento/CatalogInventory/Model/Resource/Indexer/Stock/DefaultStock.php +++ b/app/code/Magento/CatalogInventory/Model/Resource/Indexer/Stock/DefaultStock.php @@ -36,7 +36,7 @@ namespace Magento\CatalogInventory\Model\Resource\Indexer\Stock; class DefaultStock extends \Magento\Catalog\Model\Resource\Product\Indexer\AbstractIndexer - implements \Magento\CatalogInventory\Model\Resource\Indexer\Stock\StockInterface + implements StockInterface { /** * Current Product Type Id @@ -78,6 +78,7 @@ class DefaultStock /** * Initialize connection and define main table name * + * @return void */ protected function _construct() { @@ -87,7 +88,8 @@ class DefaultStock /** * Reindex all stock status data for default logic product type * - * @return \Magento\CatalogInventory\Model\Resource\Indexer\Stock\DefaultStock + * @return $this + * @throws \Exception */ public function reindexAll() { @@ -107,7 +109,7 @@ class DefaultStock * Reindex stock data for defined product ids * * @param int|array $entityIds - * @return \Magento\CatalogInventory\Model\Resource\Indexer\Stock\DefaultStock + * @return $this */ public function reindexEntity($entityIds) { @@ -119,7 +121,7 @@ class DefaultStock * Set active Product Type Id * * @param string $typeId - * @return \Magento\CatalogInventory\Model\Resource\Indexer\Stock\DefaultStock + * @return $this */ public function setTypeId($typeId) { @@ -145,7 +147,7 @@ class DefaultStock * Set Product Type Composite flag * * @param bool $flag - * @return \Magento\CatalogInventory\Model\Resource\Indexer\Stock\DefaultStock + * @return $this */ public function setIsComposite($flag) { @@ -225,8 +227,8 @@ class DefaultStock /** * Prepare stock status data in temporary index table * - * @param int|array $entityIds the product limitation - * @return \Magento\CatalogInventory\Model\Resource\Indexer\Stock\DefaultStock + * @param int|array $entityIds the product limitation + * @return $this */ protected function _prepareIndexTable($entityIds = null) { @@ -242,7 +244,7 @@ class DefaultStock * Update Stock status index by product ids * * @param array|int $entityIds - * @return \Magento\CatalogInventory\Model\Resource\Indexer\Stock\DefaultStock + * @return $this */ protected function _updateIndex($entityIds) { @@ -275,7 +277,7 @@ class DefaultStock * Update stock status index table (INSERT ... ON DUPLICATE KEY UPDATE ...) * * @param array $data - * @return \Magento\CatalogInventory\Model\Resource\Indexer\Stock\DefaultStock + * @return $this */ protected function _updateIndexTable($data) { diff --git a/app/code/Magento/CatalogInventory/Model/Resource/Indexer/Stock/StockInterface.php b/app/code/Magento/CatalogInventory/Model/Resource/Indexer/Stock/StockInterface.php index e1da76e40b7975004c238001009d581355acf813..33a301db213872bd79759bc441609d9079ea07e1 100644 --- a/app/code/Magento/CatalogInventory/Model/Resource/Indexer/Stock/StockInterface.php +++ b/app/code/Magento/CatalogInventory/Model/Resource/Indexer/Stock/StockInterface.php @@ -38,33 +38,28 @@ interface StockInterface { /** * Reindex all stock status data - * */ - public function reindexAll() -; + public function reindexAll(); /** * Reindex stock status data for defined ids * * @param int|array $entityIds */ - public function reindexEntity($entityIds) -; + public function reindexEntity($entityIds); /** * Set Product Type Id for indexer * * @param string $typeId */ - public function setTypeId($typeId) -; + public function setTypeId($typeId); + /** * Retrieve Product Type Id for indexer * * @throws \Magento\Core\Exception - * */ - public function getTypeId() -; + public function getTypeId(); } diff --git a/app/code/Magento/CatalogInventory/Model/Resource/Stock.php b/app/code/Magento/CatalogInventory/Model/Resource/Stock.php index cbe0b1936f254565bff49ef8a97438e35312677c..ca7bd283d3c07e45fd6de1e691098e33d9b313d7 100644 --- a/app/code/Magento/CatalogInventory/Model/Resource/Stock.php +++ b/app/code/Magento/CatalogInventory/Model/Resource/Stock.php @@ -33,21 +33,21 @@ class Stock extends \Magento\Core\Model\Resource\Db\AbstractDb /** * Is initialized configuration flag * - * @var boolean + * @var bool */ protected $_isConfig; /** * Manage Stock flag * - * @var boolean + * @var bool */ protected $_isConfigManageStock; /** * Backorders * - * @var boolean + * @var bool */ protected $_isConfigBackorders; @@ -131,6 +131,7 @@ class Stock extends \Magento\Core\Model\Resource\Db\AbstractDb /** * Define main table and initialize connection * + * @return void */ protected function _construct() { @@ -141,8 +142,8 @@ class Stock extends \Magento\Core\Model\Resource\Db\AbstractDb * Lock product items * * @param \Magento\CatalogInventory\Model\Stock $stock - * @param int|array $productIds - * @return \Magento\CatalogInventory\Model\Resource\Stock + * @param int|int[] $productIds + * @return $this */ public function lockProductItems($stock, $productIds) { @@ -163,7 +164,7 @@ class Stock extends \Magento\Core\Model\Resource\Db\AbstractDb * Get stock items data for requested products * * @param \Magento\CatalogInventory\Model\Stock $stock - * @param array $productIds + * @param int[] $productIds * @param bool $lockRows * @return array */ @@ -189,7 +190,7 @@ class Stock extends \Magento\Core\Model\Resource\Db\AbstractDb * @param \Magento\CatalogInventory\Model\Stock $stock * @param array $productQtys * @param string $operator +/- - * @return \Magento\CatalogInventory\Model\Resource\Stock + * @return $this */ public function correctItemsQty($stock, $productQtys, $operator = '-') { @@ -220,10 +221,10 @@ class Stock extends \Magento\Core\Model\Resource\Db\AbstractDb } /** - * add join to select only in stock products + * Add join to select only in stock products * * @param \Magento\Catalog\Model\Resource\Product\Link\Product\Collection $collection - * @return \Magento\CatalogInventory\Model\Resource\Stock + * @return $this */ public function setInStockFilterToCollection($collection) { @@ -253,6 +254,7 @@ class Stock extends \Magento\Core\Model\Resource\Db\AbstractDb /** * Load some inventory configuration settings * + * @return void */ protected function _initConfig() { @@ -277,6 +279,7 @@ class Stock extends \Magento\Core\Model\Resource\Db\AbstractDb /** * Set items out of stock basing on their quantities and config settings * + * @return void */ public function updateSetOutOfStock() { @@ -311,6 +314,7 @@ class Stock extends \Magento\Core\Model\Resource\Db\AbstractDb /** * Set items in stock basing on their quantities and config settings * + * @return void */ public function updateSetInStock() { @@ -342,6 +346,7 @@ class Stock extends \Magento\Core\Model\Resource\Db\AbstractDb /** * Update items low stock date basing on their quantities and config settings * + * @return void */ public function updateLowStockDate() { @@ -377,7 +382,7 @@ class Stock extends \Magento\Core\Model\Resource\Db\AbstractDb * * @param \Magento\Catalog\Model\Resource\Product\Collection $collection * @param array $fields - * @return \Magento\CatalogInventory\Model\Resource\Stock + * @return $this */ public function addLowStockFilter(\Magento\Catalog\Model\Resource\Product\Collection $collection, $fields) { diff --git a/app/code/Magento/CatalogInventory/Model/Resource/Stock/Item.php b/app/code/Magento/CatalogInventory/Model/Resource/Stock/Item.php index f7c6a5931238216554d87a1a50224c21d0ccd54d..a80db93e4ea391e96f3127ba3eaf00e693ae3bf0 100644 --- a/app/code/Magento/CatalogInventory/Model/Resource/Stock/Item.php +++ b/app/code/Magento/CatalogInventory/Model/Resource/Stock/Item.php @@ -58,6 +58,7 @@ class Item extends \Magento\Core\Model\Resource\Db\AbstractDb /** * Define main table and initialize connection * + * @return void */ protected function _construct() { @@ -69,7 +70,7 @@ class Item extends \Magento\Core\Model\Resource\Db\AbstractDb * * @param \Magento\CatalogInventory\Model\Stock\Item $item * @param int $productId - * @return \Magento\CatalogInventory\Model\Resource\Stock\Item + * @return $this */ public function loadByProductId(\Magento\CatalogInventory\Model\Stock\Item $item, $productId) { @@ -87,7 +88,7 @@ class Item extends \Magento\Core\Model\Resource\Db\AbstractDb * Retrieve select object and join it to product entity table to get type ids * * @param string $field - * @param mixed $value + * @param int $value * @param \Magento\CatalogInventory\Model\Stock\Item $object * @return \Magento\DB\Select */ @@ -106,7 +107,7 @@ class Item extends \Magento\Core\Model\Resource\Db\AbstractDb * * @param \Magento\Catalog\Model\Resource\Product\Collection $productCollection * @param array $columns - * @return \Magento\CatalogInventory\Model\Resource\Stock\Item + * @return $this */ public function addCatalogInventoryToProductCollection($productCollection, $columns = null) { @@ -135,7 +136,7 @@ class Item extends \Magento\Core\Model\Resource\Db\AbstractDb /** * Use qty correction for qty column update * - * @param \Magento\Core\Model\AbstractModel $object + * @param \Magento\Object $object * @param string $table * @return array */ diff --git a/app/code/Magento/CatalogInventory/Model/Resource/Stock/Item/Collection.php b/app/code/Magento/CatalogInventory/Model/Resource/Stock/Item/Collection.php index 272f841689240281e702559eea3c42cbc3ec2c24..6f64cc4f83439ac9cdeea813b9267ba2c2173504 100644 --- a/app/code/Magento/CatalogInventory/Model/Resource/Stock/Item/Collection.php +++ b/app/code/Magento/CatalogInventory/Model/Resource/Stock/Item/Collection.php @@ -27,6 +27,8 @@ */ namespace Magento\CatalogInventory\Model\Resource\Stock\Item; +use Magento\CatalogInventory\Model\Stock; + class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractCollection { /** @@ -40,7 +42,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl * @param \Magento\Data\Collection\Db\FetchStrategyInterface $fetchStrategy * @param \Magento\Event\ManagerInterface $eventManager * @param \Magento\Core\Model\StoreManagerInterface $storeManager - * @param mixed $connection + * @param \Zend_Db_Adapter_Abstract $connection * @param \Magento\Core\Model\Resource\Db\AbstractDb $resource */ public function __construct( @@ -59,6 +61,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl /** * Initialize resource model * + * @return void */ protected function _construct() { @@ -68,12 +71,12 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl /** * Add stock filter to collection * - * @param mixed $stock - * @return \Magento\CatalogInventory\Model\Resource\Stock\Item\Collection + * @param Stock|string|array $stock + * @return $this */ public function addStockFilter($stock) { - if ($stock instanceof \Magento\CatalogInventory\Model\Stock) { + if ($stock instanceof Stock) { $this->addFieldToFilter('main_table.stock_id', $stock->getId()); } else { $this->addFieldToFilter('main_table.stock_id', $stock); @@ -85,7 +88,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl * Add product filter to collection * * @param array $products - * @return \Magento\CatalogInventory\Model\Resource\Stock\Item\Collection + * @return $this */ public function addProductsFilter($products) { @@ -109,7 +112,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl * Join Stock Status to collection * * @param int $storeId - * @return \Magento\CatalogInventory\Model\Resource\Stock\Item\Collection + * @return $this */ public function joinStockStatus($storeId = null) { @@ -128,8 +131,8 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl /** * Add Managed Stock products filter to collection * - * @param boolean $isStockManagedInConfig - * @return \Magento\CatalogInventory\Model\Resource\Stock\Item\Collection + * @param bool $isStockManagedInConfig + * @return $this */ public function addManagedFilter($isStockManagedInConfig) { @@ -147,7 +150,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl * * @param string $comparisonMethod * @param float $qty - * @return \Magento\CatalogInventory\Model\Resource\Stock\Item\Collection + * @return $this * @throws \Magento\Core\Exception */ public function addQtyFilter($comparisonMethod, $qty) @@ -170,7 +173,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl /** * Initialize select object * - * @return \Magento\CatalogInventory\Model\Resource\Stock\Item\Collection + * @return $this */ protected function _initSelect() { diff --git a/app/code/Magento/CatalogInventory/Model/Resource/Stock/Status.php b/app/code/Magento/CatalogInventory/Model/Resource/Stock/Status.php index e113b7d7d5e2711d22550897c5267b6fd51373ca..d1673b4af8d7b58d27703c709e737eef7fc19429 100644 --- a/app/code/Magento/CatalogInventory/Model/Resource/Stock/Status.php +++ b/app/code/Magento/CatalogInventory/Model/Resource/Stock/Status.php @@ -67,6 +67,7 @@ class Status extends \Magento\Core\Model\Resource\Db\AbstractDb /** * Resource model initialization * + * @return void */ protected function _construct() { @@ -79,10 +80,10 @@ class Status extends \Magento\Core\Model\Resource\Db\AbstractDb * @param \Magento\CatalogInventory\Model\Stock\Status $object * @param int $productId * @param int $status - * @param float $qty + * @param float|int $qty * @param int $stockId * @param int|null $websiteId - * @return \Magento\CatalogInventory\Model\Resource\Stock\Status + * @return $this */ public function saveProductStatus(\Magento\CatalogInventory\Model\Stock\Status $object, $productId, $status, $qty = 0, $stockId = 1, $websiteId = null) @@ -234,7 +235,7 @@ class Status extends \Magento\Core\Model\Resource\Db\AbstractDb * * @param \Magento\DB\Select $select * @param \Magento\Core\Model\Website $website - * @return \Magento\CatalogInventory\Model\Resource\Stock\Status + * @return Status */ public function addStockStatusToSelect(\Magento\DB\Select $select, \Magento\Core\Model\Website $website) { @@ -254,7 +255,7 @@ class Status extends \Magento\Core\Model\Resource\Db\AbstractDb * @param \Magento\DB\Select $select * @param string|Zend_Db_Expr $entityField * @param string|Zend_Db_Expr $websiteField - * @return \Magento\CatalogInventory\Model\Resource\Stock\Status + * @return $this */ public function prepareCatalogProductIndexSelect(\Magento\DB\Select $select, $entityField, $websiteField) { @@ -272,7 +273,7 @@ class Status extends \Magento\Core\Model\Resource\Db\AbstractDb * Add only is in stock products filter to product collection * * @param \Magento\Catalog\Model\Resource\Product\Collection $collection - * @return \Magento\CatalogInventory\Model\Resource\Stock\Status + * @return $this */ public function addIsInStockFilterToCollection($collection) { diff --git a/app/code/Magento/CatalogInventory/Model/Source/Backorders.php b/app/code/Magento/CatalogInventory/Model/Source/Backorders.php index 629600e67b84e3af9cacad47c01392e0118fa7a4..3e5bc33cc5f25e8ab3981feb927cea7c2aac0b82 100644 --- a/app/code/Magento/CatalogInventory/Model/Source/Backorders.php +++ b/app/code/Magento/CatalogInventory/Model/Source/Backorders.php @@ -28,6 +28,9 @@ namespace Magento\CatalogInventory\Model\Source; class Backorders implements \Magento\Core\Model\Option\ArrayInterface { + /** + * @return array + */ public function toOptionArray() { return array( diff --git a/app/code/Magento/CatalogInventory/Model/Stock.php b/app/code/Magento/CatalogInventory/Model/Stock.php index fabc35a8b8504d15d5cbfa5f302df1cfb6d95b16..3145cc0a975680b05005a0fa8be4cd31e4e2d40d 100644 --- a/app/code/Magento/CatalogInventory/Model/Stock.php +++ b/app/code/Magento/CatalogInventory/Model/Stock.php @@ -23,6 +23,9 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\CatalogInventory\Model; + +use Magento\CatalogInventory\Model\Stock\Item; /** * Stock model @@ -32,7 +35,6 @@ * @method string getStockName() * @method \Magento\CatalogInventory\Model\Stock setStockName(string $value) */ -namespace Magento\CatalogInventory\Model; class Stock extends \Magento\Core\Model\AbstractModel { @@ -101,6 +103,9 @@ class Stock extends \Magento\Core\Model\AbstractModel $this->_stockItemFactory = $stockItemFactory; } + /** + * @return void + */ protected function _construct() { $this->_init('Magento\CatalogInventory\Model\Resource\Stock'); @@ -119,8 +124,8 @@ class Stock extends \Magento\Core\Model\AbstractModel /** * Add stock item objects to products * - * @param collection $products - * @return \Magento\CatalogInventory\Model\Stock + * @param array $productCollection + * @return $this */ public function addItemsToProducts($productCollection) { @@ -179,13 +184,13 @@ class Stock extends \Magento\Core\Model\AbstractModel * Return array of items that require full save * * @param array $items - * @return array + * @return Item[] * @throws \Magento\Core\Exception */ public function registerProductsSale($items) { $qtys = $this->_prepareProductQtys($items); - /** @var \Magento\CatalogInventory\Model\Stock\Item $item */ + /** @var Item $item */ $item = $this->_stockItemFactory->create(); $this->_getResource()->beginTransaction(); $stockInfo = $this->_getResource()->getProductsStock($this, array_keys($qtys), true); @@ -208,8 +213,8 @@ class Stock extends \Magento\Core\Model\AbstractModel } /** - * - * @param unknown_type $items + * @param array $items + * @return $this */ public function revertProductsSale($items) { @@ -222,14 +227,14 @@ class Stock extends \Magento\Core\Model\AbstractModel * Subtract ordered qty for product * * @param \Magento\Object $item - * @return \Magento\CatalogInventory\Model\Stock + * @return $this * @throws \Magento\Core\Exception */ public function registerItemSale(\Magento\Object $item) { $productId = $item->getProductId(); if ($productId) { - /** @var \Magento\CatalogInventory\Model\Stock\Item $stockItem */ + /** @var Item $stockItem */ $stockItem = $this->_stockItemFactory->create()->loadByProduct($productId); if ($this->_catalogInventoryData->isQty($stockItem->getTypeId())) { if ($item->getStoreId()) { @@ -250,12 +255,12 @@ class Stock extends \Magento\Core\Model\AbstractModel * Get back to stock (when order is canceled or whatever else) * * @param int $productId - * @param numeric $qty - * @return \Magento\CatalogInventory\Model\Stock + * @param int|float $qty + * @return $this */ public function backItemQty($productId, $qty) { - /** @var \Magento\CatalogInventory\Model\Stock\Item $stockItem */ + /** @var Item $stockItem */ $stockItem = $this->_stockItemFactory->create()->loadByProduct($productId); if ($stockItem->getId() && $this->_catalogInventoryData->isQty($stockItem->getTypeId())) { $stockItem->addQty($qty); @@ -271,8 +276,8 @@ class Stock extends \Magento\Core\Model\AbstractModel /** * Lock stock items for product ids array * - * @param array $productIds - * @return \Magento\CatalogInventory\Model\Stock + * @param int|int[] $productIds + * @return $this */ public function lockProductItems($productIds) { @@ -284,7 +289,7 @@ class Stock extends \Magento\Core\Model\AbstractModel * Adds filtering for collection to return only in stock products * * @param \Magento\Catalog\Model\Resource\Product\Link\Product\Collection $collection - * @return \Magento\CatalogInventory\Model\Stock $this + * @return $this */ public function addInStockFilterToCollection($collection) { diff --git a/app/code/Magento/CatalogInventory/Model/Stock/Item.php b/app/code/Magento/CatalogInventory/Model/Stock/Item.php index 2d4de80dd79fa9be07a01a6fe89afc0e2242d579..e2afd9b0e534f30d6973514f458dc7c6eb8f709e 100644 --- a/app/code/Magento/CatalogInventory/Model/Stock/Item.php +++ b/app/code/Magento/CatalogInventory/Model/Stock/Item.php @@ -21,7 +21,9 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\CatalogInventory\Model\Stock; +use Magento\Catalog\Model\Product; /** * Catalog Inventory Stock Model @@ -68,7 +70,6 @@ * @package Magento_CatalogInventory * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\CatalogInventory\Model\Stock; class Item extends \Magento\Core\Model\AbstractModel { @@ -117,7 +118,7 @@ class Item extends \Magento\Core\Model\AbstractModel /** * Associated product instance * - * @var \Magento\Catalog\Model\Product + * @var Product */ protected $_productInstance = null; @@ -171,7 +172,7 @@ class Item extends \Magento\Core\Model\AbstractModel protected $_locale; /** - * @var \Magento\CatalogInventory\Model\Stock\Status + * @var Status */ protected $_stockStatus; @@ -195,7 +196,7 @@ class Item extends \Magento\Core\Model\AbstractModel * @param \Magento\Core\Model\Registry $registry * @param \Magento\Customer\Model\Session $customerSession * @param \Magento\Index\Model\Indexer $indexer - * @param \Magento\CatalogInventory\Model\Stock\Status $stockStatus + * @param Status $stockStatus * @param \Magento\CatalogInventory\Helper\Data $catalogInventoryData * @param \Magento\CatalogInventory\Helper\Minsaleqty $catalogInventoryMinsaleqty * @param \Magento\Core\Model\Store\Config $coreStoreConfig @@ -211,7 +212,7 @@ class Item extends \Magento\Core\Model\AbstractModel \Magento\Core\Model\Registry $registry, \Magento\Customer\Model\Session $customerSession, \Magento\Index\Model\Indexer $indexer, - \Magento\CatalogInventory\Model\Stock\Status $stockStatus, + Status $stockStatus, \Magento\CatalogInventory\Helper\Data $catalogInventoryData, \Magento\CatalogInventory\Helper\Minsaleqty $catalogInventoryMinsaleqty, \Magento\Core\Model\Store\Config $coreStoreConfig, @@ -238,6 +239,7 @@ class Item extends \Magento\Core\Model\AbstractModel /** * Initialize resource model * + * @return void */ protected function _construct() { @@ -268,12 +270,12 @@ class Item extends \Magento\Core\Model\AbstractModel /** * Load item data by product * - * @param mixed $product - * @return \Magento\CatalogInventory\Model\Stock\Item + * @param int|Product $product + * @return $this */ public function loadByProduct($product) { - if ($product instanceof \Magento\Catalog\Model\Product) { + if ($product instanceof Product) { $product = $product->getId(); } $this->_getResource()->loadByProductId($this, $product); @@ -284,8 +286,8 @@ class Item extends \Magento\Core\Model\AbstractModel /** * Subtract quote item quantity * - * @param decimal $qty - * @return \Magento\CatalogInventory\Model\Stock\Item + * @param int|float $qty + * @return $this */ public function subtractQty($qty) { @@ -309,7 +311,7 @@ class Item extends \Magento\Core\Model\AbstractModel * Add quantity process * * @param float $qty - * @return \Magento\CatalogInventory\Model\Stock\Item + * @return $this */ public function addQty($qty) { @@ -343,10 +345,10 @@ class Item extends \Magento\Core\Model\AbstractModel /** * Adding stock data to product * - * @param \Magento\Catalog\Model\Product $product - * @return \Magento\CatalogInventory\Model\Stock\Item + * @param Product $product + * @return $this */ - public function assignProduct(\Magento\Catalog\Model\Product $product) + public function assignProduct(Product $product) { if (!$this->getId() || !$this->getProductId()) { $this->_getResource()->loadByProductId($this, $product->getId()); @@ -390,8 +392,8 @@ class Item extends \Magento\Core\Model\AbstractModel /** * Setter for customer group id * - * @param int Value of customer group id - * @return \Magento\CatalogInventory\Model\Stock\Item + * @param int $value Value of customer group id + * @return $this */ public function setCustomerGroupId($value) { @@ -478,11 +480,11 @@ class Item extends \Magento\Core\Model\AbstractModel } /** - * Retrieve Default Quantity Increments data wrapper - * - * @deprecated since 1.7.0.0 - * @return int|false - */ + * Retrieve Default Quantity Increments data wrapper + * + * @deprecated since 1.7.0.0 + * @return int|false + */ public function getDefaultQtyIncrements() { return $this->_coreStoreConfig->getConfigFlag(self::XML_PATH_ENABLE_QTY_INCREMENTS) @@ -529,9 +531,9 @@ class Item extends \Magento\Core\Model\AbstractModel /** * Check quantity * - * @param decimal $qty + * @param int|float $qty * @exception \Magento\Core\Exception - * @return bool + * @return bool */ public function checkQty($qty) { @@ -596,9 +598,9 @@ class Item extends \Magento\Core\Model\AbstractModel * Second parameter of this method specifies quantity of this product in whole shopping cart * which should be checked for stock availability * - * @param mixed $qty quantity of this item (item qty x parent item qty) - * @param mixed $summaryQty quantity of this product - * @param mixed $origQty original qty of item (not multiplied on parent item qty) + * @param int|float $qty quantity of this item (item qty x parent item qty) + * @param int|float $summaryQty quantity of this product + * @param int|float $origQty original qty of item (not multiplied on parent item qty) * @return \Magento\Object */ public function checkQuoteItemQty($qty, $summaryQty, $origQty = 0) @@ -764,8 +766,8 @@ class Item extends \Magento\Core\Model\AbstractModel /** * Add join for catalog in stock field to product collection * - * @param \Magento\Catalog\Model\Entity\Product\Collection $productCollection - * @return \Magento\CatalogInventory\Model\Stock\Item + * @param \Magento\Catalog\Model\Resource\Product\Collection $productCollection + * @return $this */ public function addCatalogInventoryToProductCollection($productCollection) { @@ -780,7 +782,7 @@ class Item extends \Magento\Core\Model\AbstractModel * @param string $itemError * @param string $quoteError * @param string $errorIndex - * @return \Magento\CatalogInventory\Model\Stock\Item + * @return $this */ protected function _addQuoteItemError(\Magento\Sales\Model\Quote\Item $item, $itemError, $quoteError, $errorIndex='error' @@ -795,7 +797,7 @@ class Item extends \Magento\Core\Model\AbstractModel /** * Before save prepare process * - * @return \Magento\CatalogInventory\Model\Stock\Item + * @return $this */ protected function _beforeSave() { @@ -855,7 +857,7 @@ class Item extends \Magento\Core\Model\AbstractModel /** * Check if item qty require stock status notification * - * @param float | null $qty + * @param float|null $qty * @return bool (true - if require, false - if not require) */ public function verifyNotification($qty = null) @@ -869,7 +871,7 @@ class Item extends \Magento\Core\Model\AbstractModel /** * Reindex CatalogInventory save event * - * @return \Magento\CatalogInventory\Model\Stock\Item + * @return $this */ protected function _afterSave() { @@ -900,8 +902,8 @@ class Item extends \Magento\Core\Model\AbstractModel /** * Add product data to stock item * - * @param \Magento\Catalog\Model\Product $product - * @return \Magento\CatalogInventory\Model\Stock\Item + * @param Product $product + * @return $this */ public function setProduct($product) { @@ -921,7 +923,7 @@ class Item extends \Magento\Core\Model\AbstractModel /** * Returns product instance * - * @return \Magento\Catalog\Model\Product|null + * @return Product|null */ public function getProduct() { @@ -968,7 +970,7 @@ class Item extends \Magento\Core\Model\AbstractModel /** * Reset model data - * @return \Magento\CatalogInventory\Model\Stock\Item + * @return $this */ public function reset() { @@ -982,7 +984,7 @@ class Item extends \Magento\Core\Model\AbstractModel * Set whether index events should be processed immediately * * @param bool $process - * @return \Magento\CatalogInventory\Model\Stock\Item + * @return $this */ public function setProcessIndexEvents($process = true) { diff --git a/app/code/Magento/CatalogInventory/Model/Stock/Status.php b/app/code/Magento/CatalogInventory/Model/Stock/Status.php index a2b6554face2ddd4274f651e3212dd63c9c1167b..25ce684f0371ee2da7386176fb543fb7ea2e36dc 100644 --- a/app/code/Magento/CatalogInventory/Model/Stock/Status.php +++ b/app/code/Magento/CatalogInventory/Model/Stock/Status.php @@ -23,6 +23,10 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\CatalogInventory\Model\Stock; + +use Magento\Catalog\Model\Product\Type\AbstractType; +use Magento\Catalog\Model\Product\Type; /** * CatalogInventory Stock Status per website Model @@ -40,7 +44,6 @@ * @method int getStockStatus() * @method \Magento\CatalogInventory\Model\Stock\Status setStockStatus(int $value) */ -namespace Magento\CatalogInventory\Model\Stock; class Status extends \Magento\Core\Model\AbstractModel { @@ -69,7 +72,7 @@ class Status extends \Magento\Core\Model\AbstractModel protected $_catalogInventoryData; /** - * @var \Magento\Catalog\Model\Product\Type + * @var Type */ protected $_productType; @@ -83,18 +86,18 @@ class Status extends \Magento\Core\Model\AbstractModel /** * Stock item factory * - * @var \Magento\CatalogInventory\Model\Stock\ItemFactory + * @var ItemFactory */ protected $_stockItemFactory; /** * @param \Magento\Core\Model\Context $context * @param \Magento\Core\Model\Registry $registry - * @param \Magento\Catalog\Model\Product\Type $productType + * @param Type $productType * @param \Magento\Catalog\Model\Product\Status $productStatus * @param \Magento\Catalog\Model\Product\Website $productWebsite * @param \Magento\Core\Model\StoreManagerInterface $storeManager - * @param \Magento\CatalogInventory\Model\Stock\ItemFactory $stockItemFactory + * @param ItemFactory $stockItemFactory * @param \Magento\CatalogInventory\Helper\Data $catalogInventoryData * @param \Magento\Core\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection @@ -103,11 +106,11 @@ class Status extends \Magento\Core\Model\AbstractModel public function __construct( \Magento\Core\Model\Context $context, \Magento\Core\Model\Registry $registry, - \Magento\Catalog\Model\Product\Type $productType, + Type $productType, \Magento\Catalog\Model\Product\Status $productStatus, \Magento\Catalog\Model\Product\Website $productWebsite, \Magento\Core\Model\StoreManagerInterface $storeManager, - \Magento\CatalogInventory\Model\Stock\ItemFactory $stockItemFactory, + ItemFactory $stockItemFactory, \Magento\CatalogInventory\Helper\Data $catalogInventoryData, \Magento\Core\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, @@ -126,6 +129,7 @@ class Status extends \Magento\Core\Model\AbstractModel /** * Init resource model * + * @return void */ protected function _construct() { @@ -155,7 +159,7 @@ class Status extends \Magento\Core\Model\AbstractModel * Retrieve Product Type Instance By Product Type * * @param string $productType - * @return \Magento\Catalog\Model\Product\Type\AbstractType + * @return AbstractType|false */ public function getProductTypeInstance($productType) { @@ -169,6 +173,7 @@ class Status extends \Magento\Core\Model\AbstractModel /** * Retrieve website models * + * @param int|null $websiteId * @return array */ public function getWebsites($websiteId = null) @@ -213,10 +218,10 @@ class Status extends \Magento\Core\Model\AbstractModel /** * Change Stock Item status process * - * @param \Magento\CatalogInventory\Model\Stock\Item $item - * @return \Magento\CatalogInventory\Model\Stock\Status + * @param Item $item + * @return $this */ - public function changeItemStatus(\Magento\CatalogInventory\Model\Stock\Item $item) + public function changeItemStatus(Item $item) { $productId = $item->getProductId(); if (!$productType = $item->getProductTypeId()) { @@ -238,7 +243,7 @@ class Status extends \Magento\Core\Model\AbstractModel * @param \Magento\Catalog\Model\Product $product * @param int $stockId * @param int $stockStatus - * @return \Magento\CatalogInventory\Model\Stock\Status + * @return $this */ public function assignProduct(\Magento\Catalog\Model\Product $product, $stockId = 1, $stockStatus = null) { @@ -257,7 +262,7 @@ class Status extends \Magento\Core\Model\AbstractModel * Rebuild stock status for all products * * @param int $websiteId - * @return \Magento\CatalogInventory\Model\Stock\Status + * @return $this */ public function rebuild($websiteId = null) { @@ -283,7 +288,7 @@ class Status extends \Magento\Core\Model\AbstractModel * @param int $productId * @param string $productType * @param int $websiteId - * @return \Magento\CatalogInventory\Model\Stock\Status + * @return $this */ public function updateStatus($productId, $productType = null, $websiteId = null) { @@ -291,7 +296,7 @@ class Status extends \Magento\Core\Model\AbstractModel $productType = $this->getProductType($productId); } - /** @var \Magento\CatalogInventory\Model\Stock\Item $item */ + /** @var Item $item */ $item = $this->_stockItemFactory->create()->loadByProduct($productId); $status = self::STATUS_IN_STOCK; @@ -316,8 +321,7 @@ class Status extends \Magento\Core\Model\AbstractModel * @param int $status * @param int $stockId * @param int $websiteId - * - * @return \Magento\CatalogInventory\Model\Stock\Status + * @return $this */ protected function _processChildren( $productId, @@ -388,13 +392,13 @@ class Status extends \Magento\Core\Model\AbstractModel * @param int $productId * @param int $stockId * @param int $websiteId - * @return \Magento\CatalogInventory\Model\Stock\Status + * @return $this */ protected function _processParents($productId, $stockId = 1, $websiteId = null) { $parentIds = array(); foreach ($this->getProductTypeInstances() as $typeInstance) { - /* @var $typeInstance \Magento\Catalog\Model\Product\Type\AbstractType */ + /* @var $typeInstance AbstractType */ $parentIds = array_merge($parentIds, $typeInstance->getParentIdsByChild($productId)); } @@ -403,7 +407,7 @@ class Status extends \Magento\Core\Model\AbstractModel } $productTypes = $this->getProductsType($parentIds); - /** @var \Magento\CatalogInventory\Model\Stock\Item $item */ + /** @var Item $item */ $item = $this->_stockItemFactory->create(); foreach ($parentIds as $parentId) { @@ -433,7 +437,7 @@ class Status extends \Magento\Core\Model\AbstractModel * @param int $qty * @param int $stockId * @param int|null $websiteId - * @return \Magento\CatalogInventory\Model\Stock\Status + * @return $this */ public function saveProductStatus($productId, $status, $qty = 0, $stockId = 1, $websiteId = null) { @@ -500,7 +504,7 @@ class Status extends \Magento\Core\Model\AbstractModel * @param \Magento\Catalog\Model\Resource\Product\Collection $productCollection * @param int|null $websiteId * @param int|null $stockId - * @return \Magento\CatalogInventory\Model\Stock\Status + * @return $this */ public function addStockStatusToProducts($productCollection, $websiteId = null, $stockId = null) { @@ -541,7 +545,7 @@ class Status extends \Magento\Core\Model\AbstractModel * * @param \Magento\DB\Select $select * @param \Magento\Core\Model\Website $website - * @return \Magento\CatalogInventory\Model\Stock\Status + * @return $this */ public function addStockStatusToSelect(\Magento\DB\Select $select, \Magento\Core\Model\Website $website) { @@ -555,7 +559,7 @@ class Status extends \Magento\Core\Model\AbstractModel * @param \Magento\DB\Select $select * @param string|Zend_Db_Expr $entityField * @param string|Zend_Db_Expr $websiteField - * @return \Magento\CatalogInventory\Model\Stock\Status + * @return $this */ public function prepareCatalogProductIndexSelect(\Magento\DB\Select $select, $entityField, $websiteField) { @@ -572,7 +576,7 @@ class Status extends \Magento\Core\Model\AbstractModel * Add only is in stock products filter to product collection * * @param \Magento\Catalog\Model\Resource\Product\Collection $collection - * @return \Magento\CatalogInventory\Model\Stock\Status + * @return $this */ public function addIsInStockFilterToCollection($collection) { diff --git a/app/code/Magento/CatalogInventory/Model/System/Config/Backend/Minqty.php b/app/code/Magento/CatalogInventory/Model/System/Config/Backend/Minqty.php index e3f42492e7e209606fbe33dc975ea8831a526c2b..f5dad3a27ae5c91199c8ae31afc52ca7e8f5a66e 100644 --- a/app/code/Magento/CatalogInventory/Model/System/Config/Backend/Minqty.php +++ b/app/code/Magento/CatalogInventory/Model/System/Config/Backend/Minqty.php @@ -36,10 +36,10 @@ namespace Magento\CatalogInventory\Model\System\Config\Backend; class Minqty extends \Magento\Core\Model\Config\Value { /** - * Validate minimum product qty value - * - * @return \Magento\CatalogInventory\Model\System\Config\Backend\Minqty - */ + * Validate minimum product qty value + * + * @return $this + */ protected function _beforeSave() { parent::_beforeSave(); diff --git a/app/code/Magento/CatalogInventory/Model/System/Config/Backend/Minsaleqty.php b/app/code/Magento/CatalogInventory/Model/System/Config/Backend/Minsaleqty.php index a0341de77f4c11454c4cf459ce30bd3946f060d6..cf01c32b07cf067fcf9836a1be504056ef7ee884 100644 --- a/app/code/Magento/CatalogInventory/Model/System/Config/Backend/Minsaleqty.php +++ b/app/code/Magento/CatalogInventory/Model/System/Config/Backend/Minsaleqty.php @@ -65,6 +65,8 @@ class Minsaleqty extends \Magento\Core\Model\Config\Value /** * Process data after load + * + * @return void */ protected function _afterLoad() { @@ -75,6 +77,8 @@ class Minsaleqty extends \Magento\Core\Model\Config\Value /** * Prepare data before save + * + * @return void */ protected function _beforeSave() { diff --git a/app/code/Magento/CatalogInventory/Model/System/Config/Backend/Qtyincrements.php b/app/code/Magento/CatalogInventory/Model/System/Config/Backend/Qtyincrements.php index 3015b05d25fff1011b7f3b1e2b765a77786af069..2bc7a3aa08f7b7abca2301fc31e7e8bf2678cce9 100644 --- a/app/code/Magento/CatalogInventory/Model/System/Config/Backend/Qtyincrements.php +++ b/app/code/Magento/CatalogInventory/Model/System/Config/Backend/Qtyincrements.php @@ -30,16 +30,21 @@ */ namespace Magento\CatalogInventory\Model\System\Config\Backend; +use Magento\Core\Exception; + class Qtyincrements extends \Magento\Core\Model\Config\Value { /** * Validate data before save + * + * @return void + * @throws Exception */ protected function _beforeSave() { $value = $this->getValue(); if (floor($value) != $value) { - throw new \Magento\Core\Exception('Decimal qty increments is not allowed.'); + throw new Exception('Decimal qty increments is not allowed.'); } } } diff --git a/app/code/Magento/CatalogRule/Block/Adminhtml/Promo/Catalog.php b/app/code/Magento/CatalogRule/Block/Adminhtml/Promo/Catalog.php index 21709697055f05517a9bbbfa730f34fd242e84e2..ce4f5bb9828ea723f86f54d1af8885a09b587558 100644 --- a/app/code/Magento/CatalogRule/Block/Adminhtml/Promo/Catalog.php +++ b/app/code/Magento/CatalogRule/Block/Adminhtml/Promo/Catalog.php @@ -37,6 +37,9 @@ namespace Magento\CatalogRule\Block\Adminhtml\Promo; class Catalog extends \Magento\Backend\Block\Widget\Grid\Container { + /** + * @return void + */ protected function _construct() { $this->_addButton('apply_rules', array( diff --git a/app/code/Magento/CatalogRule/Block/Adminhtml/Promo/Catalog/Edit.php b/app/code/Magento/CatalogRule/Block/Adminhtml/Promo/Catalog/Edit.php index 28e647acc5c2166a5ed128e056c1aee72790fe42..756f5f4a96966a335a6d1c7800821f61d846df07 100644 --- a/app/code/Magento/CatalogRule/Block/Adminhtml/Promo/Catalog/Edit.php +++ b/app/code/Magento/CatalogRule/Block/Adminhtml/Promo/Catalog/Edit.php @@ -58,6 +58,8 @@ class Edit extends \Magento\Backend\Block\Widget\Form\Container * Add standard buttons * Add "Save and Apply" button * Add "Save and Continue" button + * + * @return void */ protected function _construct() { diff --git a/app/code/Magento/CatalogRule/Block/Adminhtml/Promo/Catalog/Edit/Form.php b/app/code/Magento/CatalogRule/Block/Adminhtml/Promo/Catalog/Edit/Form.php index 1d77bde471565d62f119321d84bc70ed43d2f0c8..7f889764d26a1828db1906b2d356ae8485de3685 100644 --- a/app/code/Magento/CatalogRule/Block/Adminhtml/Promo/Catalog/Edit/Form.php +++ b/app/code/Magento/CatalogRule/Block/Adminhtml/Promo/Catalog/Edit/Form.php @@ -34,8 +34,13 @@ */ namespace Magento\CatalogRule\Block\Adminhtml\Promo\Catalog\Edit; +use Magento\Backend\Block\Widget\Form as WidgetForm; + class Form extends \Magento\Backend\Block\Widget\Form\Generic { + /** + * @return void + */ protected function _construct() { parent::_construct(); @@ -43,6 +48,9 @@ class Form extends \Magento\Backend\Block\Widget\Form\Generic $this->setTitle(__('Rule Information')); } + /** + * @return WidgetForm + */ protected function _prepareForm() { /** @var \Magento\Data\Form $form */ diff --git a/app/code/Magento/CatalogRule/Block/Adminhtml/Promo/Catalog/Edit/Tab/Actions.php b/app/code/Magento/CatalogRule/Block/Adminhtml/Promo/Catalog/Edit/Tab/Actions.php index a63052c52f1421d93207e6934aa686d1d3db6829..1bd3391d598d17282a6303a72e023ace0c6b241c 100644 --- a/app/code/Magento/CatalogRule/Block/Adminhtml/Promo/Catalog/Edit/Tab/Actions.php +++ b/app/code/Magento/CatalogRule/Block/Adminhtml/Promo/Catalog/Edit/Tab/Actions.php @@ -26,9 +26,11 @@ namespace Magento\CatalogRule\Block\Adminhtml\Promo\Catalog\Edit\Tab; -class Actions - extends \Magento\Backend\Block\Widget\Form\Generic - implements \Magento\Backend\Block\Widget\Tab\TabInterface +use Magento\Backend\Block\Widget\Form; +use Magento\Backend\Block\Widget\Form\Generic; +use Magento\Backend\Block\Widget\Tab\TabInterface; + +class Actions extends Generic implements TabInterface { /** * Prepare content for tab @@ -53,7 +55,7 @@ class Actions /** * Returns status flag about this tab can be showen or not * - * @return true + * @return bool */ public function canShowTab() { @@ -63,13 +65,16 @@ class Actions /** * Returns status flag about this tab hidden or not * - * @return true + * @return bool */ public function isHidden() { return false; } + /** + * @return Form + */ protected function _prepareForm() { $model = $this->_coreRegistry->registry('current_promo_catalog_rule'); diff --git a/app/code/Magento/CatalogRule/Block/Adminhtml/Promo/Catalog/Edit/Tab/Conditions.php b/app/code/Magento/CatalogRule/Block/Adminhtml/Promo/Catalog/Edit/Tab/Conditions.php index 2038455b8b5d6082e59fca8121694ca45b8763e2..aee7d8179c86e4462ff0b7f7e13dfe688821ab34 100644 --- a/app/code/Magento/CatalogRule/Block/Adminhtml/Promo/Catalog/Edit/Tab/Conditions.php +++ b/app/code/Magento/CatalogRule/Block/Adminhtml/Promo/Catalog/Edit/Tab/Conditions.php @@ -26,9 +26,11 @@ namespace Magento\CatalogRule\Block\Adminhtml\Promo\Catalog\Edit\Tab; -class Conditions - extends \Magento\Backend\Block\Widget\Form\Generic - implements \Magento\Backend\Block\Widget\Tab\TabInterface +use Magento\Backend\Block\Widget\Form; +use Magento\Backend\Block\Widget\Form\Generic; +use Magento\Backend\Block\Widget\Tab\TabInterface; + +class Conditions extends Generic implements TabInterface { /** * @var \Magento\Backend\Block\Widget\Form\Renderer\Fieldset @@ -84,7 +86,7 @@ class Conditions /** * Returns status flag about this tab can be showen or not * - * @return true + * @return bool */ public function canShowTab() { @@ -94,13 +96,16 @@ class Conditions /** * Returns status flag about this tab hidden or not * - * @return true + * @return bool */ public function isHidden() { return false; } + /** + * @return Form + */ protected function _prepareForm() { $model = $this->_coreRegistry->registry('current_promo_catalog_rule'); diff --git a/app/code/Magento/CatalogRule/Block/Adminhtml/Promo/Catalog/Edit/Tab/Main.php b/app/code/Magento/CatalogRule/Block/Adminhtml/Promo/Catalog/Edit/Tab/Main.php index f86d9f678777654f2f61a2fb82a9482f21cd5f65..f618fbc299cd43ed7dcc4a135bfa2baab6bafd49 100644 --- a/app/code/Magento/CatalogRule/Block/Adminhtml/Promo/Catalog/Edit/Tab/Main.php +++ b/app/code/Magento/CatalogRule/Block/Adminhtml/Promo/Catalog/Edit/Tab/Main.php @@ -33,9 +33,11 @@ */ namespace Magento\CatalogRule\Block\Adminhtml\Promo\Catalog\Edit\Tab; -class Main - extends \Magento\Backend\Block\Widget\Form\Generic - implements \Magento\Backend\Block\Widget\Tab\TabInterface +use Magento\Backend\Block\Widget\Form; +use Magento\Backend\Block\Widget\Form\Generic; +use Magento\Backend\Block\Widget\Tab\TabInterface; + +class Main extends Generic implements TabInterface { /** * @var \Magento\Core\Model\System\Store @@ -91,7 +93,7 @@ class Main /** * Returns status flag about this tab can be showed or not * - * @return true + * @return bool */ public function canShowTab() { @@ -101,13 +103,16 @@ class Main /** * Returns status flag about this tab hidden or not * - * @return true + * @return bool */ public function isHidden() { return false; } + /** + * @return Form + */ protected function _prepareForm() { $model = $this->_coreRegistry->registry('current_promo_catalog_rule'); diff --git a/app/code/Magento/CatalogRule/Block/Adminhtml/Promo/Catalog/Edit/Tabs.php b/app/code/Magento/CatalogRule/Block/Adminhtml/Promo/Catalog/Edit/Tabs.php index a555dadcf995dc9d8dc26b762552f088c35b9077..ba1459038e9c1839e45c218fc75e72ff44c30f7b 100644 --- a/app/code/Magento/CatalogRule/Block/Adminhtml/Promo/Catalog/Edit/Tabs.php +++ b/app/code/Magento/CatalogRule/Block/Adminhtml/Promo/Catalog/Edit/Tabs.php @@ -36,7 +36,9 @@ namespace Magento\CatalogRule\Block\Adminhtml\Promo\Catalog\Edit; class Tabs extends \Magento\Backend\Block\Widget\Tabs { - + /** + * @return void + */ protected function _construct() { parent::_construct(); diff --git a/app/code/Magento/CatalogRule/Block/Adminhtml/Promo/Widget/Chooser/Daterange.php b/app/code/Magento/CatalogRule/Block/Adminhtml/Promo/Widget/Chooser/Daterange.php index 10dc8415bd3285b452aa12e3b6f5af0315befd8e..61110706cff9c3709808648a0df58f33021b96ba 100644 --- a/app/code/Magento/CatalogRule/Block/Adminhtml/Promo/Widget/Chooser/Daterange.php +++ b/app/code/Magento/CatalogRule/Block/Adminhtml/Promo/Widget/Chooser/Daterange.php @@ -44,14 +44,14 @@ class Daterange extends \Magento\Backend\Block\AbstractBlock * * @var array */ - protected $_rangeValues = array('from' => '', 'to' => ''); + protected $_rangeValues = array('from' => '', 'to' => ''); /** * Range string delimiter for from/to dates * * @var string */ - protected $_rangeDelimiter = '...'; + protected $_rangeDelimiter = '...'; /** * @var \Magento\Data\FormFactory @@ -63,18 +63,18 @@ class Daterange extends \Magento\Backend\Block\AbstractBlock */ protected $mathRandom; - /** - * @param \Magento\Backend\Block\Context $context - * @param \Magento\Data\FormFactory $formFactory - * @param \Magento\Math\Random $mathRandom - * @param array $data + /** + * @param \Magento\Backend\Block\Context $context + * @param \Magento\Data\FormFactory $formFactory + * @param \Magento\Math\Random $mathRandom + * @param array $data */ - public function __construct( - \Magento\Backend\Block\Context $context, - \Magento\Data\FormFactory $formFactory, - \Magento\Math\Random $mathRandom, - array $data = array() - ) { + public function __construct( + \Magento\Backend\Block\Context $context, + \Magento\Data\FormFactory $formFactory, + \Magento\Math\Random $mathRandom, + array $data = array() + ) { $this->_formFactory = $formFactory; $this->mathRandom = $mathRandom; parent::__construct($context, $data); @@ -120,7 +120,7 @@ class Daterange extends \Magento\Backend\Block\AbstractBlock * Target element ID setter * * @param string $value - * @return \Magento\CatalogRule\Block\Adminhtml\Promo\Widget\Chooser\Daterange + * @return $this */ public function setTargetElementId($value) { @@ -133,7 +133,7 @@ class Daterange extends \Magento\Backend\Block\AbstractBlock * * @param string $from * @param string $to - * @return \Magento\CatalogRule\Block\Adminhtml\Promo\Widget\Chooser\Daterange + * @return $this */ public function setRangeValues($from, $to) { @@ -146,7 +146,7 @@ class Daterange extends \Magento\Backend\Block\AbstractBlock * Automatically attempts to split the string by delimiter * * @param string $delimitedString - * @return \Magento\CatalogRule\Block\Adminhtml\Promo\Widget\Chooser\Daterange + * @return $this */ public function setRangeValue($delimitedString) { @@ -162,7 +162,7 @@ class Daterange extends \Magento\Backend\Block\AbstractBlock * Range delimiter setter * * @param string $value - * @return \Magento\CatalogRule\Block\Adminhtml\Promo\Widget\Chooser\Daterange + * @return $this */ public function setRangeDelimiter($value) { diff --git a/app/code/Magento/CatalogRule/Block/Adminhtml/Promo/Widget/Chooser/Sku.php b/app/code/Magento/CatalogRule/Block/Adminhtml/Promo/Widget/Chooser/Sku.php index d8bf2b85a90b5fca54d647fd8784415540db3d54..74823c53e5a4503608c2555a43bd0a62903bd5da 100644 --- a/app/code/Magento/CatalogRule/Block/Adminhtml/Promo/Widget/Chooser/Sku.php +++ b/app/code/Magento/CatalogRule/Block/Adminhtml/Promo/Widget/Chooser/Sku.php @@ -33,6 +33,9 @@ */ namespace Magento\CatalogRule\Block\Adminhtml\Promo\Widget\Chooser; +use Magento\Backend\Block\Widget\Grid; +use Magento\Backend\Block\Widget\Grid\Column; + class Sku extends \Magento\Backend\Block\Widget\Grid\Extended { /** @@ -80,6 +83,9 @@ class Sku extends \Magento\Backend\Block\Widget\Grid\Extended parent::__construct($context, $backendHelper, $data); } + /** + * @return void + */ protected function _construct() { parent::_construct(); @@ -101,6 +107,10 @@ class Sku extends \Magento\Backend\Block\Widget\Grid\Extended } } + /** + * @param Column $column + * @return $this + */ protected function _addColumnFilterToCollection($column) { // Set custom filter for in product flag @@ -123,7 +133,7 @@ class Sku extends \Magento\Backend\Block\Widget\Grid\Extended /** * Prepare Catalog Product Collection for attribute SKU in Promo Conditions SKU chooser * - * @return \Magento\CatalogRule\Block\Adminhtml\Promo\Widget\Chooser\Sku + * @return $this */ protected function _prepareCollection() { @@ -139,7 +149,7 @@ class Sku extends \Magento\Backend\Block\Widget\Grid\Extended /** * Define Cooser Grid Columns and filters * - * @return \Magento\CatalogRule\Block\Adminhtml\Promo\Widget\Chooser\Sku + * @return $this */ protected function _prepareColumns() { @@ -198,6 +208,9 @@ class Sku extends \Magento\Backend\Block\Widget\Grid\Extended return parent::_prepareColumns(); } + /** + * @return string + */ public function getGridUrl() { return $this->getUrl('catalog_rule/*/chooser', array( @@ -207,6 +220,9 @@ class Sku extends \Magento\Backend\Block\Widget\Grid\Extended )); } + /** + * @return mixed + */ protected function _getSelectedProducts() { $products = $this->getRequest()->getPost('selected', array()); diff --git a/app/code/Magento/CatalogRule/Controller/Adminhtml/Promo.php b/app/code/Magento/CatalogRule/Controller/Adminhtml/Promo.php index 023646d1872bc035b74d6ce17c485fa63fb8611e..dcc377c1dea3b774e74e3255099fe494a03647ef 100644 --- a/app/code/Magento/CatalogRule/Controller/Adminhtml/Promo.php +++ b/app/code/Magento/CatalogRule/Controller/Adminhtml/Promo.php @@ -33,9 +33,13 @@ */ namespace Magento\CatalogRule\Controller\Adminhtml; -class Promo extends \Magento\Backend\App\Action -{ +use Magento\Backend\App\Action; +class Promo extends Action +{ + /** + * @return void + */ public function indexAction() { $this->_view->loadLayout(); @@ -44,6 +48,9 @@ class Promo extends \Magento\Backend\App\Action $this->_view->renderLayout(); } + /** + * @return bool + */ protected function _isAllowed() { return $this->_authorization->isAllowed('Magento_CatalogRule::promo'); diff --git a/app/code/Magento/CatalogRule/Controller/Adminhtml/Promo/Catalog.php b/app/code/Magento/CatalogRule/Controller/Adminhtml/Promo/Catalog.php index a89ac7bb4cc8f5a865af77311debbd6bab4a9e8c..37d081627a28d210eaa93b16963e868275e9bdf5 100644 --- a/app/code/Magento/CatalogRule/Controller/Adminhtml/Promo/Catalog.php +++ b/app/code/Magento/CatalogRule/Controller/Adminhtml/Promo/Catalog.php @@ -33,7 +33,16 @@ */ namespace Magento\CatalogRule\Controller\Adminhtml\Promo; -class Catalog extends \Magento\Backend\App\Action +use Magento\Backend\App\Action; +use Magento\Backend\App\Action\Context; +use Magento\CatalogRule\Model\Rule\Job; +use Magento\Core\Exception; +use Magento\Core\Filter\Date; +use Magento\Core\Model\Registry; +use Magento\Rule\Model\Condition\AbstractCondition; +use Magento\Rule\Model\Action\AbstractAction; + +class Catalog extends Action { /** * Dirty rules notice message @@ -46,30 +55,33 @@ class Catalog extends \Magento\Backend\App\Action /** * Core registry * - * @var \Magento\Core\Model\Registry + * @var Registry */ protected $_coreRegistry = null; - /* + /** * @var \Magento\Core\Filter\Date */ protected $_dateFilter; /** - * @param \Magento\Backend\App\Action\Context $context - * @param \Magento\Core\Model\Registry $coreRegistry - * @param \Magento\Core\Filter\Date $dateFilter + * @param Context $context + * @param Registry $coreRegistry + * @param Date $dateFilter */ public function __construct( - \Magento\Backend\App\Action\Context $context, - \Magento\Core\Model\Registry $coreRegistry, - \Magento\Core\Filter\Date $dateFilter + Context $context, + Registry $coreRegistry, + Date $dateFilter ) { parent::__construct($context); $this->_coreRegistry = $coreRegistry; $this->_dateFilter = $dateFilter; } + /** + * @return $this + */ protected function _initAction() { $this->_view->loadLayout(); @@ -81,6 +93,9 @@ class Catalog extends \Magento\Backend\App\Action return $this; } + /** + * @return void + */ public function indexAction() { $this->_title->add(__('Catalog Price Rules')); @@ -98,11 +113,17 @@ class Catalog extends \Magento\Backend\App\Action $this->_view->renderLayout(); } + /** + * @return void + */ public function newAction() { $this->_forward('edit'); } + /** + * @return void + */ public function editAction() { $this->_title->add(__('Catalog Price Rules')); @@ -139,6 +160,9 @@ class Catalog extends \Magento\Backend\App\Action $this->_view->renderLayout(); } + /** + * @return void + */ public function saveAction() { if ($this->getRequest()->getPost()) { @@ -156,7 +180,7 @@ class Catalog extends \Magento\Backend\App\Action if ($id) { $model->load($id); if ($id != $model->getId()) { - throw new \Magento\Core\Exception(__('Wrong rule specified.')); + throw new Exception(__('Wrong rule specified.')); } } @@ -195,7 +219,7 @@ class Catalog extends \Magento\Backend\App\Action $this->_redirect('catalog_rule/*/'); } return; - } catch (\Magento\Core\Exception $e) { + } catch (Exception $e) { $this->messageManager->addError($e->getMessage()); } catch (\Exception $e) { $this->messageManager->addError( @@ -210,6 +234,9 @@ class Catalog extends \Magento\Backend\App\Action $this->_redirect('catalog_rule/*/'); } + /** + * @return void + */ public function deleteAction() { $id = $this->getRequest()->getParam('id'); @@ -224,7 +251,7 @@ class Catalog extends \Magento\Backend\App\Action $this->messageManager->addSuccess(__('The rule has been deleted.')); $this->_redirect('catalog_rule/*/'); return; - } catch (\Magento\Core\Exception $e) { + } catch (Exception $e) { $this->messageManager->addError($e->getMessage()); } catch (\Exception $e) { $this->messageManager->addError( @@ -239,6 +266,9 @@ class Catalog extends \Magento\Backend\App\Action $this->_redirect('catalog_rule/*/'); } + /** + * @return void + */ public function newConditionHtmlAction() { $id = $this->getRequest()->getParam('id'); @@ -254,7 +284,7 @@ class Catalog extends \Magento\Backend\App\Action $model->setAttribute($typeArr[1]); } - if ($model instanceof \Magento\Rule\Model\Condition\AbstractCondition) { + if ($model instanceof AbstractCondition) { $model->setJsFormObject($this->getRequest()->getParam('form')); $html = $model->asHtmlRecursive(); } else { @@ -263,6 +293,9 @@ class Catalog extends \Magento\Backend\App\Action $this->getResponse()->setBody($html); } + /** + * @return void + */ public function chooserAction() { if ($this->getRequest()->getParam('attribute') == 'sku') { @@ -276,6 +309,9 @@ class Catalog extends \Magento\Backend\App\Action } } + /** + * @return void + */ public function newActionHtmlAction() { $id = $this->getRequest()->getParam('id'); @@ -291,7 +327,7 @@ class Catalog extends \Magento\Backend\App\Action $model->setAttribute($typeArr[1]); } - if ($model instanceof \Magento\Rule\Model\Action\AbstractAction) { + if ($model instanceof AbstractAction) { $model->setJsFormObject($this->getRequest()->getParam('form')); $html = $model->asHtmlRecursive(); } else { @@ -302,12 +338,14 @@ class Catalog extends \Magento\Backend\App\Action /** * Apply all active catalog price rules + * + * @return void */ public function applyRulesAction() { $errorMessage = __('Unable to apply rules.'); try { - /** @var $ruleJob \Magento\CatalogRule\Model\Rule\Job */ + /** @var Job $ruleJob */ $ruleJob = $this->_objectManager->get('Magento\CatalogRule\Model\Rule\Job'); $ruleJob->applyAll(); @@ -325,6 +363,9 @@ class Catalog extends \Magento\Backend\App\Action $this->_redirect('catalog_rule/*'); } + /** + * @return bool + */ protected function _isAllowed() { return $this->_authorization->isAllowed('Magento_CatalogRule::promo_catalog'); @@ -334,6 +375,7 @@ class Catalog extends \Magento\Backend\App\Action * Set dirty rules notice message * * @param string $dirtyRulesNoticeMessage + * @return void */ public function setDirtyRulesNoticeMessage($dirtyRulesNoticeMessage) { diff --git a/app/code/Magento/CatalogRule/Controller/Adminhtml/Promo/Widget.php b/app/code/Magento/CatalogRule/Controller/Adminhtml/Promo/Widget.php index 5a8698954fc242e58f73c3ecfd24bfe38273dd65..3c92ec799cc3f61310f05252300e5a4dc24f49e0 100644 --- a/app/code/Magento/CatalogRule/Controller/Adminhtml/Promo/Widget.php +++ b/app/code/Magento/CatalogRule/Controller/Adminhtml/Promo/Widget.php @@ -26,22 +26,27 @@ namespace Magento\CatalogRule\Controller\Adminhtml\Promo; -class Widget extends \Magento\Backend\App\Action +use Magento\Backend\App\Action; +use Magento\Backend\App\Action\Context; +use Magento\Catalog\Model\Category; +use Magento\Core\Model\Registry; + +class Widget extends Action { /** * Core registry * - * @var \Magento\Core\Model\Registry + * @var Registry */ protected $_coreRegistry = null; /** - * @param \Magento\Backend\App\Action\Context $context - * @param \Magento\Core\Model\Registry $coreRegistry + * @param Context $context + * @param Registry $coreRegistry */ public function __construct( - \Magento\Backend\App\Action\Context $context, - \Magento\Core\Model\Registry $coreRegistry + Context $context, + Registry $coreRegistry ) { $this->_coreRegistry = $coreRegistry; parent::__construct($context); @@ -98,6 +103,9 @@ class Widget extends \Magento\Backend\App\Action } } + /** + * @return bool + */ protected function _isAllowed() { return $this->_authorization->isAllowed('Magento_CatalogRule::promo_catalog'); @@ -105,6 +113,8 @@ class Widget extends \Magento\Backend\App\Action /** * Get tree node (Ajax version) + * + * @return void */ public function categoriesJsonAction() { @@ -125,7 +135,7 @@ class Widget extends \Magento\Backend\App\Action /** * Initialize category object in registry * - * @return \Magento\Catalog\Model\Category + * @return Category */ protected function _initCategory() { diff --git a/app/code/Magento/CatalogRule/Model/Observer.php b/app/code/Magento/CatalogRule/Model/Observer.php index 219ab91e2b9fc96aa54cffec147b3da773e93a62..1945af970fe188c4ab375266fecac3809eeb5e00 100644 --- a/app/code/Magento/CatalogRule/Model/Observer.php +++ b/app/code/Magento/CatalogRule/Model/Observer.php @@ -29,6 +29,23 @@ */ namespace Magento\CatalogRule\Model; +use Magento\Backend\Model\Session as BackendModelSession; +use Magento\Catalog\Model\Product; +use Magento\Catalog\Model\Resource\Product\Collection as ProductCollection; +use Magento\CatalogRule\Model\Rule\Condition\Combine; +use Magento\CatalogRule\Model\Rule; +use Magento\CatalogRule\Model\Resource\Rule\Collection; +use Magento\CatalogRule\Model\Rule\Product\Price; +use Magento\Core\Model\Registry; +use Magento\Core\Model\StoreManagerInterface; +use Magento\Core\Model\LocaleInterface; +use Magento\Customer\Model\Group; +use Magento\Customer\Model\Session as CustomerModelSession; +use Magento\Event\Observer as EventObserver; +use Magento\Message\ManagerInterface; +use Magento\Rule\Model\Condition\Product\AbstractProduct; +use Magento\Stdlib\DateTime; + class Observer { /** @@ -42,22 +59,22 @@ class Observer /** * Core registry * - * @var \Magento\Core\Model\Registry + * @var Registry */ protected $_coreRegistry = null; /** - * @var \Magento\Customer\Model\Session + * @var CustomerModelSession */ protected $_customerSession; /** - * @var \Magento\CatalogRule\Model\Rule\Product\Price + * @var Price */ protected $_productPrice; /** - * @var \Magento\Backend\Model\Session + * @var BackendModelSession */ protected $_backendSession; @@ -77,12 +94,12 @@ class Observer protected $_ruleCollectionFactory; /** - * @var \Magento\Core\Model\StoreManagerInterface + * @var StoreManagerInterface */ protected $_storeManager; /** - * @var \Magento\Core\Model\LocaleInterface + * @var LocaleInterface */ protected $_locale; @@ -108,13 +125,13 @@ class Observer * @param Rule\Product\Price $productPrice * @param RuleFactory $ruleFactory * @param FlagFactory $flagFactory - * @param \Magento\Core\Model\StoreManagerInterface $storeManager - * @param \Magento\Core\Model\LocaleInterface $locale - * @param \Magento\Customer\Model\Session $customerSession - * @param \Magento\Backend\Model\Session $backendSession - * @param \Magento\Core\Model\Registry $coreRegistry - * @param \Magento\Stdlib\DateTime $dateTime - * @param \Magento\Message\ManagerInterface $messageManager + * @param StoreManagerInterface $storeManager + * @param LocaleInterface $locale + * @param CustomerModelSession $customerSession + * @param BackendModelSession $backendSession + * @param Registry $coreRegistry + * @param DateTime $dateTime + * @param ManagerInterface $messageManager * * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ @@ -125,13 +142,13 @@ class Observer Rule\Product\Price $productPrice, RuleFactory $ruleFactory, FlagFactory $flagFactory, - \Magento\Core\Model\StoreManagerInterface $storeManager, - \Magento\Core\Model\LocaleInterface $locale, - \Magento\Customer\Model\Session $customerSession, - \Magento\Backend\Model\Session $backendSession, - \Magento\Core\Model\Registry $coreRegistry, - \Magento\Stdlib\DateTime $dateTime, - \Magento\Message\ManagerInterface $messageManager + StoreManagerInterface $storeManager, + LocaleInterface $locale, + CustomerModelSession $customerSession, + BackendModelSession $backendSession, + Registry $coreRegistry, + DateTime $dateTime, + ManagerInterface $messageManager ) { $this->_resourceRuleFactory = $resourceRuleFactory; $this->_resourceRule = $resourceRule; @@ -151,8 +168,8 @@ class Observer /** * Apply all catalog price rules for specific product * - * @param \Magento\Event\Observer $observer - * @return \Magento\CatalogRule\Model\Observer + * @param EventObserver $observer + * @return $this|void */ public function applyAllRulesOnProduct($observer) { @@ -178,9 +195,8 @@ class Observer * Apply all price rules for current date. * Handle cataolg_product_import_after event * - * @param \Magento\Event\Observer $observer - * - * @return \Magento\CatalogRule\Model\Observer + * @param EventObserver $observer + * @return $this */ public function applyAllRules($observer) { @@ -199,10 +215,10 @@ class Observer * Fire the same name process as catalog rule model * Event name "apply_catalog_price_rules" * - * @param \Magento\Event\Observer $observer - * @return \Magento\CatalogRule\Model\Observer + * @param EventObserver $observer + * @return $this */ - public function processApplyAll(\Magento\Event\Observer $observer) + public function processApplyAll(EventObserver $observer) { $this->_ruleFactory->create()->applyAll(); $this->_flagFactory->create() @@ -215,9 +231,8 @@ class Observer /** * Apply catalog price rules to product on frontend * - * @param \Magento\Event\Observer $observer - * - * @return \Magento\CatalogRule\Model\Observer + * @param EventObserver $observer + * @return $this */ public function processFrontFinalPrice($observer) { @@ -261,9 +276,8 @@ class Observer /** * Apply catalog price rules to product in admin * - * @param \Magento\Event\Observer $observer - * - * @return \Magento\CatalogRule\Model\Observer + * @param EventObserver $observer + * @return $this */ public function processAdminFinalPrice($observer) { @@ -304,14 +318,13 @@ class Observer /** * Calculate price using catalog price rules of configurable product * - * @param \Magento\Event\Observer $observer - * - * @return \Magento\CatalogRule\Model\Observer + * @param EventObserver $observer + * @return $this */ - public function catalogProductTypeConfigurablePrice(\Magento\Event\Observer $observer) + public function catalogProductTypeConfigurablePrice(EventObserver $observer) { $product = $observer->getEvent()->getProduct(); - if ($product instanceof \Magento\Catalog\Model\Product + if ($product instanceof Product && $product->getConfigurablePrice() !== null ) { $configurablePrice = $product->getConfigurablePrice(); @@ -331,9 +344,8 @@ class Observer * This method is called from cron process, cron is working in UTC time and * we should generate data for interval -1 day ... +1 day * - * @param \Magento\Event\Observer $observer - * - * @return \Magento\CatalogRule\Model\Observer + * @param EventObserver $observer + * @return $this */ public function dailyCatalogUpdate($observer) { @@ -344,6 +356,8 @@ class Observer /** * Clean out calculated catalog rule prices for products + * + * @return void */ public function flushPriceCache() { @@ -353,10 +367,10 @@ class Observer /** * Calculate minimal final price with catalog rule price * - * @param \Magento\Event\Observer $observer - * @return \Magento\CatalogRule\Model\Observer + * @param EventObserver $observer + * @return $this */ - public function prepareCatalogProductPriceIndexTable(\Magento\Event\Observer $observer) + public function prepareCatalogProductPriceIndexTable(EventObserver $observer) { $select = $observer->getEvent()->getSelect(); @@ -379,20 +393,19 @@ class Observer * If rules were found they will be set to inactive and notice will be add to admin session * * @param string $attributeCode - * - * @return \Magento\CatalogRule\Model\Observer + * @return $this */ protected function _checkCatalogRulesAvailability($attributeCode) { - /* @var $collection \Magento\CatalogRule\Model\Resource\Rule\Collection */ + /* @var $collection Collection */ $collection = $this->_ruleCollectionFactory->create() ->addAttributeInConditionFilter($attributeCode); $disabledRulesCount = 0; foreach ($collection as $rule) { - /* @var $rule \Magento\CatalogRule\Model\Rule */ + /* @var $rule Rule */ $rule->setIsActive(0); - /* @var $rule->getConditions() \Magento\CatalogRule\Model\Rule\Condition\Combine */ + /* @var $rule->getConditions() Combine */ $this->_removeAttributeFromConditions($rule->getConditions(), $attributeCode); $rule->save(); @@ -416,18 +429,18 @@ class Observer /** * Remove catalog attribute condition by attribute code from rule conditions * - * @param \Magento\CatalogRule\Model\Rule\Condition\Combine $combine - * + * @param Combine $combine * @param string $attributeCode + * @return void */ protected function _removeAttributeFromConditions($combine, $attributeCode) { $conditions = $combine->getConditions(); foreach ($conditions as $conditionId => $condition) { - if ($condition instanceof \Magento\CatalogRule\Model\Rule\Condition\Combine) { + if ($condition instanceof Combine) { $this->_removeAttributeFromConditions($condition, $attributeCode); } - if ($condition instanceof \Magento\Rule\Model\Condition\Product\AbstractProduct) { + if ($condition instanceof AbstractProduct) { if ($condition->getAttribute() == $attributeCode) { unset($conditions[$conditionId]); } @@ -439,11 +452,10 @@ class Observer /** * After save attribute if it is not used for promo rules already check rules for containing this attribute * - * @param \Magento\Event\Observer $observer - * - * @return \Magento\CatalogRule\Model\Observer + * @param EventObserver $observer + * @return $this */ - public function catalogAttributeSaveAfter(\Magento\Event\Observer $observer) + public function catalogAttributeSaveAfter(EventObserver $observer) { $attribute = $observer->getEvent()->getAttribute(); if ($attribute->dataHasChangedFor('is_used_for_promo_rules') && !$attribute->getIsUsedForPromoRules()) { @@ -456,10 +468,10 @@ class Observer /** * After delete attribute check rules that contains deleted attribute * - * @param \Magento\Event\Observer $observer - * @return \Magento\CatalogRule\Model\Observer + * @param EventObserver $observer + * @return $this */ - public function catalogAttributeDeleteAfter(\Magento\Event\Observer $observer) + public function catalogAttributeDeleteAfter(EventObserver $observer) { $attribute = $observer->getEvent()->getAttribute(); if ($attribute->getIsUsedForPromoRules()) { @@ -469,9 +481,13 @@ class Observer return $this; } - public function prepareCatalogProductCollectionPrices(\Magento\Event\Observer $observer) + /** + * @param EventObserver $observer + * @return $this + */ + public function prepareCatalogProductCollectionPrices(EventObserver $observer) { - /* @var $collection \Magento\Catalog\Model\Resource\Product\Collection */ + /* @var $collection ProductCollection */ $collection = $observer->getEvent()->getCollection(); $store = $this->_storeManager->getStore($observer->getEvent()->getStoreId()); $websiteId = $store->getWebsiteId(); @@ -481,7 +497,7 @@ class Observer if ($this->_customerSession->isLoggedIn()) { $groupId = $this->_customerSession->getCustomerGroupId(); } else { - $groupId = \Magento\Customer\Model\Group::NOT_LOGGED_IN_ID; + $groupId = Group::NOT_LOGGED_IN_ID; } } if ($observer->getEvent()->hasDate()) { @@ -491,7 +507,7 @@ class Observer } $productIds = array(); - /* @var $product \Magento\Catalog\Model\Product */ + /* @var $product Product */ foreach ($collection as $product) { $key = implode('|', array($date, $websiteId, $groupId, $product->getId())); if (!isset($this->_rulePrices[$key])) { @@ -514,9 +530,10 @@ class Observer /** * Create catalog rule relations for imported products * - * @param \Magento\Event\Observer $observer + * @param EventObserver $observer + * @return void */ - public function createCatalogRulesRelations(\Magento\Event\Observer $observer) + public function createCatalogRulesRelations(EventObserver $observer) { $adapter = $observer->getEvent()->getAdapter(); $affectedEntityIds = $adapter->getAffectedEntityIds(); diff --git a/app/code/Magento/CatalogRule/Model/Resource/Grid/Collection.php b/app/code/Magento/CatalogRule/Model/Resource/Grid/Collection.php index 303bdc05360ff73e2c0176b75b6d5063f54787b3..9ffeb7c748ae7a3c895e5115e86d9617010afc62 100644 --- a/app/code/Magento/CatalogRule/Model/Resource/Grid/Collection.php +++ b/app/code/Magento/CatalogRule/Model/Resource/Grid/Collection.php @@ -23,11 +23,12 @@ */ namespace Magento\CatalogRule\Model\Resource\Grid; -class Collection - extends \Magento\CatalogRule\Model\Resource\Rule\Collection +use Magento\Core\Model\Resource\Db\Collection\AbstractCollection; + +class Collection extends \Magento\CatalogRule\Model\Resource\Rule\Collection { /** - * @return $this|\Magento\Core\Model\Resource\Db\Collection\AbstractCollection + * @return $this */ protected function _initSelect() { diff --git a/app/code/Magento/CatalogRule/Model/Resource/Rule.php b/app/code/Magento/CatalogRule/Model/Resource/Rule.php index 48f0337c78896e85a8dc0a98d9fbbe528749b5c5..2f315d2ff0e615f0f3c349127c160167a2518b88 100644 --- a/app/code/Magento/CatalogRule/Model/Resource/Rule.php +++ b/app/code/Magento/CatalogRule/Model/Resource/Rule.php @@ -34,6 +34,11 @@ */ namespace Magento\CatalogRule\Model\Resource; +use Magento\Catalog\Model\Product; +use Magento\CatalogRule\Model\Rule as ModelRule; +use Magento\Core\Model\AbstractModel; +use Magento\Core\Model\Resource\Db\AbstractDb; + class Rule extends \Magento\Rule\Model\Resource\AbstractResource { /** @@ -138,6 +143,8 @@ class Rule extends \Magento\Rule\Model\Resource\AbstractResource /** * Initialize main table and table id field + * + * @return void */ protected function _construct() { @@ -147,11 +154,10 @@ class Rule extends \Magento\Rule\Model\Resource\AbstractResource /** * Add customer group ids and website ids to rule data after load * - * @param \Magento\Core\Model\AbstractModel $object - * - * @return \Magento\CatalogRule\Model\Resource\Rule + * @param AbstractModel $object + * @return AbstractDb */ - protected function _afterLoad(\Magento\Core\Model\AbstractModel $object) + protected function _afterLoad(AbstractModel $object) { $object->setData('customer_group_ids', (array)$this->getCustomerGroupIds($object->getId())); $object->setData('website_ids', (array)$this->getWebsiteIds($object->getId())); @@ -163,11 +169,10 @@ class Rule extends \Magento\Rule\Model\Resource\AbstractResource * Bind catalog rule to customer group(s) and website(s). * Update products which are matched for rule. * - * @param \Magento\Core\Model\AbstractModel $object - * - * @return \Magento\CatalogRule\Model\Resource\Rule + * @param AbstractModel $object + * @return $this */ - protected function _afterSave(\Magento\Core\Model\AbstractModel $object) + protected function _afterSave(AbstractModel $object) { if ($object->hasWebsiteIds()) { $websiteIds = $object->getWebsiteIds(); @@ -192,11 +197,11 @@ class Rule extends \Magento\Rule\Model\Resource\AbstractResource /** * Update products which are matched for rule * - * @param \Magento\CatalogRule\Model\Rule $rule - * - * @return \Magento\CatalogRule\Model\Resource\Rule + * @param ModelRule $rule + * @return $this + * @throws \Exception */ - public function updateRuleProductData(\Magento\CatalogRule\Model\Rule $rule) + public function updateRuleProductData(ModelRule $rule) { $ruleId = $rule->getId(); $write = $this->_getWriteAdapter(); @@ -287,7 +292,6 @@ class Rule extends \Magento\Rule\Model\Resource\AbstractResource * Get all product ids matched for rule * * @param int $ruleId - * * @return array */ public function getRuleProductIds($ruleId) @@ -305,8 +309,7 @@ class Rule extends \Magento\Rule\Model\Resource\AbstractResource * @param int|string $fromDate * @param int|string $toDate * @param int|null $productId - * - * @return \Magento\CatalogRule\Model\Resource\Rule + * @return $this */ public function removeCatalogPricesForDateRange($fromDate, $toDate, $productId = null) { @@ -344,8 +347,7 @@ class Rule extends \Magento\Rule\Model\Resource\AbstractResource * * @param string $date * @param int|null $productId - * - * @return \Magento\CatalogRule\Model\Resource\Rule + * @return $this */ public function deleteOldData($date, $productId = null) { @@ -366,7 +368,6 @@ class Rule extends \Magento\Rule\Model\Resource\AbstractResource * @param int $toDate * @param int|null $productId * @param int|null $websiteId - * * @return \Zend_Db_Statement_Interface */ protected function _getRuleProductsStmt($fromDate, $toDate, $productId = null, $websiteId = null) @@ -395,7 +396,7 @@ class Rule extends \Magento\Rule\Model\Resource\AbstractResource /** * Join default price and websites prices to result */ - $priceAttr = $this->_eavConfig->getAttribute(\Magento\Catalog\Model\Product::ENTITY, 'price'); + $priceAttr = $this->_eavConfig->getAttribute(Product::ENTITY, 'price'); $priceTable = $priceAttr->getBackend()->getTable(); $attributeId= $priceAttr->getId(); @@ -463,8 +464,8 @@ class Rule extends \Magento\Rule\Model\Resource\AbstractResource * @param int|string|null $fromDate * @param int|string|null $toDate * @param int $productId - * - * @return \Magento\CatalogRule\Model\Resource\Rule + * @return $this + * @throws \Exception */ public function applyAllRulesForDateRange($fromDate = null, $toDate = null, $productId = null) { @@ -494,7 +495,7 @@ class Rule extends \Magento\Rule\Model\Resource\AbstractResource } $product = null; - if ($productId instanceof \Magento\Catalog\Model\Product) { + if ($productId instanceof Product) { $product = $productId; $productId = $productId->getId(); } @@ -624,7 +625,6 @@ class Rule extends \Magento\Rule\Model\Resource\AbstractResource * * @param array $ruleData * @param null|array $productData - * * @return float */ protected function _calcRuleProductPrice($ruleData, $productData = null) @@ -652,8 +652,8 @@ class Rule extends \Magento\Rule\Model\Resource\AbstractResource * Save rule prices for products to DB * * @param array $arrData - * - * @return \Magento\CatalogRule\Model\Resource\Rule + * @return $this + * @throws \Exception */ protected function _saveRuleProductPrices($arrData) { @@ -693,8 +693,7 @@ class Rule extends \Magento\Rule\Model\Resource\AbstractResource * @param int $wId * @param int $gId * @param int $pId - * - * @return float|bool + * @return float|false */ public function getRulePrice($date, $wId, $gId, $pId) { @@ -714,7 +713,6 @@ class Rule extends \Magento\Rule\Model\Resource\AbstractResource * @param int $websiteId * @param int $customerGroupId * @param array $productIds - * * @return array */ public function getRulePrices($date, $websiteId, $customerGroupId, $productIds) @@ -761,7 +759,6 @@ class Rule extends \Magento\Rule\Model\Resource\AbstractResource * @param int|string $date * @param int $wId * @param int $pId - * * @return array */ public function getRulesForProduct($date, $wId, $pId) @@ -779,11 +776,11 @@ class Rule extends \Magento\Rule\Model\Resource\AbstractResource /** * Apply catalog rule to product * - * @param \Magento\CatalogRule\Model\Rule $rule - * @param \Magento\Catalog\Model\Product $product + * @param ModelRule $rule + * @param Product $product * @param array $websiteIds - * - * @return \Magento\CatalogRule\Model\Resource\Rule + * @return $this + * @throws \Exception */ public function applyToProduct($rule, $product, $websiteIds) { diff --git a/app/code/Magento/CatalogRule/Model/Resource/Rule/Collection.php b/app/code/Magento/CatalogRule/Model/Resource/Rule/Collection.php index 78e22df58161c652f7955341b2a2c07d9df38049..9ef1ec8869e9fec04d7f9129b9bf473253148cd3 100644 --- a/app/code/Magento/CatalogRule/Model/Resource/Rule/Collection.php +++ b/app/code/Magento/CatalogRule/Model/Resource/Rule/Collection.php @@ -43,6 +43,8 @@ class Collection extends \Magento\Rule\Model\Resource\Rule\Collection\AbstractCo /** * Set resource model + * + * @return void */ protected function _construct() { @@ -53,7 +55,7 @@ class Collection extends \Magento\Rule\Model\Resource\Rule\Collection\AbstractCo * Find product attribute in conditions or actions * * @param string $attributeCode - * @return \Magento\CatalogRule\Model\Resource\Rule\Collection + * @return $this */ public function addAttributeInConditionFilter($attributeCode) { diff --git a/app/code/Magento/CatalogRule/Model/Resource/Rule/Product/Price.php b/app/code/Magento/CatalogRule/Model/Resource/Rule/Product/Price.php index 84f755db8f7d22c0be85efbcefc68b357b2c2977..2b334c3dd95a4c1274ef017639d37d1d47870f39 100644 --- a/app/code/Magento/CatalogRule/Model/Resource/Rule/Product/Price.php +++ b/app/code/Magento/CatalogRule/Model/Resource/Rule/Product/Price.php @@ -39,6 +39,7 @@ class Price extends \Magento\Core\Model\Resource\Db\AbstractDb /** * Initialize connection and define main table * + * @return void */ protected function _construct() { diff --git a/app/code/Magento/CatalogRule/Model/Resource/Rule/Product/Price/Collection.php b/app/code/Magento/CatalogRule/Model/Resource/Rule/Product/Price/Collection.php index 90215174548381e0884a556ab1583966663fdce1..4cda501898fefd4121ea7627015987b6308bd6ce 100644 --- a/app/code/Magento/CatalogRule/Model/Resource/Rule/Product/Price/Collection.php +++ b/app/code/Magento/CatalogRule/Model/Resource/Rule/Product/Price/Collection.php @@ -29,6 +29,9 @@ namespace Magento\CatalogRule\Model\Resource\Rule\Product\Price; class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractCollection { + /** + * @return void + */ protected function _construct() { parent::_construct(); diff --git a/app/code/Magento/CatalogRule/Model/Rule.php b/app/code/Magento/CatalogRule/Model/Rule.php index f55393e32ba376fcd4a1ca7ac3582b2fc7fb76b0..a4e99c5474c6a7adf9bdece703347e15e56279af 100644 --- a/app/code/Magento/CatalogRule/Model/Rule.php +++ b/app/code/Magento/CatalogRule/Model/Rule.php @@ -26,6 +26,8 @@ namespace Magento\CatalogRule\Model; +use Magento\Catalog\Model\Product; + /** * Catalog Rule data model * @@ -224,6 +226,8 @@ class Rule extends \Magento\Rule\Model\AbstractModel /** * Init resource model and id field + * + * @return void */ protected function _construct() { @@ -235,7 +239,7 @@ class Rule extends \Magento\Rule\Model\AbstractModel /** * Getter for rule conditions collection * - * @return \Magento\CatalogRule\Model\Rule\Condition\Combine + * @return \Magento\Rule\Model\Condition\Combine */ public function getConditionsInstance() { @@ -255,7 +259,7 @@ class Rule extends \Magento\Rule\Model\AbstractModel /** * Get catalog rule customer group Ids * - * @return array + * @return array|null */ public function getCustomerGroupIds() { @@ -283,6 +287,7 @@ class Rule extends \Magento\Rule\Model\AbstractModel * Set current date for current rule * * @param string $now + * @return void */ public function setNow($now) { @@ -326,7 +331,7 @@ class Rule extends \Magento\Rule\Model\AbstractModel /** * Callback function for product matching * - * @param $args + * @param array $args * @return void */ public function callbackValidateProduct($args) @@ -342,7 +347,7 @@ class Rule extends \Magento\Rule\Model\AbstractModel /** * Apply rule to product * - * @param int|\Magento\Catalog\Model\Product $product + * @param int|Product $product * @param array|null $websiteIds * * @return void @@ -361,7 +366,7 @@ class Rule extends \Magento\Rule\Model\AbstractModel /** * Apply all price rules, invalidate related cache and refresh price index * - * @return \Magento\CatalogRule\Model\Rule + * @return void */ public function applyAll() { @@ -377,15 +382,15 @@ class Rule extends \Magento\Rule\Model\AbstractModel /** * Apply all price rules to product * - * @param int|\Magento\Catalog\Model\Product $product - * @return \Magento\CatalogRule\Model\Rule + * @param int|Product $product + * @return void */ public function applyAllRulesToProduct($product) { $this->_getResource()->applyAllRulesForDateRange(null, null, $product); $this->_invalidateCache(); - if ($product instanceof \Magento\Catalog\Model\Product) { + if ($product instanceof Product) { $productId = $product->getId(); } else { $productId = $product; @@ -394,7 +399,7 @@ class Rule extends \Magento\Rule\Model\AbstractModel if ($productId) { $this->_indexer->processEntityAction( new \Magento\Object(array('id' => $productId)), - \Magento\Catalog\Model\Product::ENTITY, + Product::ENTITY, \Magento\Catalog\Model\Product\Indexer\Price::EVENT_TYPE_REINDEX_PRICE ); } @@ -403,11 +408,11 @@ class Rule extends \Magento\Rule\Model\AbstractModel /** * Calculate price using catalog price rule of product * - * @param \Magento\Catalog\Model\Product $product + * @param Product $product * @param float $price * @return float|null */ - public function calcProductPriceRule(\Magento\Catalog\Model\Product $product, $price) + public function calcProductPriceRule(Product $product, $price) { $priceRules = null; $productId = $product->getId(); @@ -477,6 +482,7 @@ class Rule extends \Magento\Rule\Model\AbstractModel * Filtering products that must be checked for matching with rule * * @param int|array $productIds + * @return void */ public function setProductsFilter($productIds) { @@ -496,7 +502,7 @@ class Rule extends \Magento\Rule\Model\AbstractModel /** * Invalidate related cache types * - * @return \Magento\CatalogRule\Model\Rule + * @return $this */ protected function _invalidateCache() { diff --git a/app/code/Magento/CatalogRule/Model/Rule/Action/Product.php b/app/code/Magento/CatalogRule/Model/Rule/Action/Product.php index 7ff8e68e5b76dc0c094665e8c72f727daa19f135..be124c9b8453faf8f6ddedb4edf7be43d9e5e21d 100644 --- a/app/code/Magento/CatalogRule/Model/Rule/Action/Product.php +++ b/app/code/Magento/CatalogRule/Model/Rule/Action/Product.php @@ -29,6 +29,9 @@ namespace Magento\CatalogRule\Model\Rule\Action; class Product extends \Magento\Rule\Model\Action\AbstractAction { + /** + * @return $this + */ public function loadAttributeOptions() { $this->setAttributeOption(array( @@ -37,6 +40,9 @@ class Product extends \Magento\Rule\Model\Action\AbstractAction return $this; } + /** + * @return $this + */ public function loadOperatorOptions() { $this->setOperatorOption(array( @@ -48,6 +54,9 @@ class Product extends \Magento\Rule\Model\Action\AbstractAction return $this; } + /** + * @return string + */ public function asHtml() { $html = $this->getTypeElement()->getHtml().__("Update product's %1 %2: %3", $this->getAttributeElement()->getHtml(), $this->getOperatorElement()->getHtml(), $this->getValueElement()->getHtml()); diff --git a/app/code/Magento/CatalogRule/Model/Rule/Condition/Combine.php b/app/code/Magento/CatalogRule/Model/Rule/Condition/Combine.php index bfa6971890944ea968400046cbaae058cd50eea8..e10d609b6321b83fa40d7521d2ce94035a77c060 100644 --- a/app/code/Magento/CatalogRule/Model/Rule/Condition/Combine.php +++ b/app/code/Magento/CatalogRule/Model/Rule/Condition/Combine.php @@ -79,6 +79,10 @@ class Combine extends \Magento\Rule\Model\Condition\Combine return $conditions; } + /** + * @param array $productCollection + * @return $this + */ public function collectValidatedAttributes($productCollection) { foreach ($this->getConditions() as $condition) { diff --git a/app/code/Magento/CatalogRule/Model/Rule/Product/Price.php b/app/code/Magento/CatalogRule/Model/Rule/Product/Price.php index bc3998a9895e1bc4c737d9ff1c67fbea11068858..b0dba68f73d5defbdd673f7fa25f262e93d95f2f 100644 --- a/app/code/Magento/CatalogRule/Model/Rule/Product/Price.php +++ b/app/code/Magento/CatalogRule/Model/Rule/Product/Price.php @@ -51,11 +51,14 @@ */ namespace Magento\CatalogRule\Model\Rule\Product; +use Magento\DB\Select; + class Price extends \Magento\Core\Model\AbstractModel { /** * Initialize resource model * + * @return void */ protected function _construct() { @@ -65,16 +68,16 @@ class Price extends \Magento\Core\Model\AbstractModel /** * Apply price rule price to price index table * - * @param \Magento\DB\Select $select + * @param Select $select * @param array|string $indexTable * @param string $entityId * @param string $customerGroupId * @param string $websiteId * @param array $updateFields the array fields for compare with rule price and update * @param string $websiteDate - * @return \Magento\CatalogRule\Model\Rule\Product\Price + * @return $this */ - public function applyPriceRuleToIndexTable(\Magento\DB\Select $select, $indexTable, $entityId, $customerGroupId, + public function applyPriceRuleToIndexTable(Select $select, $indexTable, $entityId, $customerGroupId, $websiteId, $updateFields, $websiteDate) { diff --git a/app/code/Magento/CatalogSearch/Block/Advanced/Form.php b/app/code/Magento/CatalogSearch/Block/Advanced/Form.php index 59398d0f0138ee0daa833d7904fe1e820b74dd5f..70f211eafff82a7428daa4e6b702f740742410b2 100644 --- a/app/code/Magento/CatalogSearch/Block/Advanced/Form.php +++ b/app/code/Magento/CatalogSearch/Block/Advanced/Form.php @@ -33,32 +33,42 @@ */ namespace Magento\CatalogSearch\Block\Advanced; -class Form extends \Magento\View\Element\Template +use Magento\CatalogSearch\Model\Advanced; +use Magento\Core\Model\LocaleInterface; +use Magento\Data\Collection\Db; +use Magento\Directory\Model\CurrencyFactory; +use Magento\Eav\Model\Entity\Attribute\AbstractAttribute; +use Magento\View\Element\AbstractBlock; +use Magento\View\Element\BlockInterface; +use Magento\View\Element\Template; +use Magento\View\Element\Template\Context; + +class Form extends Template { /** * Currency factory * - * @var \Magento\Directory\Model\CurrencyFactory + * @var CurrencyFactory */ protected $_currencyFactory; /** * Catalog search advanced * - * @var \Magento\CatalogSearch\Model\Advanced + * @var Advanced */ protected $_catalogSearchAdvanced; /** - * @param \Magento\View\Element\Template\Context $context - * @param \Magento\CatalogSearch\Model\Advanced $catalogSearchAdvanced - * @param \Magento\Directory\Model\CurrencyFactory $currencyFactory + * @param Context $context + * @param Advanced $catalogSearchAdvanced + * @param CurrencyFactory $currencyFactory * @param array $data */ public function __construct( - \Magento\View\Element\Template\Context $context, - \Magento\CatalogSearch\Model\Advanced $catalogSearchAdvanced, - \Magento\Directory\Model\CurrencyFactory $currencyFactory, + Context $context, + Advanced $catalogSearchAdvanced, + CurrencyFactory $currencyFactory, array $data = array() ) { $this->_catalogSearchAdvanced = $catalogSearchAdvanced; @@ -66,6 +76,9 @@ class Form extends \Magento\View\Element\Template parent::__construct($context, $data); } + /** + * @return AbstractBlock + */ public function _prepareLayout() { // add Home breadcrumb @@ -84,7 +97,7 @@ class Form extends \Magento\View\Element\Template /** * Retrieve collection of product searchable attributes * - * @return \Magento\Data\Collection\Db + * @return Db */ public function getSearchableAttributes() { @@ -95,7 +108,7 @@ class Form extends \Magento\View\Element\Template /** * Retrieve attribute label * - * @param \Magento\Eav\Model\Entity\Attribute\AbstractAttribute $attribute + * @param AbstractAttribute $attribute * @return string */ public function getAttributeLabel($attribute) @@ -106,7 +119,7 @@ class Form extends \Magento\View\Element\Template /** * Retrieve attribute input validation class * - * @param \Magento\Eav\Model\Entity\Attribute\AbstractAttribute $attribute + * @param AbstractAttribute $attribute * @return string */ public function getAttributeValidationClass($attribute) @@ -117,7 +130,7 @@ class Form extends \Magento\View\Element\Template /** * Retrieve search string for given field from request * - * @param \Magento\Eav\Model\Entity\Attribute\AbstractAttribute $attribute + * @param AbstractAttribute $attribute * @param string|null $part * @return mixed|string */ @@ -177,7 +190,7 @@ class Form extends \Magento\View\Element\Template /** * Retrieve currency code for attribute * - * @param \Magento\Eav\Model\Entity\Attribute\AbstractAttribute $attribute + * @param AbstractAttribute $attribute * @return string */ public function getCurrency($attribute) @@ -192,7 +205,7 @@ class Form extends \Magento\View\Element\Template /** * Retrieve attribute input type * - * @param \Magento\Eav\Model\Entity\Attribute\AbstractAttribute $attribute + * @param AbstractAttribute $attribute * @return string */ public function getAttributeInputType($attribute) @@ -225,7 +238,7 @@ class Form extends \Magento\View\Element\Template /** * Build attribute select element html string * - * @param \Magento\Eav\Model\Entity\Attribute\AbstractAttribute $attribute + * @param AbstractAttribute $attribute * @return string */ public function getAttributeSelectElement($attribute) @@ -258,7 +271,7 @@ class Form extends \Magento\View\Element\Template /** * Retrieve yes/no element html for provided attribute * - * @param \Magento\Eav\Model\Entity\Attribute\AbstractAttribute $attribute + * @param AbstractAttribute $attribute * @return string */ public function getAttributeYesNoElement($attribute) @@ -280,6 +293,9 @@ class Form extends \Magento\View\Element\Template ->getHtml(); } + /** + * @return BlockInterface + */ protected function _getSelectBlock() { $block = $this->getData('_select_block'); @@ -290,6 +306,9 @@ class Form extends \Magento\View\Element\Template return $block; } + /** + * @return BlockInterface|mixed + */ protected function _getDateBlock() { $block = $this->getData('_date_block'); @@ -303,7 +322,7 @@ class Form extends \Magento\View\Element\Template /** * Retrieve advanced search model object * - * @return \Magento\CatalogSearch\Model\Advanced + * @return Advanced */ public function getModel() { @@ -323,7 +342,7 @@ class Form extends \Magento\View\Element\Template /** * Build date element html string for attribute * - * @param \Magento\Eav\Model\Entity\Attribute\AbstractAttribute $attribute + * @param AbstractAttribute $attribute * @param string $part * @return string */ @@ -338,7 +357,7 @@ class Form extends \Magento\View\Element\Template ->setTitle($this->getAttributeLabel($attribute)) ->setValue($value) ->setImage($this->getViewFileUrl('Magento_Core::calendar.gif')) - ->setDateFormat($this->_locale->getDateFormat(\Magento\Core\Model\LocaleInterface::FORMAT_TYPE_SHORT)) + ->setDateFormat($this->_locale->getDateFormat(LocaleInterface::FORMAT_TYPE_SHORT)) ->setClass('input-text') ->getHtml(); } diff --git a/app/code/Magento/CatalogSearch/Block/Advanced/Result.php b/app/code/Magento/CatalogSearch/Block/Advanced/Result.php index d7039161ef6bfb6814e53e095f4b4c6f4ee3e8ba..26ef9d02b9e6dc214fff0b95a45a9410ad657afd 100644 --- a/app/code/Magento/CatalogSearch/Block/Advanced/Result.php +++ b/app/code/Magento/CatalogSearch/Block/Advanced/Result.php @@ -23,47 +23,54 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ - namespace Magento\CatalogSearch\Block\Advanced; +use Magento\Catalog\Model\Layer; +use Magento\CatalogSearch\Model\Advanced; +use Magento\CatalogSearch\Model\Resource\Advanced\Collection; +use Magento\UrlFactory; +use Magento\View\Element\AbstractBlock; +use Magento\View\Element\Template; +use Magento\View\Element\Template\Context; + /** * Advanced search result */ -class Result extends \Magento\View\Element\Template +class Result extends Template { /** * Url factory * - * @var \Magento\UrlFactory + * @var UrlFactory */ protected $_urlFactory; /** * Catalog layer * - * @var \Magento\Catalog\Model\Layer + * @var Layer */ protected $_catalogLayer; /** * Catalog search advanced * - * @var \Magento\CatalogSearch\Model\Advanced + * @var Advanced */ protected $_catalogSearchAdvanced; /** - * @param \Magento\View\Element\Template\Context $context - * @param \Magento\CatalogSearch\Model\Advanced $catalogSearchAdvanced - * @param \Magento\Catalog\Model\Layer $catalogLayer - * @param \Magento\UrlFactory $urlFactory + * @param Context $context + * @param Advanced $catalogSearchAdvanced + * @param Layer $catalogLayer + * @param UrlFactory $urlFactory * @param array $data */ public function __construct( - \Magento\View\Element\Template\Context $context, - \Magento\CatalogSearch\Model\Advanced $catalogSearchAdvanced, - \Magento\Catalog\Model\Layer $catalogLayer, - \Magento\UrlFactory $urlFactory, + Context $context, + Advanced $catalogSearchAdvanced, + Layer $catalogLayer, + UrlFactory $urlFactory, array $data = array() ) { $this->_catalogSearchAdvanced = $catalogSearchAdvanced; @@ -72,6 +79,9 @@ class Result extends \Magento\View\Element\Template parent::__construct($context, $data); } + /** + * @return AbstractBlock + */ protected function _prepareLayout() { $breadcrumbs = $this->getLayout()->getBlock('breadcrumbs'); @@ -92,9 +102,11 @@ class Result extends \Magento\View\Element\Template /** * Set order options + * + * @return void */ - public function setListOrders() - { + public function setListOrders() { + $category = $this->_catalogLayer->getCurrentCategory(); /* @var $category \Magento\Catalog\Model\Category */ $category = $this->_catalogLayer->getCurrentCategory(); @@ -106,28 +118,42 @@ class Result extends \Magento\View\Element\Template /** * Set view mode options + * + * @return void */ public function setListModes() { $this->getChildBlock('search_result_list')->setModes(array('grid' => __('Grid'), 'list' => __('List'))); } + /** + * @return void + */ public function setListCollection() { $this->getChildBlock('search_result_list') ->setCollection($this->_getProductCollection()); } + /** + * @return Collection + */ protected function _getProductCollection() { return $this->getSearchModel()->getProductCollection(); } + /** + * @return Advanced + */ public function getSearchModel() { return $this->_catalogSearchAdvanced; } + /** + * @return mixed + */ public function getResultCount() { if (!$this->getData('result_count')) { @@ -137,11 +163,17 @@ class Result extends \Magento\View\Element\Template return $this->getData('result_count'); } + /** + * @return string + */ public function getProductListHtml() { return $this->getChildHtml('search_result_list'); } + /** + * @return string + */ public function getFormUrl() { return $this->_urlFactory->create() @@ -149,6 +181,9 @@ class Result extends \Magento\View\Element\Template ->getUrl('*/*/', array('_escape' => true)); } + /** + * @return array + */ public function getSearchCriterias() { $searchCriterias = $this->getSearchModel()->getSearchCriterias(); diff --git a/app/code/Magento/CatalogSearch/Block/Autocomplete.php b/app/code/Magento/CatalogSearch/Block/Autocomplete.php index e1adbb85aeaa9f4405c2ca65dc1adf3ca13aa9f0..feaef6bee344c56daec958ba9bd98d201c7df334 100644 --- a/app/code/Magento/CatalogSearch/Block/Autocomplete.php +++ b/app/code/Magento/CatalogSearch/Block/Autocomplete.php @@ -29,29 +29,39 @@ */ namespace Magento\CatalogSearch\Block; -class Autocomplete extends \Magento\View\Element\AbstractBlock +use Magento\CatalogSearch\Helper\Data; +use Magento\View\Element\AbstractBlock; +use Magento\View\Element\Context; + +class Autocomplete extends AbstractBlock { + /** + * @var array + */ protected $_suggestData = null; /** - * @var \Magento\CatalogSearch\Helper\Data + * @var Data */ protected $_catalogsearchHelper; /** - * @param \Magento\View\Element\Context $context - * @param \Magento\CatalogSearch\Helper\Data $catalogsearchHelper + * @param Context $context + * @param Data $catalogsearchHelper * @param array $data */ public function __construct( - \Magento\View\Element\Context $context, - \Magento\CatalogSearch\Helper\Data $catalogsearchHelper, + Context $context, + Data $catalogsearchHelper, array $data = array() ) { $this->_catalogsearchHelper = $catalogsearchHelper; parent::__construct($context, $data); } + /** + * @return string + */ protected function _toHtml() { $html = ''; @@ -87,6 +97,9 @@ class Autocomplete extends \Magento\View\Element\AbstractBlock return $html; } + /** + * @return array + */ public function getSuggestData() { if (!$this->_suggestData) { diff --git a/app/code/Magento/CatalogSearch/Block/Layer.php b/app/code/Magento/CatalogSearch/Block/Layer.php index 767378e380ee52b934f54e8f673e3e943de34f93..02ade565f81323567788b946da882d0ae7a5ab0b 100644 --- a/app/code/Magento/CatalogSearch/Block/Layer.php +++ b/app/code/Magento/CatalogSearch/Block/Layer.php @@ -30,48 +30,57 @@ */ namespace Magento\CatalogSearch\Block; -class Layer extends \Magento\Catalog\Block\Layer\View +use Magento\Catalog\Block\Layer\View; +use Magento\CatalogSearch\Helper\Data; +use Magento\CatalogSearch\Model\Layer as ModelLayer; +use Magento\CatalogSearch\Model\Resource\EngineProvider; +use Magento\Core\Model\Registry; +use Magento\View\Element\Template\Context; + +class Layer extends View { /** - * @var \Magento\CatalogSearch\Model\Resource\EngineProvider + * Engine Provider + * + * @var EngineProvider */ protected $_engineProvider; /** * Core registry * - * @var \Magento\Core\Model\Registry + * @var Registry */ protected $_coreRegistry = null; /** * Catalog search data * - * @var \Magento\CatalogSearch\Helper\Data + * @var Data */ protected $_catalogSearchData = null; /** * Catalog search layer * - * @var \Magento\CatalogSearch\Model\Layer + * @var ModelLayer */ protected $_catalogSearchLayer; /** - * @param \Magento\View\Element\Template\Context $context - * @param \Magento\CatalogSearch\Model\Layer $catalogLayer - * @param \Magento\CatalogSearch\Model\Resource\EngineProvider $engineProvider - * @param \Magento\CatalogSearch\Helper\Data $catalogSearchData - * @param \Magento\Core\Model\Registry $registry + * @param Context $context + * @param ModelLayer $catalogLayer + * @param EngineProvider $engineProvider + * @param Data $catalogSearchData + * @param Registry $registry * @param array $data */ public function __construct( - \Magento\View\Element\Template\Context $context, - \Magento\CatalogSearch\Model\Layer $catalogLayer, - \Magento\CatalogSearch\Model\Resource\EngineProvider $engineProvider, - \Magento\CatalogSearch\Helper\Data $catalogSearchData, - \Magento\Core\Model\Registry $registry, + Context $context, + ModelLayer $catalogLayer, + EngineProvider $engineProvider, + Data $catalogSearchData, + Registry $registry, array $data = array() ) { $this->_engineProvider = $engineProvider; @@ -91,6 +100,8 @@ class Layer extends \Magento\Catalog\Block\Layer\View /** * Initialize blocks names + * + * @return void */ protected function _initBlocks() { @@ -111,7 +122,7 @@ class Layer extends \Magento\Catalog\Block\Layer\View return false; } $availableResCount = (int)$this->_storeManager->getStore() - ->getConfig(\Magento\CatalogSearch\Model\Layer::XML_PATH_DISPLAY_LAYER_COUNT); + ->getConfig(ModelLayer::XML_PATH_DISPLAY_LAYER_COUNT); if (!$availableResCount || ($availableResCount > $this->getLayer()->getProductCollection()->getSize()) diff --git a/app/code/Magento/CatalogSearch/Block/Result.php b/app/code/Magento/CatalogSearch/Block/Result.php index 93505f0f14efbf097ce619355e2805fc40ef9589..3181f219b5fd054eb35182bc9c13c0290c3b00e9 100644 --- a/app/code/Magento/CatalogSearch/Block/Result.php +++ b/app/code/Magento/CatalogSearch/Block/Result.php @@ -23,45 +23,52 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ - namespace Magento\CatalogSearch\Block; +use Magento\Catalog\Block\Product\ListProduct; +use Magento\Catalog\Model\Layer as ModelLayer; +use Magento\CatalogSearch\Helper\Data; +use Magento\CatalogSearch\Model\Query; +use Magento\CatalogSearch\Model\Resource\Fulltext\Collection; +use Magento\View\Element\Template; +use Magento\View\Element\Template\Context; + /** * Product search result block */ -class Result extends \Magento\View\Element\Template +class Result extends Template { /** * Catalog Product collection * - * @var \Magento\CatalogSearch\Model\Resource\Fulltext\Collection + * @var Collection */ protected $productCollection; /** * Catalog search data * - * @var \Magento\CatalogSearch\Helper\Data + * @var Data */ protected $catalogSearchData; /** * Catalog layer * - * @var \Magento\Catalog\Model\Layer + * @var ModelLayer */ protected $catalogLayer; /** - * @param \Magento\View\Element\Template\Context $context - * @param \Magento\Catalog\Model\Layer $catalogLayer - * @param \Magento\CatalogSearch\Helper\Data $catalogSearchData + * @param Context $context + * @param ModelLayer $catalogLayer + * @param Data $catalogSearchData * @param array $data */ public function __construct( - \Magento\View\Element\Template\Context $context, - \Magento\Catalog\Model\Layer $catalogLayer, - \Magento\CatalogSearch\Helper\Data $catalogSearchData, + Context $context, + ModelLayer $catalogLayer, + Data $catalogSearchData, array $data = array() ) { $this->catalogLayer = $catalogLayer; @@ -72,7 +79,7 @@ class Result extends \Magento\View\Element\Template /** * Retrieve query model object * - * @return \Magento\CatalogSearch\Model\Query + * @return Query */ protected function _getQuery() { @@ -82,7 +89,7 @@ class Result extends \Magento\View\Element\Template /** * Prepare layout * - * @return \Magento\CatalogSearch\Block\Result + * @return $this */ protected function _prepareLayout() { @@ -118,7 +125,7 @@ class Result extends \Magento\View\Element\Template /** * Retrieve search list toolbar block * - * @return \Magento\Catalog\Block\Product\ListProduct + * @return ListProduct */ public function getListBlock() { @@ -128,7 +135,7 @@ class Result extends \Magento\View\Element\Template /** * Set search available list orders * - * @return \Magento\CatalogSearch\Block\Result + * @return $this */ public function setListOrders() { @@ -151,7 +158,7 @@ class Result extends \Magento\View\Element\Template /** * Set available view mode * - * @return \Magento\CatalogSearch\Block\Result + * @return $this */ public function setListModes() { @@ -163,7 +170,7 @@ class Result extends \Magento\View\Element\Template /** * Set Search Result collection * - * @return \Magento\CatalogSearch\Block\Result + * @return $this */ public function setListCollection() { @@ -185,7 +192,7 @@ class Result extends \Magento\View\Element\Template /** * Retrieve loaded category collection * - * @return \Magento\CatalogSearch\Model\Resource\Fulltext\Collection + * @return Collection */ protected function _getProductCollection() { diff --git a/app/code/Magento/CatalogSearch/Block/Term.php b/app/code/Magento/CatalogSearch/Block/Term.php index ffeea84a9c9d9b9bdc2e963d36af91e089335db7..f2abab15ddf5e173b55fbb8e4e93114a7c10766b 100644 --- a/app/code/Magento/CatalogSearch/Block/Term.php +++ b/app/code/Magento/CatalogSearch/Block/Term.php @@ -33,36 +33,54 @@ */ namespace Magento\CatalogSearch\Block; -class Term extends \Magento\View\Element\Template +use Magento\CatalogSearch\Model\Resource\Query\CollectionFactory; +use Magento\UrlFactory; +use Magento\UrlInterface; +use Magento\View\Element\Template; +use Magento\View\Element\Template\Context; + +class Term extends Template { + /** + * @var array + */ protected $_terms; + + + /** + * @var int + */ protected $_minPopularity; + + /** + * @var int + */ protected $_maxPopularity; /** * Url factory * - * @var \Magento\UrlFactory + * @var UrlFactory */ protected $_urlFactory; /** * Query collection factory * - * @var \Magento\CatalogSearch\Model\Resource\Query\CollectionFactory + * @var CollectionFactory */ protected $_queryCollectionFactory; /** - * @param \Magento\View\Element\Template\Context $context - * @param \Magento\CatalogSearch\Model\Resource\Query\CollectionFactory $queryCollectionFactory - * @param \Magento\UrlFactory $urlFactory + * @param Context $context + * @param CollectionFactory $queryCollectionFactory + * @param UrlFactory $urlFactory * @param array $data */ public function __construct( - \Magento\View\Element\Template\Context $context, - \Magento\CatalogSearch\Model\Resource\Query\CollectionFactory $queryCollectionFactory, - \Magento\UrlFactory $urlFactory, + Context $context, + CollectionFactory $queryCollectionFactory, + UrlFactory $urlFactory, array $data = array() ) { $this->_queryCollectionFactory = $queryCollectionFactory; @@ -73,7 +91,7 @@ class Term extends \Magento\View\Element\Template /** * Load terms and try to sort it by names * - * @return \Magento\CatalogSearch\Block\Term + * @return $this */ protected function _loadTerms() { @@ -111,15 +129,22 @@ class Term extends \Magento\View\Element\Template return $this; } + /** + * @return array + */ public function getTerms() { $this->_loadTerms(); return $this->_terms; } + /** + * @param /Magento/Object $obj + * @return string + */ public function getSearchUrl($obj) { - /** @var $url \Magento\UrlInterface */ + /** @var $url UrlInterface */ $url = $this->_urlFactory->create(); /* * url encoding will be done in Url.php http_build_query @@ -129,11 +154,17 @@ class Term extends \Magento\View\Element\Template return $url->getUrl('catalogsearch/result'); } + /** + * @return int + */ public function getMaxPopularity() { return $this->_maxPopularity; } + /** + * @return int + */ public function getMinPopularity() { return $this->_minPopularity; diff --git a/app/code/Magento/CatalogSearch/Controller/Advanced.php b/app/code/Magento/CatalogSearch/Controller/Advanced.php index fa435a9da5ee95c8da63f8c32b164abbf273974b..e42dacbabc99bfd8aef4bf4e7b5333fa12cc385b 100644 --- a/app/code/Magento/CatalogSearch/Controller/Advanced.php +++ b/app/code/Magento/CatalogSearch/Controller/Advanced.php @@ -33,43 +33,48 @@ */ namespace Magento\CatalogSearch\Controller; +use Magento\App\Action\Context; +use Magento\CatalogSearch\Model\Advanced as ModelAdvanced; +use Magento\Session\Generic; +use Magento\UrlFactory; + class Advanced extends \Magento\App\Action\Action { /** * Url factory * - * @var \Magento\UrlFactory + * @var UrlFactory */ protected $_urlFactory; /** * Catalog search advanced * - * @var \Magento\CatalogSearch\Model\Advanced + * @var ModelAdvanced */ protected $_catalogSearchAdvanced; /** * Catalog search session * - * @var \Magento\Session\Generic + * @var Generic */ protected $_catalogSearchSession; /** * Construct * - * @param \Magento\App\Action\Context $context - * @param \Magento\Session\Generic $catalogSearchSession - * @param \Magento\CatalogSearch\Model\Advanced $catalogSearchAdvanced - * @param \Magento\UrlFactory $urlFactory + * @param Context $context + * @param Generic $catalogSearchSession + * @param ModelAdvanced $catalogSearchAdvanced + * @param UrlFactory $urlFactory */ public function __construct( - \Magento\App\Action\Context $context, - \Magento\Session\Generic $catalogSearchSession, - \Magento\CatalogSearch\Model\Advanced $catalogSearchAdvanced, - \Magento\UrlFactory $urlFactory + Context $context, + Generic $catalogSearchSession, + ModelAdvanced $catalogSearchAdvanced, + UrlFactory $urlFactory ) { $this->_catalogSearchSession = $catalogSearchSession; $this->_catalogSearchAdvanced = $catalogSearchAdvanced; @@ -77,6 +82,9 @@ class Advanced extends \Magento\App\Action\Action parent::__construct($context); } + /** + * @return void + */ public function indexAction() { $this->_view->loadLayout(); @@ -84,6 +92,9 @@ class Advanced extends \Magento\App\Action\Action $this->_view->renderLayout(); } + /** + * @return void + */ public function resultAction() { $this->_view->loadLayout(); diff --git a/app/code/Magento/CatalogSearch/Controller/Ajax.php b/app/code/Magento/CatalogSearch/Controller/Ajax.php index 359ddeb4edaf64dcd073031e44690928e281db6d..9803843e2960410e63c2c1eb2d4fb73583af1fc0 100644 --- a/app/code/Magento/CatalogSearch/Controller/Ajax.php +++ b/app/code/Magento/CatalogSearch/Controller/Ajax.php @@ -33,8 +33,13 @@ */ namespace Magento\CatalogSearch\Controller; -class Ajax extends \Magento\App\Action\Action +use Magento\App\Action\Action; + +class Ajax extends Action { + /** + * @return void + */ public function suggestAction() { if (!$this->getRequest()->getParam('q', false)) { diff --git a/app/code/Magento/CatalogSearch/Controller/Result.php b/app/code/Magento/CatalogSearch/Controller/Result.php index 6b2060e430603b002c5a11d606105363bb75f6ce..60658261b89a1fba29e82006ae5f932a8145aa71 100644 --- a/app/code/Magento/CatalogSearch/Controller/Result.php +++ b/app/code/Magento/CatalogSearch/Controller/Result.php @@ -23,35 +23,39 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ - namespace Magento\CatalogSearch\Controller; +use Magento\App\Action\Action; +use Magento\App\Action\Context; +use Magento\Catalog\Model\Session; +use Magento\Core\Model\StoreManagerInterface; + /** * Catalog Search Controller */ -class Result extends \Magento\App\Action\Action +class Result extends Action { /** * Catalog session * - * @var \Magento\Catalog\Model\Session + * @var Session */ protected $_catalogSession; /** - * @var \Magento\Core\Model\StoreManagerInterface + * @var StoreManagerInterface */ protected $_storeManager; /** - * @param \Magento\App\Action\Context $context - * @param \Magento\Catalog\Model\Session $catalogSession - * @param \Magento\Core\Model\StoreManagerInterface $storeManager + * @param Context $context + * @param Session $catalogSession + * @param StoreManagerInterface $storeManager */ public function __construct( - \Magento\App\Action\Context $context, - \Magento\Catalog\Model\Session $catalogSession, - \Magento\Core\Model\StoreManagerInterface $storeManager + Context $context, + Session $catalogSession, + StoreManagerInterface $storeManager ) { $this->_storeManager = $storeManager; $this->_catalogSession = $catalogSession; @@ -60,6 +64,8 @@ class Result extends \Magento\App\Action\Action /** * Display search result + * + * @return void */ public function indexAction() { diff --git a/app/code/Magento/CatalogSearch/Controller/Term.php b/app/code/Magento/CatalogSearch/Controller/Term.php index 7960a2cf87f45f628e9bc28ae6edceac2d7d886e..98956551cbdbad3d5e32f0fbf7e4630efbe4894c 100644 --- a/app/code/Magento/CatalogSearch/Controller/Term.php +++ b/app/code/Magento/CatalogSearch/Controller/Term.php @@ -27,16 +27,18 @@ namespace Magento\CatalogSearch\Controller; +use Magento\App\Action\Action; use Magento\App\Action\NotFoundException; use Magento\App\RequestInterface; +use Magento\App\ResponseInterface; -class Term extends \Magento\App\Action\Action +class Term extends Action { /** * Dispatch request * * @param RequestInterface $request - * @return \Magento\App\ResponseInterface + * @return ResponseInterface */ public function dispatch(RequestInterface $request) { @@ -47,6 +49,9 @@ class Term extends \Magento\App\Action\Action return parent::dispatch($request); } + /** + * @return void + */ public function popularAction() { $this->_view->loadLayout(); diff --git a/app/code/Magento/CatalogSearch/Helper/Data.php b/app/code/Magento/CatalogSearch/Helper/Data.php index f45f00826e55665a0959eebeeff8e78f36ae5e56..e000ac7a75741cd7595ac42d521c946e73f19dc9 100644 --- a/app/code/Magento/CatalogSearch/Helper/Data.php +++ b/app/code/Magento/CatalogSearch/Helper/Data.php @@ -26,10 +26,22 @@ namespace Magento\CatalogSearch\Helper; +use Magento\App\Helper\AbstractHelper; +use Magento\App\Helper\Context; +use Magento\CatalogSearch\Model\Fulltext; +use Magento\CatalogSearch\Model\Query; +use Magento\CatalogSearch\Model\QueryFactory; +use Magento\CatalogSearch\Model\Resource\Fulltext\Engine; +use Magento\CatalogSearch\Model\Resource\Query\Collection; +use Magento\Core\Model\Store\ConfigInterface; +use Magento\Escaper; +use Magento\Filter\FilterManager; +use Magento\Stdlib\String; + /** * Catalog search helper */ -class Data extends \Magento\App\Helper\AbstractHelper +class Data extends AbstractHelper { /** * Query variable @@ -44,7 +56,7 @@ class Data extends \Magento\App\Helper\AbstractHelper /** * Query object * - * @var \Magento\CatalogSearch\Model\Query + * @var Query */ protected $_query; @@ -72,58 +84,58 @@ class Data extends \Magento\App\Helper\AbstractHelper /** * Search engine model * - * @var \Magento\CatalogSearch\Model\Resource\Fulltext\Engine + * @var Engine */ protected $_engine; /** * Magento string lib * - * @var \Magento\Stdlib\String + * @var String */ protected $string; /** * Core store config * - * @var \Magento\Core\Model\Store\ConfigInterface + * @var ConfigInterface */ protected $_coreStoreConfig; /** * Query factory * - * @var \Magento\CatalogSearch\Model\QueryFactory + * @var QueryFactory */ protected $_queryFactory; /** - * @var \Magento\Escaper + * @var Escaper */ protected $_escaper; /** - * @var \Magento\Filter\FilterManager + * @var FilterManager */ protected $filter; /** * Construct * - * @param \Magento\App\Helper\Context $context - * @param \Magento\Stdlib\String $string - * @param \Magento\Core\Model\Store\ConfigInterface $coreStoreConfig - * @param \Magento\CatalogSearch\Model\QueryFactory $queryFactory - * @param \Magento\Escaper $escaper - * @param \Magento\Filter\FilterManager $filter + * @param Context $context + * @param String $string + * @param ConfigInterface $coreStoreConfig + * @param QueryFactory $queryFactory + * @param Escaper $escaper + * @param FilterManager $filter */ public function __construct( - \Magento\App\Helper\Context $context, - \Magento\Stdlib\String $string, - \Magento\Core\Model\Store\ConfigInterface $coreStoreConfig, - \Magento\CatalogSearch\Model\QueryFactory $queryFactory, - \Magento\Escaper $escaper, - \Magento\Filter\FilterManager $filter + Context $context, + String $string, + ConfigInterface $coreStoreConfig, + QueryFactory $queryFactory, + Escaper $escaper, + FilterManager $filter ) { $this->string = $string; $this->_coreStoreConfig = $coreStoreConfig; @@ -146,7 +158,7 @@ class Data extends \Magento\App\Helper\AbstractHelper /** * Retrieve query model object * - * @return \Magento\CatalogSearch\Model\Query + * @return Query */ public function getQuery() { @@ -210,7 +222,7 @@ class Data extends \Magento\App\Helper\AbstractHelper /** * Retrieve suggest collection for query * - * @return \Magento\CatalogSearch\Model\Resource\Query\Collection + * @return Collection */ public function getSuggestCollection() { @@ -273,7 +285,7 @@ class Data extends \Magento\App\Helper\AbstractHelper public function getMinQueryLength($store = null) { return $this->_coreStoreConfig->getConfig( - \Magento\CatalogSearch\Model\Query::XML_PATH_MIN_QUERY_LENGTH, + Query::XML_PATH_MIN_QUERY_LENGTH, $store ); } @@ -287,7 +299,7 @@ class Data extends \Magento\App\Helper\AbstractHelper public function getMaxQueryLength($store = null) { return $this->_coreStoreConfig->getConfig( - \Magento\CatalogSearch\Model\Query::XML_PATH_MAX_QUERY_LENGTH, + Query::XML_PATH_MAX_QUERY_LENGTH, $store ); } @@ -301,7 +313,7 @@ class Data extends \Magento\App\Helper\AbstractHelper public function getMaxQueryWords($store = null) { return $this->_coreStoreConfig->getConfig( - \Magento\CatalogSearch\Model\Query::XML_PATH_MAX_QUERY_WORDS, + Query::XML_PATH_MAX_QUERY_WORDS, $store ); } @@ -310,7 +322,7 @@ class Data extends \Magento\App\Helper\AbstractHelper * Add Note message * * @param string $message - * @return \Magento\CatalogSearch\Helper\Data + * @return $this */ public function addNoteMessage($message) { @@ -322,7 +334,7 @@ class Data extends \Magento\App\Helper\AbstractHelper * Set Note messages * * @param array $messages - * @return \Magento\CatalogSearch\Helper\Data + * @return $this */ public function setNoteMessages(array $messages) { @@ -344,7 +356,7 @@ class Data extends \Magento\App\Helper\AbstractHelper * Check query of a warnings * * @param mixed $store - * @return \Magento\CatalogSearch\Helper\Data + * @return $this */ public function checkNotes($store = null) { @@ -356,9 +368,9 @@ class Data extends \Magento\App\Helper\AbstractHelper } $searchType = $this->_coreStoreConfig - ->getConfig(\Magento\CatalogSearch\Model\Fulltext::XML_PATH_CATALOG_SEARCH_TYPE); - if ($searchType == \Magento\CatalogSearch\Model\Fulltext::SEARCH_TYPE_COMBINE - || $searchType == \Magento\CatalogSearch\Model\Fulltext::SEARCH_TYPE_LIKE + ->getConfig(Fulltext::XML_PATH_CATALOG_SEARCH_TYPE); + if ($searchType == Fulltext::SEARCH_TYPE_COMBINE + || $searchType == Fulltext::SEARCH_TYPE_LIKE ) { $wordsFull = $this->filter->splitWords($this->getQueryText(), array('uniqueOnly' => true)); $wordsLike = $this->filter->splitWords( diff --git a/app/code/Magento/CatalogSearch/Model/Advanced.php b/app/code/Magento/CatalogSearch/Model/Advanced.php index bc27e517861716e26dd5878b72521fa796bdecff..18cdbaafeef5927b1db27da377a538a359dcef3c 100644 --- a/app/code/Magento/CatalogSearch/Model/Advanced.php +++ b/app/code/Magento/CatalogSearch/Model/Advanced.php @@ -51,7 +51,27 @@ */ namespace Magento\CatalogSearch\Model; -class Advanced extends \Magento\Core\Model\AbstractModel +use Magento\Catalog\Model\Config; +use Magento\Catalog\Model\Product\Visibility; +use Magento\Catalog\Model\ProductFactory; +use Magento\Catalog\Model\Resource\Eav\Attribute; +use Magento\Catalog\Model\Resource\Eav\Resource\Product\Attribute\Collection as AttributeCollection; +use Magento\Catalog\Model\Resource\Product\Attribute\CollectionFactory; +use Magento\CatalogSearch\Helper\Data; +use Magento\CatalogSearch\Model\Advanced as ModelAdvanced; +use Magento\CatalogSearch\Model\Resource\Advanced\Collection; +use Magento\CatalogSearch\Model\Resource\EngineInterface; +use Magento\CatalogSearch\Model\Resource\EngineProvider; +use Magento\Core\Exception; +use Magento\Core\Model\AbstractModel; +use Magento\Core\Model\Context; +use Magento\Core\Model\Registry; +use Magento\Core\Model\StoreManagerInterface; +use Magento\Directory\Model\Currency; +use Magento\Directory\Model\CurrencyFactory; +use Magento\Eav\Model\Entity\Attribute as EntityAttribute; + +class Advanced extends AbstractModel { /** * User friendly search criteria list @@ -63,85 +83,85 @@ class Advanced extends \Magento\Core\Model\AbstractModel /** * Current search engine * - * @var \Magento\CatalogSearch\Model\Resource\EngineInterface + * @var EngineInterface */ protected $_engine; /** * Found products collection * - * @var \Magento\CatalogSearch\Model\Resource\Advanced\Collection + * @var Collection */ protected $_productCollection; /** * Initialize dependencies * - * @var \Magento\Catalog\Model\Config + * @var Config */ protected $_catalogConfig; /** * Catalog product visibility * - * @var \Magento\Catalog\Model\Product\Visibility + * @var Visibility */ protected $_catalogProductVisibility; /** * Attribute collection factory * - * @var \Magento\Catalog\Model\Resource\Product\Attribute\CollectionFactory + * @var CollectionFactory */ protected $_attributeCollectionFactory; /** * Store manager * - * @var \Magento\Core\Model\StoreManagerInterface + * @var StoreManagerInterface */ protected $_storeManager; /** * Product factory * - * @var \Magento\Catalog\Model\ProductFactory + * @var ProductFactory */ protected $_productFactory; /** * Currency factory * - * @var \Magento\Directory\Model\CurrencyFactory + * @var CurrencyFactory */ protected $_currencyFactory; /** * Construct * - * @param \Magento\Core\Model\Context $context - * @param \Magento\Core\Model\Registry $registry - * @param \Magento\Catalog\Model\Resource\Product\Attribute\CollectionFactory $attributeCollectionFactory - * @param \Magento\Catalog\Model\Product\Visibility $catalogProductVisibility - * @param \Magento\Catalog\Model\Config $catalogConfig - * @param \Magento\CatalogSearch\Model\Resource\EngineProvider $engineProvider - * @param \Magento\CatalogSearch\Helper\Data $helper - * @param \Magento\Directory\Model\CurrencyFactory $currencyFactory - * @param \Magento\Catalog\Model\ProductFactory $productFactory - * @param \Magento\Core\Model\StoreManagerInterface $storeManager + * @param Context $context + * @param Registry $registry + * @param CollectionFactory $attributeCollectionFactory + * @param Visibility $catalogProductVisibility + * @param Config $catalogConfig + * @param EngineProvider $engineProvider + * @param Data $helper + * @param CurrencyFactory $currencyFactory + * @param ProductFactory $productFactory + * @param StoreManagerInterface $storeManager * @param array $data */ public function __construct( - \Magento\Core\Model\Context $context, - \Magento\Core\Model\Registry $registry, - \Magento\Catalog\Model\Resource\Product\Attribute\CollectionFactory $attributeCollectionFactory, - \Magento\Catalog\Model\Product\Visibility $catalogProductVisibility, - \Magento\Catalog\Model\Config $catalogConfig, - \Magento\CatalogSearch\Model\Resource\EngineProvider $engineProvider, - \Magento\CatalogSearch\Helper\Data $helper, - \Magento\Directory\Model\CurrencyFactory $currencyFactory, - \Magento\Catalog\Model\ProductFactory $productFactory, - \Magento\Core\Model\StoreManagerInterface $storeManager, + Context $context, + Registry $registry, + CollectionFactory $attributeCollectionFactory, + Visibility $catalogProductVisibility, + Config $catalogConfig, + EngineProvider $engineProvider, + Data $helper, + CurrencyFactory $currencyFactory, + ProductFactory $productFactory, + StoreManagerInterface $storeManager, array $data = array() ) { $this->_attributeCollectionFactory = $attributeCollectionFactory; @@ -163,7 +183,7 @@ class Advanced extends \Magento\Core\Model\AbstractModel */ public function getAttributes() { - /* @var $attributes \Magento\Catalog\Model\Resource\Eav\Resource\Product\Attribute\Collection */ + /* @var $attributes AttributeCollection */ $attributes = $this->getData('attributes'); if (is_null($attributes)) { $product = $this->_productFactory->create(); @@ -185,8 +205,8 @@ class Advanced extends \Magento\Core\Model\AbstractModel * Add advanced search filters to product collection * * @param array $values - * @return \Magento\CatalogSearch\Model\Advanced - * @throws \Magento\Core\Exception + * @return $this + * @throws Exception */ public function addFilters($values) { @@ -195,7 +215,7 @@ class Advanced extends \Magento\Core\Model\AbstractModel $allConditions = array(); foreach ($attributes as $attribute) { - /* @var $attribute \Magento\Catalog\Model\Resource\Eav\Attribute */ + /* @var $attribute Attribute */ if (!isset($values[$attribute->getAttributeCode()])) { continue; } @@ -245,7 +265,7 @@ class Advanced extends \Magento\Core\Model\AbstractModel if ($allConditions) { $this->getProductCollection()->addFieldsToFilter($allConditions); } else if (!$hasConditions) { - throw new \Magento\Core\Exception(__('Please specify at least one search term.')); + throw new Exception(__('Please specify at least one search term.')); } return $this; @@ -254,9 +274,9 @@ class Advanced extends \Magento\Core\Model\AbstractModel /** * Add data about search criteria to object state * - * @param \Magento\Eav\Model\Entity\Attribute $attribute + * @param EntityAttribute $attribute * @param mixed $value - * @return \Magento\CatalogSearch\Model\Advanced + * @return $this */ protected function _addSearchCriteria($attribute, $value) { @@ -266,7 +286,7 @@ class Advanced extends \Magento\Core\Model\AbstractModel if (isset($value['from']) && isset($value['to'])) { if (!empty($value['from']) || !empty($value['to'])) { if (isset($value['currency'])) { - /** @var $currencyModel \Magento\Directory\Model\Currency */ + /** @var $currencyModel Currency */ $currencyModel = $this->_currencyFactory->create()->load($value['currency']); $from = $currencyModel->format($value['from'], array(), false); $to = $currencyModel->format($value['to'], array(), false); @@ -329,7 +349,7 @@ class Advanced extends \Magento\Core\Model\AbstractModel /** * Retrieve advanced search product collection * - * @return \Magento\CatalogSearch\Model\Resource\Advanced\Collection + * @return Collection */ public function getProductCollection() { @@ -348,8 +368,8 @@ class Advanced extends \Magento\Core\Model\AbstractModel /** * Prepare product collection * - * @param \Magento\CatalogSearch\Model\Resource\Advanced\Collection $collection - * @return \Magento\Catalog\Model\Layer + * @param Collection $collection + * @return $this */ public function prepareProductCollection($collection) { diff --git a/app/code/Magento/CatalogSearch/Model/Config/Backend/Search/Type.php b/app/code/Magento/CatalogSearch/Model/Config/Backend/Search/Type.php index c08d806eefcaaf3b104ba47c8dddacf8f545d6c6..93c1087eb46c62065b4ffe47671f9b7834dc1d44 100644 --- a/app/code/Magento/CatalogSearch/Model/Config/Backend/Search/Type.php +++ b/app/code/Magento/CatalogSearch/Model/Config/Backend/Search/Type.php @@ -34,33 +34,42 @@ */ namespace Magento\CatalogSearch\Model\Config\Backend\Search; -class Type extends \Magento\Core\Model\Config\Value +use Magento\App\ConfigInterface; +use Magento\CatalogSearch\Model\Fulltext; +use Magento\Core\Model\Config\Value; +use Magento\Core\Model\Context; +use Magento\Core\Model\Registry; +use Magento\Core\Model\Resource\AbstractResource; +use Magento\Core\Model\StoreManagerInterface; +use Magento\Data\Collection\Db; + +class Type extends Value { /** * Catalog search fulltext * - * @var \Magento\CatalogSearch\Model\Fulltext + * @var Fulltext */ protected $_catalogSearchFulltext; /** - * @param \Magento\Core\Model\Context $context - * @param \Magento\Core\Model\Registry $registry - * @param \Magento\Core\Model\StoreManagerInterface $storeManager - * @param \Magento\App\ConfigInterface $config - * @param \Magento\CatalogSearch\Model\Fulltext $catalogSearchFulltext - * @param \Magento\Core\Model\Resource\AbstractResource $resource - * @param \Magento\Data\Collection\Db $resourceCollection + * @param Context $context + * @param Registry $registry + * @param StoreManagerInterface $storeManager + * @param ConfigInterface $config + * @param Fulltext $catalogSearchFulltext + * @param AbstractResource $resource + * @param Db $resourceCollection * @param array $data */ public function __construct( - \Magento\Core\Model\Context $context, - \Magento\Core\Model\Registry $registry, - \Magento\Core\Model\StoreManagerInterface $storeManager, - \Magento\App\ConfigInterface $config, - \Magento\CatalogSearch\Model\Fulltext $catalogSearchFulltext, - \Magento\Core\Model\Resource\AbstractResource $resource = null, - \Magento\Data\Collection\Db $resourceCollection = null, + Context $context, + Registry $registry, + StoreManagerInterface $storeManager, + ConfigInterface $config, + Fulltext $catalogSearchFulltext, + AbstractResource $resource = null, + Db $resourceCollection = null, array $data = array() ) { $this->_catalogSearchFulltext = $catalogSearchFulltext; @@ -70,13 +79,13 @@ class Type extends \Magento\Core\Model\Config\Value /** * After change Catalog Search Type process * - * @return \Magento\CatalogSearch\Model\Config\Backend\Search\Type|\Magento\Core\Model\AbstractModel + * @return $this */ protected function _afterSave() { $newValue = $this->getValue(); $oldValue = $this->_config->getValue( - \Magento\CatalogSearch\Model\Fulltext::XML_PATH_CATALOG_SEARCH_TYPE, + Fulltext::XML_PATH_CATALOG_SEARCH_TYPE, $this->getScope(), $this->getScopeId() ); diff --git a/app/code/Magento/CatalogSearch/Model/Config/Source/Search/Type.php b/app/code/Magento/CatalogSearch/Model/Config/Source/Search/Type.php index 6288f9fd6a37fa163d8db621f4f2ed15e75f307a..dcabbca5b77b9a4370525a8d4893a29c95a6680d 100644 --- a/app/code/Magento/CatalogSearch/Model/Config/Source/Search/Type.php +++ b/app/code/Magento/CatalogSearch/Model/Config/Source/Search/Type.php @@ -34,14 +34,20 @@ */ namespace Magento\CatalogSearch\Model\Config\Source\Search; -class Type implements \Magento\Core\Model\Option\ArrayInterface +use Magento\CatalogSearch\Model\Fulltext; +use Magento\Core\Model\Option\ArrayInterface; + +class Type implements ArrayInterface { + /** + * @return array + */ public function toOptionArray() { $types = array( - \Magento\CatalogSearch\Model\Fulltext::SEARCH_TYPE_LIKE => 'Like', - \Magento\CatalogSearch\Model\Fulltext::SEARCH_TYPE_FULLTEXT => 'Fulltext', - \Magento\CatalogSearch\Model\Fulltext::SEARCH_TYPE_COMBINE => 'Combine (Like and Fulltext)', + Fulltext::SEARCH_TYPE_LIKE => 'Like', + Fulltext::SEARCH_TYPE_FULLTEXT => 'Fulltext', + Fulltext::SEARCH_TYPE_COMBINE => 'Combine (Like and Fulltext)', ); $options = array(); foreach ($types as $k => $v) { diff --git a/app/code/Magento/CatalogSearch/Model/Fulltext.php b/app/code/Magento/CatalogSearch/Model/Fulltext.php index 7497a4b9ad46946319f337a282305f01a1e836a3..53d64ead3917938b4656198a285862eb5edade7a 100644 --- a/app/code/Magento/CatalogSearch/Model/Fulltext.php +++ b/app/code/Magento/CatalogSearch/Model/Fulltext.php @@ -42,7 +42,16 @@ */ namespace Magento\CatalogSearch\Model; -class Fulltext extends \Magento\Core\Model\AbstractModel +use Magento\CatalogSearch\Helper\Data; +use Magento\CatalogSearch\Model\Query; +use Magento\Core\Model\AbstractModel; +use Magento\Core\Model\Context; +use Magento\Core\Model\Registry; +use Magento\Core\Model\Resource\AbstractResource; +use Magento\Core\Model\Store\Config; +use Magento\Data\Collection\Db; + +class Fulltext extends AbstractModel { const SEARCH_TYPE_LIKE = 1; const SEARCH_TYPE_FULLTEXT = 2; @@ -52,33 +61,33 @@ class Fulltext extends \Magento\Core\Model\AbstractModel /** * Catalog search data * - * @var \Magento\CatalogSearch\Helper\Data + * @var Data */ protected $_catalogSearchData = null; /** * Core store config * - * @var \Magento\Core\Model\Store\Config + * @var Config */ protected $_coreStoreConfig; /** - * @param \Magento\Core\Model\Context $context - * @param \Magento\Core\Model\Registry $registry - * @param \Magento\CatalogSearch\Helper\Data $catalogSearchData - * @param \Magento\Core\Model\Store\Config $coreStoreConfig - * @param \Magento\Core\Model\Resource\AbstractResource $resource - * @param \Magento\Data\Collection\Db $resourceCollection + * @param Context $context + * @param Registry $registry + * @param Data $catalogSearchData + * @param Config $coreStoreConfig + * @param AbstractResource $resource + * @param Db $resourceCollection * @param array $data */ public function __construct( - \Magento\Core\Model\Context $context, - \Magento\Core\Model\Registry $registry, - \Magento\CatalogSearch\Helper\Data $catalogSearchData, - \Magento\Core\Model\Store\Config $coreStoreConfig, - \Magento\Core\Model\Resource\AbstractResource $resource = null, - \Magento\Data\Collection\Db $resourceCollection = null, + Context $context, + Registry $registry, + Data $catalogSearchData, + Config $coreStoreConfig, + AbstractResource $resource = null, + Db $resourceCollection = null, array $data = array() ) { $this->_catalogSearchData = $catalogSearchData; @@ -103,7 +112,7 @@ class Fulltext extends \Magento\Core\Model\AbstractModel * @param int|null $storeId Store View Id * @param int|array|null $productIds Product Entity Id * - * @return \Magento\CatalogSearch\Model\Fulltext + * @return $this */ public function rebuildIndex($storeId = null, $productIds = null) { @@ -122,7 +131,7 @@ class Fulltext extends \Magento\Core\Model\AbstractModel * * @param int $storeId Store View Id * @param int $productId Product Entity Id - * @return \Magento\CatalogSearch\Model\Fulltext + * @return $this */ public function cleanIndex($storeId = null, $productId = null) { @@ -133,7 +142,7 @@ class Fulltext extends \Magento\Core\Model\AbstractModel /** * Reset search results cache * - * @return \Magento\CatalogSearch\Model\Fulltext + * @return $this */ public function resetSearchResults() { @@ -144,12 +153,12 @@ class Fulltext extends \Magento\Core\Model\AbstractModel /** * Prepare results for query * - * @param \Magento\CatalogSearch\Model\Query $query - * @return \Magento\CatalogSearch\Model\Fulltext + * @param Query $query + * @return $this */ public function prepareResult($query = null) { - if (!$query instanceof \Magento\CatalogSearch\Model\Query) { + if (!$query instanceof Query) { $query = $this->_catalogSearchData->getQuery(); } $queryText = $this->_catalogSearchData->getQueryText(); @@ -171,10 +180,6 @@ class Fulltext extends \Magento\Core\Model\AbstractModel return $this->_coreStoreConfig->getConfig(self::XML_PATH_CATALOG_SEARCH_TYPE, $storeId); } - - - - // Deprecated methods /** @@ -183,7 +188,7 @@ class Fulltext extends \Magento\Core\Model\AbstractModel * @deprecated after 1.6.1.0 * * @param bool $value - * @return \Magento\CatalogSearch\Model\Fulltext + * @return $this */ public function setAllowTableChanges($value = true) { @@ -199,7 +204,7 @@ class Fulltext extends \Magento\Core\Model\AbstractModel * @param array $productIds * @param array $categoryIds * - * @return \Magento\CatalogSearch\Model\Fulltext + * @return $this */ public function updateCategoryIndex($productIds, $categoryIds) { diff --git a/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext.php b/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext.php index ceca16d9d7b3005fa8998e826b65b0ae4263f951..aee093f00d468b21f9a2e6c7269afce22427caa1 100644 --- a/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext.php +++ b/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext.php @@ -30,7 +30,26 @@ */ namespace Magento\CatalogSearch\Model\Indexer; -class Fulltext extends \Magento\Index\Model\Indexer\AbstractIndexer +use Magento\App\Config\ValueInterface; +use Magento\Catalog\Model\Category; +use Magento\Catalog\Model\Product; +use Magento\Catalog\Model\ProductFactory; +use Magento\Catalog\Model\Resource\Eav\Attribute; +use Magento\Catalog\Model\Resource\Product\Attribute\CollectionFactory; +use Magento\CatalogSearch\Model\Fulltext as ModelFulltext; +use Magento\CatalogSearch\Model\Resource\Indexer\Fulltext as IndexerFulltext; +use Magento\Core\Model\Context; +use Magento\Core\Model\Registry; +use Magento\Core\Model\Resource\AbstractResource; +use Magento\Core\Model\Store; +use Magento\Core\Model\Store\Group; +use Magento\Core\Model\StoreManagerInterface; +use Magento\Data\Collection\Db; +use Magento\Index\Model\Event; +use Magento\Index\Model\Indexer\AbstractIndexer; +use Magento\Index\Model\Process; + +class Fulltext extends AbstractIndexer { /** * Data key for matching result to be saved in @@ -47,62 +66,62 @@ class Fulltext extends \Magento\Index\Model\Indexer\AbstractIndexer /** * Store manager * - * @var \Magento\Core\Model\StoreManagerInterface + * @var StoreManagerInterface */ protected $_storeManager; /** * Product factory * - * @var \Magento\Catalog\Model\ProductFactory + * @var ProductFactory */ protected $_productFactory; /** * Catalog search fulltext * - * @var \Magento\CatalogSearch\Model\Fulltext + * @var ModelFulltext */ protected $_catalogSearchFulltext; /** * Attribute collection factory * - * @var \Magento\Catalog\Model\Resource\Product\Attribute\CollectionFactory + * @var CollectionFactory */ protected $_attributeCollectionFactory; /** * Catalog search indexer fulltext * - * @var \Magento\CatalogSearch\Model\Resource\Indexer\Fulltext + * @var IndexerFulltext */ protected $_catalogSearchIndexerFulltext; /** * Construct * - * @param \Magento\Core\Model\Context $context - * @param \Magento\Core\Model\Registry $registry - * @param \Magento\CatalogSearch\Model\Resource\Indexer\Fulltext $catalogSearchIndexerFulltext - * @param \Magento\Catalog\Model\Resource\Product\Attribute\CollectionFactory $attributeCollectionFactory - * @param \Magento\CatalogSearch\Model\Fulltext $catalogSearchFulltext - * @param \Magento\Catalog\Model\ProductFactory $productFactory - * @param \Magento\Core\Model\StoreManagerInterface $storeManager - * @param \Magento\Core\Model\Resource\AbstractResource $resource - * @param \Magento\Data\Collection\Db $resourceCollection + * @param Context $context + * @param Registry $registry + * @param IndexerFulltext $catalogSearchIndexerFulltext + * @param CollectionFactory $attributeCollectionFactory + * @param ModelFulltext $catalogSearchFulltext + * @param ProductFactory $productFactory + * @param StoreManagerInterface $storeManager + * @param AbstractResource $resource + * @param Db $resourceCollection * @param array $data */ public function __construct( - \Magento\Core\Model\Context $context, - \Magento\Core\Model\Registry $registry, - \Magento\CatalogSearch\Model\Resource\Indexer\Fulltext $catalogSearchIndexerFulltext, - \Magento\Catalog\Model\Resource\Product\Attribute\CollectionFactory $attributeCollectionFactory, - \Magento\CatalogSearch\Model\Fulltext $catalogSearchFulltext, - \Magento\Catalog\Model\ProductFactory $productFactory, - \Magento\Core\Model\StoreManagerInterface $storeManager, - \Magento\Core\Model\Resource\AbstractResource $resource = null, - \Magento\Data\Collection\Db $resourceCollection = null, + Context $context, + Registry $registry, + IndexerFulltext $catalogSearchIndexerFulltext, + CollectionFactory $attributeCollectionFactory, + ModelFulltext $catalogSearchFulltext, + ProductFactory $productFactory, + StoreManagerInterface $storeManager, + AbstractResource $resource = null, + Db $resourceCollection = null, array $data = array() ) { $this->_catalogSearchIndexerFulltext = $catalogSearchIndexerFulltext; @@ -116,7 +135,7 @@ class Fulltext extends \Magento\Index\Model\Indexer\AbstractIndexer /** * Retrieve resource instance * - * @return \Magento\CatalogSearch\Model\Resource\Indexer\Fulltext + * @return IndexerFulltext */ protected function _getResource() { @@ -129,43 +148,43 @@ class Fulltext extends \Magento\Index\Model\Indexer\AbstractIndexer * @var array */ protected $_matchedEntities = array( - \Magento\Catalog\Model\Product::ENTITY => array( - \Magento\Index\Model\Event::TYPE_SAVE, - \Magento\Index\Model\Event::TYPE_MASS_ACTION, - \Magento\Index\Model\Event::TYPE_DELETE + Product::ENTITY => array( + Event::TYPE_SAVE, + Event::TYPE_MASS_ACTION, + Event::TYPE_DELETE ), - \Magento\Catalog\Model\Resource\Eav\Attribute::ENTITY => array( - \Magento\Index\Model\Event::TYPE_SAVE, - \Magento\Index\Model\Event::TYPE_DELETE, + Attribute::ENTITY => array( + Event::TYPE_SAVE, + Event::TYPE_DELETE, ), - \Magento\Core\Model\Store::ENTITY => array( - \Magento\Index\Model\Event::TYPE_SAVE, - \Magento\Index\Model\Event::TYPE_DELETE + Store::ENTITY => array( + Event::TYPE_SAVE, + Event::TYPE_DELETE ), - \Magento\Core\Model\Store\Group::ENTITY => array( - \Magento\Index\Model\Event::TYPE_SAVE + Group::ENTITY => array( + Event::TYPE_SAVE ), - \Magento\App\Config\ValueInterface::ENTITY => array( - \Magento\Index\Model\Event::TYPE_SAVE + ValueInterface::ENTITY => array( + Event::TYPE_SAVE ), - \Magento\Catalog\Model\Category::ENTITY => array( - \Magento\Index\Model\Event::TYPE_SAVE + Category::ENTITY => array( + Event::TYPE_SAVE ) ); /** * Related Configuration Settings for match * - * @var array + * @var string[] */ protected $_relatedConfigSettings = array( - \Magento\CatalogSearch\Model\Fulltext::XML_PATH_CATALOG_SEARCH_TYPE + ModelFulltext::XML_PATH_CATALOG_SEARCH_TYPE ); /** * Retrieve Fulltext Search instance * - * @return \Magento\CatalogSearch\Model\Fulltext + * @return ModelFulltext */ protected function _getIndexer() { @@ -197,10 +216,10 @@ class Fulltext extends \Magento\Index\Model\Indexer\AbstractIndexer * Overwrote for check is flat catalog product is enabled and specific save * attribute, store, store_group * - * @param \Magento\Index\Model\Event $event + * @param Event $event * @return bool */ - public function matchEvent(\Magento\Index\Model\Event $event) + public function matchEvent(Event $event) { $data = $event->getNewData(); if (isset($data[self::EVENT_MATCH_RESULT_KEY])) { @@ -208,24 +227,24 @@ class Fulltext extends \Magento\Index\Model\Indexer\AbstractIndexer } $entity = $event->getEntity(); - if ($entity == \Magento\Catalog\Model\Resource\Eav\Attribute::ENTITY) { - /* @var $attribute \Magento\Catalog\Model\Resource\Eav\Attribute */ + if ($entity == Attribute::ENTITY) { + /* @var $attribute Attribute */ $attribute = $event->getDataObject(); if (!$attribute) { $result = false; - } elseif ($event->getType() == \Magento\Index\Model\Event::TYPE_SAVE) { + } elseif ($event->getType() == Event::TYPE_SAVE) { $result = $attribute->dataHasChangedFor('is_searchable'); - } elseif ($event->getType() == \Magento\Index\Model\Event::TYPE_DELETE) { + } elseif ($event->getType() == Event::TYPE_DELETE) { $result = $attribute->getIsSearchable(); } else { $result = false; } - } else if ($entity == \Magento\Core\Model\Store::ENTITY) { - if ($event->getType() == \Magento\Index\Model\Event::TYPE_DELETE) { + } else if ($entity == Store::ENTITY) { + if ($event->getType() == Event::TYPE_DELETE) { $result = true; } else { - /* @var $store \Magento\Core\Model\Store */ + /* @var $store Store */ $store = $event->getDataObject(); if ($store && $store->isObjectNew()) { $result = true; @@ -233,15 +252,15 @@ class Fulltext extends \Magento\Index\Model\Indexer\AbstractIndexer $result = false; } } - } else if ($entity == \Magento\Core\Model\Store\Group::ENTITY) { - /* @var $storeGroup \Magento\Core\Model\Store\Group */ + } else if ($entity == Group::ENTITY) { + /* @var $storeGroup Group */ $storeGroup = $event->getDataObject(); if ($storeGroup && $storeGroup->dataHasChangedFor('website_id')) { $result = true; } else { $result = false; } - } else if ($entity == \Magento\App\Config\ValueInterface::ENTITY) { + } else if ($entity == ValueInterface::ENTITY) { $data = $event->getDataObject(); if ($data && in_array($data->getPath(), $this->_relatedConfigSettings)) { $result = $data->isValueChanged(); @@ -260,25 +279,26 @@ class Fulltext extends \Magento\Index\Model\Indexer\AbstractIndexer /** * Register data required by process in event object * - * @param \Magento\Index\Model\Event $event + * @param Event $event + * @return void */ - protected function _registerEvent(\Magento\Index\Model\Event $event) + protected function _registerEvent(Event $event) { $event->addNewData(self::EVENT_MATCH_RESULT_KEY, true); switch ($event->getEntity()) { - case \Magento\Catalog\Model\Product::ENTITY: + case Product::ENTITY: $this->_registerCatalogProductEvent($event); break; - case \Magento\App\Config\ValueInterface::ENTITY: - case \Magento\Core\Model\Store::ENTITY: - case \Magento\Catalog\Model\Resource\Eav\Attribute::ENTITY: - case \Magento\Core\Model\Store\Group::ENTITY: + case ValueInterface::ENTITY: + case Store::ENTITY: + case Attribute::ENTITY: + case Group::ENTITY: $event->addNewData('catalogsearch_fulltext_skip_call_event_handler', true); $process = $event->getProcess(); - $process->changeStatus(\Magento\Index\Model\Process::STATUS_REQUIRE_REINDEX); + $process->changeStatus(Process::STATUS_REQUIRE_REINDEX); break; - case \Magento\Catalog\Model\Category::ENTITY: + case Category::ENTITY: $this->_registerCatalogCategoryEvent($event); break; default: @@ -289,14 +309,14 @@ class Fulltext extends \Magento\Index\Model\Indexer\AbstractIndexer /** * Get data required for category'es products reindex * - * @param \Magento\Index\Model\Event $event - * @return \Magento\CatalogSearch\Model\Indexer\Fulltext + * @param Event $event + * @return $this */ - protected function _registerCatalogCategoryEvent(\Magento\Index\Model\Event $event) + protected function _registerCatalogCategoryEvent(Event $event) { switch ($event->getType()) { - case \Magento\Index\Model\Event::TYPE_SAVE: - /* @var $category \Magento\Catalog\Model\Category */ + case Event::TYPE_SAVE: + /* @var $category Category */ $category = $event->getDataObject(); $productIds = $category->getAffectedProductIds(); if ($productIds) { @@ -320,25 +340,25 @@ class Fulltext extends \Magento\Index\Model\Indexer\AbstractIndexer /** * Register data required by catatalog product process in event object * - * @param \Magento\Index\Model\Event $event - * @return \Magento\CatalogSearch\Model\Indexer\Fulltext + * @param Event $event + * @return $this */ - protected function _registerCatalogProductEvent(\Magento\Index\Model\Event $event) + protected function _registerCatalogProductEvent(Event $event) { switch ($event->getType()) { - case \Magento\Index\Model\Event::TYPE_SAVE: - /* @var $product \Magento\Catalog\Model\Product */ + case Event::TYPE_SAVE: + /* @var $product Product */ $product = $event->getDataObject(); $event->addNewData('catalogsearch_update_product_id', $product->getId()); break; - case \Magento\Index\Model\Event::TYPE_DELETE: - /* @var $product \Magento\Catalog\Model\Product */ + case Event::TYPE_DELETE: + /* @var $product Product */ $product = $event->getDataObject(); $event->addNewData('catalogsearch_delete_product_id', $product->getId()); break; - case \Magento\Index\Model\Event::TYPE_MASS_ACTION: + case Event::TYPE_MASS_ACTION: /* @var $actionObject \Magento\Object */ $actionObject = $event->getDataObject(); @@ -419,9 +439,10 @@ class Fulltext extends \Magento\Index\Model\Indexer\AbstractIndexer /** * Process event * - * @param \Magento\Index\Model\Event $event + * @param Event $event + * @return void */ - protected function _processEvent(\Magento\Index\Model\Event $event) + protected function _processEvent(Event $event) { $data = $event->getNewData(); @@ -500,6 +521,8 @@ class Fulltext extends \Magento\Index\Model\Indexer\AbstractIndexer /** * Rebuild all index data * + * @return void + * @throws \Exception */ public function reindexAll() { diff --git a/app/code/Magento/CatalogSearch/Model/Layer.php b/app/code/Magento/CatalogSearch/Model/Layer.php index 769e3aa535a2394be1b39158ce78569635d530ed..d4df6833c1ae0d140c8315bb1a14d34178d4c2ea 100644 --- a/app/code/Magento/CatalogSearch/Model/Layer.php +++ b/app/code/Magento/CatalogSearch/Model/Layer.php @@ -26,73 +26,90 @@ namespace Magento\CatalogSearch\Model; -class Layer extends \Magento\Catalog\Model\Layer +use Magento\Catalog\Model\CategoryFactory; +use Magento\Catalog\Model\Config; +use Magento\Catalog\Model\Layer\Filter\Attribute as FilterAttribute; +use Magento\Catalog\Model\Layer\StateFactory; +use Magento\Catalog\Model\Layer as ModelLayer; +use Magento\Catalog\Model\Product\Visibility; +use Magento\Catalog\Model\Resource\Product\Attribute\Collection; +use Magento\Catalog\Model\Resource\Product\Attribute\CollectionFactory as AttributeCollectionFactory; +use Magento\Catalog\Model\Resource\Product; +use Magento\CatalogSearch\Helper\Data; +use Magento\CatalogSearch\Model\Query; +use Magento\CatalogSearch\Model\Resource\Fulltext\CollectionFactory; +use Magento\Core\Model\Registry; +use Magento\Core\Model\StoreManagerInterface; +use Magento\Customer\Model\Session; +use Magento\Eav\Model\Entity\Attribute; + +class Layer extends ModelLayer { const XML_PATH_DISPLAY_LAYER_COUNT = 'catalog/search/use_layered_navigation_count'; /** * Catalog search data * - * @var \Magento\CatalogSearch\Helper\Data + * @var Data */ protected $_catalogSearchData = null; /** * Store manager * - * @var \Magento\Core\Model\StoreManagerInterface + * @var StoreManagerInterface */ protected $_storeManager; /** * Catalog config * - * @var \Magento\Catalog\Model\Config + * @var Config */ protected $_catalogConfig; /** * Catalog product visibility * - * @var \Magento\Catalog\Model\Product\Visibility + * @var Visibility */ protected $_catalogProductVisibility; /** * Fulltext collection factory * - * @var \Magento\CatalogSearch\Model\Resource\Fulltext\CollectionFactory + * @var CollectionFactory */ protected $_fulltextCollectionFactory; /** * Construct * - * @param \Magento\Catalog\Model\Layer\StateFactory $layerStateFactory - * @param \Magento\Catalog\Model\CategoryFactory $categoryFactory - * @param \Magento\Catalog\Model\Resource\Product\Attribute\CollectionFactory $attributeCollectionFactory - * @param \Magento\Catalog\Model\Resource\Product $catalogProduct - * @param \Magento\Core\Model\StoreManagerInterface $storeManager - * @param \Magento\Catalog\Model\Product\Visibility $catalogProductVisibility - * @param \Magento\Catalog\Model\Config $catalogConfig - * @param \Magento\Customer\Model\Session $customerSession - * @param \Magento\Core\Model\Registry $coreRegistry - * @param \Magento\CatalogSearch\Model\Resource\Fulltext\CollectionFactory $fulltextCollectionFactory - * @param \Magento\CatalogSearch\Helper\Data $catalogSearchData + * @param StateFactory $layerStateFactory + * @param CategoryFactory $categoryFactory + * @param AttributeCollectionFactory $attributeCollectionFactory + * @param Product $catalogProduct + * @param StoreManagerInterface $storeManager + * @param Visibility $catalogProductVisibility + * @param Config $catalogConfig + * @param Session $customerSession + * @param Registry $coreRegistry + * @param CollectionFactory $fulltextCollectionFactory + * @param Data $catalogSearchData * @param array $data */ public function __construct( - \Magento\Catalog\Model\Layer\StateFactory $layerStateFactory, - \Magento\Catalog\Model\CategoryFactory $categoryFactory, - \Magento\Catalog\Model\Resource\Product\Attribute\CollectionFactory $attributeCollectionFactory, - \Magento\Catalog\Model\Resource\Product $catalogProduct, - \Magento\Core\Model\StoreManagerInterface $storeManager, - \Magento\Catalog\Model\Product\Visibility $catalogProductVisibility, - \Magento\Catalog\Model\Config $catalogConfig, - \Magento\Customer\Model\Session $customerSession, - \Magento\Core\Model\Registry $coreRegistry, - \Magento\CatalogSearch\Model\Resource\Fulltext\CollectionFactory $fulltextCollectionFactory, - \Magento\CatalogSearch\Helper\Data $catalogSearchData, + StateFactory $layerStateFactory, + CategoryFactory $categoryFactory, + AttributeCollectionFactory $attributeCollectionFactory, + Product $catalogProduct, + StoreManagerInterface $storeManager, + Visibility $catalogProductVisibility, + Config $catalogConfig, + Session $customerSession, + Registry $coreRegistry, + CollectionFactory $fulltextCollectionFactory, + Data $catalogSearchData, array $data = array() ) { $this->_fulltextCollectionFactory = $fulltextCollectionFactory; @@ -107,7 +124,7 @@ class Layer extends \Magento\Catalog\Model\Layer /** * Get current layer product collection * - * @return \Magento\Catalog\Model\Resource\Product\Attribute\Collection + * @return Collection */ public function getProductCollection() { @@ -124,8 +141,8 @@ class Layer extends \Magento\Catalog\Model\Layer /** * Prepare product collection * - * @param \Magento\Catalog\Model\Resource\Product\Attribute\Collection $collection - * @return \Magento\Catalog\Model\Layer + * @param Collection $collection + * @return $this */ public function prepareProductCollection($collection) { @@ -166,15 +183,15 @@ class Layer extends \Magento\Catalog\Model\Layer public function getStateTags(array $additionalTags = array()) { $additionalTags = parent::getStateTags($additionalTags); - $additionalTags[] = \Magento\CatalogSearch\Model\Query::CACHE_TAG; + $additionalTags[] = Query::CACHE_TAG; return $additionalTags; } /** * Add filters to attribute collection * - * @param \Magento\Catalog\Model\Resource\Product\Attribute\Collection $collection - * @return \Magento\Catalog\Model\Resource\Product\Attribute\Collection + * @param Collection $collection + * @return Collection */ protected function _prepareAttributeCollection($collection) { @@ -186,13 +203,13 @@ class Layer extends \Magento\Catalog\Model\Layer /** * Prepare attribute for use in layered navigation * - * @param \Magento\Eav\Model\Entity\Attribute $attribute - * @return \Magento\Eav\Model\Entity\Attribute + * @param Attribute $attribute + * @return Attribute */ protected function _prepareAttribute($attribute) { $attribute = parent::_prepareAttribute($attribute); - $attribute->setIsFilterable(\Magento\Catalog\Model\Layer\Filter\Attribute::OPTIONS_ONLY_WITH_RESULTS); + $attribute->setIsFilterable(FilterAttribute::OPTIONS_ONLY_WITH_RESULTS); return $attribute; } } diff --git a/app/code/Magento/CatalogSearch/Model/Query.php b/app/code/Magento/CatalogSearch/Model/Query.php index afccb9331ad9969cd67976e956cafbbfccefc23b..6a01bcdae0f2f3af77039f5fbe15a23a28ffaa20 100644 --- a/app/code/Magento/CatalogSearch/Model/Query.php +++ b/app/code/Magento/CatalogSearch/Model/Query.php @@ -54,7 +54,20 @@ */ namespace Magento\CatalogSearch\Model; -class Query extends \Magento\Core\Model\AbstractModel +use Magento\CatalogSearch\Model\Resource\Query\Collection as QueryCollection; +use Magento\CatalogSearch\Model\Resource\Query\CollectionFactory as QueryCollectionFactory; +use Magento\CatalogSearch\Model\Resource\Search\Collection; +use Magento\CatalogSearch\Model\Resource\Search\CollectionFactory; +use Magento\Core\Model\AbstractModel; +use Magento\Core\Model\Context; +use Magento\Core\Model\Registry; +use Magento\Core\Model\Resource\AbstractResource; +use Magento\Core\Model\Store\Config; +use Magento\Core\Model\StoreManagerInterface; +use Magento\Data\Collection\Db; +use Magento\Eav\Model\Entity\Collection\AbstractCollection; + +class Query extends AbstractModel { /** * Event prefix @@ -78,53 +91,53 @@ class Query extends \Magento\Core\Model\AbstractModel /** * Core store config * - * @var \Magento\Core\Model\Store\Config + * @var Config */ protected $_coreStoreConfig; /** * Store manager * - * @var \Magento\Core\Model\StoreManagerInterface + * @var StoreManagerInterface */ protected $_storeManager; /** * Search collection factory * - * @var \Magento\CatalogSearch\Model\Resource\Search\CollectionFactory + * @var CollectionFactory */ protected $_searchCollectionFactory; /** * Query collection factory * - * @var \Magento\CatalogSearch\Model\Resource\Query\CollectionFactory + * @var QueryCollectionFactory */ protected $_queryCollectionFactory; /** * Construct * - * @param \Magento\Core\Model\Context $context - * @param \Magento\Core\Model\Registry $registry - * @param \Magento\CatalogSearch\Model\Resource\Query\CollectionFactory $queryCollectionFactory - * @param \Magento\CatalogSearch\Model\Resource\Search\CollectionFactory $searchCollectionFactory - * @param \Magento\Core\Model\StoreManagerInterface $storeManager - * @param \Magento\Core\Model\Store\Config $coreStoreConfig - * @param \Magento\Core\Model\Resource\AbstractResource $resource - * @param \Magento\Data\Collection\Db $resourceCollection + * @param Context $context + * @param Registry $registry + * @param QueryCollectionFactory $queryCollectionFactory + * @param CollectionFactory $searchCollectionFactory + * @param StoreManagerInterface $storeManager + * @param Config $coreStoreConfig + * @param AbstractResource $resource + * @param Db $resourceCollection * @param array $data */ public function __construct( - \Magento\Core\Model\Context $context, - \Magento\Core\Model\Registry $registry, - \Magento\CatalogSearch\Model\Resource\Query\CollectionFactory $queryCollectionFactory, - \Magento\CatalogSearch\Model\Resource\Search\CollectionFactory $searchCollectionFactory, - \Magento\Core\Model\StoreManagerInterface $storeManager, - \Magento\Core\Model\Store\Config $coreStoreConfig, - \Magento\Core\Model\Resource\AbstractResource $resource = null, - \Magento\Data\Collection\Db $resourceCollection = null, + Context $context, + Registry $registry, + QueryCollectionFactory $queryCollectionFactory, + CollectionFactory $searchCollectionFactory, + StoreManagerInterface $storeManager, + Config $coreStoreConfig, + AbstractResource $resource = null, + Db $resourceCollection = null, array $data = array() ) { $this->_queryCollectionFactory = $queryCollectionFactory; @@ -146,7 +159,7 @@ class Query extends \Magento\Core\Model\AbstractModel /** * Retrieve search collection * - * @return \Magento\CatalogSearch\Model\Resource\Search\Collection + * @return Collection */ public function getSearchCollection() { @@ -156,7 +169,7 @@ class Query extends \Magento\Core\Model\AbstractModel /** * Retrieve collection of search results * - * @return \Magento\Eav\Model\Entity\Collection\AbstractCollection + * @return AbstractCollection */ public function getResultCollection() { @@ -181,7 +194,7 @@ class Query extends \Magento\Core\Model\AbstractModel /** * Retrieve collection of suggest queries * - * @return \Magento\CatalogSearch\Model\Resource\Query\Collection + * @return QueryCollection */ public function getSuggestCollection() { @@ -199,7 +212,7 @@ class Query extends \Magento\Core\Model\AbstractModel * Load Query object by query string * * @param string $text - * @return \Magento\CatalogSearch\Model\Query + * @return $this */ public function loadByQuery($text) { @@ -213,7 +226,7 @@ class Query extends \Magento\Core\Model\AbstractModel * Load Query object only by query text (skip 'synonym For') * * @param string $text - * @return \Magento\CatalogSearch\Model\Query + * @return $this */ public function loadByQueryText($text) { @@ -227,7 +240,7 @@ class Query extends \Magento\Core\Model\AbstractModel * Set Store Id * * @param int $storeId - * @return \Magento\CatalogSearch\Model\Query + * @return void */ public function setStoreId($storeId) { @@ -250,7 +263,7 @@ class Query extends \Magento\Core\Model\AbstractModel /** * Prepare save query for result * - * @return \Magento\CatalogSearch\Model\Query + * @return $this */ public function prepare() { diff --git a/app/code/Magento/CatalogSearch/Model/Resource/Advanced.php b/app/code/Magento/CatalogSearch/Model/Resource/Advanced.php index 17ef3520b478797601900961de945258741fc2f3..b11dc5749bc05efbe080e764ef040820d133390f 100644 --- a/app/code/Magento/CatalogSearch/Model/Resource/Advanced.php +++ b/app/code/Magento/CatalogSearch/Model/Resource/Advanced.php @@ -23,7 +23,7 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ - +namespace Magento\CatalogSearch\Model\Resource; /** * Advanced Catalog Search resource model @@ -32,8 +32,6 @@ * @package Magento_CatalogSearch * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\CatalogSearch\Model\Resource; - class Advanced extends \Magento\Core\Model\Resource\Db\AbstractDb { /** @@ -70,6 +68,7 @@ class Advanced extends \Magento\Core\Model\Resource\Db\AbstractDb /** * Initialize connection and define catalog product table as main table * + * @return void */ protected function _construct() { @@ -108,7 +107,7 @@ class Advanced extends \Magento\Core\Model\Resource\Db\AbstractDb * @param \Magento\Catalog\Model\Resource\Eav\Attribute $attribute * @param string|array $value * @param \Magento\CatalogSearch\Model\Resource\Advanced\Collection $collection - * @return mixed + * @return string|array */ public function prepareCondition($attribute, $value, $collection) { diff --git a/app/code/Magento/CatalogSearch/Model/Resource/Advanced/Collection.php b/app/code/Magento/CatalogSearch/Model/Resource/Advanced/Collection.php index 7a3244fb6a905010ea62dc606e86db8aa5722d38..0d3ed7fd4e3fd732313c1cf16f25a1bb66b9132c 100644 --- a/app/code/Magento/CatalogSearch/Model/Resource/Advanced/Collection.php +++ b/app/code/Magento/CatalogSearch/Model/Resource/Advanced/Collection.php @@ -23,7 +23,9 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\CatalogSearch\Model\Resource\Advanced; +use Magento\Core\Exception; /** * Collection Advanced @@ -32,8 +34,6 @@ * @package Magento_CatalogSearch * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\CatalogSearch\Model\Resource\Advanced; - class Collection extends \Magento\Catalog\Model\Resource\Product\Collection { /** @@ -63,7 +63,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Product\Collection * @param \Magento\Customer\Model\Session $customerSession * @param \Magento\Stdlib\DateTime $dateTime * @param \Magento\Core\Model\Date $date - * @param mixed $connection + * @param \Zend_Db_Adapter_Abstract $connection * * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ @@ -117,8 +117,8 @@ class Collection extends \Magento\Catalog\Model\Resource\Product\Collection * Add not indexable fields to search * * @param array $fields - * @return \Magento\CatalogSearch\Model\Resource\Advanced\Collection - * @throws \Magento\Core\Exception + * @return $this + * @throws Exception */ public function addFieldsToFilter($fields) { @@ -174,7 +174,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Product\Collection $invalidDateMessage = __('Please specify correct data.'); if ($conditionValue['from']) { if (!\Zend_Date::isDate($conditionValue['from'])) { - throw new \Magento\Core\Exception($invalidDateMessage); + throw new Exception($invalidDateMessage); } if (!is_numeric($conditionValue['from'])){ $conditionValue['from'] = $this->_date->gmtDate(null, $conditionValue['from']); @@ -186,7 +186,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Product\Collection } if ($conditionValue['to']) { if (!\Zend_Date::isDate($conditionValue['to'])) { - throw new \Magento\Core\Exception($invalidDateMessage); + throw new Exception($invalidDateMessage); } if (!is_numeric($conditionValue['to'])){ $conditionValue['to'] = $this->_date->gmtDate(null, $conditionValue['to']); diff --git a/app/code/Magento/CatalogSearch/Model/Resource/Fulltext.php b/app/code/Magento/CatalogSearch/Model/Resource/Fulltext.php index d923b0060f7ebb7c5f341fff7b376495dc26fa22..511cd415bf202bbf0d13b67a4f5e5eb4f248600a 100644 --- a/app/code/Magento/CatalogSearch/Model/Resource/Fulltext.php +++ b/app/code/Magento/CatalogSearch/Model/Resource/Fulltext.php @@ -23,7 +23,6 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ - namespace Magento\CatalogSearch\Model\Resource; /** @@ -192,6 +191,7 @@ class Fulltext extends \Magento\Core\Model\Resource\Db\AbstractDb /** * Init resource model * + * @return void */ protected function _construct() { @@ -211,9 +211,9 @@ class Fulltext extends \Magento\Core\Model\Resource\Db\AbstractDb /** * Regenerate search index for store(s) * - * @param int|null $storeId - * @param int|array|null $productIds - * @return \Magento\CatalogSearch\Model\Resource\Fulltext + * @param int|null $storeId + * @param int|array|null $productIds + * @return $this */ public function rebuildIndex($storeId = null, $productIds = null) { @@ -234,7 +234,7 @@ class Fulltext extends \Magento\Core\Model\Resource\Db\AbstractDb * * @param int $storeId Store View Id * @param int|array $productIds Product Entity Id - * @return \Magento\CatalogSearch\Model\Resource\Fulltext + * @return $this */ protected function _rebuildStoreIndex($storeId, $productIds = null) { @@ -381,7 +381,7 @@ class Fulltext extends \Magento\Core\Model\Resource\Db\AbstractDb * * @param null|int $storeId * @param null|array $productIds - * @return \Magento\CatalogSearch\Model\Resource\Fulltext + * @return $this */ public function resetSearchResults($storeId = null, $productIds = null) { @@ -437,7 +437,7 @@ class Fulltext extends \Magento\Core\Model\Resource\Db\AbstractDb * * @param int $storeId Store View Id * @param int $productId Product Entity Id - * @return \Magento\CatalogSearch\Model\Resource\Fulltext + * @return $this */ public function cleanIndex($storeId = null, $productId = null) { @@ -454,7 +454,7 @@ class Fulltext extends \Magento\Core\Model\Resource\Db\AbstractDb * @param \Magento\CatalogSearch\Model\Fulltext $object * @param string $queryText * @param \Magento\CatalogSearch\Model\Query $query - * @return \Magento\CatalogSearch\Model\Resource\Fulltext + * @return $this */ public function prepareResult($object, $queryText, $query) { @@ -691,7 +691,7 @@ class Fulltext extends \Magento\Core\Model\Resource\Db\AbstractDb * * @param int $productId Product Entity Id * @param string $typeId Super Product Link Type - * @return array + * @return array|null */ protected function _getProductChildIds($productId, $typeId) { @@ -862,7 +862,7 @@ class Fulltext extends \Magento\Core\Model\Resource\Db\AbstractDb * @param int $productId * @param int $storeId * @param string $index - * @return \Magento\CatalogSearch\Model\Resource\Fulltext + * @return $this */ protected function _saveProductIndex($productId, $storeId, $index) { @@ -878,7 +878,7 @@ class Fulltext extends \Magento\Core\Model\Resource\Db\AbstractDb * * @param int $storeId * @param array $productIndexes - * @return \Magento\CatalogSearch\Model\Resource\Fulltext + * @return $this */ protected function _saveProductIndexes($storeId, $productIndexes) { @@ -894,7 +894,7 @@ class Fulltext extends \Magento\Core\Model\Resource\Db\AbstractDb * * @param int $storeId * @param string $date - * @return string + * @return string|null */ protected function _getStoreDate($storeId, $date = null) { @@ -926,11 +926,11 @@ class Fulltext extends \Magento\Core\Model\Resource\Db\AbstractDb /** * Update category products indexes * - * deprecated after 1.6.2.0 + * @deprecated after 1.6.2.0 * * @param array $productIds * @param array $categoryIds - * @return \Magento\CatalogSearch\Model\Resource\Fulltext + * @return $this */ public function updateCategoryIndex($productIds, $categoryIds) { diff --git a/app/code/Magento/CatalogSearch/Model/Resource/Fulltext/Collection.php b/app/code/Magento/CatalogSearch/Model/Resource/Fulltext/Collection.php index fdfaa6d99f2a2c273d8e204942f40c61f5c27efb..42d43f09add31d6ec7e0240c88eae8584992fbbe 100644 --- a/app/code/Magento/CatalogSearch/Model/Resource/Fulltext/Collection.php +++ b/app/code/Magento/CatalogSearch/Model/Resource/Fulltext/Collection.php @@ -23,7 +23,7 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ - +namespace Magento\CatalogSearch\Model\Resource\Fulltext; /** * Fulltext Collection @@ -32,8 +32,6 @@ * @package Magento_CatalogSearch * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\CatalogSearch\Model\Resource\Fulltext; - class Collection extends \Magento\Catalog\Model\Resource\Product\Collection { /** @@ -71,7 +69,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Product\Collection * @param \Magento\Stdlib\DateTime $dateTime * @param \Magento\CatalogSearch\Helper\Data $catalogSearchData * @param \Magento\CatalogSearch\Model\Fulltext $catalogSearchFulltext - * @param mixed $connection + * @param \Zend_Db_Adapter_Abstract $connection * * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ @@ -137,7 +135,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Product\Collection * Add search query filter * * @param string $query - * @return \Magento\CatalogSearch\Model\Resource\Fulltext\Collection + * @return $this */ public function addSearchFilter($query) { @@ -160,7 +158,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Product\Collection * * @param string $attribute * @param string $dir - * @return \Magento\CatalogSearch\Model\Resource\Fulltext\Collection + * @return $this */ public function setOrder($attribute, $dir = 'desc') { @@ -175,7 +173,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Product\Collection /** * Stub method for campatibility with other search engines * - * @return \Magento\CatalogSearch\Model\Resource\Fulltext\Collection + * @return $this */ public function setGeneralDefaultQuery() { diff --git a/app/code/Magento/CatalogSearch/Model/Resource/Fulltext/Engine.php b/app/code/Magento/CatalogSearch/Model/Resource/Fulltext/Engine.php index 7b3c61ec31ab27bc692dffba9a5768a111bc0097..e097d1b10a02349cfc4f74a735482787ea940f7a 100644 --- a/app/code/Magento/CatalogSearch/Model/Resource/Fulltext/Engine.php +++ b/app/code/Magento/CatalogSearch/Model/Resource/Fulltext/Engine.php @@ -23,7 +23,7 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ - +namespace Magento\CatalogSearch\Model\Resource\Fulltext; /** * CatalogSearch Fulltext Index Engine resource model @@ -32,8 +32,6 @@ * @package Magento_CatalogSearch * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\CatalogSearch\Model\Resource\Fulltext; - class Engine extends \Magento\Core\Model\Resource\Db\AbstractDb implements \Magento\CatalogSearch\Model\Resource\EngineInterface { @@ -117,6 +115,7 @@ class Engine extends \Magento\Core\Model\Resource\Db\AbstractDb /** * Init resource model * + * @return void */ protected function _construct() { @@ -130,7 +129,7 @@ class Engine extends \Magento\Core\Model\Resource\Db\AbstractDb * @param int $storeId * @param array $index * @param string $entity 'product'|'cms' - * @return \Magento\CatalogSearch\Model\Resource\Fulltext\Engine + * @return $this */ public function saveEntityIndex($entityId, $storeId, $index, $entity = 'product') { @@ -148,7 +147,7 @@ class Engine extends \Magento\Core\Model\Resource\Db\AbstractDb * @param int $storeId * @param array $entityIndexes * @param string $entity 'product'|'cms' - * @return \Magento\CatalogSearch\Model\Resource\Fulltext\Engine + * @return $this */ public function saveEntityIndexes($storeId, $entityIndexes, $entity = 'product') { @@ -172,7 +171,7 @@ class Engine extends \Magento\Core\Model\Resource\Db\AbstractDb /** * Retrieve allowed visibility values for current engine * - * @return array + * @return int[] */ public function getAllowedVisibility() { @@ -195,7 +194,7 @@ class Engine extends \Magento\Core\Model\Resource\Db\AbstractDb * @param int $storeId * @param int $entityId * @param string $entity 'product'|'cms' - * @return \Magento\CatalogSearch\Model\Resource\Fulltext\Engine + * @return $this */ public function cleanIndex($storeId = null, $entityId = null, $entity = 'product') { diff --git a/app/code/Magento/CatalogSearch/Model/Resource/Helper.php b/app/code/Magento/CatalogSearch/Model/Resource/Helper.php index 3e98407a3c8f6e348455d9883d7e905dab2ce029..8129ec6b3273e6319bd79b400238eb3a9ba59d0a 100644 --- a/app/code/Magento/CatalogSearch/Model/Resource/Helper.php +++ b/app/code/Magento/CatalogSearch/Model/Resource/Helper.php @@ -23,7 +23,7 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ - +namespace Magento\CatalogSearch\Model\Resource; /** * CatalogSearch Mysql resource helper model @@ -32,8 +32,6 @@ * @package Magento_Catalog * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\CatalogSearch\Model\Resource; - class Helper extends \Magento\Eav\Model\Resource\Helper { /** @@ -52,8 +50,8 @@ class Helper extends \Magento\Eav\Model\Resource\Helper * * @param string $table * @param string $alias - * @param \Magento\DB\Select $select - * @return \Magento\DB\Select $select + * @param \Magento\DB\Select $select + * @return \Zend_Db_Expr */ public function chooseFulltext($table, $alias, $select) { diff --git a/app/code/Magento/CatalogSearch/Model/Resource/Indexer/Fulltext.php b/app/code/Magento/CatalogSearch/Model/Resource/Indexer/Fulltext.php index dd6aad641dc8df85802f796e1e22f399ec0de661..203bf67faf6844f230f27d399d923a3d81f041cd 100644 --- a/app/code/Magento/CatalogSearch/Model/Resource/Indexer/Fulltext.php +++ b/app/code/Magento/CatalogSearch/Model/Resource/Indexer/Fulltext.php @@ -23,7 +23,7 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ - +namespace Magento\CatalogSearch\Model\Resource\Indexer; /** * CatalogSearch fulltext indexer resource model @@ -32,12 +32,12 @@ * @package Magento_CatalogSearch * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\CatalogSearch\Model\Resource\Indexer; - class Fulltext extends \Magento\Core\Model\Resource\Db\AbstractDb { /** * Initialize connection and define catalog product table as main table + * + * @return void */ protected function _construct() { diff --git a/app/code/Magento/CatalogSearch/Model/Resource/Query.php b/app/code/Magento/CatalogSearch/Model/Resource/Query.php index 578c87a0da7706618c1f18fb8834704d37b17ea7..4fb3aee4d556dfadfd5582c8e808cd52cd42fc4d 100644 --- a/app/code/Magento/CatalogSearch/Model/Resource/Query.php +++ b/app/code/Magento/CatalogSearch/Model/Resource/Query.php @@ -23,7 +23,9 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\CatalogSearch\Model\Resource; +use Magento\Core\Model\Resource\Db\AbstractDb; /** * Catalog search query resource model @@ -32,9 +34,7 @@ * @package Magento_CatalogSearch * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\CatalogSearch\Model\Resource; - -class Query extends \Magento\Core\Model\Resource\Db\AbstractDb +class Query extends AbstractDb { /** * Date @@ -65,6 +65,8 @@ class Query extends \Magento\Core\Model\Resource\Db\AbstractDb /** * Init resource data + * + * @return void */ protected function _construct() { @@ -76,7 +78,7 @@ class Query extends \Magento\Core\Model\Resource\Db\AbstractDb * * @param \Magento\Core\Model\AbstractModel $object * @param string $value - * @return \Magento\CatalogSearch\Model\Resource\Query + * @return $this */ public function loadByQuery(\Magento\Core\Model\AbstractModel $object, $value) { @@ -100,7 +102,7 @@ class Query extends \Magento\Core\Model\Resource\Db\AbstractDb * * @param \Magento\Core\Model\AbstractModel $object * @param string $value - * @return \Magento\CatalogSearch\Model\Resource\Query + * @return $this */ public function loadByQueryText(\Magento\Core\Model\AbstractModel $object, $value) { @@ -123,7 +125,7 @@ class Query extends \Magento\Core\Model\Resource\Db\AbstractDb * @param \Magento\Core\Model\AbstractModel $object * @param int|string $value * @param null|string $field - * @return \Magento\CatalogSearch\Model\Resource\Query + * @return $this|AbstractDb */ public function load(\Magento\Core\Model\AbstractModel $object, $value, $field = null) { @@ -137,7 +139,7 @@ class Query extends \Magento\Core\Model\Resource\Db\AbstractDb /** * @param \Magento\Core\Model\AbstractModel $object - * @return \Magento\CatalogSearch\Model\Resource\Query + * @return $this */ public function _beforeSave(\Magento\Core\Model\AbstractModel $object) { diff --git a/app/code/Magento/CatalogSearch/Model/Resource/Query/Collection.php b/app/code/Magento/CatalogSearch/Model/Resource/Query/Collection.php index ec68c024aca5d7f9c3523c9a79746b6335db79c3..e8abac3f255ec2657ac3f3ae81ecf5f0c554fe97 100644 --- a/app/code/Magento/CatalogSearch/Model/Resource/Query/Collection.php +++ b/app/code/Magento/CatalogSearch/Model/Resource/Query/Collection.php @@ -23,7 +23,9 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\CatalogSearch\Model\Resource\Query; +use Magento\Core\Model\Store; /** * Catalog search query collection @@ -32,8 +34,6 @@ * @package Magento_CatalogSearch * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\CatalogSearch\Model\Resource\Query; - class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractCollection { /** @@ -64,7 +64,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl * @param \Magento\Event\ManagerInterface $eventManager * @param \Magento\Core\Model\StoreManagerInterface $storeManager * @param \Magento\CatalogSearch\Model\Resource\Helper $resourceHelper - * @param mixed $connection + * @param \Zend_Db_Adapter_Abstract $connection * @param \Magento\Core\Model\Resource\Db\AbstractDb $resource */ public function __construct( @@ -85,6 +85,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl /** * Init model for collection * + * @return void */ protected function _construct() { @@ -94,12 +95,12 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl /** * Set Store ID for filter * - * @param mixed $store - * @return \Magento\CatalogSearch\Model\Resource\Query\Collection + * @param Store|int $store + * @return $this */ public function setStoreId($store) { - if ($store instanceof \Magento\Core\Model\Store) { + if ($store instanceof Store) { $store = $store->getId(); } $this->_storeId = $store; @@ -120,7 +121,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl * Set search query text to filter * * @param string $query - * @return \Magento\CatalogSearch\Model\Resource\Query\Collection + * @return $this */ public function setQueryFilter($query) { @@ -145,7 +146,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl * Set Popular Search Query Filter * * @param int|array $storeIds - * @return \Magento\CatalogSearch\Model\Resource\Query\Collection + * @return $this */ public function setPopularQueryFilter($storeIds = null) { @@ -177,7 +178,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl /** * Set Recent Queries Order * - * @return \Magento\CatalogSearch\Model\Resource\Query\Collection + * @return $this */ public function setRecentQueryFilter() { @@ -189,7 +190,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl * Filter collection by specified store ids * * @param array|int $storeIds - * @return \Magento\CatalogSearch\Model\Resource\Query\Collection + * @return $this */ public function addStoreFilter($storeIds) { diff --git a/app/code/Magento/CatalogSearch/Model/Resource/Search/Collection.php b/app/code/Magento/CatalogSearch/Model/Resource/Search/Collection.php index 9fdc928199492d88d3f5410bd7912b7300fe8d28..9ec480f17715c5210e7101a7bb925c4ad7b9dd7c 100644 --- a/app/code/Magento/CatalogSearch/Model/Resource/Search/Collection.php +++ b/app/code/Magento/CatalogSearch/Model/Resource/Search/Collection.php @@ -23,7 +23,7 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ - +namespace Magento\CatalogSearch\Model\Resource\Search; /** * Search collection @@ -32,8 +32,6 @@ * @package Magento_CatalogSearch * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\CatalogSearch\Model\Resource\Search; - class Collection extends \Magento\Catalog\Model\Resource\Product\Collection { /** @@ -77,7 +75,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Product\Collection * @param \Magento\Customer\Model\Session $customerSession * @param \Magento\Stdlib\DateTime $dateTime * @param \Magento\Catalog\Model\Resource\Product\Attribute\CollectionFactory $attributeCollectionFactory - * @param mixed $connection + * @param \Zend_Db_Adapter_Abstract $connection * * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ @@ -131,7 +129,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Product\Collection * Add search query filter * * @param string $query - * @return \Magento\CatalogSearch\Model\Resource\Search\Collection + * @return $this */ public function addSearchFilter($query) { @@ -193,7 +191,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Product\Collection /** * Retrieve SQL for search entities * - * @param unknown_type $query + * @param mixed $query * @return string */ protected function _getSearchEntityIdsSql($query) @@ -243,7 +241,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Product\Collection $sql = $this->_getSearchInOptionSql($query); if ($sql) { - $selects[] = "SELECT * FROM ({$sql}) AS inoptionsql"; // inheritant unions may be inside + $selects[] = "SELECT * FROM ({$sql}) AS inoptionsql"; // inherent unions may be inside } $sql = $this->getConnection()->select()->union($selects, \Zend_Db_Select::SQL_UNION_ALL); @@ -253,7 +251,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Product\Collection /** * Retrieve SQL for search entities by option * - * @param unknown_type $query + * @param mixed $query * @return string */ protected function _getSearchInOptionSql($query) diff --git a/app/code/Magento/Checkout/Controller/Onepage.php b/app/code/Magento/Checkout/Controller/Onepage.php index 5e0eb30d8633782c8b8c8e7dd51127ff39f9a0ae..6c9145018c56b3d2ca9e285af8c5ee02d24868a4 100644 --- a/app/code/Magento/Checkout/Controller/Onepage.php +++ b/app/code/Magento/Checkout/Controller/Onepage.php @@ -52,6 +52,11 @@ class Onepage extends \Magento\Checkout\Controller\Action */ protected $_coreRegistry = null; + /** + * @var \Magento\Translate\InlineInterface + */ + protected $_translateInline; + /** * @var \Magento\Core\App\Action\FormKeyValidator */ @@ -61,15 +66,18 @@ class Onepage extends \Magento\Checkout\Controller\Action * @param \Magento\App\Action\Context $context * @param \Magento\Customer\Model\Session $customerSession * @param \Magento\Core\Model\Registry $coreRegistry + * @param \Magento\Translate\InlineInterface $translateInline, * @param \Magento\Core\App\Action\FormKeyValidator $formKeyValidator */ public function __construct( \Magento\App\Action\Context $context, \Magento\Customer\Model\Session $customerSession, \Magento\Core\Model\Registry $coreRegistry, + \Magento\Translate\InlineInterface $translateInline, \Magento\Core\App\Action\FormKeyValidator $formKeyValidator ) { $this->_coreRegistry = $coreRegistry; + $this->_translateInline = $translateInline; $this->_formKeyValidator = $formKeyValidator; parent::__construct($context, $customerSession); } @@ -86,10 +94,10 @@ class Onepage extends \Magento\Checkout\Controller\Action $this->_request = $request; $this->_preDispatchValidateCustomer(); - $checkoutSessionQuote = $this->_objectManager->get('Magento\Checkout\Model\Session')->getQuote(); - if ($checkoutSessionQuote->getIsMultiShipping()) { - $checkoutSessionQuote->setIsMultiShipping(false); - $checkoutSessionQuote->removeAllAddresses(); + /** @var \Magento\Sales\Model\Quote $quote */ + $quote = $this->_objectManager->get('Magento\Checkout\Model\Session')->getQuote(); + if ($quote->isMultipleShippingAddresses()) { + $quote->removeAllAddresses(); } if (!$this->_canShowForUnregisteredUsers()) { @@ -118,7 +126,6 @@ class Onepage extends \Magento\Checkout\Controller\Action { if (!$this->getOnepage()->getQuote()->hasItems() || $this->getOnepage()->getQuote()->getHasError() - || $this->getOnepage()->getQuote()->getIsMultiShipping() ) { $this->_ajaxRedirectResponse(); return true; @@ -147,7 +154,7 @@ class Onepage extends \Magento\Checkout\Controller\Action $layout->generateXml(); $layout->generateElements(); $output = $layout->getOutput(); - $this->_objectManager->get('Magento\Core\Model\Translate')->processResponseBody($output); + $this->_translateInline->processResponseBody($output); return $output; } diff --git a/app/code/Magento/Checkout/Helper/Data.php b/app/code/Magento/Checkout/Helper/Data.php index 3f637af2e7104f22fc5cb553247e67bbc373c875..af1aceffc2685d798a3ea3537a68e0baf514bd46 100644 --- a/app/code/Magento/Checkout/Helper/Data.php +++ b/app/code/Magento/Checkout/Helper/Data.php @@ -70,6 +70,13 @@ class Data extends \Magento\App\Helper\AbstractHelper */ protected $_emailTemplFactory; + /** + * Translator model + * + * @var \Magento\TranslateInterface + */ + protected $_translator; + /** * @param \Magento\App\Helper\Context $context * @param \Magento\Core\Model\Store\Config $coreStoreConfig @@ -78,6 +85,7 @@ class Data extends \Magento\App\Helper\AbstractHelper * @param \Magento\Core\Model\LocaleInterface $locale * @param \Magento\Checkout\Model\Resource\Agreement\CollectionFactory $agreementCollectionFactory * @param \Magento\Email\Model\TemplateFactory $emailTemplFactory + * @param \Magento\TranslateInterface $translator */ public function __construct( \Magento\App\Helper\Context $context, @@ -86,7 +94,8 @@ class Data extends \Magento\App\Helper\AbstractHelper \Magento\Checkout\Model\Session $checkoutSession, \Magento\Core\Model\LocaleInterface $locale, \Magento\Checkout\Model\Resource\Agreement\CollectionFactory $agreementCollectionFactory, - \Magento\Email\Model\TemplateFactory $emailTemplFactory + \Magento\Email\Model\TemplateFactory $emailTemplFactory, + \Magento\TranslateInterface $translator ) { $this->_coreStoreConfig = $coreStoreConfig; $this->_storeManager = $storeManager; @@ -94,6 +103,7 @@ class Data extends \Magento\App\Helper\AbstractHelper $this->_locale = $locale; $this->_agreementCollectionFactory = $agreementCollectionFactory; $this->_emailTemplFactory = $emailTemplFactory; + $this->_translator = $translator; parent::__construct($context); } diff --git a/app/code/Magento/Checkout/Model/Type/Onepage.php b/app/code/Magento/Checkout/Model/Type/Onepage.php index df09ffeff599a8a84240a295803703aa87bbb175..84d88f364eba3808d7c63b590506078e79ea2ef0 100644 --- a/app/code/Magento/Checkout/Model/Type/Onepage.php +++ b/app/code/Magento/Checkout/Model/Type/Onepage.php @@ -243,13 +243,10 @@ class Onepage } } - /** - * Reset multishipping flag before any manipulations with quote address - * addAddress method for quote object related on this flag - */ - if ($this->getQuote()->getIsMultiShipping()) { - $this->getQuote()->setIsMultiShipping(false); - $this->getQuote()->save(); + $quote = $this->getQuote(); + if ($quote->isMultipleShippingAddresses()) { + $quote->removeAllAddresses(); + $quote->save(); } /* @@ -258,7 +255,7 @@ class Onepage */ $customer = $customerSession->getCustomer(); if ($customer) { - $this->getQuote()->assignCustomer($customer); + $quote->assignCustomer($customer); } return $this; } @@ -660,12 +657,15 @@ class Onepage /** * Validate quote state to be integrated with one page checkout process + * + * @throws \Magento\Core\Exception */ - public function validate() + protected function validate() { - $quote = $this->getQuote(); - if ($quote->getIsMultiShipping()) { - throw new \Magento\Core\Exception(__('Invalid checkout type')); + $quote = $this->getQuote(); + + if ($quote->isMultipleShippingAddresses()) { + throw new \Magento\Core\Exception(__('There are more than one shipping address.')); } if ($quote->getCheckoutMethod() == self::METHOD_GUEST diff --git a/app/code/Magento/Cms/Block/Widget/Page/Link.php b/app/code/Magento/Cms/Block/Widget/Page/Link.php index 4d899ad640116757b2755ddbc1c5603f2f8f3a4d..e0f49577bbce55f4330f7ffd52b9fbae42a9afe8 100644 --- a/app/code/Magento/Cms/Block/Widget/Page/Link.php +++ b/app/code/Magento/Cms/Block/Widget/Page/Link.php @@ -139,7 +139,7 @@ class Link * * @return string */ - public function getLable() + public function getLabel() { if ($this->getData('anchor_text')) { $this->_anchorText = $this->getData('anchor_text'); diff --git a/app/code/Magento/Cms/Controller/Adminhtml/Wysiwyg/Images.php b/app/code/Magento/Cms/Controller/Adminhtml/Wysiwyg/Images.php index 64df4431b966710e8467080f58d196ed2d0bbae5..f5fd0f987a4e6bbe37890119f2a3c577f932afbf 100644 --- a/app/code/Magento/Cms/Controller/Adminhtml/Wysiwyg/Images.php +++ b/app/code/Magento/Cms/Controller/Adminhtml/Wysiwyg/Images.php @@ -125,7 +125,7 @@ class Images extends \Magento\Backend\App\Action public function deleteFolderAction() { try { - $path = $this->getStorage()->getSession()->getCurrentPath(); + $path = $this->getStorage()->getCmsWysiwygImages()->getCurrentPath(); $this->getStorage()->deleteDirectory($path); } catch (\Exception $e) { $result = array('error' => true, 'message' => $e->getMessage()); diff --git a/app/code/Magento/Cms/Model/Wysiwyg/Images/Storage.php b/app/code/Magento/Cms/Model/Wysiwyg/Images/Storage.php index 26a90ca1136c23800444ccc32f58233ef83cc69a..8a02492c7a9d6524ea4a7249285c62c346ae6d9e 100644 --- a/app/code/Magento/Cms/Model/Wysiwyg/Images/Storage.php +++ b/app/code/Magento/Cms/Model/Wysiwyg/Images/Storage.php @@ -26,6 +26,8 @@ namespace Magento\Cms\Model\Wysiwyg\Images; +use Magento\Cms\Helper\Wysiwyg\Images; + /** * Wysiwyg Images model * @@ -656,6 +658,16 @@ class Storage extends \Magento\Object return $this->_resizeParameters['height']; } + /** + * Get cms wysiwyg images helper + * + * @return Images|null + */ + public function getCmsWysiwygImages() + { + return $this->_cmsWysiwygImages; + } + /** * Is path under storage root directory * diff --git a/app/code/Magento/Contacts/Controller/Index.php b/app/code/Magento/Contacts/Controller/Index.php index e3fb5dc36f397515375bc3843555af110944efb9..b91dd363e52e5f2af100a0f5e90f744f28e08802 100644 --- a/app/code/Magento/Contacts/Controller/Index.php +++ b/app/code/Magento/Contacts/Controller/Index.php @@ -84,8 +84,8 @@ class Index extends \Magento\App\Action\Action } $post = $this->getRequest()->getPost(); if ($post) { - $translate = $this->_objectManager->get('Magento\Core\Model\Translate'); - /* @var $translate \Magento\Core\Model\Translate */ + $translate = $this->_objectManager->get('Magento\TranslateInterface'); + /* @var $translate \Magento\TranslateInterface */ $translate->setTranslateInline(false); try { $postObject = new \Magento\Object(); diff --git a/app/code/Magento/Core/Helper/Data.php b/app/code/Magento/Core/Helper/Data.php index b4ed7ae65a05f6ab90bbbbd4d8921fd6013c8f78..759bf077e9e449798c88cd0a4354a1e4507021fa 100644 --- a/app/code/Magento/Core/Helper/Data.php +++ b/app/code/Magento/Core/Helper/Data.php @@ -216,8 +216,9 @@ class Data extends \Magento\App\Helper\AbstractHelper public function jsonEncode($valueToEncode, $cycleCheck = false, $options = array()) { $json = \Zend_Json::encode($valueToEncode, $cycleCheck, $options); - if ($this->_translator->isAllowed()) { - $this->_translator->processResponseBody($json, true); + $translateInline = $this->_inlineFactory->get(); + if ($translateInline->isAllowed()) { + $translateInline->processResponseBody($json, true); } return $json; diff --git a/app/code/Magento/Core/Helper/Translate.php b/app/code/Magento/Core/Helper/Translate.php index ad3ebae367410da44c0feefce8630d5044e15ba2..90bc72c918644b166ec4983016e78e850739275f 100644 --- a/app/code/Magento/Core/Helper/Translate.php +++ b/app/code/Magento/Core/Helper/Translate.php @@ -39,22 +39,34 @@ class Translate extends \Magento\App\Helper\AbstractHelper protected $_design; /** - * @var \Magento\Core\Model\Translate + * Inline translate + * + * @var \Magento\Translate\Inline\ParserInterface + */ + protected $_inlineParser; + + /** + * Translate library + * + * @var \Magento\Translate */ - protected $translator; + protected $_translator; /** * @param \Magento\App\Helper\Context $context * @param \Magento\View\DesignInterface $design - * @param \Magento\Core\Model\Translate $translator + * @param \Magento\Translate\Inline\ParserInterface $inlineParser + * @param \Magento\Translate $translate */ public function __construct( \Magento\App\Helper\Context $context, \Magento\View\DesignInterface $design, - \Magento\Core\Model\Translate $translator + \Magento\Translate\Inline\ParserInterface $inlineParser, + \Magento\Translate $translate ) { - $this->translator = $translator; $this->_design = $design; + $this->_inlineParser = $inlineParser; + $this->_translator = $translate; parent::__construct($context); } @@ -73,7 +85,7 @@ class Translate extends \Magento\App\Helper\AbstractHelper $this->_design->setArea($area); } - $this->translator->processAjaxPost($translate); + $this->_inlineParser->processAjaxPost($translate); $result = $returnType == 'json' ? "{success:true}" : true; } catch (\Exception $e) { $result = $returnType == 'json' ? "{error:true,message:'" . $e->getMessage() . "'}" : false; @@ -87,21 +99,21 @@ class Translate extends \Magento\App\Helper\AbstractHelper * @param string $localeCode * @param bool $forceReload * @param null $area - * @return \Magento\Core\Model\Translate + * @return \Magento\TranslateInterface */ public function initTranslate($localeCode, $forceReload, $area = null) { - $this->translator->setLocale($localeCode); + $this->_translator->setLocale($localeCode); $dispatchResult = new \Magento\Object(array( 'inline_type' => null )); $this->_eventManager->dispatch('translate_initialization_before', array( - 'translate_object' => $this->translator, + 'translate_object' => $this->_translator, 'result' => $dispatchResult )); $area = isset($area) ? $area : $this->_design->getArea(); - $this->translator->init($area, $dispatchResult, $forceReload); + $this->_translator->init($area, $dispatchResult, $forceReload); return $this; } } diff --git a/app/code/Magento/Core/Model/App.php b/app/code/Magento/Core/Model/App.php index dcac8a85672c32348701f558deda58d7056564ba..ab9506aac54906fa22cddd3d95d242d5cf00a473 100644 --- a/app/code/Magento/Core/Model/App.php +++ b/app/code/Magento/Core/Model/App.php @@ -53,7 +53,7 @@ class App implements \Magento\AppInterface /** * Magento version */ - const VERSION = '2.0.0.0-dev63'; + const VERSION = '2.0.0.0-dev64'; /** @@ -518,7 +518,7 @@ class App implements \Magento\AppInterface 'revision' => '0', 'patch' => '0', 'stability' => 'dev', - 'number' => '63', + 'number' => '64', ); } } diff --git a/app/code/Magento/Core/Model/App/Area.php b/app/code/Magento/Core/Model/App/Area.php index f27ab68343562da92d11fcd418d93801df4dbc75..4e7f005fc7a0ee201f7dae1b9ebe2975d328050b 100644 --- a/app/code/Magento/Core/Model/App/Area.php +++ b/app/code/Magento/Core/Model/App/Area.php @@ -70,7 +70,7 @@ class Area /** * Translator * - * @var \Magento\Core\Model\Translate + * @var \Magento\TranslateInterface */ protected $_translator; @@ -121,7 +121,7 @@ class Area /** * @param \Magento\Logger $logger * @param \Magento\Event\ManagerInterface $eventManager - * @param \Magento\Core\Model\Translate $translator + * @param \Magento\TranslateInterface $translator * @param \Magento\App\ConfigInterface $config * @param \Magento\ObjectManager $objectManager * @param \Magento\App\ObjectManager\ConfigLoader $diConfigLoader @@ -133,7 +133,7 @@ class Area public function __construct( \Magento\Logger $logger, \Magento\Event\ManagerInterface $eventManager, - \Magento\Core\Model\Translate $translator, + \Magento\TranslateInterface $translator, \Magento\App\ConfigInterface $config, \Magento\ObjectManager $objectManager, \Magento\App\ObjectManager\ConfigLoader $diConfigLoader, diff --git a/app/code/Magento/Core/Model/App/Emulation.php b/app/code/Magento/Core/Model/App/Emulation.php index de56941ebf332de917aa733dd0e3aaa4a03e5b56..5af97ec89c611071f2d4eadd4319d9655ac23c18 100644 --- a/app/code/Magento/Core/Model/App/Emulation.php +++ b/app/code/Magento/Core/Model/App/Emulation.php @@ -46,7 +46,7 @@ class Emulation extends \Magento\Object protected $_storeManager; /** - * @var \Magento\Core\Model\Translate + * @var \Magento\TranslateInterface */ protected $_translate; @@ -73,7 +73,7 @@ class Emulation extends \Magento\Object protected $_design; /** - * @var \Magento\Core\Model\Translate\Inline\ConfigFactory + * @var \Magento\Translate\Inline\ConfigFactory */ protected $_configFactory; @@ -82,10 +82,10 @@ class Emulation extends \Magento\Object * @param \Magento\Core\Model\StoreManagerInterface $storeManager * @param \Magento\View\DesignInterface $viewDesign * @param \Magento\Core\Model\Design $design - * @param \Magento\Core\Model\Translate $translate + * @param \Magento\TranslateInterface $translate * @param \Magento\Core\Helper\Translate $helperTranslate * @param \Magento\Core\Model\Store\Config $coreStoreConfig - * @param \Magento\Core\Model\Translate\Inline\ConfigFactory $configFactory + * @param \Magento\Translate\Inline\ConfigFactory $configFactory * @param \Magento\Core\Model\LocaleInterface $locale * @param array $data */ @@ -94,10 +94,10 @@ class Emulation extends \Magento\Object \Magento\Core\Model\StoreManagerInterface $storeManager, \Magento\View\DesignInterface $viewDesign, \Magento\Core\Model\Design $design, - \Magento\Core\Model\Translate $translate, + \Magento\TranslateInterface $translate, \Magento\Core\Helper\Translate $helperTranslate, \Magento\Core\Model\Store\Config $coreStoreConfig, - \Magento\Core\Model\Translate\Inline\ConfigFactory $configFactory, + \Magento\Translate\Inline\ConfigFactory $configFactory, \Magento\Core\Model\LocaleInterface $locale, array $data = array() ) { @@ -131,7 +131,7 @@ class Emulation extends \Magento\Object $area = \Magento\Core\Model\App\Area::AREA_FRONTEND; } $initialTranslateInline = $emulateStoreInlineTranslation - ? $this->_emulateInlineTranslation($storeId, $area) + ? $this->_emulateInlineTranslation($storeId) : $this->_emulateInlineTranslation(); $initialDesign = $this->_emulateDesign($storeId, $area); // Current store needs to be changed right before locale change and after design change @@ -172,16 +172,15 @@ class Emulation extends \Magento\Object * Function disables inline translation if $storeId is null * * @param integer|null $storeId - * @param string $area * * @return boolean initial inline translation state */ - protected function _emulateInlineTranslation($storeId = null, $area = \Magento\Core\Model\App\Area::AREA_FRONTEND) + protected function _emulateInlineTranslation($storeId = null) { if (is_null($storeId)) { $newTranslateInline = false; } else { - $newTranslateInline = $this->_configFactory->create($area)->isActive($storeId); + $newTranslateInline = $this->_configFactory->get()->isActive($storeId); } $translateInline = $this->_translate->getTranslateInline(); $this->_translate->setTranslateInline($newTranslateInline); diff --git a/lib/Magento/App/Config/Loader.php b/app/code/Magento/Core/Model/BaseScopeResolver.php similarity index 57% rename from lib/Magento/App/Config/Loader.php rename to app/code/Magento/Core/Model/BaseScopeResolver.php index d45fb0c7ed9387f9967955d60c3b7ff916c82acc..8d3e2d51ccf90a14ad0c938a172bde64b4b29cb3 100644 --- a/lib/Magento/App/Config/Loader.php +++ b/app/code/Magento/Core/Model/BaseScopeResolver.php @@ -1,7 +1,5 @@ <?php /** - * Loader - * * Magento * * NOTICE OF LICENSE @@ -24,39 +22,34 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\App\Config; +namespace Magento\Core\Model; -class Loader implements \Magento\App\Config\LoaderInterface +class BaseScopeResolver implements \Magento\BaseScopeResolverInterface { /** - * @var \Magento\App\Config\Scope\Resolver + * @var \Magento\Core\Model\StoreManagerInterface */ - protected $_scopeResolver; + protected $_storeManager; /** - * @var \Magento\App\Config\ScopePool - */ - protected $_scopePool; - - /** - * @param \Magento\App\Config\Scope\Resolver $scopeResolver - * @param \Magento\App\Config\ScopePool $scopePool + * @param \Magento\Core\Model\StoreManagerInterface $storeManager */ public function __construct( - \Magento\App\Config\Scope\Resolver $scopeResolver, - \Magento\App\Config\ScopePool $scopePool + \Magento\Core\Model\StoreManagerInterface $storeManager ) { - $this->_scopeResolver = $scopeResolver; - $this->_scopePool = $scopePool; + $this->_storeManager = $storeManager; } /** - * Process of config loading - * - * @return \Magento\App\Config\DataInterface + * {@inheritdoc} */ - public function load() + public function getScope($scopeId = null) { - return $this->_scopePool->getScope($this->_scopeResolver->getScope()); + $scope = $this->_storeManager->getStore($scopeId); + if (!($scope instanceof \Magento\BaseScopeInterface)) { + throw new \Magento\Exception('Invalid scope object'); + } + + return $scope; } } diff --git a/app/code/Magento/Core/Model/Config.php b/app/code/Magento/Core/Model/Config.php deleted file mode 100644 index ebcd853626069e36b0717c3f79154d4b7cd55fe6..0000000000000000000000000000000000000000 --- a/app/code/Magento/Core/Model/Config.php +++ /dev/null @@ -1,87 +0,0 @@ -<?php -/** - * Application configuration object. Used to access configuration when application is initialized and installed. - * - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - */ - -namespace Magento\Core\Model; - -class Config implements \Magento\App\ConfigInterface -{ - /** - * Config cache tag - */ - const CACHE_TAG = 'CONFIG'; - - /** - * @var \Magento\Core\Model\Config\SectionPool - */ - protected $_sectionPool; - - /** - * @param Config\SectionPool $sectionPool - */ - public function __construct(\Magento\Core\Model\Config\SectionPool $sectionPool) - { - $this->_sectionPool = $sectionPool; - } - - /** - * Retrieve config value by path and scope - * - * @param string $path - * @param string $scope - * @param string $scopeCode - * @return mixed - */ - public function getValue($path = null, $scope = 'default', $scopeCode = null) - { - return $this->_sectionPool->getSection($scope, $scopeCode)->getValue($path); - } - - /** - * Set config value in the corresponding config scope - * - * @param string $path - * @param mixed $value - * @param string $scope - * @param null|string $scopeCode - */ - public function setValue($path, $value, $scope = 'default', $scopeCode = null) - { - $this->_sectionPool->getSection($scope, $scopeCode)->setValue($path, $value); - } - - /** - * Retrieve config flag - * - * @param string $path - * @param string $scope - * @param null|string $scopeCode - * @return bool - */ - public function isSetFlag($path, $scope = 'default', $scopeCode = null) - { - return (bool)$this->getValue($path, $scope, $scopeCode); - } -} diff --git a/app/code/Magento/Core/Model/Config/Data.php b/app/code/Magento/Core/Model/Config/Data.php deleted file mode 100644 index 8de467c63c1f89e28292fd675b93099f511db124..0000000000000000000000000000000000000000 --- a/app/code/Magento/Core/Model/Config/Data.php +++ /dev/null @@ -1,104 +0,0 @@ -<?php -/** - * Configuration data container for default, stores and websites config values - * - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - */ -namespace Magento\Core\Model\Config; - -class Data implements \Magento\Core\Model\Config\DataInterface -{ - /** - * Config data - * - * @var array - */ - protected $_data = array(); - - /** - * Config source data - * - * @var array - */ - protected $_source = array(); - - /** - * @param \Magento\Core\Model\Config\MetadataProcessor $processor - * @param array $data - */ - public function __construct(\Magento\Core\Model\Config\MetadataProcessor $processor, array $data) - { - $this->_data = $processor->process($data); - $this->_source = $data; - } - - /** - * @return array - */ - public function getSource() - { - return $this->_source; - } - - /** - * Retrieve configuration value by path - * - * @param null|string $path - * @return array|string - */ - public function getValue($path = null) - { - if ($path === null) { - return $this->_data; - } - $keys = explode('/', $path); - $data = $this->_data; - foreach ($keys as $key) { - if (is_array($data) && array_key_exists($key, $data)) { - $data = $data[$key]; - } else { - return false; - } - } - return $data; - } - - /** - * Set configuration value - *l - * @param string $path - * @param mixed $value - */ - public function setValue($path, $value) - { - $keys = explode('/', $path); - $lastKey = array_pop($keys); - $currentElement = &$this->_data; - foreach ($keys as $key) { - if (!isset($currentElement[$key])) { - $currentElement[$key] = array(); - } - $currentElement = &$currentElement[$key]; - } - $currentElement[$lastKey] = $value; - } -} diff --git a/app/code/Magento/Core/Model/Config/Initial.php b/app/code/Magento/Core/Model/Config/Initial.php deleted file mode 100644 index b72945b2c3922d64b8464f91bf6064c55ddaf5ed..0000000000000000000000000000000000000000 --- a/app/code/Magento/Core/Model/Config/Initial.php +++ /dev/null @@ -1,106 +0,0 @@ -<?php -/** - * Initial configuration data container. Provides interface for reading initial config values - * - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - */ -namespace Magento\Core\Model\Config; - -class Initial -{ - /** - * Config data - * - * @var array - */ - protected $_data = array(); - - /** - * Config metadata - * - * @var array - */ - protected $_metadata = array(); - - /** - * @param \Magento\Core\Model\Config\Initial\Reader $reader - * @param \Magento\App\Cache\Type\Config $cache - * @param string $cacheId - */ - public function __construct( - \Magento\Core\Model\Config\Initial\Reader $reader, - \Magento\App\Cache\Type\Config $cache, - $cacheId = 'initial_config' - ) { - $data = $cache->load($cacheId); - if (!$data) { - $data = $reader->read(); - $cache->save(serialize($data), $cacheId); - } else { - $data = unserialize($data); - } - $this->_data = $data['data']; - $this->_metadata = $data['metadata']; - } - - /** - * Get default config - * - * @return array - */ - public function getDefault() - { - return $this->_data['default']; - } - - /** - * Retrieve store initial config by code - * - * @param string $code - * @return array - */ - public function getStore($code) - { - return isset($this->_data['stores'][$code]) ? $this->_data['stores'][$code] : array(); - } - - /** - * Retrieve website initial config by code - * - * @param string $code - * @return array - */ - public function getWebsite($code) - { - return isset($this->_data['websites'][$code]) ? $this->_data['websites'][$code] : array(); - } - - /** - * Get configuration metadata - * - * @return array - */ - public function getMetadata() - { - return $this->_metadata; - } -} diff --git a/app/code/Magento/Core/Model/Config/Initial/Reader.php b/app/code/Magento/Core/Model/Config/Initial/Reader.php deleted file mode 100644 index 330c88411cd7d66a5731d2b49c05b4e9f675738a..0000000000000000000000000000000000000000 --- a/app/code/Magento/Core/Model/Config/Initial/Reader.php +++ /dev/null @@ -1,142 +0,0 @@ -<?php -/** - * Default configuration data reader. Reads configuration data from storage - * - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - */ -namespace Magento\Core\Model\Config\Initial; - -class Reader -{ - /** - * File locator - * - * @var \Magento\Config\FileResolverInterface - */ - protected $_fileResolver; - - /** - * Config converter - * - * @var \Magento\Core\Model\Config\Initial\Converter - */ - protected $_converter; - - /** - * Config file name - * - * @var string - */ - protected $_fileName; - - /** - * Class of dom configuration document used for merge - * - * @var string - */ - protected $_domDocumentClass; - - /** - * Scope priority loading scheme - * - * @var array - */ - protected $_scopePriorityScheme = array('primary', 'global'); - - /** - * Path to corresponding XSD file with validation rules for config - * - * @var string - */ - protected $_schemaFile; - - /** - * @param \Magento\Config\FileResolverInterface $fileResolver - * @param Converter $converter - * @param SchemaLocator $schemaLocator - * @param \Magento\Config\ValidationStateInterface $validationState - * @param string $fileName - * @param string $domDocumentClass - */ - public function __construct( - \Magento\Config\FileResolverInterface $fileResolver, - Converter $converter, - SchemaLocator $schemaLocator, - \Magento\Config\ValidationStateInterface $validationState, - $fileName = 'config.xml', - $domDocumentClass = 'Magento\Config\Dom' - ) { - $this->_schemaFile = $validationState->isValidated() ? $schemaLocator->getSchema() : null; - $this->_fileResolver = $fileResolver; - $this->_converter = $converter; - $this->_domDocumentClass = $domDocumentClass; - $this->_fileName = $fileName; - } - - /** - * Load configuration scope - * - * @return array - * - * @throws \Magento\Exception - */ - public function read() - { - $fileList = array(); - foreach ($this->_scopePriorityScheme as $scope) { - $directories = $this->_fileResolver->get($this->_fileName, $scope); - foreach ($directories as $key => $directory) { - $fileList[$key] = $directory; - } - } - - if (!count($fileList)) { - return array(); - } - - /** @var \Magento\Config\Dom $domDocument */ - $domDocument = null; - foreach ($fileList as $file) { - try { - if (is_null($domDocument)) { - $class = $this->_domDocumentClass; - $domDocument = new $class( - $file, - array(), - $this->_schemaFile - ); - } else { - $domDocument->merge($file); - } - } catch (\Magento\Config\Dom\ValidationException $e) { - throw new \Magento\Exception("Invalid XML in file " . $file . ":\n" . $e->getMessage()); - } - } - - $output = array(); - if ($domDocument) { - $output = $this->_converter->convert($domDocument->getDom()); - } - return $output; - } - -} diff --git a/app/code/Magento/Core/Model/Config/MetadataProcessor.php b/app/code/Magento/Core/Model/Config/MetadataProcessor.php deleted file mode 100644 index 69601427eecf9f32129c3e3095aafe0da6307636..0000000000000000000000000000000000000000 --- a/app/code/Magento/Core/Model/Config/MetadataProcessor.php +++ /dev/null @@ -1,108 +0,0 @@ -<?php -/** - * Configuration data metadata processor - * - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - */ -namespace Magento\Core\Model\Config; - -class MetadataProcessor -{ - /** - * @var \Magento\Core\Model\Config\Data\BackendModelPool - */ - protected $_backendModelPool; - - /** - * @var array - */ - protected $_metadata = array(); - - /** - * @param \Magento\Core\Model\Config\Data\BackendModelPool $backendModelPool - * @param \Magento\Core\Model\Config\Initial $initialConfig - */ - public function __construct( - \Magento\Core\Model\Config\Data\BackendModelPool $backendModelPool, - \Magento\Core\Model\Config\Initial $initialConfig - ) { - $this->_backendModelPool = $backendModelPool; - $this->_metadata = $initialConfig->getMetadata(); - } - - /** - * Retrieve array value by path - * - * @param array $data - * @param string $path - * @return string|null - */ - protected function _getValue(array $data, $path) - { - $keys = explode('/', $path); - foreach ($keys as $key) { - if (is_array($data) && array_key_exists($key, $data)) { - $data = $data[$key]; - } else { - return null; - } - } - return $data; - } - - /** - * Set array value by path - * - * @param array $container - * @param string $path - * @param string $value - */ - protected function _setValue(array &$container, $path, $value) - { - $segments = explode('/', $path); - $currentPointer = &$container; - foreach ($segments as $segment) { - if (!isset($currentPointer[$segment])) { - $currentPointer[$segment] = array(); - } - $currentPointer = &$currentPointer[$segment]; - } - $currentPointer = $value; - } - - /** - * Process config data - * - * @param array $data - * @return array - */ - public function process(array $data) - { - foreach ($this->_metadata as $path => $metadata) { - /** @var \Magento\Core\Model\Config\Data\BackendModelInterface $backendModel */ - $backendModel = $this->_backendModelPool->get($metadata['backendModel']); - $value = $backendModel->processValue($this->_getValue($data, $path)); - $this->_setValue($data, $path, $value); - } - return $data; - } -} diff --git a/app/code/Magento/Core/Model/Config/Section/Processor/Placeholder.php b/app/code/Magento/Core/Model/Config/Scope/Processor/Placeholder.php similarity index 98% rename from app/code/Magento/Core/Model/Config/Section/Processor/Placeholder.php rename to app/code/Magento/Core/Model/Config/Scope/Processor/Placeholder.php index 5d9a2aca8927bc6cc425ab02743c73f0d9012905..e1e06eec00172d90a6744ea7d97832b474805686 100644 --- a/app/code/Magento/Core/Model/Config/Section/Processor/Placeholder.php +++ b/app/code/Magento/Core/Model/Config/Scope/Processor/Placeholder.php @@ -23,7 +23,7 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Core\Model\Config\Section\Processor; +namespace Magento\Core\Model\Config\Scope\Processor; class Placeholder { diff --git a/app/code/Magento/Core/Model/Config/Section/Reader/DefaultReader.php b/app/code/Magento/Core/Model/Config/Scope/Reader/DefaultReader.php similarity index 76% rename from app/code/Magento/Core/Model/Config/Section/Reader/DefaultReader.php rename to app/code/Magento/Core/Model/Config/Scope/Reader/DefaultReader.php index 92b5e70bb16a50213bf08a014b1414a5dd781abb..49f70112839021f73e2fadb5e91500f361a1041c 100644 --- a/app/code/Magento/Core/Model/Config/Section/Reader/DefaultReader.php +++ b/app/code/Magento/Core/Model/Config/Scope/Reader/DefaultReader.php @@ -23,17 +23,17 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Core\Model\Config\Section\Reader; +namespace Magento\Core\Model\Config\Scope\Reader; -class DefaultReader +class DefaultReader implements \Magento\App\Config\Scope\ReaderInterface { /** - * @var \Magento\Core\Model\Config\Initial + * @var \Magento\App\Config\Initial */ protected $_initialConfig; /** - * @var \Magento\Core\Model\Config\Section\Converter + * @var \Magento\App\Config\Scope\Converter */ protected $_converter; @@ -48,14 +48,14 @@ class DefaultReader protected $_appState; /** - * @param \Magento\Core\Model\Config\Initial $initialConfig - * @param \Magento\Core\Model\Config\Section\Converter $converter + * @param \Magento\App\Config\Initial $initialConfig + * @param \Magento\App\Config\Scope\Converter $converter * @param \Magento\Core\Model\Resource\Config\Value\Collection\ScopedFactory $collectionFactory * @param \Magento\App\State $appState */ public function __construct( - \Magento\Core\Model\Config\Initial $initialConfig, - \Magento\Core\Model\Config\Section\Converter $converter, + \Magento\App\Config\Initial $initialConfig, + \Magento\App\Config\Scope\Converter $converter, \Magento\Core\Model\Resource\Config\Value\Collection\ScopedFactory $collectionFactory, \Magento\App\State $appState ) { @@ -72,9 +72,11 @@ class DefaultReader */ public function read() { - $config = $this->_initialConfig->getDefault(); + $config = $this->_initialConfig->getData(\Magento\BaseScopeInterface::SCOPE_DEFAULT); if ($this->_appState->isInstalled()) { - $collection = $this->_collectionFactory->create(array('scope' => 'default')); + $collection = $this->_collectionFactory->create( + array('scope' => \Magento\BaseScopeInterface::SCOPE_DEFAULT) + ); $dbDefaultConfig = array(); foreach ($collection as $item) { $dbDefaultConfig[$item->getPath()] = $item->getValue(); diff --git a/app/code/Magento/Core/Model/Config/Section/Reader/Store.php b/app/code/Magento/Core/Model/Config/Scope/Reader/Store.php similarity index 71% rename from app/code/Magento/Core/Model/Config/Section/Reader/Store.php rename to app/code/Magento/Core/Model/Config/Scope/Reader/Store.php index e9ea6a0ba33f06d015dfdf1568bc117e2d58109f..5f3b9ac4f1aabecb181e0805b0d7e6a4babe829c 100644 --- a/app/code/Magento/Core/Model/Config/Section/Reader/Store.php +++ b/app/code/Magento/Core/Model/Config/Scope/Reader/Store.php @@ -21,22 +21,22 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Core\Model\Config\Section\Reader; +namespace Magento\Core\Model\Config\Scope\Reader; -class Store +class Store implements \Magento\App\Config\Scope\ReaderInterface { /** - * @var \Magento\Core\Model\Config\Initial + * @var \Magento\App\Config\Initial */ protected $_initialConfig; /** - * @var \Magento\Core\Model\Config\SectionPool + * @var \Magento\App\Config\ScopePool */ - protected $_sectionPool; + protected $_scopePool; /** - * @var \Magento\Core\Model\Config\Section\Store\Converter + * @var \Magento\Core\Model\Config\Scope\Store\Converter */ protected $_converter; @@ -56,23 +56,23 @@ class Store protected $_appState; /** - * @param \Magento\Core\Model\Config\Initial $initialConfig - * @param \Magento\Core\Model\Config\SectionPool $sectionPool - * @param \Magento\Core\Model\Config\Section\Store\Converter $converter + * @param \Magento\App\Config\Initial $initialConfig + * @param \Magento\App\Config\ScopePool $scopePool + * @param \Magento\Core\Model\Config\Scope\Store\Converter $converter * @param \Magento\Core\Model\Resource\Config\Value\Collection\ScopedFactory $collectionFactory * @param \Magento\Core\Model\StoreFactory $storeFactory * @param \Magento\App\State $appState */ public function __construct( - \Magento\Core\Model\Config\Initial $initialConfig, - \Magento\Core\Model\Config\SectionPool $sectionPool, - \Magento\Core\Model\Config\Section\Store\Converter $converter, + \Magento\App\Config\Initial $initialConfig, + \Magento\App\Config\ScopePool $scopePool, + \Magento\Core\Model\Config\Scope\Store\Converter $converter, \Magento\Core\Model\Resource\Config\Value\Collection\ScopedFactory $collectionFactory, \Magento\Core\Model\StoreFactory $storeFactory, \Magento\App\State $appState ) { $this->_initialConfig = $initialConfig; - $this->_sectionPool = $sectionPool; + $this->_scopePool = $scopePool; $this->_converter = $converter; $this->_collectionFactory = $collectionFactory; $this->_storeFactory = $storeFactory; @@ -85,13 +85,13 @@ class Store * @param string $code * @return array */ - public function read($code) + public function read($code = null) { if ($this->_appState->isInstalled()) { $store = $this->_storeFactory->create(); $store->load($code); - $websiteConfig = $this->_sectionPool->getSection('website', $store->getWebsite()->getCode())->getSource(); - $config = array_replace_recursive($websiteConfig, $this->_initialConfig->getStore($code)); + $websiteConfig = $this->_scopePool->getScope('website', $store->getWebsite()->getCode())->getSource(); + $config = array_replace_recursive($websiteConfig, $this->_initialConfig->getData("sotres|{$code}")); $collection = $this->_collectionFactory->create(array('scope' => 'stores', 'scopeId' => $store->getId())); $dbStoreConfig = array(); @@ -100,8 +100,10 @@ class Store } $config = $this->_converter->convert($dbStoreConfig, $config); } else { - $websiteConfig = $this->_sectionPool->getSection('website', 'default')->getSource(); - $config = $this->_converter->convert($websiteConfig, $this->_initialConfig->getStore($code)); + $websiteConfig = $this->_scopePool + ->getScope('website', \Magento\BaseScopeInterface::SCOPE_DEFAULT) + ->getSource(); + $config = $this->_converter->convert($websiteConfig, $this->_initialConfig->getData("stores|{$code}")); } return $config; } diff --git a/app/code/Magento/Core/Model/Config/Section/Reader/Website.php b/app/code/Magento/Core/Model/Config/Scope/Reader/Website.php similarity index 77% rename from app/code/Magento/Core/Model/Config/Section/Reader/Website.php rename to app/code/Magento/Core/Model/Config/Scope/Reader/Website.php index 815e599e349c0f5707c56fcb466c150e67bebbc8..2f731ea4f23e6925f8082d60b77845411018606c 100644 --- a/app/code/Magento/Core/Model/Config/Section/Reader/Website.php +++ b/app/code/Magento/Core/Model/Config/Scope/Reader/Website.php @@ -21,22 +21,22 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Core\Model\Config\Section\Reader; +namespace Magento\Core\Model\Config\Scope\Reader; -class Website +class Website implements \Magento\App\Config\Scope\ReaderInterface { /** - * @var \Magento\Core\Model\Config\Initial + * @var \Magento\App\Config\Initial */ protected $_initialConfig; /** - * @var \Magento\Core\Model\Config\SectionPool + * @var \Magento\App\Config\ScopePool */ - protected $_sectionPool; + protected $_scopePool; /** - * @var \Magento\Core\Model\Config\Section\Converter + * @var \Magento\App\Config\Scope\Converter */ protected $_converter; @@ -56,23 +56,23 @@ class Website protected $_appState; /** - * @param \Magento\Core\Model\Config\Initial $initialConfig - * @param \Magento\Core\Model\Config\SectionPool $sectionPool - * @param \Magento\Core\Model\Config\Section\Converter $converter + * @param \Magento\App\Config\Initial $initialConfig + * @param \Magento\App\Config\ScopePool $scopePool + * @param \Magento\App\Config\Scope\Converter $converter * @param \Magento\Core\Model\Resource\Config\Value\Collection\ScopedFactory $collectionFactory * @param \Magento\Core\Model\WebsiteFactory $websiteFactory * @param \Magento\App\State $appState */ public function __construct( - \Magento\Core\Model\Config\Initial $initialConfig, - \Magento\Core\Model\Config\SectionPool $sectionPool, - \Magento\Core\Model\Config\Section\Converter $converter, + \Magento\App\Config\Initial $initialConfig, + \Magento\App\Config\ScopePool $scopePool, + \Magento\App\Config\Scope\Converter $converter, \Magento\Core\Model\Resource\Config\Value\Collection\ScopedFactory $collectionFactory, \Magento\Core\Model\WebsiteFactory $websiteFactory, \Magento\App\State $appState ) { $this->_initialConfig = $initialConfig; - $this->_sectionPool = $sectionPool; + $this->_scopePool = $scopePool; $this->_converter = $converter; $this->_collectionFactory = $collectionFactory; $this->_websiteFactory = $websiteFactory; @@ -85,10 +85,11 @@ class Website * @param string $code * @return array */ - public function read($code) + public function read($code = null) { $config = array_replace_recursive( - $this->_sectionPool->getSection('default')->getSource(), $this->_initialConfig->getWebsite($code) + $this->_scopePool->getScope(\Magento\BaseScopeInterface::SCOPE_DEFAULT)->getSource(), + $this->_initialConfig->getData("websites|{$code}") ); if ($this->_appState->isInstalled()) { diff --git a/app/code/Magento/Core/Model/Config/Section/ReaderPool.php b/app/code/Magento/Core/Model/Config/Scope/ReaderPool.php similarity index 68% rename from app/code/Magento/Core/Model/Config/Section/ReaderPool.php rename to app/code/Magento/Core/Model/Config/Scope/ReaderPool.php index bbed8adb48d7a5708900738b8f704c21eff0e964..c80313f033a8a211d44e763d0ab835f1da947cea 100644 --- a/app/code/Magento/Core/Model/Config/Section/ReaderPool.php +++ b/app/code/Magento/Core/Model/Config/Scope/ReaderPool.php @@ -21,9 +21,9 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Core\Model\Config\Section; +namespace Magento\Core\Model\Config\Scope; -class ReaderPool +class ReaderPool implements \Magento\App\Config\Scope\ReaderPoolInterface { /** * List of readers @@ -33,14 +33,14 @@ class ReaderPool protected $_readers = array(); /** - * @param \Magento\Core\Model\Config\Section\Reader\DefaultReader $default - * @param \Magento\Core\Model\Config\Section\Reader\Website $website - * @param \Magento\Core\Model\Config\Section\Reader\Store $store + * @param ReaderInterface $default + * @param ReaderInterface $website + * @param ReaderInterface $store */ public function __construct( - \Magento\Core\Model\Config\Section\Reader\DefaultReader $default, - \Magento\Core\Model\Config\Section\Reader\Website $website, - \Magento\Core\Model\Config\Section\Reader\Store $store + \Magento\App\Config\Scope\ReaderInterface $default, + \Magento\App\Config\Scope\ReaderInterface $website, + \Magento\App\Config\Scope\ReaderInterface $store ) { $this->_readers = array( 'default' => $default, @@ -52,13 +52,13 @@ class ReaderPool } /** - * Retrieve reader by scope + * Retrieve reader by scope type * - * @param string $scope + * @param string $scopeType * @return mixed */ - public function getReader($scope) + public function getReader($scopeType) { - return $this->_readers[$scope]; + return $this->_readers[$scopeType]; } } diff --git a/app/code/Magento/Core/Model/Config/Section/Store/Converter.php b/app/code/Magento/Core/Model/Config/Scope/Store/Converter.php similarity index 79% rename from app/code/Magento/Core/Model/Config/Section/Store/Converter.php rename to app/code/Magento/Core/Model/Config/Scope/Store/Converter.php index d10b56772165f7d60ed70354b0d6506ce2468ae9..03953b8e69a43f86087bc9530cfb206507a41f27 100644 --- a/app/code/Magento/Core/Model/Config/Section/Store/Converter.php +++ b/app/code/Magento/Core/Model/Config/Scope/Store/Converter.php @@ -23,19 +23,19 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Core\Model\Config\Section\Store; +namespace Magento\Core\Model\Config\Scope\Store; -class Converter extends \Magento\Core\Model\Config\Section\Converter +class Converter extends \Magento\App\Config\Scope\Converter { /** - * @var \Magento\Core\Model\Config\Section\Processor\Placeholder + * @var \Magento\Core\Model\Config\Scope\Processor\Placeholder */ protected $_processor; /** - * @param \Magento\Core\Model\Config\Section\Processor\Placeholder $processor + * @param \Magento\Core\Model\Config\Scope\Processor\Placeholder $processor */ - public function __construct(\Magento\Core\Model\Config\Section\Processor\Placeholder $processor) + public function __construct(\Magento\Core\Model\Config\Scope\Processor\Placeholder $processor) { $this->_processor = $processor; } diff --git a/app/code/Magento/Core/Model/Config/SectionPool.php b/app/code/Magento/Core/Model/Config/SectionPool.php deleted file mode 100644 index 708c8abab54f519a8cbdb5e786b26c037aa79b07..0000000000000000000000000000000000000000 --- a/app/code/Magento/Core/Model/Config/SectionPool.php +++ /dev/null @@ -1,110 +0,0 @@ -<?php -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - */ -namespace Magento\Core\Model\Config; - -class SectionPool -{ - const CACHE_TAG = 'config_sections'; - - /** - * @var \Magento\Core\Model\Config\Section\ReaderPool - */ - protected $_readerPool; - - /** - * @var \Magento\Core\Model\Config\DataFactory - */ - protected $_dataFactory; - - /** - * @var \Magento\Cache\FrontendInterface - */ - protected $_cache; - - /** - * @var string - */ - protected $_cacheId; - - /** - * @var \Magento\Core\Model\Config\Data[] - */ - protected $_sections = array(); - - /** - * @param \Magento\Core\Model\Config\Section\ReaderPool $readerList - * @param \Magento\Core\Model\Config\DataFactory $dataFactory - * @param \Magento\Cache\FrontendInterface $cache - * @param string $cacheId - */ - public function __construct( - \Magento\Core\Model\Config\Section\ReaderPool $readerList, - \Magento\Core\Model\Config\DataFactory $dataFactory, - \Magento\Cache\FrontendInterface $cache, - $cacheId = 'default_config_cache' - ) { - $this->_readerPool = $readerList; - $this->_dataFactory = $dataFactory; - $this->_cache = $cache; - $this->_cacheId = $cacheId; - } - - /** - * Retrieve config section - * - * @param string $scopeType - * @param string $scopeCode - * @return \Magento\Core\Model\Config\Data - */ - public function getSection($scopeType, $scopeCode = null) - { - $code = $scopeType . '|' . $scopeCode; - if (!isset($this->_sections[$code])) { - $cacheKey = $this->_cacheId . '|' . $code; - $data = $this->_cache->load($cacheKey); - if ($data) { - $data = unserialize($data); - } else { - $reader = $this->_readerPool->getReader($scopeType); - if ($scopeType === 'default') { - $data = $reader->read(); - } else { - $data = $reader->read($scopeCode); - } - $this->_cache->save(serialize($data), $cacheKey, array(self::CACHE_TAG)); - } - $this->_sections[$code] = $this->_dataFactory->create(array('data' => $data)); - } - return $this->_sections[$code]; - } - - /** - * Clear clear cache of all sections - */ - public function clean() - { - $this->_sections = array(); - $this->_cache->clean(\Zend_Cache::CLEANING_MODE_MATCHING_TAG, array(self::CACHE_TAG)); - } -} diff --git a/app/code/Magento/Core/Model/Config/Storage/Writer/Db.php b/app/code/Magento/Core/Model/Config/Storage/Db.php similarity index 94% rename from app/code/Magento/Core/Model/Config/Storage/Writer/Db.php rename to app/code/Magento/Core/Model/Config/Storage/Db.php index 7923908b6a3719aa9dca09cdfd3b94f168e64a68..c6b9c6f86efc481fdf103393685b1e79d70e9198 100644 --- a/app/code/Magento/Core/Model/Config/Storage/Writer/Db.php +++ b/app/code/Magento/Core/Model/Config/Storage/Db.php @@ -23,9 +23,9 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Core\Model\Config\Storage\Writer; +namespace Magento\Core\Model\Config\Storage; -class Db implements \Magento\Core\Model\Config\Storage\WriterInterface +class Db implements \Magento\App\Config\Storage\WriterInterface { /** * Resource model of config data diff --git a/app/code/Magento/Core/Model/Config/Value.php b/app/code/Magento/Core/Model/Config/Value.php index 064a131e5954764fa339a515c5ff0c19d173a19b..48c82758c41f5f81e3c98301ecb22e497e9b8067 100644 --- a/app/code/Magento/Core/Model/Config/Value.php +++ b/app/code/Magento/Core/Model/Config/Value.php @@ -136,7 +136,7 @@ class Value extends \Magento\Core\Model\AbstractModel implements \Magento\App\Co if ($websiteCode) { return $this->_storeManager->getWebsite($websiteCode)->getConfig($path); } - return (string) $this->_config->getValue($path, 'default'); + return (string) $this->_config->getValue($path, \Magento\BaseScopeInterface::SCOPE_DEFAULT); } diff --git a/app/code/Magento/Core/Model/Layout.php b/app/code/Magento/Core/Model/Layout.php index 92a3f5559376ec8058f8ebf02eb8fe251230c0f6..84b73b7f1587a16b13e1b5c438c3c06e4dca82a1 100644 --- a/app/code/Magento/Core/Model/Layout.php +++ b/app/code/Magento/Core/Model/Layout.php @@ -207,6 +207,11 @@ class Layout extends \Magento\Simplexml\Config implements \Magento\View\LayoutIn */ protected $messageManager; + /** + * @var bool + */ + protected $isPrivate = false; + /** * @param \Magento\View\Layout\ProcessorFactory $processorFactory * @param Resource\Theme\CollectionFactory $themeFactory @@ -1609,8 +1614,30 @@ class Layout extends \Magento\Simplexml\Config implements \Magento\View\LayoutIn * * @return bool */ - public function isCacheable() + public function isCacheable() { return !(boolean)count($this->_xml->xpath('//' . Element::TYPE_BLOCK . '[@cacheable="false"]')); } + + /** + * Check is exists non-cacheable layout elements + * + * @return bool + */ + public function isPrivate() + { + return $this->isPrivate; + } + + /** + * Mark layout as private + * + * @param bool $isPrivate + * @return Layout + */ + public function setIsPrivate($isPrivate = true) + { + $this->isPrivate = (bool) $isPrivate; + return $this; + } } diff --git a/app/code/Magento/Core/Model/Resource/Translate.php b/app/code/Magento/Core/Model/Resource/Translate.php index d4d9ba168416850e4468bd0d26541f16119c8546..4d400fb80fc6988c11889a786a9ecfad89091755 100644 --- a/app/code/Magento/Core/Model/Resource/Translate.php +++ b/app/code/Magento/Core/Model/Resource/Translate.php @@ -34,7 +34,7 @@ */ namespace Magento\Core\Model\Resource; -class Translate extends \Magento\Core\Model\Resource\Db\AbstractDb +class Translate extends \Magento\Core\Model\Resource\Db\AbstractDb implements \Magento\Translate\ResourceInterface { /** * @var \Magento\App\State @@ -75,7 +75,7 @@ class Translate extends \Magento\Core\Model\Resource\Db\AbstractDb * Retrieve translation array for store / locale code * * @param int $storeId - * @param string|Zend_Locale $locale + * @param string $locale * @return array */ public function getTranslationArray($storeId = null, $locale = null) diff --git a/app/code/Magento/Core/Model/ScopeInterface.php b/app/code/Magento/Core/Model/ScopeInterface.php index dbb7f94e56cfd11d4dd5a3df917572e5c7bad457..705b242c345e6bca30e3e69eda9ae63ee97b7244 100644 --- a/app/code/Magento/Core/Model/ScopeInterface.php +++ b/app/code/Magento/Core/Model/ScopeInterface.php @@ -28,7 +28,6 @@ interface ScopeInterface /**#@+ * Scope types */ - const SCOPE_DEFAULT = 'default'; const SCOPE_STORES = 'stores'; const SCOPE_WEBSITES = 'websites'; /**#@-*/ diff --git a/app/code/Magento/Core/Model/Store.php b/app/code/Magento/Core/Model/Store.php index 38fe3c23a677b04370db39e98f71d311690c5dab..61db3a5e753dd1572e7fed8e5ebb872d274bddda 100644 --- a/app/code/Magento/Core/Model/Store.php +++ b/app/code/Magento/Core/Model/Store.php @@ -38,7 +38,8 @@ namespace Magento\Core\Model; * @method \Magento\Core\Model\Store setSortOrder(int $value) * @method \Magento\Core\Model\Store setIsActive(int $value) */ -class Store extends AbstractModel implements \Magento\Url\ScopeInterface +class Store extends AbstractModel + implements \Magento\BaseScopeInterface, \Magento\Url\ScopeInterface { /** * Entity name @@ -296,20 +297,26 @@ class Store extends AbstractModel implements \Magento\Url\ScopeInterface protected $_cookie; /** - * @param \Magento\Core\Model\Context $context - * @param \Magento\Core\Model\Registry $registry + * @var \Magento\App\ResponseInterface + */ + protected $response; + + /** + * @param Context $context + * @param Registry $registry * @param \Magento\Core\Helper\File\Storage\Database $coreFileStorageDatabase * @param \Magento\App\Cache\Type\Config $configCacheType * @param \Magento\UrlInterface $url * @param \Magento\App\RequestInterface $request - * @param \Magento\Core\Model\Resource\Config\Data $configDataResource + * @param Resource\Config\Data $configDataResource * @param \Magento\App\Filesystem $filesystem - * @param \Magento\Core\Model\Store\Config $coreStoreConfig + * @param Store\Config $coreStoreConfig * @param \Magento\App\ReinitableConfigInterface $coreConfig - * @param \Magento\Core\Model\Resource\Store $resource - * @param \Magento\Core\Model\StoreManagerInterface $storeManager + * @param Resource\Store $resource + * @param StoreManagerInterface $storeManager * @param \Magento\Session\SidResolverInterface $sidResolver * @param \Magento\Stdlib\Cookie $cookie + * @param \Magento\App\ResponseInterface $response * @param \Magento\Data\Collection\Db $resourceCollection * @param bool $isCustomEntryPoint * @param array $data @@ -329,6 +336,7 @@ class Store extends AbstractModel implements \Magento\Url\ScopeInterface \Magento\Core\Model\StoreManagerInterface $storeManager, \Magento\Session\SidResolverInterface $sidResolver, \Magento\Stdlib\Cookie $cookie, + \Magento\App\ResponseInterface $response, \Magento\Data\Collection\Db $resourceCollection = null, $isCustomEntryPoint = false, array $data = array() @@ -345,6 +353,7 @@ class Store extends AbstractModel implements \Magento\Url\ScopeInterface $this->_storeManager = $storeManager; $this->_sidResolver = $sidResolver; $this->_cookie = $cookie; + $this->response = $response; parent::__construct($context, $registry, $resource, $resourceCollection, $data); } @@ -655,7 +664,7 @@ class Store extends AbstractModel implements \Magento\Url\ScopeInterface && $this->_coreFileStorageDatabase->checkDbUsage() ) { return $this->getBaseUrl(\Magento\UrlInterface::URL_TYPE_WEB, $secure) - . $filesystem->getUri(\Magento\App\Filesystem::PUB_DIR) . '/' . self::MEDIA_REWRITE_SCRIPT; + . $filesystem->getUri(\Magento\App\Filesystem::PUB_DIR) . '/' . self::MEDIA_REWRITE_SCRIPT; } return false; } @@ -682,8 +691,8 @@ class Store extends AbstractModel implements \Magento\Url\ScopeInterface public function isUseStoreInUrl() { return !($this->hasDisableStoreInUrl() && $this->getDisableStoreInUrl()) - && $this->_appState->isInstalled() - && $this->getConfig(self::XML_PATH_STORE_IN_URL); + && $this->_appState->isInstalled() + && $this->getConfig(self::XML_PATH_STORE_IN_URL); } /** @@ -736,7 +745,7 @@ class Store extends AbstractModel implements \Magento\Url\ScopeInterface if ($this->_appState->isInstalled()) { $secureBaseUrl = $this->_coreStoreConfig->getConfig(self::XML_PATH_SECURE_BASE_URL); - + if (!$secureBaseUrl) { return false; } @@ -918,12 +927,25 @@ class Store extends AbstractModel implements \Magento\Url\ScopeInterface $this->setCurrentCurrencyCode($baseCurrency->getCode()); } - $this->setData('current_currency', $currency); + $this->setCurrentCurrency($currency); } return $currency; } + /** + * Set current currency + * + * @param $currency + * @return $this + */ + public function setCurrentCurrency($currency) + { + $this->response->setVary('current_currency', $currency->getCurrencyCode()); + $this->setData('current_currency', $currency); + return $this; + } + /** * Retrieve current currency rate * @@ -1129,9 +1151,9 @@ class Store extends AbstractModel implements \Magento\Url\ScopeInterface } return $storeParsedUrl['scheme'] . '://' . $storeParsedUrl['host'] - . (isset($storeParsedUrl['port']) ? ':' . $storeParsedUrl['port'] : '') - . $storeParsedUrl['path'] . $requestString - . ($storeParsedQuery ? '?'.http_build_query($storeParsedQuery, '', '&') : ''); + . (isset($storeParsedUrl['port']) ? ':' . $storeParsedUrl['port'] : '') + . $storeParsedUrl['path'] . $requestString + . ($storeParsedQuery ? '?'.http_build_query($storeParsedQuery, '', '&') : ''); } /** diff --git a/app/code/Magento/Core/Model/Store/Storage/Db.php b/app/code/Magento/Core/Model/Store/Storage/Db.php index 9c7262ab3f91915d50fd29aa814c9a364156cd6b..eb1a26c4f8de4c43d1c6538dfa1abc33e11b67e8 100644 --- a/app/code/Magento/Core/Model/Store/Storage/Db.php +++ b/app/code/Magento/Core/Model/Store/Storage/Db.php @@ -156,18 +156,10 @@ class Db implements StorageInterface protected $_url; /** - * @param StoreFactory $storeFactory - * @param Website\Factory $websiteFactory - * @param Group\Factory $groupFactory - * @param \Magento\App\ConfigInterface $config - * @param \Magento\Stdlib\Cookie $cookie - * @param State $appState - * @param \Magento\Backend\Model\UrlInterface $url - * @param $isSingleStoreAllowed - * @param $scopeCode - * @param $scopeType - * @param null $currentStore + * @var \Magento\App\ResponseInterface */ + protected $response; + public function __construct( \Magento\Core\Model\StoreFactory $storeFactory, \Magento\Core\Model\Website\Factory $websiteFactory, @@ -176,6 +168,7 @@ class Db implements StorageInterface \Magento\Stdlib\Cookie $cookie, \Magento\App\State $appState, \Magento\Backend\Model\UrlInterface $url, + \Magento\App\ResponseInterface $response, $isSingleStoreAllowed, $scopeCode, $scopeType, @@ -191,6 +184,7 @@ class Db implements StorageInterface $this->_appState = $appState; $this->_cookie = $cookie; $this->_url = $url; + $this->response = $response; if ($currentStore) { $this->_currentStore = $currentStore; } @@ -290,6 +284,7 @@ class Db implements StorageInterface $this->_cookie->set(Store::COOKIE_NAME, null); } else { $this->_cookie->set(Store::COOKIE_NAME, $this->_currentStore, true); + $this->response->setVary(Store::ENTITY, $this->_currentStore); } } return; diff --git a/app/code/Magento/Core/Model/Translate/Inline/Config.php b/app/code/Magento/Core/Model/Translate/Inline/Config.php index 493be45b4c3896287716d76fb8d346af3dd13be9..48c9bfebd51476c898a02e5778c032ed981ce182 100644 --- a/app/code/Magento/Core/Model/Translate/Inline/Config.php +++ b/app/code/Magento/Core/Model/Translate/Inline/Config.php @@ -30,7 +30,7 @@ */ namespace Magento\Core\Model\Translate\Inline; -class Config implements ConfigInterface +class Config implements \Magento\Translate\Inline\ConfigInterface { /** * Core store config @@ -39,22 +39,36 @@ class Config implements ConfigInterface */ protected $_coreStoreConfig; + /** + * @var \Magento\Core\Helper\Data + */ + protected $_helper; + /** * @param \Magento\Core\Model\Store\Config $coreStoreConfig + * @param \Magento\Core\Helper\Data $helper */ - public function __construct(\Magento\Core\Model\Store\Config $coreStoreConfig) - { + public function __construct( + \Magento\Core\Model\Store\Config $coreStoreConfig, + \Magento\Core\Helper\Data $helper + ) { $this->_coreStoreConfig = $coreStoreConfig; + $this->_helper = $helper; } /** - * Check whether inline translation is enabled - * - * @param int|null $store - * @return bool + * @inheritdoc + */ + public function isActive($scope = null) + { + return $this->_coreStoreConfig->getConfigFlag('dev/translate_inline/active', $scope); + } + + /** + * @inheritdoc */ - public function isActive($store = null) + public function isDevAllowed($scope = null) { - return $this->_coreStoreConfig->getConfigFlag('dev/translate_inline/active', $store); + return $this->_helper->isDevAllowed($scope); } } diff --git a/app/code/Magento/Core/Model/Translate/InlineParser.php b/app/code/Magento/Core/Model/Translate/Inline/Parser.php similarity index 79% rename from app/code/Magento/Core/Model/Translate/InlineParser.php rename to app/code/Magento/Core/Model/Translate/Inline/Parser.php index a2417daaf350f126c5dd2f511f7d13b087ac72be..452b7faa1aaacfe4cfa71c9d66b2af2d1bd60b96 100644 --- a/app/code/Magento/Core/Model/Translate/InlineParser.php +++ b/app/code/Magento/Core/Model/Translate/Inline/Parser.php @@ -28,15 +28,10 @@ * This class is responsible for parsing content and applying necessary html element * wrapping and client scripts for inline translation. */ -namespace Magento\Core\Model\Translate; +namespace Magento\Core\Model\Translate\Inline; -class InlineParser +class Parser implements \Magento\Translate\Inline\ParserInterface { - /** - * Default state for jason flag - */ - const JSON_FLAG_DEFAULT_STATE = false; - /** * data-translate html element attribute name */ @@ -61,7 +56,7 @@ class InlineParser * * @var bool */ - protected $_isJson = self::JSON_FLAG_DEFAULT_STATE; + protected $_isJson = \Magento\Translate\Inline\ParserInterface::JSON_FLAG_DEFAULT_STATE; /** * Get max translate block in same tag @@ -125,19 +120,9 @@ class InlineParser ); /** - * @var \Magento\View\DesignInterface - */ - protected $_design; - - /** - * @var \Magento\Core\Helper\Data - */ - protected $_helper; - - /** - * @var \Magento\Core\Model\Resource\Translate\String + * @var \Magento\Core\Model\Resource\Translate\StringFactory */ - protected $_resource; + protected $_resourceFactory; /** * @var \Magento\Core\Model\StoreManagerInterface @@ -154,68 +139,54 @@ class InlineParser */ protected $_appState; + /** + * @var \Magento\Translate\InlineInterface + */ + protected $_translateInline; + + /** + * @var \Magento\App\Cache\TypeListInterface + */ + protected $_appCache; + /** * Initialize base inline translation model * - * @param \Magento\Core\Model\Resource\Translate\String $resource + * @param \Magento\Core\Model\Resource\Translate\StringFactory $resource * @param \Magento\Core\Model\StoreManagerInterface $storeManager - * @param \Magento\View\DesignInterface $design - * @param \Magento\Core\Helper\Data $helper * @param \Zend_Filter_Interface $inputFilter * @param \Magento\App\State $appState + * @param \Magento\App\Cache\TypeListInterface $appCache, + * @param \Magento\Translate\InlineInterface $translateInline */ public function __construct( - \Magento\Core\Model\Resource\Translate\String $resource, - \Magento\View\DesignInterface $design, - \Magento\Core\Helper\Data $helper, + \Magento\Core\Model\Resource\Translate\StringFactory $resource, \Magento\Core\Model\StoreManagerInterface $storeManager, \Zend_Filter_Interface $inputFilter, - \Magento\App\State $appState + \Magento\App\State $appState, + \Magento\App\Cache\TypeListInterface $appCache, + \Magento\Translate\InlineInterface $translateInline ) { - $this->_resource = $resource; - $this->_design = $design; - $this->_helper = $helper; + $this->_resourceFactory = $resource; $this->_storeManager = $storeManager; $this->_inputFilter = $inputFilter; $this->_appState = $appState; - } - - /** - * @return \Magento\View\DesignInterface - */ - public function getDesignPackage() - { - return $this->_design; - } - - /** - * @return \Magento\Core\Helper\Data - */ - public function getHelper() - { - return $this->_helper; - } - - /** - * @return \Magento\Core\Model\StoreManagerInterface - */ - public function getStoreManager() - { - return $this->_storeManager; + $this->_appCache = $appCache; + $this->_translateInline = $translateInline; } /** * Parse and save edited translation * * @param array $translateParams - * @param \Magento\Core\Model\Translate\InlineInterface $inlineInterface - * @return \Magento\Core\Model\Translate\InlineParser + * @return $this */ - public function processAjaxPost(array $translateParams, $inlineInterface) + public function processAjaxPost(array $translateParams) { - if (!$inlineInterface->isAllowed()) { + if (!$this->_translateInline->isAllowed()) { return $this; } + $this->_appCache->invalidate(\Magento\App\Cache\Type\Translate::TYPE_IDENTIFIER); $this->_validateTranslationParams($translateParams); $this->_filterTranslationParams($translateParams, array('custom')); @@ -223,16 +194,18 @@ class InlineParser /** @var $validStoreId int */ $validStoreId = $this->_storeManager->getStore()->getId(); + /** @var $resource \Magento\Core\Model\Resource\Translate\String */ + $resource = $this->_resourceFactory->create(); foreach ($translateParams as $param) { if ($this->_appState->getAreaCode() == \Magento\Backend\App\Area\FrontNameResolver::AREA_CODE) { $storeId = 0; } else if (empty($param['perstore'])) { - $this->_resource->deleteTranslate($param['original'], null, false); + $resource->deleteTranslate($param['original'], null, false); $storeId = 0; } else { $storeId = $validStoreId; } - $this->_resource->saveTranslate($param['original'], $param['custom'], null, $storeId); + $resource->saveTranslate($param['original'], $param['custom'], null, $storeId); } return $this; } @@ -273,16 +246,15 @@ class InlineParser * Replace html body with translation wrapping. * * @param string $body - * @param \Magento\Core\Model\Translate\InlineInterface $inlineInterface * @return string */ - public function processResponseBodyString($body, $inlineInterface) + public function processResponseBodyString($body) { $this->_content = $body; - $this->_specialTags($inlineInterface); - $this->_tagAttributes($inlineInterface); - $this->_otherText($inlineInterface); + $this->_specialTags(); + $this->_tagAttributes(); + $this->_otherText(); return $this->_content; } @@ -311,7 +283,7 @@ class InlineParser * Set flag about parsed content is Json * * @param bool $flag - * @return \Magento\Core\Model\Translate\InlineParser + * @return $this */ public function setIsJson($flag) { @@ -353,17 +325,16 @@ class InlineParser /** * Format translation for special tags. Adding translate mode attribute for vde requests. * - * @param \Magento\Core\Model\Translate\InlineInterface $inlineInterface * @param string $tagHtml * @param string $tagName * @param array $trArr * @return string */ - protected function _applySpecialTagsFormat($inlineInterface, $tagHtml, $tagName, $trArr) + protected function _applySpecialTagsFormat($tagHtml, $tagName, $trArr) { $specialTags = $tagHtml . '<span class="translate-inline-' . $tagName . '" ' . $this->_getHtmlAttribute(self::DATA_TRANSLATE, htmlspecialchars('[' . join(',', $trArr) . ']')); - $additionalAttr = $this->_getAdditionalHtmlAttribute($inlineInterface, $tagName); + $additionalAttr = $this->_getAdditionalHtmlAttribute($tagName); if ($additionalAttr !== null) { $specialTags .= ' ' . $additionalAttr . '>'; } else { @@ -376,17 +347,16 @@ class InlineParser /** * Format translation for simple tags. Added translate mode attribute for vde requests. * - * @param \Magento\Core\Model\Translate\InlineInterface $inlineInterface * @param string $tagHtml * @param string $tagName * @param array $trArr * @return string */ - protected function _applySimpleTagsFormat($inlineInterface, $tagHtml, $tagName, $trArr) + protected function _applySimpleTagsFormat($tagHtml, $tagName, $trArr) { $simpleTags = substr($tagHtml, 0, strlen($tagName) + 1) . ' ' . $this->_getHtmlAttribute(self::DATA_TRANSLATE, htmlspecialchars('[' . join(',', $trArr) . ']')); - $additionalAttr = $this->_getAdditionalHtmlAttribute($inlineInterface, $tagName); + $additionalAttr = $this->_getAdditionalHtmlAttribute($tagName); if ($additionalAttr !== null) { $simpleTags .= ' ' . $additionalAttr; } @@ -423,21 +393,18 @@ class InlineParser /** * Prepare tags inline translates - * - * @param \Magento\Core\Model\Translate\InlineInterface $inlineInterface */ - private function _tagAttributes($inlineInterface) + private function _tagAttributes() { - $this->_prepareTagAttributesForContent($this->_content, $inlineInterface); + $this->_prepareTagAttributesForContent($this->_content); } /** * Prepare tags inline translates for the content * * @param string $content - * @param \Magento\Core\Model\Translate\InlineInterface $inlineInterface */ - private function _prepareTagAttributesForContent(&$content, $inlineInterface) + private function _prepareTagAttributesForContent(&$content) { $quoteHtml = $this->_getHtmlQuote(); $tagMatch = array(); @@ -459,7 +426,7 @@ class InlineParser $trAttr = ' ' . $this->_getHtmlAttribute(self::DATA_TRANSLATE, htmlspecialchars('[' . join(',', $trArr) . ']')); } - $trAttr = $this->_addTranslateAttribute($inlineInterface, $trAttr); + $trAttr = $this->_addTranslateAttribute($trAttr); $tagHtml = substr_replace($tagHtml, $trAttr, strlen($tagMatch[1][0]) + 1, 1); $content = substr_replace($content, $tagHtml, $tagMatch[0][1], strlen($tagMatch[0][0])); @@ -483,14 +450,13 @@ class InlineParser /** * Add data-translate-mode attribute * - * @param \Magento\Core\Model\Translate\InlineInterface $inlineInterface * @param string $trAttr * @return string */ - private function _addTranslateAttribute($inlineInterface, $trAttr) + private function _addTranslateAttribute($trAttr) { $translateAttr = $trAttr; - $additionalAttr = $this->_getAdditionalHtmlAttribute($inlineInterface); + $additionalAttr = $this->_getAdditionalHtmlAttribute(); if ($additionalAttr !== null) { $translateAttr .= ' ' . $additionalAttr . ' '; } @@ -513,16 +479,11 @@ class InlineParser /** * Prepare special tags - * - * @param \Magento\Core\Model\Translate\InlineInterface $inlineInterface */ - private function _specialTags($inlineInterface) + private function _specialTags() { - $this->_translateTags($this->_content, $this->_allowedTagsGlobal, - $inlineInterface, '_applySpecialTagsFormat'); - - $this->_translateTags($this->_content, $this->_allowedTagsSimple, - $inlineInterface, '_applySimpleTagsFormat'); + $this->_translateTags($this->_content, $this->_allowedTagsGlobal, '_applySpecialTagsFormat'); + $this->_translateTags($this->_content, $this->_allowedTagsSimple, '_applySimpleTagsFormat'); } /** @@ -530,10 +491,9 @@ class InlineParser * * @param string $content * @param array $tagsList - * @param \Magento\Core\Model\Translate\InlineInterface $inlineInterface * @param string|array $formatCallback */ - private function _translateTags(&$content, $tagsList, $inlineInterface, $formatCallback) + private function _translateTags(&$content, $tagsList, $formatCallback) { $nextTag = 0; @@ -573,7 +533,7 @@ class InlineParser if (!empty($trArr)) { $trArr = array_unique($trArr); - $tagHtml = call_user_func(array($this, $formatCallback), $inlineInterface, $tagHtml, $tagName, $trArr); + $tagHtml = call_user_func(array($this, $formatCallback), $tagHtml, $tagName, $trArr); $tagClosurePos = $tagMatch[0][1] + strlen($tagHtml); $content = substr_replace($content, $tagHtml, $tagMatch[0][1], $tagLength); } @@ -612,10 +572,8 @@ class InlineParser /** * Prepare other text inline translates - * - * @param \Magento\Core\Model\Translate\InlineInterface $inlineInterface */ - private function _otherText($inlineInterface) + private function _otherText() { $next = 0; $matches = array(); @@ -628,7 +586,7 @@ class InlineParser 'scope' => $matches[4][0], )); - $spanHtml = $this->_getDataTranslateSpan($inlineInterface, + $spanHtml = $this->_getDataTranslateSpan( htmlspecialchars('[' . $translateProperties . ']'), $matches[1][0]); $this->_content = substr_replace($this->_content, $spanHtml, $matches[0][1], strlen($matches[0][0])); $next = $matches[0][1] + strlen($spanHtml) - 1; @@ -638,15 +596,14 @@ class InlineParser /** * Returns the html span that contains the data translate attribute including vde specific translate mode attribute * - * @param \Magento\Core\Model\Translate\InlineInterface $inlineInterface * @param string $data * @param string $text * @return string */ - protected function _getDataTranslateSpan($inlineInterface, $data, $text) + protected function _getDataTranslateSpan($data, $text) { $translateSpan = '<span '. $this->_getHtmlAttribute(self::DATA_TRANSLATE, $data); - $additionalAttr = $this->_getAdditionalHtmlAttribute($inlineInterface); + $additionalAttr = $this->_getAdditionalHtmlAttribute(); if ($additionalAttr !== null) { $translateSpan .= ' ' . $additionalAttr; } @@ -657,12 +614,11 @@ class InlineParser /** * Add an additional html attribute if needed. * - * @param \Magento\Core\Model\Translate\InlineInterface $inlineInterface * @param mixed|string $tagName * @return string */ - protected function _getAdditionalHtmlAttribute($inlineInterface, $tagName = null) + protected function _getAdditionalHtmlAttribute($tagName = null) { - return $inlineInterface->getAdditionalHtmlAttribute($tagName); + return $this->_translateInline->getAdditionalHtmlAttribute($tagName); } } diff --git a/app/code/Magento/Core/Model/Url/Rewrite.php b/app/code/Magento/Core/Model/Url/Rewrite.php index 66fcaaafa24c014feebb0cd9b52030c3acb22057..0ead5b3347ecb84485d482b983c0fdd8c7951329 100644 --- a/app/code/Magento/Core/Model/Url/Rewrite.php +++ b/app/code/Magento/Core/Model/Url/Rewrite.php @@ -84,12 +84,18 @@ class Rewrite extends \Magento\Core\Model\AbstractModel */ protected $_storeManager; + /** + * @var \Magento\App\ResponseInterface + */ + protected $response; + /** * @param \Magento\Core\Model\Context $context * @param \Magento\Core\Model\Registry $registry * @param \Magento\Core\Model\Store\Config $coreStoreConfig * @param \Magento\Core\Model\App $app * @param \Magento\Core\Model\StoreManagerInterface $storeManager + * @param \Magento\App\ResponseInterface $response * @param \Magento\Core\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data @@ -100,6 +106,7 @@ class Rewrite extends \Magento\Core\Model\AbstractModel \Magento\Core\Model\Store\Config $coreStoreConfig, \Magento\Core\Model\App $app, \Magento\Core\Model\StoreManagerInterface $storeManager, + \Magento\App\ResponseInterface $response, \Magento\Core\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() @@ -107,6 +114,7 @@ class Rewrite extends \Magento\Core\Model\AbstractModel $this->_coreStoreConfig = $coreStoreConfig; $this->_app = $app; $this->_storeManager = $storeManager; + $this->response = $response; parent::__construct($context, $registry, $resource, $resourceCollection, $data); } @@ -288,6 +296,7 @@ class Rewrite extends \Magento\Core\Model\AbstractModel $this->setStoreId($currentStore->getId())->loadByIdPath($this->getIdPath()); $this->_app->getCookie()->set(\Magento\Core\Model\Store::COOKIE_NAME, $currentStore->getCode(), true); + $this->response->setVary(\Magento\Core\Model\Store::ENTITY, $currentStore->getCode()); $targetUrl = $request->getBaseUrl(). '/' . $this->getRequestPath(); $this->_sendRedirectHeaders($targetUrl, true); @@ -304,6 +313,7 @@ class Rewrite extends \Magento\Core\Model\AbstractModel if ($external === 'http:/' || $external === 'https:') { $destinationStoreCode = $this->_storeManager->getStore($this->getStoreId())->getCode(); $this->_app->getCookie()->set(\Magento\Core\Model\Store::COOKIE_NAME, $destinationStoreCode, true); + $this->response->setVary(\Magento\Core\Model\Store::ENTITY, $destinationStoreCode); $this->_sendRedirectHeaders($this->getTargetPath(), $isPermanentRedirectOption); } else { diff --git a/app/code/Magento/Core/Model/Validator/Factory.php b/app/code/Magento/Core/Model/Validator/Factory.php index ef9f53d299d70b10f6ebac1ec4ef93534d2b51c9..c56a32a34f53784afe9599948b2d5cfa2bd36aee 100644 --- a/app/code/Magento/Core/Model/Validator/Factory.php +++ b/app/code/Magento/Core/Model/Validator/Factory.php @@ -33,7 +33,7 @@ class Factory protected $_objectManager; /** - * @var \Magento\Core\Model\Translate + * @var \Magento\TranslateInterface */ protected $_translator; @@ -49,12 +49,12 @@ class Factory * * @param \Magento\ObjectManager $objectManager * @param \Magento\Module\Dir\Reader $moduleReader - * @param \Magento\Core\Model\Translate $translator + * @param \Magento\TranslateInterface $translator */ public function __construct( \Magento\ObjectManager $objectManager, \Magento\Module\Dir\Reader $moduleReader, - \Magento\Core\Model\Translate $translator + \Magento\TranslateInterface $translator ) { $this->_objectManager = $objectManager; $this->_translator = $translator; @@ -70,9 +70,9 @@ class Factory { $translateAdapter = $this->_translator; $objectManager = $this->_objectManager; - // Pass translations to \Magento\Core\Model\Translate from validators + // Pass translations to \Magento\TranslateInterface from validators $translatorCallback = function () use ($translateAdapter, $objectManager) { - /** @var \Magento\Core\Model\Translate $translateAdapter */ + /** @var \Magento\TranslateInterface $translateAdapter */ return $translateAdapter->translate(func_get_args()); }; /** @var \Magento\Translate\Adapter $translator */ diff --git a/app/code/Magento/Core/etc/di.xml b/app/code/Magento/Core/etc/di.xml index 6bbc5c1ce0898f83b8e354bb8992cb8a9063a29e..252e2c952dc7bc73e1b5839ff636c4c3bc03e593 100644 --- a/app/code/Magento/Core/etc/di.xml +++ b/app/code/Magento/Core/etc/di.xml @@ -33,10 +33,10 @@ <preference for="Magento\Session\SessionManagerInterface" type="Magento\Core\Model\Session" /> <preference for="Magento\Core\Model\LocaleInterface" type="Magento\Core\Model\Locale" /> <preference for="Magento\Core\Model\DataService\ConfigInterface" type="Magento\Core\Model\DataService\Config" /> - <preference for="Magento\App\ConfigInterface" type="Magento\Core\Model\Config" /> - <preference for="Magento\App\ReinitableConfigInterface" type="Magento\Core\Model\ReinitableConfig" /> - <preference for="Magento\Core\Model\Config\DataInterface" type="Magento\Core\Model\Config\Data" /> - <preference for="Magento\Core\Model\Config\Storage\WriterInterface" type="Magento\Core\Model\Config\Storage\Writer\Db" /> + <preference for="Magento\App\ConfigInterface" type="Magento\App\Config" /> + <preference for="Magento\App\ReinitableConfigInterface" type="Magento\App\ReinitableConfig" /> + <preference for="Magento\App\Config\Scope\ReaderPoolInterface" type="Magento\Core\Model\Config\Scope\ReaderPool" /> + <preference for="Magento\App\Config\Storage\WriterInterface" type="Magento\Core\Model\Config\Storage\Db" /> <preference for="Magento\PubSub\Event\QueueWriterInterface" type="Magento\PubSub\Event\QueueWriter" /> <preference for="Magento\PubSub\Event\FactoryInterface" type="Magento\PubSub\Event\Factory" /> <preference for="Magento\View\Design\Theme\FileInterface" type="Magento\Core\Model\Theme\File" /> @@ -53,10 +53,12 @@ <preference for="Magento\View\Design\Theme\Customization\ConfigInterface" type="Magento\Core\Model\Theme\Customization\Config" /> <preference for="Magento\View\Asset\ConfigInterface" type="Magento\Core\Model\Asset\Config" /> <preference for="Magento\App\ViewInterface" type="Magento\App\View" /> - <preference for="Magento\TranslateInterface" type="Magento\Core\Model\Translate" /> + <preference for="Magento\TranslateInterface" type="Magento\Translate" /> <preference for="Magento\App\Response\RedirectInterface" type="Magento\Core\App\Response\Redirect" /> <preference for="Magento\Data\Collection\EntityFactoryInterface" type="Magento\Core\Model\EntityFactory" /> - <preference for="Magento\Core\Model\Translate\InlineInterface" type="Magento\Core\Model\Translate\Inline" /> + <preference for="Magento\Translate\InlineInterface" type="Magento\Translate\Inline" /> + <preference for="Magento\Translate\Inline\ConfigInterface" type="Magento\Core\Model\Translate\Inline\Config" /> + <preference for="Magento\Translate\Inline\ParserInterface" type="Magento\Core\Model\Translate\Inline\Parser" /> <preference for="Magento\Session\ValidatorInterface" type="Magento\Core\Model\Session\Validator" /> <preference for="Magento\Session\StorageInterface" type="Magento\Session\Storage" /> <preference for="Magento\Url\RouteParamsResolverInterface" type="Magento\Core\Model\Url\RouteParamsResolver" /> @@ -72,6 +74,16 @@ <preference for="Magento\Mview\View\SubscriptionInterface" type="Magento\Mview\View\Subscription" /> <preference for="Magento\Mview\View\ChangelogInterface" type="Magento\Mview\View\Changelog" /> <preference for="Magento\Css\PreProcessor\AdapterInterface" type="Magento\Css\PreProcessor\Adapter\Oyejorge" /> + <preference for="Magento\Translate\ResourceInterface" type="Magento\Core\Model\Resource\Translate" /> + <preference for="Magento\BaseScopeResolverInterface" type="Magento\Core\Model\BaseScopeResolver" /> + <type name="Magento\Translate\Inline"> + <param name="templateFileName"> + <value>Magento_Core::translate_inline.phtml</value> + </param> + <param name="translatorRoute"> + <value>core/ajax/translate</value> + </param> + </type> <type name="Magento\App\DefaultPath\DefaultPath"> <param name="parts"> <array> @@ -265,27 +277,48 @@ </type> <type name="Magento\Phrase\Renderer\Translate"> <param name="translator"> - <instance type="Magento\Core\Model\Translate" /> + <instance type="Magento\Translate" /> </param> </type> - <type name="Magento\Core\Model\Translate\InlineParser"> + <type name="Magento\Core\Model\Translate\Inline\Parser"> <param name="inputFilter"> <instance type="Magento\Core\Model\Input\Filter\MaliciousCode" /> </param> </type> - <type name="Magento\Core\Model\Config\SectionPool"> + <type name="Magento\App\Config\ScopePool"> <param name="cache"> <instance type="Magento\App\Cache\Type\Config" /> </param> </type> - <type name="Magento\Core\Model\Config\Section\Reader\Website"> - <param name="sectionPool"> - <instance type="Magento\Core\Model\Config\SectionPool\Proxy" /> + <type name="Magento\Core\Model\Config\Scope\Reader\Website"> + <param name="scopePool"> + <instance type="Magento\App\Config\ScopePool\Proxy" /> + </param> + </type> + <type name="Magento\Core\Model\Config\Scope\Reader\Store"> + <param name="scopePool"> + <instance type="Magento\App\Config\ScopePool\Proxy" /> </param> </type> - <type name="Magento\Core\Model\Config\Section\Reader\Store"> - <param name="sectionPool"> - <instance type="Magento\Core\Model\Config\SectionPool\Proxy" /> + <type name="Magento\App\Config\Initial\SchemaLocator"> + <param name="moduleName"> + <value>Magento_Core</value> + </param> + </type> + <type name="Magento\App\Config\Initial\Reader"> + <param name="converter"> + <instance type="Magento\App\Config\Initial\Converter" /> + </param> + </type> + <type name="Magento\Core\Model\Config\Scope\ReaderPool"> + <param name="default"> + <instance type="Magento\Core\Model\Config\Scope\Reader\DefaultReader" /> + </param> + <param name="website"> + <instance type="Magento\Core\Model\Config\Scope\Reader\Website" /> + </param> + <param name="store"> + <instance type="Magento\Core\Model\Config\Scope\Reader\Store" /> </param> </type> <type name="Magento\Core\App\Router\Base"> @@ -351,7 +384,7 @@ <value>fieldset_config</value> </param> </type> - <type name="Magento\Core\Model\Locale\Hierarchy\Config"> + <type name="Magento\Locale\Hierarchy\Config"> <param name="reader"> <instance type="Magento\Core\Model\Locale\Hierarchy\Config\Reader" /> </param> @@ -395,7 +428,7 @@ <instance type="Magento\Core\Helper\Data\Proxy" /> </param> </type> - <type name="Magento\Core\Model\Config\Section\Processor\Placeholder"> + <type name="Magento\Core\Model\Config\Scope\Processor\Placeholder"> <param name="request"> <instance type="Magento\App\Request\Http\Proxy" /> </param> @@ -470,7 +503,7 @@ </type> <type name="Magento\Core\Model\App\Area"> <param name="translator"> - <instance type="Magento\Core\Model\Translate\Proxy" /> + <instance type="Magento\Translate" /> </param> <param name="design"> <instance type="Magento\Core\Model\Design\Proxy" /> @@ -552,4 +585,13 @@ </array> </param> </type> + <type name="Magento\App\Config\Initial\Converter"> + <param name="nodeMap"> + <array> + <item key="default"><value>/config/default</value></item> + <item key="stores"><value>/config/stores</value></item> + <item key="websites"><value>/config/websites</value></item> + </array> + </param> + </type> </config> diff --git a/app/code/Magento/Core/sql/core_setup/install-1.6.0.0.php b/app/code/Magento/Core/sql/core_setup/install-1.6.0.0.php index eb6776bc79fe51eb74c56adc46f72ee5294c2d75..d856fed2969b9c5bba6e96667e2fa671ca5191a1 100644 --- a/app/code/Magento/Core/sql/core_setup/install-1.6.0.0.php +++ b/app/code/Magento/Core/sql/core_setup/install-1.6.0.0.php @@ -307,7 +307,7 @@ $table = $installer->getConnection() ), 'Key Id of Translation') ->addColumn('string', \Magento\DB\Ddl\Table::TYPE_TEXT, 255, array( 'nullable' => false, - 'default' => \Magento\Core\Model\Translate::DEFAULT_STRING, + 'default' => \Magento\TranslateInterface::DEFAULT_STRING, ), 'Translation String') ->addColumn('store_id', \Magento\DB\Ddl\Table::TYPE_SMALLINT, null, array( 'unsigned' => true, diff --git a/app/code/Magento/Core/sql/core_setup/upgrade-1.6.0.2-1.6.0.3.php b/app/code/Magento/Core/sql/core_setup/upgrade-1.6.0.2-1.6.0.3.php index 44aa9135131259faa098928fcba71727c97ba219..ad4e9a201d560fe9d0b93b9f52a461fe233131fb 100644 --- a/app/code/Magento/Core/sql/core_setup/upgrade-1.6.0.2-1.6.0.3.php +++ b/app/code/Magento/Core/sql/core_setup/upgrade-1.6.0.2-1.6.0.3.php @@ -40,7 +40,7 @@ $connection->dropIndex($table, $installer->getIdxName( $connection->addColumn($table, 'crc_string', array( 'type' => \Magento\DB\Ddl\Table::TYPE_BIGINT, 'nullable' => false, - 'default' => crc32(\Magento\Core\Model\Translate::DEFAULT_STRING), + 'default' => crc32(\Magento\TranslateInterface::DEFAULT_STRING), 'comment' => 'Translation String CRC32 Hash', )); diff --git a/app/code/Magento/Cron/Model/Config/Reader/Db.php b/app/code/Magento/Cron/Model/Config/Reader/Db.php index 5b29551e4d545ab8ad73741003a0929701032a5d..e930a1a5f9a0afbf8a1d23124518f72e3978e850 100644 --- a/app/code/Magento/Cron/Model/Config/Reader/Db.php +++ b/app/code/Magento/Cron/Model/Config/Reader/Db.php @@ -39,21 +39,21 @@ class Db protected $_converter; /** - * @var \Magento\Core\Model\Config\Section\Reader\DefaultReader + * @var \Magento\App\Config\Scope\ReaderInterface */ - protected $_defaultReader; + protected $_reader; /** * Initialize parameters * - * @param \Magento\Core\Model\Config\Section\Reader\DefaultReader $defaultReader - * @param \Magento\Cron\Model\Config\Converter\Db $converter + * @param \Magento\App\Config\Scope\ReaderInterface $defaultReader + * @param \Magento\Cron\Model\Config\Converter\Db $converter */ public function __construct( - \Magento\Core\Model\Config\Section\Reader\DefaultReader $defaultReader, + \Magento\App\Config\Scope\ReaderInterface $defaultReader, \Magento\Cron\Model\Config\Converter\Db $converter ) { - $this->_defaultReader = $defaultReader; + $this->_reader = $defaultReader; $this->_converter = $converter; } @@ -64,6 +64,6 @@ class Db */ public function get() { - return $this->_converter->convert($this->_defaultReader->read()); + return $this->_converter->convert($this->_reader->read()); } } diff --git a/app/code/Magento/Cron/etc/di.xml b/app/code/Magento/Cron/etc/di.xml index 5ef9bee105b33eaa86b23018e2c2ce88af794537..cc1bc7452d03e8eaedff73ccd64969758a33e342 100644 --- a/app/code/Magento/Cron/etc/di.xml +++ b/app/code/Magento/Cron/etc/di.xml @@ -26,16 +26,8 @@ <config> <preference for="Magento\Cron\Model\ConfigInterface" type="Magento\Cron\Model\Config" /> <type name="Magento\Cron\Model\Config\Reader\Db"> - <param name="converter"> - <instance type="Magento\Cron\Model\Config\Converter\Db" /> - </param> - </type> - <type name="Magento\Cron\Model\Config\Reader\Xml"> - <param name="converter"> - <instance type="Magento\Cron\Model\Config\Converter\Xml" /> - </param> - <param name="schemaLocator"> - <instance type="Magento\Cron\Model\Config\SchemaLocator" /> + <param name="defaultReader"> + <instance type="Magento\Core\Model\Config\Scope\Reader\DefaultReader" /> </param> </type> <type name="Magento\App\Cron"> diff --git a/app/code/Magento/Customer/Model/Customer.php b/app/code/Magento/Customer/Model/Customer.php index ea8c6f2d5af197902915df67d4fc6c7c4f0822db..3ee15ab8d917837613f07565e43d95a830623c3a 100644 --- a/app/code/Magento/Customer/Model/Customer.php +++ b/app/code/Magento/Customer/Model/Customer.php @@ -68,6 +68,8 @@ class Customer extends \Magento\Core\Model\AbstractModel const SUBSCRIBED_YES = 'yes'; const SUBSCRIBED_NO = 'no'; + const ENTITY = 'customer'; + /** * Model event prefix * @@ -203,14 +205,14 @@ class Customer extends \Magento\Core\Model\AbstractModel * @param \Magento\Core\Model\StoreManagerInterface $storeManager * @param \Magento\Eav\Model\Config $config * @param \Magento\Core\Model\Store\Config $coreStoreConfig - * @param \Magento\Customer\Model\Resource\Customer $resource - * @param \Magento\Customer\Model\Config\Share $configShare - * @param \Magento\Customer\Model\AddressFactory $addressFactory - * @param \Magento\Customer\Model\Resource\Address\CollectionFactory $addressesFactory + * @param Resource\Customer $resource + * @param Config\Share $configShare + * @param AddressFactory $addressFactory + * @param Resource\Address\CollectionFactory $addressesFactory * @param \Magento\Email\Model\Template\MailerFactory $mailerFactory * @param \Magento\Email\Model\InfoFactory $emailInfoFactory * @param \Magento\Customer\Service\V1\CustomerGroupServiceInterface $groupService - * @param \Magento\Customer\Model\AttributeFactory $attributeFactory + * @param AttributeFactory $attributeFactory * @param \Magento\Encryption\EncryptorInterface $encryptor * @param \Magento\Math\Random $mathRandom * @param \Magento\Stdlib\DateTime $dateTime diff --git a/app/code/Magento/Customer/Model/Session.php b/app/code/Magento/Customer/Model/Session.php index 133fa1f2b1fd6535f151010c0628e43e0499c967..2c7c5ae8a91148953a8d216d33a341d4d983c0dd 100644 --- a/app/code/Magento/Customer/Model/Session.php +++ b/app/code/Magento/Customer/Model/Session.php @@ -94,6 +94,10 @@ class Session extends \Magento\Session\SessionManager */ protected $_storeManager; + /** + * @var \Magento\App\ResponseInterface + */ + protected $response; /** * @param \Magento\App\RequestInterface $request * @param \Magento\Session\SidResolverInterface $sidResolver @@ -129,6 +133,7 @@ class Session extends \Magento\Session\SessionManager \Magento\Core\Model\Session $session, \Magento\Event\ManagerInterface $eventManager, \Magento\Core\Model\StoreManagerInterface $storeManager, + \Magento\App\ResponseInterface $response, $sessionName = null, array $data = array() ) { @@ -141,6 +146,7 @@ class Session extends \Magento\Session\SessionManager $this->_session = $session; $this->_eventManager = $eventManager; $this->_storeManager = $storeManager; + $this->response = $response; parent::__construct($request, $sidResolver, $sessionConfig, $saveHandler, $validator, $storage); $this->start($sessionName); $this->_eventManager->dispatch('customer_session_init', array('customer_session' => $this)); @@ -177,6 +183,7 @@ class Session extends \Magento\Session\SessionManager $customer->setConfirmation(null)->save(); $customer->setIsJustConfirmed(true); } + $this->response->setVary('customer_group', $this->_customer->getGroupId()); return $this; } @@ -219,6 +226,7 @@ class Session extends \Magento\Session\SessionManager */ public function getCustomerId() { + if ($this->storage->getData('customer_id')) { return $this->storage->getData('customer_id'); } @@ -251,6 +259,7 @@ class Session extends \Magento\Session\SessionManager if ($this->isLoggedIn() && $this->getCustomer()) { return $this->getCustomer()->getGroupId(); } + return \Magento\Customer\Model\Group::NOT_LOGGED_IN_ID; } diff --git a/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Container.php b/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Container.php index ddbf259c6f1e0704f8232747bceecea062c6eded..1867cd3aeab3cbcdd49268f04a1381b71e2f253b 100644 --- a/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Container.php +++ b/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Container.php @@ -23,14 +23,13 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\DesignEditor\Block\Adminhtml\Editor; /** * Editor toolbar * * @method \Magento\DesignEditor\Block\Adminhtml\Editor\Container setTheme(\Magento\View\Design\ThemeInterface $theme) */ -namespace Magento\DesignEditor\Block\Adminhtml\Editor; - class Container extends \Magento\Backend\Block\Widget\Container { /** @@ -42,6 +41,8 @@ class Container extends \Magento\Backend\Block\Widget\Container /** * Add elements in layout + * + * @return void */ protected function _prepareLayout() { @@ -67,7 +68,7 @@ class Container extends \Magento\Backend\Block\Widget\Container /** * @param string $url * - * @return \Magento\DesignEditor\Block\Adminhtml\Editor\Container + * @return $this */ public function setFrameUrl($url) { diff --git a/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Form/Element/Button.php b/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Form/Element/Button.php index af8b2b1efb1c515dc7946c08b2495d152cb4822f..863a972385a2960c6a20e07d434ecbccf3ec99c2 100644 --- a/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Form/Element/Button.php +++ b/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Form/Element/Button.php @@ -23,18 +23,17 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\DesignEditor\Block\Adminhtml\Editor\Form\Element; /** * Form element button */ -namespace Magento\DesignEditor\Block\Adminhtml\Editor\Form\Element; - class Button extends \Magento\Data\Form\Element\AbstractElement { /** * Additional html attributes * - * @var array + * @var string[] */ protected $_htmlAttributes = array('data-mage-init'); @@ -70,7 +69,7 @@ class Button extends \Magento\Data\Form\Element\AbstractElement /** * Html attributes * - * @return array + * @return string[] */ public function getHtmlAttributes() { diff --git a/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Form/Element/ColorPicker.php b/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Form/Element/ColorPicker.php index d89ad5bfa32da8e0eb35b79da7320e11ddd6f036..e76d41649128f28aab4667733b22e718014e03ea 100644 --- a/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Form/Element/ColorPicker.php +++ b/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Form/Element/ColorPicker.php @@ -23,6 +23,7 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\DesignEditor\Block\Adminhtml\Editor\Form\Element; /** * Form element renderer to display color picker element for VDE @@ -34,8 +35,6 @@ * @method string getNote() * @method \Magento\DesignEditor\Block\Adminhtml\Editor\Form\Element\ColorPicker setCssClass($class) */ -namespace Magento\DesignEditor\Block\Adminhtml\Editor\Form\Element; - class ColorPicker extends \Magento\Data\Form\Element\AbstractElement { /** @@ -45,6 +44,8 @@ class ColorPicker extends \Magento\Data\Form\Element\AbstractElement /** * Constructor helper + * + * @return void */ public function _construct() { diff --git a/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Form/Element/Column.php b/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Form/Element/Column.php index 7edb97b6d16a6f2a9615f254d26c579832984c97..f674c997b6a09895258a3ad67fbcf249990c1f05 100644 --- a/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Form/Element/Column.php +++ b/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Form/Element/Column.php @@ -23,14 +23,13 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\DesignEditor\Block\Adminhtml\Editor\Form\Element; /** * Column renderer to Quick Styles panel in VDE * * @method \Magento\DesignEditor\Block\Adminhtml\Editor\Form\Element\Column setClass($class) */ -namespace Magento\DesignEditor\Block\Adminhtml\Editor\Form\Element; - class Column extends \Magento\Data\Form\Element\Fieldset implements \Magento\DesignEditor\Block\Adminhtml\Editor\Form\Element\ContainerInterface @@ -52,6 +51,8 @@ class Column /** * Constructor helper + * + * @return void */ public function _construct() { @@ -64,7 +65,7 @@ class Column /** * Add element types that can be added to 'column' element * - * @return \Magento\DesignEditor\Block\Adminhtml\Editor\Form\Element\Column + * @return $this */ protected function _addElementTypes() { @@ -89,7 +90,7 @@ class Column /** * @param \Magento\DesignEditor\Model\Editor\Tools\QuickStyles\Form\Renderer\Factory $factory - * @return \Magento\DesignEditor\Block\Adminhtml\Editor\Form\Element\Column + * @return $this */ public function setRendererFactory($factory) { @@ -111,7 +112,7 @@ class Column /** * @param \Magento\DesignEditor\Model\Editor\Tools\QuickStyles\Form\Element\Factory $factory - * @return \Magento\DesignEditor\Block\Adminhtml\Editor\Form\Element\Column + * @return $this */ public function setElementsFactory($factory) { diff --git a/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Form/Element/Composite/AbstractComposite.php b/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Form/Element/Composite/AbstractComposite.php index eaca4a2e917e5ff3bfe4edf9e59d74ca0be30791..998b88a80cf9e41f365dc7492c9bbc847da28112 100644 --- a/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Form/Element/Composite/AbstractComposite.php +++ b/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Form/Element/Composite/AbstractComposite.php @@ -23,6 +23,7 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\DesignEditor\Block\Adminhtml\Editor\Form\Element\Composite; /** * Parent composite form element for VDE @@ -44,8 +45,6 @@ * @method string getLabel() * @method \Magento\DesignEditor\Block\Adminhtml\Editor\Form\Element\Composite\AbstractComposite setLegend($legend) */ -namespace Magento\DesignEditor\Block\Adminhtml\Editor\Form\Element\Composite; - abstract class AbstractComposite extends \Magento\Data\Form\Element\Fieldset implements \Magento\DesignEditor\Block\Adminhtml\Editor\Form\Element\ContainerInterface @@ -93,6 +92,8 @@ abstract class AbstractComposite /** * Constructor helper + * + * @return void */ protected function _construct() { diff --git a/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Form/Element/FontPicker.php b/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Form/Element/FontPicker.php index 0d568bac39a1598e64ea2bf5ee0b6f8da71877f7..64c683e9dde25e914ba56931b9874a1fa62aac3b 100644 --- a/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Form/Element/FontPicker.php +++ b/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Form/Element/FontPicker.php @@ -24,6 +24,8 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\DesignEditor\Block\Adminhtml\Editor\Form\Element; + /** * Form element renderer to display font picker element for VDE * @@ -31,8 +33,6 @@ * @method \Magento\DesignEditor\Block\Adminhtml\Editor\Form\Element\FontPicker setOptions(array $options) * @method \Magento\DesignEditor\Block\Adminhtml\Editor\Form\Element\FontPicker setCssClass($class) */ -namespace Magento\DesignEditor\Block\Adminhtml\Editor\Form\Element; - class FontPicker extends \Magento\Data\Form\Element\Select { /** @@ -43,7 +43,7 @@ class FontPicker extends \Magento\Data\Form\Element\Select /** * Default options which can be limited further by element's 'options' data * - * @var array + * @var string[] */ protected $_defaultOptions = array( 'Arial, Helvetica, sans-serif', @@ -54,6 +54,8 @@ class FontPicker extends \Magento\Data\Form\Element\Select /** * Constructor helper + * + * @return void */ public function _construct() { diff --git a/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Form/Element/Uploader.php b/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Form/Element/Uploader.php index 08584e34f89e3bbea5ea251ffd50cab7e96a92d3..985287fbc0b1c42dbcd4725af291f392fd1e1971 100644 --- a/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Form/Element/Uploader.php +++ b/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Form/Element/Uploader.php @@ -23,6 +23,7 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\DesignEditor\Block\Adminhtml\Editor\Form\Element; /** * Form element renderer to display file element for VDE @@ -30,8 +31,6 @@ * @method \Magento\DesignEditor\Block\Adminhtml\Editor\Form\Element\Uploader setAccept($accept) * @method \Magento\DesignEditor\Block\Adminhtml\Editor\Form\Element\Uploader setMultiple(bool $isMultiple) */ -namespace Magento\DesignEditor\Block\Adminhtml\Editor\Form\Element; - class Uploader extends \Magento\Data\Form\Element\File { //const CONTROL_TYPE = 'uploader'; @@ -39,14 +38,14 @@ class Uploader extends \Magento\Data\Form\Element\File /** * Additional html attributes * - * @var array + * @var string[] */ protected $_htmlAttributes = array('accept', 'multiple'); /** * Html attributes * - * @return array + * @return string[] */ public function getHtmlAttributes() { diff --git a/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Form/Renderer/BackgroundUploader.php b/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Form/Renderer/BackgroundUploader.php index 7c027c4fe91906f10b1a645eb9bd60debc8245d3..5a816d5e29d9800b7d21c48323eaabf7b6bd2eee 100644 --- a/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Form/Renderer/BackgroundUploader.php +++ b/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Form/Renderer/BackgroundUploader.php @@ -23,12 +23,11 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\DesignEditor\Block\Adminhtml\Editor\Form\Renderer; /** * Color-picker form element renderer */ -namespace Magento\DesignEditor\Block\Adminhtml\Editor\Form\Renderer; - class BackgroundUploader extends \Magento\DesignEditor\Block\Adminhtml\Editor\Form\Renderer { diff --git a/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Form/Renderer/Checkbox.php b/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Form/Renderer/Checkbox.php index 2d07ad8848d038b3710f7182a9de934ccaea9cc4..be24f00f4ec19615f3dcea33fb1764ce7f47094b 100644 --- a/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Form/Renderer/Checkbox.php +++ b/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Form/Renderer/Checkbox.php @@ -23,12 +23,11 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\DesignEditor\Block\Adminhtml\Editor\Form\Renderer; /** * Checkbox form element renderer */ -namespace Magento\DesignEditor\Block\Adminhtml\Editor\Form\Renderer; - class Checkbox extends \Magento\DesignEditor\Block\Adminhtml\Editor\Form\Renderer\Recursive { @@ -37,7 +36,7 @@ class Checkbox * * Upper is rendered first and is inserted into next using <?php echo $this->getHtml() ?> * - * @var array + * @var string[] */ protected $_templates = array( 'Magento_DesignEditor::editor/form/renderer/element/input.phtml', diff --git a/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Form/Renderer/ColorPicker.php b/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Form/Renderer/ColorPicker.php index ca16c27468dee14a58f54dcc0f54943d26a2b53e..83d0f7026702614d0b25aea9a282d9064a4a4670 100644 --- a/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Form/Renderer/ColorPicker.php +++ b/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Form/Renderer/ColorPicker.php @@ -23,12 +23,11 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\DesignEditor\Block\Adminhtml\Editor\Form\Renderer; /** * Color-picker form element renderer */ -namespace Magento\DesignEditor\Block\Adminhtml\Editor\Form\Renderer; - class ColorPicker extends \Magento\DesignEditor\Block\Adminhtml\Editor\Form\Renderer\Recursive { @@ -38,7 +37,7 @@ class ColorPicker * Upper is rendered first and is inserted into next using <?php echo $this->getHtml() ?> * Templates used are based fieldset/element.phtml but split into several templates * - * @var array + * @var string[] */ protected $_templates = array( 'Magento_DesignEditor::editor/form/renderer/element/input.phtml', @@ -52,7 +51,7 @@ class ColorPicker * * Actually it will be added to a field wrapper * - * @return array + * @return string[] */ public function getFieldClass() { diff --git a/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Form/Renderer/Composite.php b/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Form/Renderer/Composite.php index 935a8131b394baa5cbc2337000c18d860b3085b5..2eb43ae4c9e1345a7c7370062de869683943fef4 100644 --- a/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Form/Renderer/Composite.php +++ b/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Form/Renderer/Composite.php @@ -23,12 +23,11 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\DesignEditor\Block\Adminhtml\Editor\Form\Renderer; /** * Composite form element renderer */ -namespace Magento\DesignEditor\Block\Adminhtml\Editor\Form\Renderer; - class Composite extends \Magento\DesignEditor\Block\Adminhtml\Editor\Form\Renderer\Recursive { @@ -38,7 +37,7 @@ class Composite * Upper is rendered first and is inserted into next using <?php echo $this->getHtml() ?> * This templates are made of fieldset.phtml but split into several templates * - * @var array + * @var string[] */ protected $_templates = array( 'Magento_DesignEditor::editor/form/renderer/composite/children.phtml', @@ -51,7 +50,7 @@ class Composite * * Used in composite.phtml * - * @return array + * @return string[] */ public function getCssClasses() { diff --git a/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Form/Renderer/Font.php b/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Form/Renderer/Font.php index 65285c2a5b47c685c753ca015be06b9767a8320f..3d453b03a2695a049c8b20085d9309b09b0c65d4 100644 --- a/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Form/Renderer/Font.php +++ b/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Form/Renderer/Font.php @@ -23,12 +23,11 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\DesignEditor\Block\Adminhtml\Editor\Form\Renderer; /** * Composite 'font' element renderer */ -namespace Magento\DesignEditor\Block\Adminhtml\Editor\Form\Renderer; - class Font extends \Magento\DesignEditor\Block\Adminhtml\Editor\Form\Renderer { @@ -42,7 +41,7 @@ class Font /** * Get element CSS classes * - * @return array + * @return string[] */ public function getClasses() { diff --git a/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Form/Renderer/LogoUploader.php b/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Form/Renderer/LogoUploader.php index 2fd100da8b6f092ff44704422c97068a4730cce8..ffd9e42ad16fc02b0e4ebed178a0a570c3620fca 100644 --- a/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Form/Renderer/LogoUploader.php +++ b/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Form/Renderer/LogoUploader.php @@ -23,7 +23,6 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ - namespace Magento\DesignEditor\Block\Adminhtml\Editor\Form\Renderer; /** @@ -53,7 +52,7 @@ class LogoUploader * * Upper is rendered first and is inserted into next using <?php echo $this->getHtml() ?> * - * @var array + * @var string[] */ protected $_templates = array( 'Magento_DesignEditor::editor/form/renderer/element/input.phtml', diff --git a/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Form/Renderer/Recursive.php b/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Form/Renderer/Recursive.php index 60ac128b7f674cf5df4fc5b5963457fc2be13f01..911a87d01e5c8b2ab93a6ef474cb705d5ed75f81 100644 --- a/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Form/Renderer/Recursive.php +++ b/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Form/Renderer/Recursive.php @@ -23,6 +23,7 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\DesignEditor\Block\Adminhtml\Editor\Form\Renderer; /** * Recursive renderer that uses several templates @@ -30,8 +31,6 @@ * @method string getHtml() * @method \Magento\DesignEditor\Block\Adminhtml\Editor\Form\Renderer\Recursive setHtml($html) */ -namespace Magento\DesignEditor\Block\Adminhtml\Editor\Form\Renderer; - class Recursive extends \Magento\Backend\Block\Template implements \Magento\Data\Form\Element\Renderer\RendererInterface { @@ -56,7 +55,7 @@ class Recursive extends \Magento\Backend\Block\Template * * Upper is rendered first and is inserted into next using <?php echo $this->getHtml() ?> * - * @var array + * @var string[] */ protected $_templates = array(); diff --git a/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Form/Renderer/Uploader.php b/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Form/Renderer/Uploader.php index 583e64fcd96bffb540cd95a3bb5ac911e4ef30e9..a40e209c96d2597baa9a9e0c4888ef4b0233274f 100644 --- a/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Form/Renderer/Uploader.php +++ b/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Form/Renderer/Uploader.php @@ -23,12 +23,11 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\DesignEditor\Block\Adminhtml\Editor\Form\Renderer; /** * File uploader form element renderer */ -namespace Magento\DesignEditor\Block\Adminhtml\Editor\Form\Renderer; - class Uploader extends \Magento\DesignEditor\Block\Adminhtml\Editor\Form\Renderer\Recursive { @@ -37,7 +36,7 @@ class Uploader * * Upper is rendered first and is inserted into next using <?php echo $this->getHtml() ?> * - * @var array + * @var string[] */ protected $_templates = array( 'Magento_DesignEditor::editor/form/renderer/element/input.phtml', diff --git a/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Toolbar/Buttons.php b/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Toolbar/Buttons.php index 36b8a13c07cc169565784f795367ff5019b8d87e..dfce6e495884699eba8fd1b3fb5f9d84645e9440 100644 --- a/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Toolbar/Buttons.php +++ b/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Toolbar/Buttons.php @@ -23,6 +23,7 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\DesignEditor\Block\Adminhtml\Editor\Toolbar; /** * VDE buttons block @@ -30,8 +31,6 @@ * @method \Magento\DesignEditor\Block\Adminhtml\Editor\Toolbar\Buttons setVirtualThemeId(int $id) * @method int getVirtualThemeId() */ -namespace Magento\DesignEditor\Block\Adminhtml\Editor\Toolbar; - class Buttons extends \Magento\DesignEditor\Block\Adminhtml\Editor\Toolbar\AbstractBlock { @@ -75,7 +74,7 @@ class Buttons * Get current theme id * * @param int $themeId - * @return \Magento\DesignEditor\Block\Adminhtml\Editor\Toolbar\Buttons + * @return $this */ public function setThemeId($themeId) { diff --git a/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Toolbar/Buttons/Edit.php b/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Toolbar/Buttons/Edit.php index 6d2a225ce137057065aebfcce7364b77b70b8309..6cba0c34a5fa67a35feab45aff74bd5d0709aafd 100644 --- a/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Toolbar/Buttons/Edit.php +++ b/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Toolbar/Buttons/Edit.php @@ -23,12 +23,11 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\DesignEditor\Block\Adminhtml\Editor\Toolbar\Buttons; /** * Edit button block */ -namespace Magento\DesignEditor\Block\Adminhtml\Editor\Toolbar\Buttons; - class Edit extends \Magento\Backend\Block\Widget\Button\SplitButton { @@ -102,7 +101,7 @@ class Edit /** * Whether button is disabled * - * @return mixed + * @return bool */ public function getDisabled() { diff --git a/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Toolbar/Buttons/Save.php b/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Toolbar/Buttons/Save.php index ea0891b6e8ed6a9a33ac0551978d5f80fa38c724..713ebcd6b7323a8e52311cd84c259bb338e3bf5c 100644 --- a/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Toolbar/Buttons/Save.php +++ b/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Toolbar/Buttons/Save.php @@ -23,6 +23,7 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\DesignEditor\Block\Adminhtml\Editor\Toolbar\Buttons; /** * Save button block @@ -31,8 +32,6 @@ * @method \Magento\DesignEditor\Block\Adminhtml\Editor\Toolbar\Buttons\Save setHasThemeAssigned(bool $flag) * @method \Magento\DesignEditor\Block\Adminhtml\Editor\Toolbar\Buttons\Save setMode(bool $flag) */ -namespace Magento\DesignEditor\Block\Adminhtml\Editor\Toolbar\Buttons; - class Save extends \Magento\Backend\Block\Widget\Button\SplitButton { /** @@ -99,7 +98,7 @@ class Save extends \Magento\Backend\Block\Widget\Button\SplitButton /** * Whether button is disabled * - * @return mixed + * @return bool */ public function getDisabled() { diff --git a/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Tools.php b/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Tools.php index 75b2ed9fe617ca2b699b51b934fc3ce049662437..a2626e0096cded00ad88cbfad71693707ed8278f 100644 --- a/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Tools.php +++ b/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Tools.php @@ -23,6 +23,7 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\DesignEditor\Block\Adminhtml\Editor; /** * Block that renders VDE tools panel @@ -30,8 +31,6 @@ * @method string getMode() * @method \Magento\DesignEditor\Block\Adminhtml\Editor\Tools setMode($mode) */ -namespace Magento\DesignEditor\Block\Adminhtml\Editor; - class Tools extends \Magento\Backend\Block\Template { /** @@ -104,7 +103,7 @@ class Tools extends \Magento\Backend\Block\Template /** * Get tabs html * - * @return array + * @return string[] */ public function getTabContents() { @@ -118,7 +117,7 @@ class Tools extends \Magento\Backend\Block\Template /** * Get tabs handles * - * @return array + * @return string[] */ public function getTabHandles() { diff --git a/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Tools/Code.php b/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Tools/Code.php index a7dd5c6598571556ad7322ffe3f4b46f0b780e91..0a21fa85fb011dd9da42854c0da09968bcd68f6c 100644 --- a/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Tools/Code.php +++ b/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Tools/Code.php @@ -23,12 +23,11 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\DesignEditor\Block\Adminhtml\Editor\Tools; /** * Block that renders Code tab (or Advanced tab) */ -namespace Magento\DesignEditor\Block\Adminhtml\Editor\Tools; - class Code extends \Magento\DesignEditor\Block\Adminhtml\Editor\Tools\Tabs\AbstractTabs { diff --git a/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Tools/Code/Css.php b/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Tools/Code/Css.php index e730ee7668d445b7e4e3b048896f89baad4c39d2..187b5b43daf450f0e29bd8f7e17b9e0417f0b99c 100644 --- a/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Tools/Code/Css.php +++ b/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Tools/Code/Css.php @@ -23,18 +23,17 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\DesignEditor\Block\Adminhtml\Editor\Tools\Code; /** * Block that renders CSS tab */ -namespace Magento\DesignEditor\Block\Adminhtml\Editor\Tools\Code; - class Css extends \Magento\View\Element\Template { /** * Get file groups content * - * @return array + * @return string[] */ public function getFileGroups() { diff --git a/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Tools/Code/Css/Group.php b/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Tools/Code/Css/Group.php index 83ede77bd1b4be92ca2cae59994da17e122e863a..b15e5078abab24fcd0f8ddcf8bba5d6aa43ade0c 100644 --- a/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Tools/Code/Css/Group.php +++ b/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Tools/Code/Css/Group.php @@ -23,12 +23,11 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\DesignEditor\Block\Adminhtml\Editor\Tools\Code\Css; /** * Block that renders group of files */ -namespace Magento\DesignEditor\Block\Adminhtml\Editor\Tools\Code\Css; - class Group extends \Magento\Backend\Block\Widget\Form { /** @@ -68,7 +67,7 @@ class Group extends \Magento\Backend\Block\Widget\Form /** * Check if files group needs "add" button * - * @return bool + * @return false */ public function hasAddButton() { @@ -78,7 +77,7 @@ class Group extends \Magento\Backend\Block\Widget\Form /** * Check if files group needs download buttons next to each file * - * @return bool + * @return true */ public function hasDownloadButton() { diff --git a/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Tools/Code/ImageSizing.php b/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Tools/Code/ImageSizing.php index 6f5c166a39c62fd1fba10f187b2be97022850190..d1f48b00bdfe67f55a096d79422c1b5e3bcf0f54 100644 --- a/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Tools/Code/ImageSizing.php +++ b/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Tools/Code/ImageSizing.php @@ -23,9 +23,11 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ - namespace Magento\DesignEditor\Block\Adminhtml\Editor\Tools\Code; +use Magento\Data\Form; +use Magento\DesignEditor\Model\Editor\Tools\Controls\Configuration; + /** * Block that renders Custom tab * @@ -86,11 +88,11 @@ class ImageSizing extends \Magento\Backend\Block\Widget\Form\Generic /** * Create a form element with necessary controls * - * @return \Magento\Theme\Block\Adminhtml\System\Design\Theme\Edit\Tab\Css + * @return $this */ protected function _prepareForm() { - /** @var \Magento\Data\Form $form */ + /** @var Form $form */ $form = $this->_formFactory->create(array( 'data' => array( 'action' => '#', @@ -105,7 +107,7 @@ class ImageSizing extends \Magento\Backend\Block\Widget\Form\Generic $isFilePresent = true; try{ - /** @var $controlsConfig \Magento\DesignEditor\Model\Editor\Tools\Controls\Configuration */ + /** @var $controlsConfig Configuration */ $controlsConfig = $this->_controlFactory->create( \Magento\DesignEditor\Model\Editor\Tools\Controls\Factory::TYPE_IMAGE_SIZING, $this->_themeContext->getStagingTheme() @@ -129,9 +131,9 @@ class ImageSizing extends \Magento\Backend\Block\Widget\Form\Generic /** * Initialize form elements * - * @param \Magento\DesignEditor\Model\Editor\Tools\Controls\Configuration $controlsConfig - * @param \Magento\Data\Form $form - * @return \Magento\DesignEditor\Block\Adminhtml\Editor\Tools\Code\ImageSizing + * @param Configuration $controlsConfig + * @param Form $form + * @return $this */ protected function _initFormElements($controlsConfig, $form) { @@ -184,11 +186,11 @@ class ImageSizing extends \Magento\Backend\Block\Widget\Form\Generic * Add white border checkbox to form * * @param array $control - * @return \Magento\DesignEditor\Block\Adminhtml\Editor\Tools\Code\ImageSizing + * @return $this */ protected function _addWhiteBorderElement($control) { - /** @var $form \Magento\Data\Form */ + /** @var $form Form */ $form = $this->getForm(); $fieldMessage = __('Add white borders to images that are smaller than the container.'); foreach ($control['components'] as $name => $component) { @@ -217,11 +219,11 @@ class ImageSizing extends \Magento\Backend\Block\Widget\Form\Generic * * @param string $name * @param array $control - * @return \Magento\DesignEditor\Block\Adminhtml\Editor\Tools\Code\ImageSizing + * @return $this */ protected function _addImageSizeFieldset($name, $control) { - /** @var $form \Magento\Data\Form */ + /** @var $form Form */ $form = $this->getForm(); $fieldset = $form->addFieldset($name, array( 'name' => $name, @@ -246,7 +248,7 @@ class ImageSizing extends \Magento\Backend\Block\Widget\Form\Generic * @param \Magento\Data\Form\Element\Fieldset $fieldset * @param array $component * @param string $componentName - * @return \Magento\DesignEditor\Block\Adminhtml\Editor\Tools\Code\ImageSizing + * @return $this */ protected function _addFormElement($fieldset, $component, $componentName) { @@ -273,7 +275,7 @@ class ImageSizing extends \Magento\Backend\Block\Widget\Form\Generic * @param \Magento\Data\Form\Element\Fieldset $fieldset * @param array $component * @param string $componentName - * @return \Magento\DesignEditor\Block\Adminhtml\Editor\Tools\Code\ImageSizing + * @return $this */ protected function _addImageTypeElement($fieldset, $component, $componentName) { @@ -291,7 +293,7 @@ class ImageSizing extends \Magento\Backend\Block\Widget\Form\Generic * @param \Magento\Data\Form\Element\Fieldset $fieldset * @param array $component * @param string $componentName - * @return \Magento\DesignEditor\Block\Adminhtml\Editor\Tools\Code\ImageSizing + * @return $this */ protected function _addImageWidthElement($fieldset, $component, $componentName) { @@ -310,7 +312,7 @@ class ImageSizing extends \Magento\Backend\Block\Widget\Form\Generic * @param \Magento\Data\Form\Element\Fieldset $fieldset * @param array $component * @param string $componentName - * @return \Magento\DesignEditor\Block\Adminhtml\Editor\Tools\Code\ImageSizing + * @return $this */ protected function _addImageHeightElement($fieldset, $component, $componentName) { @@ -329,7 +331,7 @@ class ImageSizing extends \Magento\Backend\Block\Widget\Form\Generic * @param \Magento\Data\Form\Element\Fieldset $fieldset * @param array $component * @param string $componentName - * @return \Magento\DesignEditor\Block\Adminhtml\Editor\Tools\Code\ImageSizing + * @return $this */ protected function _addImageRatioElement($fieldset, $component, $componentName) { @@ -353,7 +355,7 @@ class ImageSizing extends \Magento\Backend\Block\Widget\Form\Generic * @param \Magento\Data\Form\Element\Fieldset $fieldset * @param array $defaultValues * @param string $name - * @return \Magento\DesignEditor\Block\Adminhtml\Editor\Tools\Code\ImageSizing + * @return $this */ protected function _addResetButton($fieldset, $defaultValues, $name) { @@ -403,7 +405,7 @@ class ImageSizing extends \Magento\Backend\Block\Widget\Form\Generic /** * Return product image types * - * @return array + * @return string[] */ public function getImageTypes() { diff --git a/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Tools/Files/Content/Files.php b/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Tools/Files/Content/Files.php index 83e17b407ac6a6336a601c97f5130146a1b6f660..6a6b80013408b802931917c0a0a138f225d6eb7d 100644 --- a/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Tools/Files/Content/Files.php +++ b/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Tools/Files/Content/Files.php @@ -23,6 +23,7 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\DesignEditor\Block\Adminhtml\Editor\Tools\Files\Content; /** * Files files block @@ -31,8 +32,6 @@ * setStorage(\Magento\Theme\Model\Wysiwyg\Storage $storage) * @method \Magento\Theme\Model\Wysiwyg\Storage getStorage */ -namespace Magento\DesignEditor\Block\Adminhtml\Editor\Tools\Files\Content; - class Files extends \Magento\Theme\Block\Adminhtml\Wysiwyg\Files\Content\Files { diff --git a/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Tools/QuickStyles.php b/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Tools/QuickStyles.php index ca87099ae2873f3a24cc7c141b11ece3a0fe98e1..8d4db87fc18a22660b627564886df0df386d7390 100644 --- a/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Tools/QuickStyles.php +++ b/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Tools/QuickStyles.php @@ -34,11 +34,15 @@ class QuickStyles { /** * Tab HTML identifier + * + * @var string */ protected $_htmlId = 'vde-tab-quick-styles'; /** * Tab HTML title + * + * @var string */ protected $_title = 'Quick Styles'; diff --git a/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Tools/Tabs/AbstractTabs.php b/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Tools/Tabs/AbstractTabs.php index f97550c3918876a650ebcfa64f57d99c5006dd91..d72fdd0cdd8a49c49b1965da39dd40659390c61d 100644 --- a/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Tools/Tabs/AbstractTabs.php +++ b/app/code/Magento/DesignEditor/Block/Adminhtml/Editor/Tools/Tabs/AbstractTabs.php @@ -23,14 +23,13 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\DesignEditor\Block\Adminhtml\Editor\Tools\Tabs; /** * Block that renders tabs * * @method bool getIsActive() */ -namespace Magento\DesignEditor\Block\Adminhtml\Editor\Tools\Tabs; - abstract class AbstractTabs extends \Magento\View\Element\Template { /** @@ -76,7 +75,7 @@ abstract class AbstractTabs extends \Magento\View\Element\Template /** * Get tabs html * - * @return array + * @return string[] */ public function getTabContents() { @@ -95,7 +94,7 @@ abstract class AbstractTabs extends \Magento\View\Element\Template /** * Get tabs handles * - * @return array + * @return string[] */ public function getTabHandles() { diff --git a/app/code/Magento/DesignEditor/Block/Adminhtml/Theme.php b/app/code/Magento/DesignEditor/Block/Adminhtml/Theme.php index bbe4314c53de4488008e0920783578421f452965..db94e73c4e626eb495423296c0869375772545f5 100644 --- a/app/code/Magento/DesignEditor/Block/Adminhtml/Theme.php +++ b/app/code/Magento/DesignEditor/Block/Adminhtml/Theme.php @@ -23,6 +23,9 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\DesignEditor\Block\Adminhtml; + +use Magento\Backend\Block\Widget\Button; /** * Design editor theme @@ -30,14 +33,12 @@ * @method \Magento\DesignEditor\Block\Adminhtml\Theme setTheme(\Magento\View\Design\ThemeInterface $theme) * @method \Magento\View\Design\ThemeInterface getTheme() */ -namespace Magento\DesignEditor\Block\Adminhtml; - class Theme extends \Magento\Backend\Block\Template { /** * Buttons array * - * @var array + * @var Button[] */ protected $_buttons = array(); @@ -63,7 +64,7 @@ class Theme extends \Magento\Backend\Block\Template /** * Add button * - * @param \Magento\Backend\Block\Widget\Button $button + * @param Button $button * @return \Magento\DesignEditor\Block\Adminhtml\Theme */ public function addButton($button) @@ -91,7 +92,7 @@ class Theme extends \Magento\Backend\Block\Template public function getButtonsHtml() { $output = ''; - /** @var $button \Magento\Backend\Block\Widget\Button */ + /** @var $button Button */ foreach ($this->_buttons as $button) { $output .= $button->toHtml(); } @@ -101,7 +102,7 @@ class Theme extends \Magento\Backend\Block\Template /** * Return array of assigned stores titles * - * @return array + * @return string[] */ public function getStoresTitles() { @@ -134,11 +135,11 @@ class Theme extends \Magento\Backend\Block\Template /** * Get quick save button * - * @return \Magento\Backend\Block\Widget\Button + * @return Button */ public function getQuickSaveButton() { - /** @var $saveButton \Magento\Backend\Block\Widget\Button */ + /** @var $saveButton Button */ $saveButton = $this->getLayout()->createBlock('Magento\Backend\Block\Widget\Button'); $saveButton->setData(array( 'label' => __('Save'), diff --git a/app/code/Magento/DesignEditor/Block/Adminhtml/Theme/Button.php b/app/code/Magento/DesignEditor/Block/Adminhtml/Theme/Button.php index e22a9a4de3a97bc631260c1ecceaa35fa0fd3c95..c85c5e683e5a5463bf78ae6fb33986808ffcf320 100644 --- a/app/code/Magento/DesignEditor/Block/Adminhtml/Theme/Button.php +++ b/app/code/Magento/DesignEditor/Block/Adminhtml/Theme/Button.php @@ -24,15 +24,17 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\DesignEditor\Block\Adminhtml\Theme; + /** * Button widget */ -namespace Magento\DesignEditor\Block\Adminhtml\Theme; - class Button extends \Magento\View\Element\Template { /** * Define block template + * + * @return void */ protected function _construct() { diff --git a/app/code/Magento/DesignEditor/Block/Adminhtml/Theme/Selector/SelectorList/AbstractSelectorList.php b/app/code/Magento/DesignEditor/Block/Adminhtml/Theme/Selector/SelectorList/AbstractSelectorList.php index ab4e1655fbf3f31cfdd5541826e54b3bb8c9d209..b3d3f54afde385997f4061519f26bb6469cf3749 100644 --- a/app/code/Magento/DesignEditor/Block/Adminhtml/Theme/Selector/SelectorList/AbstractSelectorList.php +++ b/app/code/Magento/DesignEditor/Block/Adminhtml/Theme/Selector/SelectorList/AbstractSelectorList.php @@ -65,7 +65,7 @@ abstract class AbstractSelectorList /** * Get list items of themes * - * @return array + * @return string[] */ public function getListItems() { diff --git a/app/code/Magento/DesignEditor/Block/Adminhtml/Theme/Selector/SelectorList/Available.php b/app/code/Magento/DesignEditor/Block/Adminhtml/Theme/Selector/SelectorList/Available.php index 4cf132a9a2560204b12dea134f1468a04bdf7824..ff1f08f3dcbbf933a9cb13b5ca59fb6ad9c6b4b7 100644 --- a/app/code/Magento/DesignEditor/Block/Adminhtml/Theme/Selector/SelectorList/Available.php +++ b/app/code/Magento/DesignEditor/Block/Adminhtml/Theme/Selector/SelectorList/Available.php @@ -24,14 +24,14 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\DesignEditor\Block\Adminhtml\Theme\Selector\SelectorList; + /** * Available theme list * * @method int getNextPage() * @method \Magento\DesignEditor\Block\Adminhtml\Theme\Selector\SelectorList\Available setNextPage(int $page) */ -namespace Magento\DesignEditor\Block\Adminhtml\Theme\Selector\SelectorList; - class Available extends \Magento\DesignEditor\Block\Adminhtml\Theme\Selector\SelectorList\AbstractSelectorList { @@ -61,7 +61,7 @@ class Available * Get edit button * * @param \Magento\DesignEditor\Block\Adminhtml\Theme $themeBlock - * @return $this + * @return void */ protected function _addEditButtonHtml($themeBlock) { diff --git a/app/code/Magento/DesignEditor/Block/Adminhtml/Theme/Selector/StoreView.php b/app/code/Magento/DesignEditor/Block/Adminhtml/Theme/Selector/StoreView.php index 0154e2df50a16dd731135363fc2a57a5ce0337e3..e62238740eae4c0dd71c3785a6d7ac5844bf1a4d 100644 --- a/app/code/Magento/DesignEditor/Block/Adminhtml/Theme/Selector/StoreView.php +++ b/app/code/Magento/DesignEditor/Block/Adminhtml/Theme/Selector/StoreView.php @@ -23,7 +23,6 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ - namespace Magento\DesignEditor\Block\Adminhtml\Theme\Selector; /** diff --git a/app/code/Magento/DesignEditor/Block/Adminhtml/Theme/Selector/Tabs.php b/app/code/Magento/DesignEditor/Block/Adminhtml/Theme/Selector/Tabs.php index 37b4db2cacd65bbdd4a5760bbc83e79dd2d56a65..6fbbcd5d576230fa4fdcda565175d51cbfe66a69 100644 --- a/app/code/Magento/DesignEditor/Block/Adminhtml/Theme/Selector/Tabs.php +++ b/app/code/Magento/DesignEditor/Block/Adminhtml/Theme/Selector/Tabs.php @@ -23,16 +23,17 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\DesignEditor\Block\Adminhtml\Theme\Selector; /** * Theme selectors tabs container */ -namespace Magento\DesignEditor\Block\Adminhtml\Theme\Selector; - class Tabs extends \Magento\Backend\Block\Widget\Tabs { /** * Initialize tab + * + * @return void */ protected function _construct() { diff --git a/app/code/Magento/DesignEditor/Controller/Adminhtml/System/Design/Editor.php b/app/code/Magento/DesignEditor/Controller/Adminhtml/System/Design/Editor.php index 21ce1f25aa6d3b640506d9d2d23524e3befdf2a3..57294ea6ff3cc15590fc5fa718df51350de1264d 100644 --- a/app/code/Magento/DesignEditor/Controller/Adminhtml/System/Design/Editor.php +++ b/app/code/Magento/DesignEditor/Controller/Adminhtml/System/Design/Editor.php @@ -26,6 +26,10 @@ namespace Magento\DesignEditor\Controller\Adminhtml\System\Design; +use Magento\Core\Model\Store; +use Magento\Core\Exception as CoreException; +use Magento\View\Design\ThemeInterface; + /** * Backend controller for the design editor * @@ -60,6 +64,8 @@ class Editor extends \Magento\Backend\App\Action /** * Display the design editor launcher page + * + * @return void */ public function indexAction() { @@ -70,6 +76,8 @@ class Editor extends \Magento\Backend\App\Action /** * Ajax loading available themes + * + * @return void */ public function loadThemeListAction() { @@ -102,6 +110,8 @@ class Editor extends \Magento\Backend\App\Action /** * Activate the design editor in the session and redirect to the frontend of the selected store + * + * @return void */ public function launchAction() { @@ -113,7 +123,7 @@ class Editor extends \Magento\Backend\App\Action $themeContext->setEditableThemeById($themeId); $launchedTheme = $themeContext->getEditableTheme(); if ($launchedTheme->isPhysical()) { - $launchedTheme = $launchedTheme->getDomainModel(\Magento\View\Design\ThemeInterface::TYPE_PHYSICAL) + $launchedTheme = $launchedTheme->getDomainModel(ThemeInterface::TYPE_PHYSICAL) ->createVirtualTheme($launchedTheme); $this->_redirect($this->getUrl('adminhtml/*/*', array('theme_id' => $launchedTheme->getId()))); return; @@ -137,7 +147,7 @@ class Editor extends \Magento\Backend\App\Action )); $this->_view->renderLayout(); - } catch (\Magento\Core\Exception $e) { + } catch (CoreException $e) { $this->messageManager->addException($e, $e->getMessage()); $this->_objectManager->get('Magento\Logger')->logException($e); $this->_redirect('adminhtml/*/'); @@ -152,6 +162,8 @@ class Editor extends \Magento\Backend\App\Action /** * Assign theme to list of store views + * + * @return void */ public function assignThemeToStoreAction() { @@ -168,10 +180,10 @@ class Editor extends \Magento\Backend\App\Action $themeCustomization = $theme->isVirtual() ? $theme - : $theme->getDomainModel(\Magento\View\Design\ThemeInterface::TYPE_PHYSICAL) + : $theme->getDomainModel(ThemeInterface::TYPE_PHYSICAL) ->createVirtualTheme($theme); - /** @var $themeCustomization \Magento\View\Design\ThemeInterface */ + /** @var $themeCustomization ThemeInterface */ $this->_themeConfig->assignToStore($themeCustomization, $this->_getStores()); $successMessage = $hadThemeAssigned @@ -199,6 +211,8 @@ class Editor extends \Magento\Backend\App\Action /** * Rename title action + * + * @return void */ public function quickEditAction() { @@ -210,13 +224,13 @@ class Editor extends \Magento\Backend\App\Action try { $theme = $this->_loadThemeById($themeId); if (!$theme->isEditable()) { - throw new \Magento\Core\Exception(__('Sorry, but you can\'t edit theme "%1".', + throw new CoreException(__('Sorry, but you can\'t edit theme "%1".', $theme->getThemeTitle())); } $theme->setThemeTitle($themeTitle); $theme->save(); $response = array('success' => true); - } catch (\Magento\Core\Exception $e) { + } catch (CoreException $e) { $response = array('error' => true, 'message' => $e->getMessage()); $this->_objectManager->get('Magento\Logger')->logException($e); } catch (\Exception $e) { @@ -228,6 +242,8 @@ class Editor extends \Magento\Backend\App\Action /** * Display available theme list. Only when no customized themes + * + * @return void */ public function firstEntranceAction() { @@ -238,6 +254,8 @@ class Editor extends \Magento\Backend\App\Action /** * Apply changes from 'staging' theme to 'virtual' theme + * + * @return void */ public function saveAction() { @@ -266,18 +284,20 @@ class Editor extends \Magento\Backend\App\Action /** * Duplicate theme action + * + * @return void */ public function duplicateAction() { $themeId = (int)$this->getRequest()->getParam('theme_id'); - /** @var $themeCopy \Magento\View\Design\ThemeInterface */ + /** @var $themeCopy ThemeInterface */ $themeCopy = $this->_objectManager->create('Magento\View\Design\ThemeInterface'); /** @var $copyService \Magento\Theme\Model\CopyService */ $copyService = $this->_objectManager->get('Magento\Theme\Model\CopyService'); try { $theme = $this->_loadThemeById($themeId); if (!$theme->isVirtual()) { - throw new \Magento\Core\Exception(__('Sorry, but you can\'t edit theme "%1".', + throw new CoreException(__('Sorry, but you can\'t edit theme "%1".', $theme->getThemeTitle())); } $themeCopy->setData($theme->getData()); @@ -288,7 +308,7 @@ class Editor extends \Magento\Backend\App\Action $this->messageManager->addSuccess( __('You saved a duplicate copy of this theme in "My Customizations."') ); - } catch (\Magento\Core\Exception $e) { + } catch (CoreException $e) { $this->messageManager->addError($e->getMessage()); $this->_objectManager->get('Magento\Logger')->logException($e); } catch (\Exception $e) { @@ -301,7 +321,8 @@ class Editor extends \Magento\Backend\App\Action /** * Revert 'staging' theme to the state of 'physical' or 'virtual' * - * @throws \Magento\Core\Exception + * @return void + * @throws CoreException */ public function revertAction() { @@ -310,13 +331,13 @@ class Editor extends \Magento\Backend\App\Action $virtualTheme = $this->_loadThemeById($themeId); if (!$virtualTheme->isVirtual()) { - throw new \Magento\Core\Exception(__('Theme "%1" is not editable.', $virtualTheme->getId())); + throw new CoreException(__('Theme "%1" is not editable.', $virtualTheme->getId())); } try { /** @var $copyService \Magento\Theme\Model\CopyService */ $copyService = $this->_objectManager->get('Magento\Theme\Model\CopyService'); - $stagingTheme = $virtualTheme->getDomainModel(\Magento\View\Design\ThemeInterface::TYPE_VIRTUAL) + $stagingTheme = $virtualTheme->getDomainModel(ThemeInterface::TYPE_VIRTUAL) ->getStagingTheme(); switch ($revertTo) { case 'last_saved': @@ -327,7 +348,7 @@ class Editor extends \Magento\Backend\App\Action break; case 'physical': - $physicalTheme = $virtualTheme->getDomainModel(\Magento\View\Design\ThemeInterface::TYPE_VIRTUAL) + $physicalTheme = $virtualTheme->getDomainModel(ThemeInterface::TYPE_VIRTUAL) ->getPhysicalTheme(); $copyService->copy($physicalTheme, $stagingTheme); $message = __('Theme "%1" reverted to last default state', @@ -350,6 +371,8 @@ class Editor extends \Magento\Backend\App\Action /** * Set page title + * + * @return void */ protected function _setTitle() { @@ -361,7 +384,7 @@ class Editor extends \Magento\Backend\App\Action * * @param int $themeId * @return \Magento\Core\Model\Theme - * @throws \Magento\Core\Exception + * @throws CoreException */ protected function _loadThemeById($themeId) { @@ -369,7 +392,7 @@ class Editor extends \Magento\Backend\App\Action $themeFactory = $this->_objectManager->create('Magento\View\Design\Theme\FlyweightFactory'); $theme = $themeFactory->create($themeId); if (empty($theme)) { - throw new \Magento\Core\Exception(__('We can\'t find this theme.')); + throw new CoreException(__('We can\'t find this theme.')); } return $theme; } @@ -387,9 +410,9 @@ class Editor extends \Magento\Backend\App\Action /** * Pass data to the Tools panel blocks that is needed it for rendering * - * @param \Magento\View\Design\ThemeInterface $theme + * @param ThemeInterface $theme * @param string $mode - * @return \Magento\DesignEditor\Controller\Adminhtml\System\Design\Editor + * @return $this */ protected function _configureToolsBlocks($theme, $mode) { @@ -414,10 +437,10 @@ class Editor extends \Magento\Backend\App\Action /** * Pass data to the Toolbar panel blocks that is needed for rendering * - * @param \Magento\View\Design\ThemeInterface $theme - * @param \Magento\View\Design\ThemeInterface $editableTheme + * @param ThemeInterface $theme + * @param ThemeInterface $editableTheme * @param string $mode - * @return \Magento\DesignEditor\Controller\Adminhtml\System\Design\Editor + * @return $this */ protected function _configureToolbarBlocks($theme, $editableTheme, $mode) { @@ -445,9 +468,9 @@ class Editor extends \Magento\Backend\App\Action /** * Set to iframe block selected mode and theme * - * @param \Magento\View\Design\ThemeInterface $editableTheme + * @param ThemeInterface $editableTheme * @param string $mode - * @return \Magento\DesignEditor\Controller\Adminhtml\System\Design\Editor + * @return $this */ protected function _configureEditorBlock($editableTheme, $mode) { @@ -469,13 +492,15 @@ class Editor extends \Magento\Backend\App\Action { $isCustomized = (bool)$this->_objectManager->get('Magento\Core\Model\Resource\Theme\CollectionFactory') ->create() - ->addTypeFilter(\Magento\View\Design\ThemeInterface::TYPE_VIRTUAL) + ->addTypeFilter(ThemeInterface::TYPE_VIRTUAL) ->getSize(); return !$isCustomized; } /** * Load layout + * + * @return void */ protected function _renderStoreDesigner() { @@ -547,7 +572,7 @@ class Editor extends \Magento\Backend\App\Action * * @todo temporary method. used until we find a way to convert array to JSON on JS side * - * @return array + * @return Store[] * @throws \InvalidArgumentException */ protected function _getStores() diff --git a/app/code/Magento/DesignEditor/Controller/Adminhtml/System/Design/Editor/Files.php b/app/code/Magento/DesignEditor/Controller/Adminhtml/System/Design/Editor/Files.php index 4ffee9de16df125b5a44bb04c229e96988cdd07e..c823745f74a8da9a33c7ae3e0f9efc6dfe3da591 100644 --- a/app/code/Magento/DesignEditor/Controller/Adminhtml/System/Design/Editor/Files.php +++ b/app/code/Magento/DesignEditor/Controller/Adminhtml/System/Design/Editor/Files.php @@ -24,17 +24,18 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\DesignEditor\Controller\Adminhtml\System\Design\Editor; + /** * Files controller */ - -namespace Magento\DesignEditor\Controller\Adminhtml\System\Design\Editor; - class Files extends \Magento\Theme\Controller\Adminhtml\System\Design\Wysiwyg\Files { /** * Tree json action + * + * @return void */ public function treeJsonAction() { @@ -51,6 +52,8 @@ class Files /** * Contents action + * + * @return void */ public function contentsAction() { diff --git a/app/code/Magento/DesignEditor/Controller/Adminhtml/System/Design/Editor/Tools.php b/app/code/Magento/DesignEditor/Controller/Adminhtml/System/Design/Editor/Tools.php index e65165e2770ff075477e22156e9a1a34ab895115..dcb27510fe8e6ac3f235f4f71a4b3aab59534835 100644 --- a/app/code/Magento/DesignEditor/Controller/Adminhtml/System/Design/Editor/Tools.php +++ b/app/code/Magento/DesignEditor/Controller/Adminhtml/System/Design/Editor/Tools.php @@ -26,6 +26,8 @@ namespace Magento\DesignEditor\Controller\Adminhtml\System\Design\Editor; +use Magento\Core\Exception as CoreException; + /** * Backend controller for the design editor * @@ -47,7 +49,9 @@ class Tools extends \Magento\Backend\App\Action } /** - * Upload custom CSS action + * Upload custom CSS action + * + * @return void */ public function uploadAction() { @@ -70,7 +74,7 @@ class Tools extends \Magento\Backend\App\Action 'message' => __('You updated the custom.css file.'), 'content' => $cssFileData['content'] ); - } catch (\Magento\Core\Exception $e) { + } catch (CoreException $e) { $response = array('error' => true, 'message' => $e->getMessage()); $this->_objectManager->get('Magento\Logger')->logException($e); } catch (\Exception $e) { @@ -82,6 +86,8 @@ class Tools extends \Magento\Backend\App\Action /** * Save custom css file + * + * @return void */ public function saveCssContentAction() { @@ -100,7 +106,7 @@ class Tools extends \Magento\Backend\App\Action 'filename' => $customCss->getFileName(), 'message' => __('You updated the %1 file.', $customCss->getFileName()) ); - } catch (\Magento\Core\Exception $e) { + } catch (CoreException $e) { $response = array('error' => true, 'message' => $e->getMessage()); $this->_objectManager->get('Magento\Logger')->logException($e); } catch (\Exception $e) { @@ -112,6 +118,8 @@ class Tools extends \Magento\Backend\App\Action /** * Ajax list of existing javascript files + * + * @return void */ public function jsListAction() { @@ -129,6 +137,8 @@ class Tools extends \Magento\Backend\App\Action /** * Upload js file + * + * @return void */ public function uploadJsAction() { @@ -147,7 +157,7 @@ class Tools extends \Magento\Backend\App\Action $jsFile->save(); $this->_forward('jsList'); return; - } catch (\Magento\Core\Exception $e) { + } catch (CoreException $e) { $response = array('error' => true, 'message' => $e->getMessage()); $this->_objectManager->get('Magento\Logger')->logException($e); } catch (\Exception $e) { @@ -159,6 +169,8 @@ class Tools extends \Magento\Backend\App\Action /** * Delete custom file action + * + * @return void */ public function deleteCustomFilesAction() { @@ -176,6 +188,8 @@ class Tools extends \Magento\Backend\App\Action /** * Reorder js file + * + * @return void */ public function reorderJsAction() { @@ -187,7 +201,7 @@ class Tools extends \Magento\Backend\App\Action \Magento\View\Design\Theme\Customization\File\Js::TYPE, $reorderJsFiles ); $result = array('success' => true); - } catch (\Magento\Core\Exception $e) { + } catch (CoreException $e) { $result = array('error' => true, 'message' => $e->getMessage()); $this->_objectManager->get('Magento\Logger')->logException($e); } catch (\Exception $e) { @@ -199,6 +213,8 @@ class Tools extends \Magento\Backend\App\Action /** * Save image sizes + * + * @return void */ public function saveImageSizingAction() { @@ -219,7 +235,7 @@ class Tools extends \Magento\Backend\App\Action $imageSizing = $imageSizingValidator->validate($configuration->getAllControlsData(), $imageSizing); $configuration->saveData($imageSizing); $result = array('success' => true, 'message' => __('We saved the image sizes.')); - } catch (\Magento\Core\Exception $e) { + } catch (CoreException $e) { $result = array('error' => true, 'message' => $e->getMessage()); $this->_objectManager->get('Magento\Logger')->logException($e); } catch (\Exception $e) { @@ -232,6 +248,8 @@ class Tools extends \Magento\Backend\App\Action /** * Upload quick style image + * + * @return void */ public function uploadQuickStyleImageAction() { @@ -254,7 +272,7 @@ class Tools extends \Magento\Backend\App\Action $configuration->saveData(array($keys[0] => $result['css_path'])); $response = array('error' => false, 'content' => $result); - } catch (\Magento\Core\Exception $e) { + } catch (CoreException $e) { $this->messageManager->addError($e->getMessage()); $response = array('error' => true, 'message' => $e->getMessage()); $this->_objectManager->get('Magento\Logger')->logException($e); @@ -269,6 +287,8 @@ class Tools extends \Magento\Backend\App\Action /** * Remove quick style image + * + * @return void */ public function removeQuickStyleImageAction() { @@ -294,7 +314,7 @@ class Tools extends \Magento\Backend\App\Action $configuration->saveData(array($elementName => '')); $response = array('error' => false, 'content' => $result); - } catch (\Magento\Core\Exception $e) { + } catch (CoreException $e) { $response = array('error' => true, 'message' => $e->getMessage()); $this->_objectManager->get('Magento\Logger')->logException($e); } catch (\Exception $e) { @@ -309,7 +329,8 @@ class Tools extends \Magento\Backend\App\Action /** * Upload store logo * - * @throws \Magento\Core\Exception + * @return void + * @throws CoreException */ public function uploadStoreLogoAction() { @@ -319,7 +340,7 @@ class Tools extends \Magento\Backend\App\Action /** @var $theme \Magento\View\Design\ThemeInterface */ $theme = $this->_objectManager->create('Magento\View\Design\ThemeInterface'); if (!$theme->load($themeId)->getId() || !$theme->isEditable()) { - throw new \Magento\Core\Exception( + throw new CoreException( __('The file can\'t be found or edited.') ); } @@ -329,7 +350,7 @@ class Tools extends \Magento\Backend\App\Action $store = $this->_objectManager->get('Magento\Core\Model\Store')->load($storeId); if (!$customizationConfig->isThemeAssignedToStore($theme, $store)) { - throw new \Magento\Core\Exception(__('This theme is not assigned to a store view #%1.', + throw new CoreException(__('This theme is not assigned to a store view #%1.', $theme->getId())); } /** @var $storeLogo \Magento\DesignEditor\Model\Editor\Tools\QuickStyles\LogoUploader */ @@ -339,7 +360,7 @@ class Tools extends \Magento\Backend\App\Action $this->_reinitSystemConfiguration(); $response = array('error' => false, 'content' => array('name' => basename($storeLogo->getValue()))); - } catch (\Magento\Core\Exception $e) { + } catch (CoreException $e) { $response = array('error' => true, 'message' => $e->getMessage()); $this->_objectManager->get('Magento\Logger')->logException($e); } catch (\Exception $e) { @@ -354,7 +375,8 @@ class Tools extends \Magento\Backend\App\Action /** * Remove store logo * - * @throws \Magento\Core\Exception + * @return void + * @throws CoreException */ public function removeStoreLogoAction() { @@ -364,7 +386,7 @@ class Tools extends \Magento\Backend\App\Action /** @var $theme \Magento\View\Design\ThemeInterface */ $theme = $this->_objectManager->create('Magento\View\Design\ThemeInterface'); if (!$theme->load($themeId)->getId() || !$theme->isEditable()) { - throw new \Magento\Core\Exception( + throw new CoreException( __('The file can\'t be found or edited.') ); } @@ -374,7 +396,7 @@ class Tools extends \Magento\Backend\App\Action $store = $this->_objectManager->get('Magento\Core\Model\Store')->load($storeId); if (!$customizationConfig->isThemeAssignedToStore($theme, $store)) { - throw new \Magento\Core\Exception(__('This theme is not assigned to a store view #%1.', + throw new CoreException(__('This theme is not assigned to a store view #%1.', $theme->getId())); } @@ -384,7 +406,7 @@ class Tools extends \Magento\Backend\App\Action $this->_reinitSystemConfiguration(); $response = array('error' => false, 'content' => array()); - } catch (\Magento\Core\Exception $e) { + } catch (CoreException $e) { $response = array('error' => true, 'message' => $e->getMessage()); $this->_objectManager->get('Magento\Logger')->logException($e); } catch (\Exception $e) { @@ -398,6 +420,8 @@ class Tools extends \Magento\Backend\App\Action /** * Save quick styles data + * + * @return void */ public function saveQuickStylesAction() { @@ -414,7 +438,7 @@ class Tools extends \Magento\Backend\App\Action ); $configuration->saveData(array($controlId => $controlValue)); $response = array('success' => true); - } catch (\Magento\Core\Exception $e) { + } catch (CoreException $e) { $response = array('error' => true, 'message' => $e->getMessage()); $this->_objectManager->get('Magento\Logger')->logException($e); } catch (\Exception $e) { diff --git a/app/code/Magento/DesignEditor/Controller/Varien/Router/Standard.php b/app/code/Magento/DesignEditor/Controller/Varien/Router/Standard.php index 26901fcc4720297f5426340c7a5560e8393f97dc..2cc3f70dc805a4d26b2113c0bb11449c4dbb9874 100644 --- a/app/code/Magento/DesignEditor/Controller/Varien/Router/Standard.php +++ b/app/code/Magento/DesignEditor/Controller/Varien/Router/Standard.php @@ -37,7 +37,7 @@ class Standard extends \Magento\Core\App\Router\Base /** * Routers that must not been matched * - * @var array + * @var string[] */ protected $_excludedRouters = array('admin', 'vde'); @@ -150,7 +150,7 @@ class Standard extends \Magento\Core\App\Router\Base * Modify request path to imitate basic request * * @param \Magento\App\RequestInterface $request - * @return \Magento\DesignEditor\Controller\Varien\Router\Standard + * @return $this */ protected function _prepareVdeRequest(\Magento\App\RequestInterface $request) { diff --git a/app/code/Magento/DesignEditor/Helper/Data.php b/app/code/Magento/DesignEditor/Helper/Data.php index a3617a91570307d580ed803af9a316ccb2907a0a..e5494195bf0019749a7275d286ef5b2c5d584d6d 100644 --- a/app/code/Magento/DesignEditor/Helper/Data.php +++ b/app/code/Magento/DesignEditor/Helper/Data.php @@ -23,12 +23,13 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\DesignEditor\Helper; + +use Magento\App\RequestInterface; /** * Design Editor main helper */ -namespace Magento\DesignEditor\Helper; - class Data extends \Magento\App\Helper\AbstractHelper { /** @@ -62,7 +63,7 @@ class Data extends \Magento\App\Helper\AbstractHelper /** * @param \Magento\App\Helper\Context $context - * @param $frontName + * @param string $frontName * @param array $disabledCacheTypes */ public function __construct( @@ -98,10 +99,10 @@ class Data extends \Magento\App\Helper\AbstractHelper /** * This method returns an indicator of whether or not the current request is for vde * - * @param \Magento\App\RequestInterface $request + * @param RequestInterface $request * @return bool */ - public function isVdeRequest(\Magento\App\RequestInterface $request = null) + public function isVdeRequest(RequestInterface $request = null) { if (null !== $request) { $result = false; @@ -119,7 +120,7 @@ class Data extends \Magento\App\Helper\AbstractHelper /** * Get available modes for Design Editor * - * @return array + * @return string[] */ public function getAvailableModes() { @@ -129,7 +130,7 @@ class Data extends \Magento\App\Helper\AbstractHelper /** * Returns the translation mode the current request is in (null, text, script, or alt). * - * @return mixed + * @return string|null */ public function getTranslationMode() { @@ -139,10 +140,10 @@ class Data extends \Magento\App\Helper\AbstractHelper /** * Sets the translation mode for the current request (null, text, script, or alt); * - * @param \Magento\App\RequestInterface $request - * @return \Magento\DesignEditor\Helper\Data + * @param RequestInterface $request + * @return $this */ - public function setTranslationMode(\Magento\App\RequestInterface $request) + public function setTranslationMode(RequestInterface $request) { $this->_translationMode = $request->getParam(self::TRANSLATION_MODE, null); return $this; diff --git a/app/code/Magento/DesignEditor/Model/Config/Control/AbstractControl.php b/app/code/Magento/DesignEditor/Model/Config/Control/AbstractControl.php index 39ee11319514d8e17e692b081091e048b6fddc12..d3b103733e4da2a0a47f7299c70a893cf994f1f7 100644 --- a/app/code/Magento/DesignEditor/Model/Config/Control/AbstractControl.php +++ b/app/code/Magento/DesignEditor/Model/Config/Control/AbstractControl.php @@ -23,18 +23,17 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\DesignEditor\Model\Config\Control; /** * Controls configuration */ -namespace Magento\DesignEditor\Model\Config\Control; - abstract class AbstractControl extends \Magento\Config\AbstractXml { /** * Keys of layout params attributes * - * @var array + * @var string[] */ protected $_controlAttributes = array(); diff --git a/app/code/Magento/DesignEditor/Model/Config/Control/ImageSizing.php b/app/code/Magento/DesignEditor/Model/Config/Control/ImageSizing.php index cdef62f01626a78deb716548b4abfd1bae57728f..03881248dc28e069d44b77064b29171204ee396f 100644 --- a/app/code/Magento/DesignEditor/Model/Config/Control/ImageSizing.php +++ b/app/code/Magento/DesignEditor/Model/Config/Control/ImageSizing.php @@ -23,18 +23,17 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\DesignEditor\Model\Config\Control; /** * Image Sizing configuration */ -namespace Magento\DesignEditor\Model\Config\Control; - class ImageSizing extends \Magento\DesignEditor\Model\Config\Control\AbstractControl { /** * Keys of layout params attributes * - * @var array + * @var string[] */ protected $_controlAttributes = array('title'); @@ -44,7 +43,7 @@ class ImageSizing extends \Magento\DesignEditor\Model\Config\Control\AbstractCon protected $_moduleReader; /** - * @param $configFiles + * @param array $configFiles * @param \Magento\Module\Dir\Reader $moduleReader */ public function __construct( diff --git a/app/code/Magento/DesignEditor/Model/Config/Control/QuickStyles.php b/app/code/Magento/DesignEditor/Model/Config/Control/QuickStyles.php index f3d398f9f8fcad895fecbcb7f4d98170eebdd632..ad51da83094328325b6e0013539ba32c3f0509ee 100644 --- a/app/code/Magento/DesignEditor/Model/Config/Control/QuickStyles.php +++ b/app/code/Magento/DesignEditor/Model/Config/Control/QuickStyles.php @@ -23,33 +23,34 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\DesignEditor\Model\Config\Control; + +use Magento\Module\Dir\Reader; /** * Quick styles configuration */ -namespace Magento\DesignEditor\Model\Config\Control; - class QuickStyles extends \Magento\DesignEditor\Model\Config\Control\AbstractControl { /** * Keys of layout params attributes * - * @var array + * @var string[] */ protected $_controlAttributes = array('title', 'tab', 'column'); /** - * @var \Magento\Module\Dir\Reader + * @var Reader */ protected $_moduleReader; /** - * @param $configFiles + * @param array $configFiles * @param \Magento\Module\Dir\Reader $moduleReader */ public function __construct( $configFiles, - \Magento\Module\Dir\Reader $moduleReader + Reader $moduleReader ) { $this->_moduleReader = $moduleReader; parent::__construct($configFiles); diff --git a/app/code/Magento/DesignEditor/Model/Editor/Tools/Controls/Configuration.php b/app/code/Magento/DesignEditor/Model/Editor/Tools/Controls/Configuration.php index 9a466c482a236a998960f98272c776668950a53b..e025cdc978eb3b2dcaec25e3579735f9894e4121 100644 --- a/app/code/Magento/DesignEditor/Model/Editor/Tools/Controls/Configuration.php +++ b/app/code/Magento/DesignEditor/Model/Editor/Tools/Controls/Configuration.php @@ -24,11 +24,11 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\DesignEditor\Model\Editor\Tools\Controls; + /** * Configuration of controls */ -namespace Magento\DesignEditor\Model\Editor\Tools\Controls; - class Configuration { /** @@ -130,7 +130,7 @@ class Configuration /** * Initialize view configurations * - * @return \Magento\DesignEditor\Model\Editor\Tools\Controls\Configuration + * @return $this */ protected function _initViewConfigs() { @@ -148,7 +148,7 @@ class Configuration /** * Load all control values * - * @return \Magento\DesignEditor\Model\Editor\Tools\Controls\Configuration + * @return $this */ protected function _loadControlsData() { @@ -165,7 +165,7 @@ class Configuration * Prepare list of control links * * @param array $controls - * @return \Magento\DesignEditor\Model\Editor\Tools\Controls\Configuration + * @return $this */ protected function _prepareControlList(array &$controls) { @@ -184,7 +184,7 @@ class Configuration * @param array $control * @param string $paramName * @param \Magento\Config\View $viewConfiguration - * @return \Magento\DesignEditor\Model\Editor\Tools\Controls\Configuration + * @return $this */ protected function _loadControlData(array &$control, $paramName, \Magento\Config\View $viewConfiguration) { @@ -224,7 +224,7 @@ class Configuration * Extract module and key name * * @param string $value - * @return array + * @return string[] */ protected function _extractModuleKey($value) { @@ -255,7 +255,7 @@ class Configuration * Save control values data * * @param array $controlsData - * @return \Magento\DesignEditor\Model\Editor\Tools\Controls\Configuration + * @return $this */ public function saveData(array $controlsData) { @@ -299,7 +299,7 @@ class Configuration * Save customized DOM of view configuration * * @param \DOMDocument $config - * @return \Magento\DesignEditor\Model\Editor\Tools\Controls\Configuration + * @return $this */ protected function _saveViewConfiguration(\DOMDocument $config) { diff --git a/app/code/Magento/DesignEditor/Model/Editor/Tools/Controls/Factory.php b/app/code/Magento/DesignEditor/Model/Editor/Tools/Controls/Factory.php index 80cec9c726f940afdb4e9cbb52316c24b41ee087..b32a50506babe89b7578c4c8972dc10cb1b640a8 100644 --- a/app/code/Magento/DesignEditor/Model/Editor/Tools/Controls/Factory.php +++ b/app/code/Magento/DesignEditor/Model/Editor/Tools/Controls/Factory.php @@ -24,11 +24,11 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\DesignEditor\Model\Editor\Tools\Controls; + /** * Controls configuration factory */ -namespace Magento\DesignEditor\Model\Editor\Tools\Controls; - class Factory { /**#@+ @@ -111,7 +111,7 @@ class Factory * @param string $type * @param \Magento\View\Design\ThemeInterface $theme * @param \Magento\View\Design\ThemeInterface $parentTheme - * @param array $files + * @param string[] $files * @return \Magento\DesignEditor\Model\Editor\Tools\Controls\Configuration * @throws \Magento\Exception */ diff --git a/app/code/Magento/DesignEditor/Model/Editor/Tools/ImageSizing/Validator.php b/app/code/Magento/DesignEditor/Model/Editor/Tools/ImageSizing/Validator.php index eb734112f4dbcaf78154a6b711f0acbb53538762..cd60d6666a2c448b681a92cf2e4320cf39ad3a38 100644 --- a/app/code/Magento/DesignEditor/Model/Editor/Tools/ImageSizing/Validator.php +++ b/app/code/Magento/DesignEditor/Model/Editor/Tools/ImageSizing/Validator.php @@ -23,12 +23,11 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\DesignEditor\Model\Editor\Tools\ImageSizing; /** * Image sizing validator */ -namespace Magento\DesignEditor\Model\Editor\Tools\ImageSizing; - class Validator { /** @@ -64,7 +63,7 @@ class Validator /** * List of allowed filed control types * - * @var array + * @var string[] */ protected $_allowedTypes = array( self::FIELD_WHITE_BORDER, @@ -113,7 +112,7 @@ class Validator * Initialize list of controls for validation * * @param array $controls - * @return \Magento\DesignEditor\Model\Editor\Tools\ImageSizing\Validator + * @return $this */ protected function _initFieldByTypes(array $controls) { @@ -134,7 +133,7 @@ class Validator * @param array $validators * @param array $fields * @param array $data - * @return \Magento\DesignEditor\Model\Editor\Tools\ImageSizing\Validator + * @return $this */ protected function _validate(array $validators, array $fields, array $data) { @@ -208,7 +207,7 @@ class Validator * Instantiate class validator * * @param array $validators - * @return \Magento\DesignEditor\Model\Editor\Tools\ImageSizing\Validator + * @return $this */ protected function _instantiateValidators(array &$validators) { diff --git a/app/code/Magento/DesignEditor/Model/Editor/Tools/QuickStyles/Form/Builder.php b/app/code/Magento/DesignEditor/Model/Editor/Tools/QuickStyles/Form/Builder.php index 5c926079ff493dcce548817f80702750675d73d0..fbf86cca1436f66ebb769fbcdbdf998740a20374 100644 --- a/app/code/Magento/DesignEditor/Model/Editor/Tools/QuickStyles/Form/Builder.php +++ b/app/code/Magento/DesignEditor/Model/Editor/Tools/QuickStyles/Form/Builder.php @@ -23,12 +23,13 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\DesignEditor\Model\Editor\Tools\QuickStyles\Form; + +use Magento\Data\Form; /** * VDE area model */ -namespace Magento\DesignEditor\Model\Editor\Tools\QuickStyles\Form; - class Builder { /** @@ -80,7 +81,7 @@ class Builder * Create varien data form with provided params * * @param array $data - * @return \Magento\Data\Form + * @return Form * @throws \InvalidArgumentException */ public function create(array $data = array()) @@ -101,7 +102,7 @@ class Builder } if ($isFilePresent) { - /** @var $form \Magento\Data\Form */ + /** @var $form Form */ $form = $this->_formFactory->create(array( 'data' => $data, )); @@ -130,7 +131,7 @@ class Builder /** * Check is any elements present in form * - * @param \Magento\Data\Form $form + * @param Form $form * @return bool */ protected function _isFormEmpty($form) @@ -150,7 +151,7 @@ class Builder /** * Add column elements to form * - * @param \Magento\Data\Form $form + * @param Form $form * @param string $tab * @return array */ @@ -241,7 +242,8 @@ class Builder /** * Add custom element types * - * @param \Magento\Data\Form $form + * @param Form $form + * @return void */ protected function _addElementTypes($form) { diff --git a/app/code/Magento/DesignEditor/Model/Editor/Tools/QuickStyles/Form/Element/Factory.php b/app/code/Magento/DesignEditor/Model/Editor/Tools/QuickStyles/Form/Element/Factory.php index 2c58e887698804375019891d7a28293d5c8fd38a..aa090553b6eb9bded6c204409b1fff9470abad01 100644 --- a/app/code/Magento/DesignEditor/Model/Editor/Tools/QuickStyles/Form/Element/Factory.php +++ b/app/code/Magento/DesignEditor/Model/Editor/Tools/QuickStyles/Form/Element/Factory.php @@ -23,8 +23,6 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ - - namespace Magento\DesignEditor\Model\Editor\Tools\QuickStyles\Form\Element; class Factory diff --git a/app/code/Magento/DesignEditor/Model/Editor/Tools/QuickStyles/Form/Renderer/Factory.php b/app/code/Magento/DesignEditor/Model/Editor/Tools/QuickStyles/Form/Renderer/Factory.php index 4b093d7902fd47866f6cbb480a3a51b7ff19b366..7859822286aa73c69d0c9e9066c402d30eab8c73 100644 --- a/app/code/Magento/DesignEditor/Model/Editor/Tools/QuickStyles/Form/Renderer/Factory.php +++ b/app/code/Magento/DesignEditor/Model/Editor/Tools/QuickStyles/Form/Renderer/Factory.php @@ -23,17 +23,15 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\DesignEditor\Model\Editor\Tools\QuickStyles\Form\Renderer; + +use Magento\Data\Form\Element\Renderer\RendererInterface; /** * Block that renders JS tab * * @method \Magento\View\Design\ThemeInterface getTheme() * @method setTheme($theme) - * - */ -namespace Magento\DesignEditor\Model\Editor\Tools\QuickStyles\Form\Renderer; - -/** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class Factory @@ -103,7 +101,7 @@ class Factory * * @param string $elementClassName * @param string $rendererName - * @return \Magento\Data\Form\Element\Renderer\RendererInterface + * @return RendererInterface * @throws \Magento\Core\Exception */ public function create($elementClassName, $rendererName) @@ -125,6 +123,10 @@ class Factory * If Renderer01 used to render Element01 that should render some other Element02 using same Renderer01 it will * cause an error. Cause internal Renderer01 property '_element' will be overwritten with Element02 during * reuse of renderer and then will not be restored. + * + * @param string $elementClassName + * @param string|null $rendererName + * @return RendererInterface */ public function getSharedInstance($elementClassName, $rendererName = null) { diff --git a/app/code/Magento/DesignEditor/Model/Editor/Tools/QuickStyles/ImageUploader.php b/app/code/Magento/DesignEditor/Model/Editor/Tools/QuickStyles/ImageUploader.php index 01268fb160d7d48d53fb22ee6fff17972205f3ba..371d16cc17427e3d6d1f33920dcf83ff01097684 100644 --- a/app/code/Magento/DesignEditor/Model/Editor/Tools/QuickStyles/ImageUploader.php +++ b/app/code/Magento/DesignEditor/Model/Editor/Tools/QuickStyles/ImageUploader.php @@ -24,11 +24,11 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\DesignEditor\Model\Editor\Tools\QuickStyles; + /** * Quick style file uploader */ -namespace Magento\DesignEditor\Model\Editor\Tools\QuickStyles; - class ImageUploader extends \Magento\Object { /** @@ -56,7 +56,7 @@ class ImageUploader extends \Magento\Object /** * Allowed extensions * - * @var array + * @var string[] */ protected $_allowedExtensions = array('jpg', 'jpeg', 'gif', 'png'); @@ -96,7 +96,7 @@ class ImageUploader extends \Magento\Object * Set storage path * * @param string $path - * @return \Magento\DesignEditor\Model\Editor\Tools\QuickStyles\ImageUploader + * @return $this */ public function setStoragePath($path) { @@ -150,7 +150,7 @@ class ImageUploader extends \Magento\Object * Remove file * * @param string $file - * @return \Magento\DesignEditor\Model\Editor\Tools\QuickStyles\ImageUploader + * @return $this */ public function removeFile($file) { diff --git a/app/code/Magento/DesignEditor/Model/Editor/Tools/QuickStyles/Renderer.php b/app/code/Magento/DesignEditor/Model/Editor/Tools/QuickStyles/Renderer.php index 4920439cb61571b0b0191f3f3ece5af711fb96dd..30435b0e04c2970c64ef7623204ab8b79b9dd5c0 100644 --- a/app/code/Magento/DesignEditor/Model/Editor/Tools/QuickStyles/Renderer.php +++ b/app/code/Magento/DesignEditor/Model/Editor/Tools/QuickStyles/Renderer.php @@ -23,12 +23,11 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\DesignEditor\Model\Editor\Tools\QuickStyles; /** * Quick style CSS renderer */ -namespace Magento\DesignEditor\Model\Editor\Tools\QuickStyles; - class Renderer { /** @@ -66,7 +65,7 @@ class Renderer * * @param array $data * @param string $content - * @return \Magento\DesignEditor\Model\Editor\Tools\QuickStyles\Renderer + * @return $this */ protected function _rendererCssRecursively($data, &$content) { diff --git a/app/code/Magento/DesignEditor/Model/Editor/Tools/QuickStyles/Renderer/AbstractRenderer.php b/app/code/Magento/DesignEditor/Model/Editor/Tools/QuickStyles/Renderer/AbstractRenderer.php index 0f3444dce9185ed5a13a65ef81236e370a703296..ad2d82469977e89267c5c2302d98a693b3dc68da 100644 --- a/app/code/Magento/DesignEditor/Model/Editor/Tools/QuickStyles/Renderer/AbstractRenderer.php +++ b/app/code/Magento/DesignEditor/Model/Editor/Tools/QuickStyles/Renderer/AbstractRenderer.php @@ -23,12 +23,11 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\DesignEditor\Model\Editor\Tools\QuickStyles\Renderer; /** * Quick style abstract renderer */ -namespace Magento\DesignEditor\Model\Editor\Tools\QuickStyles\Renderer; - abstract class AbstractRenderer { /** diff --git a/app/code/Magento/DesignEditor/Model/Editor/Tools/QuickStyles/Renderer/BackgroundImage.php b/app/code/Magento/DesignEditor/Model/Editor/Tools/QuickStyles/Renderer/BackgroundImage.php index b165868ccd013207b94560a58d636fc71ef2e15d..383e190bd7553060c907ec2c531d5806bd0fad88 100644 --- a/app/code/Magento/DesignEditor/Model/Editor/Tools/QuickStyles/Renderer/BackgroundImage.php +++ b/app/code/Magento/DesignEditor/Model/Editor/Tools/QuickStyles/Renderer/BackgroundImage.php @@ -23,12 +23,11 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\DesignEditor\Model\Editor\Tools\QuickStyles\Renderer; /** * Background image renderer */ -namespace Magento\DesignEditor\Model\Editor\Tools\QuickStyles\Renderer; - class BackgroundImage extends \Magento\DesignEditor\Model\Editor\Tools\QuickStyles\Renderer\AbstractRenderer { diff --git a/app/code/Magento/DesignEditor/Model/Editor/Tools/QuickStyles/Renderer/DefaultRenderer.php b/app/code/Magento/DesignEditor/Model/Editor/Tools/QuickStyles/Renderer/DefaultRenderer.php index 971c344daa67b7896aa9a1adbbeaa63c52ed0db6..97ee155ef6ad9d1d58e9ef807107e2a2bf3c17a3 100644 --- a/app/code/Magento/DesignEditor/Model/Editor/Tools/QuickStyles/Renderer/DefaultRenderer.php +++ b/app/code/Magento/DesignEditor/Model/Editor/Tools/QuickStyles/Renderer/DefaultRenderer.php @@ -24,11 +24,11 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\DesignEditor\Model\Editor\Tools\QuickStyles\Renderer; + /** * Default css renderer */ -namespace Magento\DesignEditor\Model\Editor\Tools\QuickStyles\Renderer; - class DefaultRenderer extends \Magento\DesignEditor\Model\Editor\Tools\QuickStyles\Renderer\AbstractRenderer { diff --git a/app/code/Magento/DesignEditor/Model/Editor/Tools/QuickStyles/Renderer/Factory.php b/app/code/Magento/DesignEditor/Model/Editor/Tools/QuickStyles/Renderer/Factory.php index e17e976e8372b8062569bca6f5100b9240281924..b1b05ebe0fc76927eea6a84200c55af96a9fa7d8 100644 --- a/app/code/Magento/DesignEditor/Model/Editor/Tools/QuickStyles/Renderer/Factory.php +++ b/app/code/Magento/DesignEditor/Model/Editor/Tools/QuickStyles/Renderer/Factory.php @@ -24,11 +24,11 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\DesignEditor\Model\Editor\Tools\QuickStyles\Renderer; + /** * Quick style renderer factory */ -namespace Magento\DesignEditor\Model\Editor\Tools\QuickStyles\Renderer; - class Factory { /** diff --git a/app/code/Magento/DesignEditor/Model/Observer.php b/app/code/Magento/DesignEditor/Model/Observer.php index 89833bd6dfee679efb90b6a0067a60c2d54cbcd4..52eae9934daab4cf95e6cdbdb1608113c3c6f29e 100644 --- a/app/code/Magento/DesignEditor/Model/Observer.php +++ b/app/code/Magento/DesignEditor/Model/Observer.php @@ -23,12 +23,13 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\DesignEditor\Model; + +use Magento\Event\Observer as EventObserver; /** * Observer for design editor module */ -namespace Magento\DesignEditor\Model; - class Observer { /** @@ -57,9 +58,10 @@ class Observer * Remove non-VDE JavaScript assets in design mode * Applicable in combination with enabled 'vde_design_mode' flag for 'head' block * - * @param \Magento\Event\Observer $event + * @param EventObserver $event + * @return void */ - public function clearJs(\Magento\Event\Observer $event) + public function clearJs(EventObserver $event) { /** @var $layout \Magento\View\LayoutInterface */ $layout = $event->getEvent()->getLayout(); @@ -91,7 +93,8 @@ class Observer /** * Save quick styles * - * @param \Magento\Event\Observer $event + * @param EventObserver $event + * @return void */ public function saveQuickStyles($event) { @@ -117,7 +120,8 @@ class Observer /** * Save time stamp of last change * - * @param \Magento\Event\Observer $event + * @param EventObserver $event + * @return void */ public function saveChangeTime($event) { @@ -135,10 +139,10 @@ class Observer /** * Determine if the vde specific translation class should be used. * - * @param \Magento\Event\Observer $observer - * @return \Magento\DesignEditor\Model\Observer + * @param EventObserver $observer + * @return $this */ - public function initializeTranslation(\Magento\Event\Observer $observer) + public function initializeTranslation(EventObserver $observer) { if ($this->_helper->isVdeRequest()) { // Request is for vde. Override the translation class. diff --git a/app/code/Magento/DesignEditor/Model/Plugin/ThemeCopyService.php b/app/code/Magento/DesignEditor/Model/Plugin/ThemeCopyService.php index 272ba3614c5dfcfada2ebb563819c48b70c9e3b0..12b276d3cb836bd706f9e4bdc30179d4d337ff86 100644 --- a/app/code/Magento/DesignEditor/Model/Plugin/ThemeCopyService.php +++ b/app/code/Magento/DesignEditor/Model/Plugin/ThemeCopyService.php @@ -43,6 +43,7 @@ class ThemeCopyService * * @param array $methodArguments * @param \Magento\Code\Plugin\InvocationChain $invocationChain + * @return void */ public function aroundCopy(array $methodArguments, \Magento\Code\Plugin\InvocationChain $invocationChain) { diff --git a/app/code/Magento/DesignEditor/Model/State.php b/app/code/Magento/DesignEditor/Model/State.php index 99c1e2d0a5eb608e69518fa08d22fd04b620a788..65424fc2ffa20be812696912b02c0af535f95d0b 100644 --- a/app/code/Magento/DesignEditor/Model/State.php +++ b/app/code/Magento/DesignEditor/Model/State.php @@ -24,11 +24,11 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\DesignEditor\Model; + /** * Design editor state model */ -namespace Magento\DesignEditor\Model; - class State { /** @@ -135,6 +135,7 @@ class State * * @param string $areaCode * @param \Magento\App\RequestInterface $request + * @return void */ public function update($areaCode, \Magento\App\RequestInterface $request) { @@ -154,7 +155,7 @@ class State /** * Reset VDE state data * - * @return \Magento\DesignEditor\Model\State + * @return $this */ public function reset() { @@ -169,6 +170,7 @@ class State * * @param string $mode * @param string $areaCode + * @return void */ protected function _injectLayout($mode, $areaCode) { @@ -182,6 +184,8 @@ class State /** * Create url model instance that will be used instead of \Magento\UrlInterface in navigation mode + * + * @return void */ protected function _injectUrlModel($mode) { @@ -195,6 +199,8 @@ class State /** * Set current VDE theme + * + * @return void */ protected function _setTheme() { @@ -213,6 +219,8 @@ class State /** * Disable some cache types in VDE mode + * + * @return void */ protected function _disableCache() { diff --git a/app/code/Magento/DesignEditor/Model/Theme/Change.php b/app/code/Magento/DesignEditor/Model/Theme/Change.php index 1ff58c69313dd06fe794bbf0d3021a343c27d95d..030e5e6fda4fe542fd86e2d402e3da58ba6283c5 100644 --- a/app/code/Magento/DesignEditor/Model/Theme/Change.php +++ b/app/code/Magento/DesignEditor/Model/Theme/Change.php @@ -23,16 +23,17 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\DesignEditor\Model\Theme; /** * Design editor theme change */ -namespace Magento\DesignEditor\Model\Theme; - class Change extends \Magento\Core\Model\AbstractModel { /** * Theme model initialization + * + * @return void */ protected function _construct() { diff --git a/app/code/Magento/DesignEditor/Model/Theme/Context.php b/app/code/Magento/DesignEditor/Model/Theme/Context.php index 9914bc6728b99da4775a267ae8bdeabf25de8005..7719d48adc490f6d8155e3f5da5d08a271d3231f 100644 --- a/app/code/Magento/DesignEditor/Model/Theme/Context.php +++ b/app/code/Magento/DesignEditor/Model/Theme/Context.php @@ -23,12 +23,13 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\DesignEditor\Model\Theme; + +use Magento\Core\Exception as CoreException; /** * Design editor theme context */ -namespace Magento\DesignEditor\Model\Theme; - class Context { /** @@ -68,7 +69,7 @@ class Context /** * Reset checked theme * - * @return \Magento\DesignEditor\Model\State + * @return $this */ public function reset() { @@ -81,16 +82,16 @@ class Context * * @param int $themeId * @return $this - * @throws \Magento\Core\Exception + * @throws CoreException */ public function setEditableThemeById($themeId) { $this->_theme = $this->_themeFactory->create(); if (!$this->_theme->load($themeId)->getId()) { - throw new \Magento\Core\Exception(__('We can\'t find theme "%1".', $themeId)); + throw new CoreException(__('We can\'t find theme "%1".', $themeId)); } if ($this->_theme->getType() === \Magento\View\Design\ThemeInterface::TYPE_STAGING) { - throw new \Magento\Core\Exception(__('Wrong theme type set as editable')); + throw new CoreException(__('Wrong theme type set as editable')); } return $this; } @@ -99,12 +100,12 @@ class Context * Get current editable theme * * @return \Magento\Core\Model\Theme - * @throws \Magento\Core\Exception + * @throws CoreException */ public function getEditableTheme() { if (null === $this->_theme) { - throw new \Magento\Core\Exception(__('Theme has not been set')); + throw new CoreException(__('Theme has not been set')); } return $this->_theme; } @@ -113,14 +114,14 @@ class Context * Get staging theme * * @return \Magento\Core\Model\Theme - * @throws \Magento\Core\Exception + * @throws CoreException */ public function getStagingTheme() { if (null === $this->_stagingTheme) { $editableTheme = $this->getEditableTheme(); if (!$editableTheme->isVirtual()) { - throw new \Magento\Core\Exception( + throw new CoreException( __('Theme "%1" is not editable.', $editableTheme->getThemeTitle()) ); } diff --git a/app/code/Magento/DesignEditor/Model/Theme/Resource/Change.php b/app/code/Magento/DesignEditor/Model/Theme/Resource/Change.php index 94bef0b5f12886233b87e4a6f5ba14dd67bf58fd..6e1d028722a2fa11dc0a6d37492e380a4fb32016 100644 --- a/app/code/Magento/DesignEditor/Model/Theme/Resource/Change.php +++ b/app/code/Magento/DesignEditor/Model/Theme/Resource/Change.php @@ -23,12 +23,11 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\DesignEditor\Model\Theme\Resource; /** * Theme change resource model */ -namespace Magento\DesignEditor\Model\Theme\Resource; - class Change extends \Magento\Core\Model\Resource\Db\AbstractDb { /** @@ -39,6 +38,7 @@ class Change extends \Magento\Core\Model\Resource\Db\AbstractDb /** * @param \Magento\App\Resource $resource * @param \Magento\Stdlib\DateTime $dateTime + * @return void */ public function __construct(\Magento\App\Resource $resource, \Magento\Stdlib\DateTime $dateTime) { diff --git a/app/code/Magento/DesignEditor/Model/Translate/InlineVde.php b/app/code/Magento/DesignEditor/Model/Translate/InlineVde.php index d6c6a07108939516980ba8129e752aa700e081d7..0c20236cb2dda69f189d5583cbe220fd86199950 100644 --- a/app/code/Magento/DesignEditor/Model/Translate/InlineVde.php +++ b/app/code/Magento/DesignEditor/Model/Translate/InlineVde.php @@ -23,12 +23,12 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\DesignEditor\Model\Translate; + /** * Inline translation specific to Vde. */ -namespace Magento\DesignEditor\Model\Translate; - -class InlineVde implements \Magento\Core\Model\Translate\InlineInterface +class InlineVde implements \Magento\Translate\InlineInterface { /** * data-translate-mode attribute name @@ -66,7 +66,7 @@ class InlineVde implements \Magento\Core\Model\Translate\InlineInterface protected $_helper; /** - * @var \Magento\Core\Model\Translate\InlineParser + * @var \Magento\Translate\Inline\ParserInterface */ protected $_parser; @@ -87,21 +87,37 @@ class InlineVde implements \Magento\Core\Model\Translate\InlineInterface */ protected $_objectManager; + /** + * @var \Magento\View\DesignInterface + */ + protected $_design; + + /** + * @var \Magento\BaseScopeResolverInterface + */ + protected $_scopeResolver; + /** * Initialize inline translation model specific for vde * - * @param \Magento\Core\Model\Translate\InlineParser $parser + * @param \Magento\View\DesignInterface $design + * @param \Magento\BaseScopeResolverInterface $scopeResolver + * @param \Magento\Translate\Inline\ParserFactory $parserFactory * @param \Magento\DesignEditor\Helper\Data $helper * @param \Magento\UrlInterface $url * @param \Magento\ObjectManager $objectManager */ public function __construct( - \Magento\Core\Model\Translate\InlineParser $parser, + \Magento\View\DesignInterface $design, + \Magento\BaseScopeResolverInterface $scopeResolver, + \Magento\Translate\Inline\ParserFactory $parserFactory, \Magento\DesignEditor\Helper\Data $helper, \Magento\UrlInterface $url, \Magento\ObjectManager $objectManager ) { - $this->_parser = $parser; + $this->_design = $design; + $this->_scopeResolver = $scopeResolver; + $this->_parser = $parserFactory->create(array('translateInline' => $this)); $this->_helper = $helper; $this->_url = $url; $this->_objectManager = $objectManager; @@ -120,11 +136,11 @@ class InlineVde implements \Magento\Core\Model\Translate\InlineInterface /** * Replace VDE specific translation templates with HTML fragments * - * @param array|string $body + * @param string[]|string $body * @param bool $isJson - * @return \Magento\DesignEditor\Model\Translate\InlineVde + * @return $this */ - public function processResponseBody(&$body, $isJson) + public function processResponseBody(&$body, $isJson = false) { if (is_array($body)) { foreach ($body as &$part) { @@ -142,7 +158,7 @@ class InlineVde implements \Magento\Core\Model\Translate\InlineInterface * Returns the translation mode html attribute needed by vde to specify which translation mode the * element represents. * - * @param mixed|string $tagName + * @param string|null $tagName * @return string */ public function getAdditionalHtmlAttribute($tagName = null) @@ -152,6 +168,8 @@ class InlineVde implements \Magento\Core\Model\Translate\InlineInterface /** * Create block to render script and html with added inline translation content specific for vde. + * + * @return void */ private function _insertInlineScriptsHtml($content) { @@ -159,16 +177,16 @@ class InlineVde implements \Magento\Core\Model\Translate\InlineInterface return; } - $store = $this->_parser->getStoreManager()->getStore(); + $scope = $this->_scopeResolver->getScope(); $ajaxUrl = $this->_url->getUrl('core/ajax/translate', array( - '_secure' => $store->isCurrentlySecure(), + '_secure' => $scope->isCurrentlySecure(), \Magento\DesignEditor\Helper\Data::TRANSLATION_MODE => $this->_helper->getTranslationMode() )); /** @var $block \Magento\View\Element\Template */ $block = $this->_objectManager->create('Magento\View\Element\Template'); - $block->setArea($this->_parser->getDesignPackage()->getArea()); + $block->setArea($this->_design->getArea()); $block->setAjaxUrl($ajaxUrl); $block->setFrameUrl($this->_getFrameUrl()); diff --git a/app/code/Magento/DesignEditor/Model/Url/NavigationMode.php b/app/code/Magento/DesignEditor/Model/Url/NavigationMode.php index 13840b5d30335fac3b3d57f69ca03f149eeaf434..87abae83f3505db4f92d7e43658cda52530b9560 100644 --- a/app/code/Magento/DesignEditor/Model/Url/NavigationMode.php +++ b/app/code/Magento/DesignEditor/Model/Url/NavigationMode.php @@ -23,12 +23,11 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\DesignEditor\Model\Url; /** * Navigation mode design editor url model */ -namespace Magento\DesignEditor\Model\Url; - class NavigationMode extends \Magento\Url { /** diff --git a/app/code/Magento/Directory/Block/Currency.php b/app/code/Magento/Directory/Block/Currency.php index e56e81ec8646d80503ede82b667cdb3152300034..bdc944644debc5450b0d154adef3ab053a37d674 100644 --- a/app/code/Magento/Directory/Block/Currency.php +++ b/app/code/Magento/Directory/Block/Currency.php @@ -132,11 +132,11 @@ class Currency extends \Magento\View\Element\Template public function getCurrentCurrencyCode() { if (is_null($this->_getData('current_currency_code'))) { + // do not use $this->_storeManager->getStore()->getCurrentCurrencyCode() because of probability // to get an invalid (without base rate) currency from code saved in session $this->setData('current_currency_code', $this->_storeManager->getStore()->getCurrentCurrency()->getCode()); } - return $this->_getData('current_currency_code'); } diff --git a/app/code/Magento/Directory/Model/Observer.php b/app/code/Magento/Directory/Model/Observer.php index b09bbb3a41584edad04a84aa7af23aead4bf378a..2a0fe8ab0932dc5d07a173833a5ed5827aa1e44a 100644 --- a/app/code/Magento/Directory/Model/Observer.php +++ b/app/code/Magento/Directory/Model/Observer.php @@ -54,7 +54,7 @@ class Observer protected $_coreStoreConfig; /** - * @var \Magento\Core\Model\Translate + * @var \Magento\TranslateInterface */ protected $_translate; @@ -76,7 +76,7 @@ class Observer /** * @param \Magento\Directory\Model\Currency\Import\Factory $importFactory * @param \Magento\Core\Model\Store\Config $coreStoreConfig - * @param \Magento\Core\Model\Translate $translate + * @param \Magento\TranslateInterface $translate * @param \Magento\Email\Model\TemplateFactory $emailTemplateFactory * @param \Magento\Core\Model\StoreManagerInterface $storeManager * @param \Magento\Directory\Model\CurrencyFactory $currencyFactory @@ -84,7 +84,7 @@ class Observer public function __construct( \Magento\Directory\Model\Currency\Import\Factory $importFactory, \Magento\Core\Model\Store\Config $coreStoreConfig, - \Magento\Core\Model\Translate $translate, + \Magento\TranslateInterface $translate, \Magento\Email\Model\TemplateFactory $emailTemplateFactory, \Magento\Core\Model\StoreManagerInterface $storeManager, \Magento\Directory\Model\CurrencyFactory $currencyFactory diff --git a/app/code/Magento/Eav/Block/Adminhtml/Attribute/Edit/Js.php b/app/code/Magento/Eav/Block/Adminhtml/Attribute/Edit/Js.php index 2d7a9593c2b1703e1e7e54268cb5e5a1aae95742..0c718870e025a723938d8aa48b71e2466926959a 100644 --- a/app/code/Magento/Eav/Block/Adminhtml/Attribute/Edit/Js.php +++ b/app/code/Magento/Eav/Block/Adminhtml/Attribute/Edit/Js.php @@ -35,5 +35,10 @@ namespace Magento\Eav\Block\Adminhtml\Attribute\Edit; class Js extends \Magento\Backend\Block\Template { + /** + * Js template + * + * @var string + */ protected $_template = 'attribute/edit/js.phtml'; } diff --git a/app/code/Magento/Eav/Block/Adminhtml/Attribute/Edit/Main/AbstractMain.php b/app/code/Magento/Eav/Block/Adminhtml/Attribute/Edit/Main/AbstractMain.php index 2213c6c44f5d64766037a4ab0a8d04c52dead3b3..bb6a45e97f6f880e02bac68243e28c5eefb86de9 100644 --- a/app/code/Magento/Eav/Block/Adminhtml/Attribute/Edit/Main/AbstractMain.php +++ b/app/code/Magento/Eav/Block/Adminhtml/Attribute/Edit/Main/AbstractMain.php @@ -34,9 +34,16 @@ */ namespace Magento\Eav\Block\Adminhtml\Attribute\Edit\Main; +use Magento\Catalog\Model\Resource\Eav\Attribute; + abstract class AbstractMain extends \Magento\Backend\Block\Widget\Form\Generic { + /** + * Attribute instance + * + * @var Attribute + */ protected $_attribute = null; /** @@ -88,6 +95,12 @@ abstract class AbstractMain parent::__construct($context, $registry, $formFactory, $data); } + /** + * Set attribute object + * + * @param Attribute $attribute + * @return $this + */ public function setAttributeObject($attribute) { $this->_attribute = $attribute; @@ -95,7 +108,9 @@ abstract class AbstractMain } /** - * @return \Magento\Catalog\Model\Resource\Eav\Attribute + * Return attribute object + * + * @return Attribute */ public function getAttributeObject() { @@ -108,7 +123,7 @@ abstract class AbstractMain /** * Preparing default form elements for editing attribute * - * @return \Magento\Eav\Block\Adminhtml\Attribute\Edit\Main\AbstractMain + * @return $this */ protected function _prepareForm() { @@ -250,7 +265,7 @@ abstract class AbstractMain /** * Initialize form fileds values * - * @return \Magento\Eav\Block\Adminhtml\Attribute\Edit\Main\AbstractMain + * @return $this */ protected function _initFormValues() { @@ -265,7 +280,7 @@ abstract class AbstractMain /** * This method is called before rendering HTML * - * @return \Magento\Eav\Block\Adminhtml\Attribute\Edit\Main\AbstractMain + * @return $this */ protected function _beforeToHtml() { diff --git a/app/code/Magento/Eav/Block/Adminhtml/Attribute/Edit/Options/AbstractOptions.php b/app/code/Magento/Eav/Block/Adminhtml/Attribute/Edit/Options/AbstractOptions.php index 396a3838d29ff56b36b3114aadb60688091793f9..90a4f076b45aaeb03f1d89286c2a83e5a75d6652 100644 --- a/app/code/Magento/Eav/Block/Adminhtml/Attribute/Edit/Options/AbstractOptions.php +++ b/app/code/Magento/Eav/Block/Adminhtml/Attribute/Edit/Options/AbstractOptions.php @@ -54,7 +54,7 @@ abstract class AbstractOptions extends \Magento\View\Element\AbstractBlock } /** - * @inheritdoc + * {@inheritdoc} * @return string */ protected function _toHtml() diff --git a/app/code/Magento/Eav/Block/Adminhtml/Attribute/Edit/Options/Options.php b/app/code/Magento/Eav/Block/Adminhtml/Attribute/Edit/Options/Options.php index 460faf3c31b025c308df84cb03bee1751646f18e..c3e5dc39d251dcf8d4dd2f12c45cd2b1594a4b12 100644 --- a/app/code/Magento/Eav/Block/Adminhtml/Attribute/Edit/Options/Options.php +++ b/app/code/Magento/Eav/Block/Adminhtml/Attribute/Edit/Options/Options.php @@ -33,6 +33,8 @@ */ namespace Magento\Eav\Block\Adminhtml\Attribute\Edit\Options; +use Magento\Core\Model\Resource\Store\Collection; + class Options extends \Magento\Backend\Block\Template { /** @var \Magento\Core\Model\Registry */ @@ -87,7 +89,7 @@ class Options extends \Magento\Backend\Block\Template /** * Retrieve stores collection with default store * - * @return array + * @return Collection */ public function getStores() { @@ -240,7 +242,7 @@ class Options extends \Magento\Backend\Block\Template /** * Retrieve attribute option values for given store id * - * @param integer $storeId + * @param int $storeId * @return array */ public function getStoreOptionValues($storeId) diff --git a/app/code/Magento/Eav/Block/Adminhtml/Attribute/Grid/AbstractGrid.php b/app/code/Magento/Eav/Block/Adminhtml/Attribute/Grid/AbstractGrid.php index 9a045d5c69a0d97f7c32ecfea63585314b7fa075..c87639095b6407ed829dfdb2dab509f0af0b9fc2 100644 --- a/app/code/Magento/Eav/Block/Adminhtml/Attribute/Grid/AbstractGrid.php +++ b/app/code/Magento/Eav/Block/Adminhtml/Attribute/Grid/AbstractGrid.php @@ -23,6 +23,7 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Eav\Block\Adminhtml\Attribute\Grid; /** * Product attributes grid @@ -31,8 +32,6 @@ * @package Magento_Adminhtml * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\Eav\Block\Adminhtml\Attribute\Grid; - abstract class AbstractGrid extends \Magento\Backend\Block\Widget\Grid\Extended { /** @@ -42,6 +41,9 @@ abstract class AbstractGrid extends \Magento\Backend\Block\Widget\Grid\Extended */ protected $_module = 'adminhtml'; + /** + * @return void + */ protected function _construct() { parent::_construct(); @@ -53,7 +55,7 @@ abstract class AbstractGrid extends \Magento\Backend\Block\Widget\Grid\Extended /** * Prepare default grid column * - * @return \Magento\Eav\Block\Adminhtml\Attribute\Grid\AbstractGrid + * @return $this */ protected function _prepareColumns() { diff --git a/app/code/Magento/Eav/Model/Adminhtml/System/Config/Source/Inputtype.php b/app/code/Magento/Eav/Model/Adminhtml/System/Config/Source/Inputtype.php index 5731c843b6f34ae3dbc5b579aa4882745d6c6a55..adfa4def53c680c3abf7a632d0981adffea26bf1 100644 --- a/app/code/Magento/Eav/Model/Adminhtml/System/Config/Source/Inputtype.php +++ b/app/code/Magento/Eav/Model/Adminhtml/System/Config/Source/Inputtype.php @@ -27,6 +27,11 @@ namespace Magento\Eav\Model\Adminhtml\System\Config\Source; class Inputtype implements \Magento\Core\Model\Option\ArrayInterface { + /** + * Return array of options + * + * @return array + */ public function toOptionArray() { return array( diff --git a/app/code/Magento/Eav/Model/Attribute.php b/app/code/Magento/Eav/Model/Attribute.php index 00554b4a11c2408af57c6c9d248e4c1086e14d7d..5ef654b0bd63f7ede78a79ad5ad2a38b3f1de48a 100644 --- a/app/code/Magento/Eav/Model/Attribute.php +++ b/app/code/Magento/Eav/Model/Attribute.php @@ -36,6 +36,8 @@ */ namespace Magento\Eav\Model; +use Magento\Core\Model\Website; + abstract class Attribute extends \Magento\Eav\Model\Entity\Attribute { /** @@ -54,15 +56,15 @@ abstract class Attribute extends \Magento\Eav\Model\Entity\Attribute /** * Active Website instance * - * @var \Magento\Core\Model\Website + * @var Website */ protected $_website; /** * Set active website instance * - * @param \Magento\Core\Model\Website|int $website - * @return \Magento\Eav\Model\Attribute + * @param Website|int $website + * @return $this */ public function setWebsite($website) { @@ -73,7 +75,7 @@ abstract class Attribute extends \Magento\Eav\Model\Entity\Attribute /** * Return active website instance * - * @return \Magento\Core\Model\Website + * @return Website */ public function getWebsite() { @@ -87,7 +89,7 @@ abstract class Attribute extends \Magento\Eav\Model\Entity\Attribute /** * Processing object after save data * - * @return \Magento\Eav\Model\Attribute + * @return $this */ protected function _afterSave() { @@ -130,7 +132,7 @@ abstract class Attribute extends \Magento\Eav\Model\Entity\Attribute * Set validate rules * * @param array|string $rules - * @return \Magento\Eav\Model\Attribute + * @return $this */ public function setValidateRules($rules) { diff --git a/app/code/Magento/Eav/Model/Attribute/Data/AbstractData.php b/app/code/Magento/Eav/Model/Attribute/Data/AbstractData.php index b4ea1b770a64195bae6e7dc97f274da0df600aa1..d654c79e59e6ac3c3da0dd65e8cf69f6e9cae8ac 100644 --- a/app/code/Magento/Eav/Model/Attribute/Data/AbstractData.php +++ b/app/code/Magento/Eav/Model/Attribute/Data/AbstractData.php @@ -23,7 +23,10 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Eav\Model\Attribute\Data; +use Magento\App\RequestInterface; +use Magento\Core\Exception as CoreException; /** * EAV Attribute Abstract Data Model @@ -32,8 +35,6 @@ * @package Magento_Eav * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\Eav\Model\Attribute\Data; - abstract class AbstractData { /** @@ -60,14 +61,14 @@ abstract class AbstractData /** * Scope visibility flag * - * @var boolean + * @var bool */ protected $_requestScopeOnly = true; /** * Is AJAX request flag * - * @var boolean + * @var bool */ protected $_isAjax = false; @@ -114,7 +115,7 @@ abstract class AbstractData * Set attribute instance * * @param \Magento\Eav\Model\Entity\Attribute\AbstractAttribute $attribute - * @return \Magento\Eav\Model\Attribute\Data\AbstractData + * @return $this */ public function setAttribute(\Magento\Eav\Model\Entity\Attribute\AbstractAttribute $attribute) { @@ -125,13 +126,13 @@ abstract class AbstractData /** * Return Attribute instance * - * @throws \Magento\Core\Exception + * @throws CoreException * @return \Magento\Eav\Model\Attribute */ public function getAttribute() { if (!$this->_attribite) { - throw new \Magento\Core\Exception(__('Attribute object is undefined')); + throw new CoreException(__('Attribute object is undefined')); } return $this->_attribite; } @@ -140,7 +141,7 @@ abstract class AbstractData * Set Request scope * * @param string $scope - * @return string + * @return $this */ public function setRequestScope($scope) { @@ -152,8 +153,8 @@ abstract class AbstractData * Set scope visibility * Search value only in scope or search value in scope and global * - * @param boolean $flag - * @return \Magento\Eav\Model\Attribute\Data\AbstractData + * @param bool $flag + * @return $this */ public function setRequestScopeOnly($flag) { @@ -165,7 +166,7 @@ abstract class AbstractData * Set entity instance * * @param \Magento\Core\Model\AbstractModel $entity - * @return \Magento\Eav\Model\Attribute\Data\AbstractData + * @return $this */ public function setEntity(\Magento\Core\Model\AbstractModel $entity) { @@ -181,7 +182,7 @@ abstract class AbstractData public function getEntity() { if (!$this->_entity) { - throw new \Magento\Core\Exception(__('Entity object is undefined')); + throw new CoreException(__('Entity object is undefined')); } return $this->_entity; } @@ -190,7 +191,7 @@ abstract class AbstractData * Set array of full extracted data * * @param array $data - * @return \Magento\Eav\Model\Attribute\Data\AbstractData + * @return $this */ public function setExtractedData(array $data) { @@ -259,7 +260,7 @@ abstract class AbstractData * Get/Set/Reset date filter format * * @param string|null|false $format - * @return \Magento\Eav\Model\Attribute\Data\AbstractData|string + * @return $this|string */ protected function _dateFilterFormat($format = null) { @@ -299,7 +300,7 @@ abstract class AbstractData * Validate value by attribute input validation rule * * @param string $value - * @return string + * @return string|true */ protected function _validateInputRule($value) { @@ -491,8 +492,8 @@ abstract class AbstractData /** * Set is AJAX Request flag * - * @param boolean $flag - * @return \Magento\Eav\Model\Attribute\Data\AbstractData + * @param bool $flag + * @return $this */ public function setIsAjaxRequest($flag = true) { @@ -503,7 +504,7 @@ abstract class AbstractData /** * Return is AJAX Request * - * @return boolean + * @return bool */ public function getIsAjaxRequest() { @@ -513,10 +514,10 @@ abstract class AbstractData /** * Return Original Attribute value from Request * - * @param \Magento\App\RequestInterface $request + * @param RequestInterface $request * @return mixed */ - protected function _getRequestValue(\Magento\App\RequestInterface $request) + protected function _getRequestValue(RequestInterface $request) { $attrCode = $this->getAttribute()->getAttributeCode(); if ($this->_requestScope) { @@ -552,17 +553,17 @@ abstract class AbstractData /** * Extract data from request and return value * - * @param \Magento\App\RequestInterface $request + * @param RequestInterface $request * @return array|string */ - abstract public function extractValue(\Magento\App\RequestInterface $request); + abstract public function extractValue(RequestInterface $request); /** * Validate data * * @param array|string $value - * @throws \Magento\Core\Exception - * @return boolean + * @throws CoreException + * @return bool */ abstract public function validateValue($value); @@ -570,7 +571,7 @@ abstract class AbstractData * Export attribute value to entity model * * @param array|string $value - * @return \Magento\Eav\Model\Attribute\Data\AbstractData + * @return $this */ abstract public function compactValue($value); @@ -578,7 +579,7 @@ abstract class AbstractData * Restore attribute value from SESSION to entity model * * @param array|string $value - * @return \Magento\Eav\Model\Attribute\Data\AbstractData + * @return $this */ abstract public function restoreValue($value); diff --git a/app/code/Magento/Eav/Model/Attribute/Data/Date.php b/app/code/Magento/Eav/Model/Attribute/Data/Date.php index d7f0620c6932e3c5cc6eeaab04fc58cd6a39b3be..f5dbf83cbb10baed7643ad02315f6828b21f3d2a 100644 --- a/app/code/Magento/Eav/Model/Attribute/Data/Date.php +++ b/app/code/Magento/Eav/Model/Attribute/Data/Date.php @@ -23,7 +23,9 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Eav\Model\Attribute\Data; +use Magento\App\RequestInterface; /** * EAV Entity Attribute Date Data Model @@ -32,17 +34,15 @@ * @package Magento_Eav * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\Eav\Model\Attribute\Data; - class Date extends \Magento\Eav\Model\Attribute\Data\AbstractData { /** * Extract data from request and return value * - * @param \Magento\App\RequestInterface $request + * @param RequestInterface $request * @return array|string */ - public function extractValue(\Magento\App\RequestInterface $request) + public function extractValue(RequestInterface $request) { $value = $this->_getRequestValue($request); return $this->_applyInputFilter($value); @@ -53,7 +53,7 @@ class Date extends \Magento\Eav\Model\Attribute\Data\AbstractData * Return true or array of errors * * @param array|string $value - * @return boolean|array + * @return bool|array */ public function validateValue($value) { @@ -104,7 +104,7 @@ class Date extends \Magento\Eav\Model\Attribute\Data\AbstractData * Export attribute value to entity model * * @param array|string $value - * @return \Magento\Eav\Model\Attribute\Data\Date + * @return $this */ public function compactValue($value) { @@ -121,7 +121,7 @@ class Date extends \Magento\Eav\Model\Attribute\Data\AbstractData * Restore attribute value from SESSION to entity model * * @param array|string $value - * @return \Magento\Eav\Model\Attribute\Data\Date + * @return $this */ public function restoreValue($value) { diff --git a/app/code/Magento/Eav/Model/Attribute/Data/File.php b/app/code/Magento/Eav/Model/Attribute/Data/File.php index a4744e929ee0b063c0bb48fd0e50e3fc81b93556..3dc2d16b2cf6881d07caeec4260f1599a94ad469 100644 --- a/app/code/Magento/Eav/Model/Attribute/Data/File.php +++ b/app/code/Magento/Eav/Model/Attribute/Data/File.php @@ -23,6 +23,9 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Eav\Model\Attribute\Data; + +use Magento\App\RequestInterface; /** * EAV Entity Attribute File Data Model @@ -31,8 +34,6 @@ * @package Magento_Eav * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\Eav\Model\Attribute\Data; - class File extends \Magento\Eav\Model\Attribute\Data\AbstractData { /** @@ -82,10 +83,10 @@ class File extends \Magento\Eav\Model\Attribute\Data\AbstractData /** * Extract data from request and return value * - * @param \Magento\App\RequestInterface $request - * @return array|string + * @param RequestInterface $request + * @return array|string|bool */ - public function extractValue(\Magento\App\RequestInterface $request) + public function extractValue(RequestInterface $request) { if ($this->getIsAjaxRequest()) { return false; @@ -141,7 +142,7 @@ class File extends \Magento\Eav\Model\Attribute\Data\AbstractData * Return array of errors * * @param array $value - * @return array + * @return string[] */ protected function _validateByRules($value) { @@ -188,8 +189,7 @@ class File extends \Magento\Eav\Model\Attribute\Data\AbstractData * Validate data * * @param array|string $value - * @throws \Magento\Core\Exception - * @return boolean + * @return bool */ public function validateValue($value) { @@ -230,9 +230,8 @@ class File extends \Magento\Eav\Model\Attribute\Data\AbstractData /** * Export attribute value to entity model * - * @param \Magento\Core\Model\AbstractModel $entity * @param array|string $value - * @return \Magento\Eav\Model\Attribute\Data\File + * @return $this */ public function compactValue($value) { @@ -284,7 +283,7 @@ class File extends \Magento\Eav\Model\Attribute\Data\AbstractData * Restore attribute value from SESSION to entity model * * @param array|string $value - * @return \Magento\Eav\Model\Attribute\Data\File + * @return $this */ public function restoreValue($value) { @@ -294,6 +293,7 @@ class File extends \Magento\Eav\Model\Attribute\Data\AbstractData /** * Return formated attribute value from entity model * + * @param string $format * @return string|array */ public function outputValue($format = \Magento\Eav\Model\AttributeDataFactory::OUTPUT_FORMAT_TEXT) diff --git a/app/code/Magento/Eav/Model/Attribute/Data/Image.php b/app/code/Magento/Eav/Model/Attribute/Data/Image.php index 2cb85ce36dcb58f3a7fbfe8faaf49778ecefc905..bd6dc237788f1699b0199d359fb40541c6af81b2 100644 --- a/app/code/Magento/Eav/Model/Attribute/Data/Image.php +++ b/app/code/Magento/Eav/Model/Attribute/Data/Image.php @@ -23,7 +23,7 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ - +namespace Magento\Eav\Model\Attribute\Data; /** * EAV Entity Attribute Image File Data Model @@ -32,8 +32,6 @@ * @package Magento_Eav * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\Eav\Model\Attribute\Data; - class Image extends \Magento\Eav\Model\Attribute\Data\File { /** diff --git a/app/code/Magento/Eav/Model/Attribute/Data/Multiline.php b/app/code/Magento/Eav/Model/Attribute/Data/Multiline.php index c9eb22dd4b387ed491e0c2eaabea4a3ad09e2a26..9be436c72b90a2ba0c35f1c7c3f748e0eb521372 100644 --- a/app/code/Magento/Eav/Model/Attribute/Data/Multiline.php +++ b/app/code/Magento/Eav/Model/Attribute/Data/Multiline.php @@ -23,7 +23,9 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Eav\Model\Attribute\Data; +use Magento\App\RequestInterface; /** * EAV Entity Attribute Multiply line Data Model @@ -32,17 +34,15 @@ * @package Magento_Eav * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\Eav\Model\Attribute\Data; - class Multiline extends \Magento\Eav\Model\Attribute\Data\Text { /** * Extract data from request and return value * - * @param \Magento\App\RequestInterface $request + * @param RequestInterface $request * @return array|string */ - public function extractValue(\Magento\App\RequestInterface $request) + public function extractValue(RequestInterface $request) { $value = $this->_getRequestValue($request); if (!is_array($value)) { @@ -58,7 +58,7 @@ class Multiline extends \Magento\Eav\Model\Attribute\Data\Text * Return true or array of errors * * @param array|string $value - * @return boolean|array + * @return bool|array */ public function validateValue($value) { @@ -105,9 +105,8 @@ class Multiline extends \Magento\Eav\Model\Attribute\Data\Text /** * Export attribute value to entity model * - * @param \Magento\Core\Model\AbstractModel $entity * @param array|string $value - * @return \Magento\Eav\Model\Attribute\Data\Multiline + * @return $this */ public function compactValue($value) { @@ -121,7 +120,7 @@ class Multiline extends \Magento\Eav\Model\Attribute\Data\Text * Restore attribute value from SESSION to entity model * * @param array|string $value - * @return \Magento\Eav\Model\Attribute\Data\Multiline + * @return $this */ public function restoreValue($value) { diff --git a/app/code/Magento/Eav/Model/Attribute/Data/Multiselect.php b/app/code/Magento/Eav/Model/Attribute/Data/Multiselect.php index b14a2a48dc503faa513e07387d9915ec58888ce7..cdd1694b89453372ef7b74ab0fd69c66e3a81ab5 100644 --- a/app/code/Magento/Eav/Model/Attribute/Data/Multiselect.php +++ b/app/code/Magento/Eav/Model/Attribute/Data/Multiselect.php @@ -23,7 +23,9 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Eav\Model\Attribute\Data; +use Magento\App\RequestInterface; /** * EAV Entity Attribute Multiply select Data Model @@ -32,17 +34,15 @@ * @package Magento_Eav * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\Eav\Model\Attribute\Data; - class Multiselect extends \Magento\Eav\Model\Attribute\Data\Select { /** * Extract data from request and return value * - * @param \Magento\App\RequestInterface $request + * @param RequestInterface $request * @return array|string */ - public function extractValue(\Magento\App\RequestInterface $request) + public function extractValue(RequestInterface $request) { $values = $this->_getRequestValue($request); if ($values !== false && !is_array($values)) { @@ -55,7 +55,7 @@ class Multiselect extends \Magento\Eav\Model\Attribute\Data\Select * Export attribute value to entity model * * @param array|string $value - * @return \Magento\Eav\Model\Attribute\Data\Multiselect + * @return $this */ public function compactValue($value) { diff --git a/app/code/Magento/Eav/Model/Attribute/Data/Select.php b/app/code/Magento/Eav/Model/Attribute/Data/Select.php index ca81c78b138528c78909a17ef02ba8800ed4ba2b..ed097f4768773883582a61c9ea387655b9e7b72c 100644 --- a/app/code/Magento/Eav/Model/Attribute/Data/Select.php +++ b/app/code/Magento/Eav/Model/Attribute/Data/Select.php @@ -23,7 +23,9 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Eav\Model\Attribute\Data; +use Magento\App\RequestInterface; /** * EAV Entity Attribute Select Data Model @@ -32,17 +34,15 @@ * @package Magento_Eav * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\Eav\Model\Attribute\Data; - class Select extends \Magento\Eav\Model\Attribute\Data\AbstractData { /** * Extract data from request and return value * - * @param \Magento\App\RequestInterface $request + * @param RequestInterface $request * @return array|string */ - public function extractValue(\Magento\App\RequestInterface $request) + public function extractValue(RequestInterface $request) { return $this->_getRequestValue($request); } @@ -52,7 +52,7 @@ class Select extends \Magento\Eav\Model\Attribute\Data\AbstractData * Return true or array of errors * * @param array|string $value - * @return boolean|array + * @return bool|array */ public function validateValue($value) { @@ -84,7 +84,7 @@ class Select extends \Magento\Eav\Model\Attribute\Data\AbstractData * Export attribute value to entity model * * @param array|string $value - * @return \Magento\Eav\Model\Attribute\Data\Select + * @return $this */ public function compactValue($value) { @@ -98,7 +98,7 @@ class Select extends \Magento\Eav\Model\Attribute\Data\AbstractData * Restore attribute value from SESSION to entity model * * @param array|string $value - * @return \Magento\Eav\Model\Attribute\Data\Select + * @return $this */ public function restoreValue($value) { @@ -119,6 +119,7 @@ class Select extends \Magento\Eav\Model\Attribute\Data\AbstractData /** * Return formated attribute value from entity model * + * @param string $format * @return string|array */ public function outputValue($format = \Magento\Eav\Model\AttributeDataFactory::OUTPUT_FORMAT_TEXT) diff --git a/app/code/Magento/Eav/Model/Attribute/Data/Text.php b/app/code/Magento/Eav/Model/Attribute/Data/Text.php index 870f7dffc4339d755fb8e8e9e790ee33226b2ab4..8330b6310829b2e5ab7508b2d217ea4fe25d1863 100644 --- a/app/code/Magento/Eav/Model/Attribute/Data/Text.php +++ b/app/code/Magento/Eav/Model/Attribute/Data/Text.php @@ -23,7 +23,9 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Eav\Model\Attribute\Data; +use Magento\App\RequestInterface; /** * EAV Entity Attribute Text Data Model @@ -32,8 +34,6 @@ * @package Magento_Eav * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\Eav\Model\Attribute\Data; - class Text extends \Magento\Eav\Model\Attribute\Data\AbstractData { /** @@ -58,10 +58,10 @@ class Text extends \Magento\Eav\Model\Attribute\Data\AbstractData /** * Extract data from request and return value * - * @param \Magento\App\RequestInterface $request + * @param RequestInterface $request * @return array|string */ - public function extractValue(\Magento\App\RequestInterface $request) + public function extractValue(RequestInterface $request) { $value = $this->_getRequestValue($request); return $this->_applyInputFilter($value); @@ -72,7 +72,7 @@ class Text extends \Magento\Eav\Model\Attribute\Data\AbstractData * Return true or array of errors * * @param array|string $value - * @return boolean|array + * @return bool|array */ public function validateValue($value) { @@ -121,7 +121,7 @@ class Text extends \Magento\Eav\Model\Attribute\Data\AbstractData * Export attribute value to entity model * * @param array|string $value - * @return \Magento\Eav\Model\Attribute\Data\Text + * @return $this */ public function compactValue($value) { @@ -135,7 +135,7 @@ class Text extends \Magento\Eav\Model\Attribute\Data\AbstractData * Restore attribute value from SESSION to entity model * * @param array|string $value - * @return \Magento\Eav\Model\Attribute\Data\Text + * @return $this */ public function restoreValue($value) { diff --git a/app/code/Magento/Eav/Model/Config.php b/app/code/Magento/Eav/Model/Config.php index e0a613644adfa9408ec50510bf6e788f4caf240a..6f4feba064779a2284f63249bf8a04a4f556e744 100644 --- a/app/code/Magento/Eav/Model/Config.php +++ b/app/code/Magento/Eav/Model/Config.php @@ -27,6 +27,8 @@ namespace Magento\Eav\Model; +use Magento\Eav\Model\Entity\Type; + class Config { const ENTITIES_CACHE_ID = 'EAV_ENTITY_TYPES'; @@ -91,7 +93,7 @@ class Config /** * Cache flag * - * @var unknown_type + * @var bool|null */ protected $_isCacheEnabled = null; @@ -138,7 +140,7 @@ class Config /** * Reset object state * - * @return \Magento\Eav\Model\Config + * @return $this */ public function clear() { @@ -168,7 +170,7 @@ class Config * * @param mixed $obj * @param mixed $id - * @return \Magento\Eav\Model\Config + * @return $this */ protected function _save($obj, $id) { @@ -181,7 +183,7 @@ class Config * * @param int $id * @param string $code - * @return \Magento\Eav\Model\Config + * @return $this */ protected function _addEntityTypeReference($id, $code) { @@ -206,7 +208,7 @@ class Config * @param int $id * @param string $code * @param string $entityTypeCode - * @return \Magento\Eav\Model\Config + * @return $this */ protected function _addAttributeReference($id, $code, $entityTypeCode) { @@ -219,7 +221,7 @@ class Config * * @param int $id * @param string $entityTypeCode - * @return string + * @return string|null */ protected function _getAttributeReference($id, $entityTypeCode) { @@ -268,7 +270,7 @@ class Config /** * Initialize all entity types data * - * @return \Magento\Eav\Model\Config + * @return $this */ protected function _initEntityTypes() { @@ -324,12 +326,13 @@ class Config /** * Get entity type object by entity type code/identifier * - * @param mixed $code - * @return \Magento\Eav\Model\Entity\Type + * @param int|string $code + * @return Type + * @throws \Magento\Core\Exception */ public function getEntityType($code) { - if ($code instanceof \Magento\Eav\Model\Entity\Type) { + if ($code instanceof Type) { return $code; } \Magento\Profiler::start('EAV: '.__METHOD__, array('group' => 'EAV', 'method' => __METHOD__)); @@ -374,7 +377,7 @@ class Config * Initialize all attributes for entity type * * @param string $entityType - * @return \Magento\Eav\Model\Config + * @return $this */ protected function _initAttributes($entityType) { @@ -524,7 +527,7 @@ class Config * * @param mixed $entityType * @param mixed $attributes - * @return \Magento\Eav\Model\Config + * @return $this */ public function preloadAttributes($entityType, $attributes) { @@ -615,7 +618,7 @@ class Config * * @param mixed $entityType * @param array $attributes - * @return \Magento\Eav\Model\Config + * @return $this */ public function loadCollectionAttributes($entityType, $attributes) { @@ -725,9 +728,9 @@ class Config /** * Import attributes data from external source * - * @param string|\Magento\Eav\Model\Entity\Type $entityType + * @param string|Type $entityType * @param array $attributes - * @return \Magento\Eav\Model\Config + * @return $this */ public function importAttributesData($entityType, array $attributes) { diff --git a/app/code/Magento/Eav/Model/Entity/AbstractEntity.php b/app/code/Magento/Eav/Model/Entity/AbstractEntity.php index 7e938cb9fd7ed7b4088681b81d819d9824067bea..343c53fb3653a2653b3e36af733d5fa0c378f5d7 100644 --- a/app/code/Magento/Eav/Model/Entity/AbstractEntity.php +++ b/app/code/Magento/Eav/Model/Entity/AbstractEntity.php @@ -34,6 +34,15 @@ */ namespace Magento\Eav\Model\Entity; +use Magento\Eav\Model\Entity\Type; +use Magento\Core\Exception; +use Magento\Core\Model\Config\Element; +use Magento\Eav\Model\Entity\Attribute\AbstractAttribute; +use Magento\Core\Model\AbstractModel; +use Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend; +use Magento\Eav\Model\Entity\Attribute\Frontend\AbstractFrontend; +use Magento\Eav\Model\Entity\Attribute\Source\AbstractSource; + abstract class AbstractEntity extends \Magento\Core\Model\Resource\AbstractResource implements \Magento\Eav\Model\Entity\EntityInterface { @@ -54,7 +63,7 @@ abstract class AbstractEntity extends \Magento\Core\Model\Resource\AbstractResou /** * Entity type configuration * - * @var \Magento\Eav\Model\Entity\Type + * @var Type */ protected $_type; @@ -138,14 +147,14 @@ abstract class AbstractEntity extends \Magento\Core\Model\Resource\AbstractResou /** * Partial load flag * - * @var boolean + * @var bool */ protected $_isPartialLoad = false; /** * Partial save flag * - * @var boolean + * @var bool */ protected $_isPartialSave = false; @@ -246,7 +255,7 @@ abstract class AbstractEntity extends \Magento\Core\Model\Resource\AbstractResou * * @param \Zend_Db_Adapter_Abstract|string $read * @param \Zend_Db_Adapter_Abstract|string|null $write - * @return \Magento\Eav\Model\Entity\AbstractEntity + * @return $this */ public function setConnection($read, $write = null) { @@ -258,6 +267,8 @@ abstract class AbstractEntity extends \Magento\Core\Model\Resource\AbstractResou /** * Resource initialization + * + * @return void */ protected function _construct() { @@ -310,7 +321,7 @@ abstract class AbstractEntity extends \Magento\Core\Model\Resource\AbstractResou } /** - * For compatibility with \Magento\Core\Model\AbstractModel + * For compatibility with AbstractModel * * @return string */ @@ -335,8 +346,8 @@ abstract class AbstractEntity extends \Magento\Core\Model\Resource\AbstractResou * * Accepts config node or name of entity type * - * @param string|\Magento\Eav\Model\Entity\Type $type - * @return \Magento\Eav\Model\Entity\AbstractEntity + * @param string|Type $type + * @return $this */ public function setType($type) { @@ -347,8 +358,8 @@ abstract class AbstractEntity extends \Magento\Core\Model\Resource\AbstractResou /** * Retrieve current entity config * - * @return \Magento\Eav\Model\Entity\Type - * @throws \Magento\Core\Exception + * @return Type + * @throws Exception */ public function getEntityType() { @@ -385,8 +396,8 @@ abstract class AbstractEntity extends \Magento\Core\Model\Resource\AbstractResou * If string - removes only one, if array - all specified * * @param array|string|null $attributes - * @return \Magento\Eav\Model\Entity\AbstractEntity - * @throws \Magento\Core\Exception + * @return $this + * @throws Exception */ public function unsetAttributes($attributes = null) { @@ -436,8 +447,8 @@ abstract class AbstractEntity extends \Magento\Core\Model\Resource\AbstractResou * * If attribute is not found false is returned * - * @param string|integer|\Magento\Core\Model\Config\Element $attribute - * @return \Magento\Eav\Model\Entity\Attribute\AbstractAttribute || false + * @param string|int|Element $attribute + * @return AbstractAttribute|false */ public function getAttribute($attribute) { @@ -463,13 +474,13 @@ abstract class AbstractEntity extends \Magento\Core\Model\Resource\AbstractResou if (!$attributeInstance->getAttributeCode() && in_array($attribute, $this->getDefaultAttributes())) { $attributeInstance ->setAttributeCode($attribute) - ->setBackendType(\Magento\Eav\Model\Entity\Attribute\AbstractAttribute::TYPE_STATIC) + ->setBackendType(AbstractAttribute::TYPE_STATIC) ->setIsGlobal(1) ->setEntity($this) ->setEntityType($this->getEntityType()) ->setEntityTypeId($this->getEntityType()->getId()); } - } elseif ($attribute instanceof \Magento\Eav\Model\Entity\Attribute\AbstractAttribute) { + } elseif ($attribute instanceof AbstractAttribute) { $attributeInstance = $attribute; $attributeCode = $attributeInstance->getAttributeCode(); if (isset($this->_attributesByCode[$attributeCode])) { @@ -478,7 +489,7 @@ abstract class AbstractEntity extends \Magento\Core\Model\Resource\AbstractResou } if (empty($attributeInstance) - || !($attributeInstance instanceof \Magento\Eav\Model\Entity\Attribute\AbstractAttribute) + || !($attributeInstance instanceof AbstractAttribute) || (!$attributeInstance->getId() && !in_array($attributeInstance->getAttributeCode(), $this->getDefaultAttributes())) ) { @@ -515,7 +526,7 @@ abstract class AbstractEntity extends \Magento\Core\Model\Resource\AbstractResou if (!isset(self::$_defaultAttributes[$entityTypeId][$attributeCode])) { $attribute = $this->_universalFactory->create($this->getEntityType()->getAttributeModel()) ->setAttributeCode($attributeCode) - ->setBackendType(\Magento\Eav\Model\Entity\Attribute\AbstractAttribute::TYPE_STATIC) + ->setBackendType(AbstractAttribute::TYPE_STATIC) ->setIsGlobal(1) ->setEntityType($this->getEntityType()) ->setEntityTypeId($this->getEntityType()->getId()); @@ -528,10 +539,10 @@ abstract class AbstractEntity extends \Magento\Core\Model\Resource\AbstractResou /** * Adding attribute to entity * - * @param \Magento\Eav\Model\Entity\Attribute\AbstractAttribute $attribute - * @return \Magento\Eav\Model\Entity\AbstractEntity + * @param AbstractAttribute $attribute + * @return $this */ - public function addAttribute(\Magento\Eav\Model\Entity\Attribute\AbstractAttribute $attribute) + public function addAttribute(AbstractAttribute $attribute) { $attribute->setEntity($this); $attributeCode = $attribute->getAttributeCode(); @@ -551,8 +562,8 @@ abstract class AbstractEntity extends \Magento\Core\Model\Resource\AbstractResou /** * Retrieve partial load flag * - * @param boolean $flag - * @return boolean + * @param bool $flag + * @return bool */ public function isPartialLoad($flag = null) { @@ -566,8 +577,8 @@ abstract class AbstractEntity extends \Magento\Core\Model\Resource\AbstractResou /** * Retrieve partial save flag * - * @param boolean $flag - * @return boolean + * @param bool $flag + * @return bool */ public function isPartialSave($flag = null) { @@ -582,7 +593,7 @@ abstract class AbstractEntity extends \Magento\Core\Model\Resource\AbstractResou * Retrieve configuration for all attributes * * @param null|object $object - * @return \Magento\Eav\Model\Entity\Attribute\AbstractAttribute + * @return $this */ public function loadAllAttributes($object = null) { @@ -626,7 +637,7 @@ abstract class AbstractEntity extends \Magento\Core\Model\Resource\AbstractResou $this->_attrSetEntity->addSetInfo($this->getEntityType(), $attributes, $setId); foreach ($attributes as $code => $attribute) { - /* @var $attribute \Magento\Eav\Model\Entity\Attribute\AbstractAttribute */ + /* @var $attribute AbstractAttribute */ if (!$attribute->isInSet($setId)) { unset($attributes[$code]); } @@ -662,8 +673,8 @@ abstract class AbstractEntity extends \Magento\Core\Model\Resource\AbstractResou * Check whether the attribute is Applicable to the object * * @param \Magento\Object $object - * @param \Magento\Eav\Model\Entity\Attribute\AbstractAttribute $attribute - * @return boolean + * @param AbstractAttribute $attribute + * @return bool */ protected function _isApplicableAttribute($object, $attribute) { @@ -755,10 +766,10 @@ abstract class AbstractEntity extends \Magento\Core\Model\Resource\AbstractResou /** * Check whether attribute instance (attribute, backend, frontend or source) has method and applicable * - * @param \Magento\Eav\Model\Entity\Attribute\AbstractAttribute|\Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend|\Magento\Eav\Model\Entity\Attribute\Frontend\AbstractFrontend|\Magento\Eav\Model\Entity\Attribute\Source\AbstractSource $instance + * @param AbstractAttribute|AbstractBackend|AbstractFrontend|AbstractSource $instance * @param string $method * @param array $args array of arguments - * @return boolean + * @return bool */ protected function _isCallableAttributeInstance($instance, $method, $args) { @@ -892,8 +903,8 @@ abstract class AbstractEntity extends \Magento\Core\Model\Resource\AbstractResou * Check whether the attribute is a real field in entity table * * @see \Magento\Eav\Model\Entity\AbstractEntity::getAttribute for $attribute format - * @param integer|string|\Magento\Eav\Model\Entity\Attribute\AbstractAttribute $attribute - * @return boolean + * @param int|string|AbstractAttribute $attribute + * @return bool */ public function isAttributeStatic($attribute) { @@ -931,7 +942,7 @@ abstract class AbstractEntity extends \Magento\Core\Model\Resource\AbstractResou * Set new increment id to object * * @param \Magento\Object $object - * @return \Magento\Eav\Model\Entity\AbstractEntity + * @return $this */ public function setNewIncrementId(\Magento\Object $object) { @@ -951,11 +962,11 @@ abstract class AbstractEntity extends \Magento\Core\Model\Resource\AbstractResou /** * Check attribute unique value * - * @param \Magento\Eav\Model\Entity\Attribute\AbstractAttribute $attribute + * @param AbstractAttribute $attribute * @param \Magento\Object $object - * @return boolean + * @return bool */ - public function checkAttributeUniqueValue(\Magento\Eav\Model\Entity\Attribute\AbstractAttribute $attribute, $object) + public function checkAttributeUniqueValue(AbstractAttribute $attribute, $object) { $adapter = $this->_getReadAdapter(); $select = $adapter->select(); @@ -1012,10 +1023,10 @@ abstract class AbstractEntity extends \Magento\Core\Model\Resource\AbstractResou /** * Load entity's attributes into the object * - * @param \Magento\Core\Model\AbstractModel $object - * @param integer $entityId + * @param AbstractModel $object + * @param int $entityId * @param array|null $attributes - * @return \Magento\Eav\Model\Entity\AbstractEntity + * @return $this */ public function load($object, $entityId, $attributes = array()) { @@ -1053,8 +1064,8 @@ abstract class AbstractEntity extends \Magento\Core\Model\Resource\AbstractResou /** * Load model attributes data * - * @param \Magento\Core\Model\AbstractModel $object - * @return \Magento\Eav\Model\Entity\AbstractEntity + * @param AbstractModel $object + * @return $this */ protected function _loadModelAttributes($object) { @@ -1102,7 +1113,7 @@ abstract class AbstractEntity extends \Magento\Core\Model\Resource\AbstractResou * Retrieve select object for loading base entity row * * @param \Magento\Object $object - * @param mixed $rowId + * @param string|int $rowId * @return \Zend_Db_Select */ protected function _getLoadRowSelect($object, $rowId) @@ -1135,7 +1146,7 @@ abstract class AbstractEntity extends \Magento\Core\Model\Resource\AbstractResou * * @param \Magento\Object $object * @param array $valueRow - * @return \Magento\Eav\Model\Entity\AbstractEntity + * @return $this */ protected function _setAttributeValue($object, $valueRow) { @@ -1153,7 +1164,7 @@ abstract class AbstractEntity extends \Magento\Core\Model\Resource\AbstractResou * Save entity's attributes into the object's resource * * @param \Magento\Object $object - * @return \Magento\Eav\Model\Entity\AbstractEntity + * @return $this */ public function save(\Magento\Object $object) { @@ -1198,8 +1209,9 @@ abstract class AbstractEntity extends \Magento\Core\Model\Resource\AbstractResou * Aggregate Data for attributes that will be deleted * * @param array $delete - * @param \Magento\Eav\Model\Entity\Attribute\AbstractAttribute $attribute + * @param AbstractAttribute $attribute * @param \Magento\Eav\Model\Entity\AbstractEntity $object + * @return void */ private function _aggregateDeleteData(&$delete, $attribute, $object) { @@ -1322,12 +1334,12 @@ abstract class AbstractEntity extends \Magento\Core\Model\Resource\AbstractResou /** * Return if attribute exists in original data array. * - * @param \Magento\Eav\Model\Entity\Attribute\AbstractAttribute $attribute + * @param AbstractAttribute $attribute * @param mixed $v New value of the attribute. Can be used in subclasses. * @param array $origData * @return bool */ - protected function _canUpdateAttribute(\Magento\Eav\Model\Entity\Attribute\AbstractAttribute $attribute, $v, array &$origData) + protected function _canUpdateAttribute(AbstractAttribute $attribute, $v, array &$origData) { return array_key_exists($attribute->getAttributeCode(), $origData); } @@ -1378,7 +1390,7 @@ abstract class AbstractEntity extends \Magento\Core\Model\Resource\AbstractResou * Save object collected data * * @param array $saveData array('newObject', 'entityRow', 'insert', 'update', 'delete') - * @return \Magento\Eav\Model\Entity\AbstractEntity + * @return $this */ protected function _processSaveData($saveData) { @@ -1389,7 +1401,7 @@ abstract class AbstractEntity extends \Magento\Core\Model\Resource\AbstractResou * @see \Magento\Eav\Model\Entity\AbstractEntity::_collectSaveData() * * @var array $entityRow - * @var \Magento\Core\Model\AbstractModel $newObject + * @var AbstractModel $newObject * @var array $insert * @var array $update * @var array $delete @@ -1473,9 +1485,9 @@ abstract class AbstractEntity extends \Magento\Core\Model\Resource\AbstractResou * Insert entity attribute value * * @param \Magento\Object $object - * @param \Magento\Eav\Model\Entity\Attribute\AbstractAttribute $attribute + * @param AbstractAttribute $attribute * @param mixed $value - * @return \Magento\Eav\Model\Entity\AbstractEntity + * @return $this */ protected function _insertAttribute($object, $attribute, $value) { @@ -1486,10 +1498,10 @@ abstract class AbstractEntity extends \Magento\Core\Model\Resource\AbstractResou * Update entity attribute value * * @param \Magento\Object $object - * @param \Magento\Eav\Model\Entity\Attribute\AbstractAttribute $attribute + * @param AbstractAttribute $attribute * @param mixed $valueId * @param mixed $value - * @return \Magento\Eav\Model\Entity\AbstractEntity + * @return $this */ protected function _updateAttribute($object, $attribute, $valueId, $value) { @@ -1501,10 +1513,10 @@ abstract class AbstractEntity extends \Magento\Core\Model\Resource\AbstractResou * * Collect for mass save * - * @param \Magento\Core\Model\AbstractModel $object - * @param \Magento\Eav\Model\Entity\Attribute\AbstractAttribute $attribute + * @param AbstractModel $object + * @param AbstractAttribute $attribute * @param mixed $value - * @return \Magento\Eav\Model\Entity\AbstractEntity + * @return $this */ protected function _saveAttribute($object, $attribute, $value) { @@ -1530,7 +1542,7 @@ abstract class AbstractEntity extends \Magento\Core\Model\Resource\AbstractResou /** * Save and detele collected attribute values * - * @return \Magento\Eav\Model\Entity\AbstractEntity + * @return $this */ protected function _processAttributeValues() { @@ -1554,10 +1566,10 @@ abstract class AbstractEntity extends \Magento\Core\Model\Resource\AbstractResou * Prepare value for save * * @param mixed $value - * @param \Magento\Eav\Model\Entity\Attribute\AbstractAttribute $attribute + * @param AbstractAttribute $attribute * @return mixed */ - protected function _prepareValueForSave($value, \Magento\Eav\Model\Entity\Attribute\AbstractAttribute $attribute) + protected function _prepareValueForSave($value, AbstractAttribute $attribute) { $type = $attribute->getBackendType(); if (($type == 'int' || $type == 'decimal' || $type == 'datetime') && $value === '') { @@ -1606,7 +1618,7 @@ abstract class AbstractEntity extends \Magento\Core\Model\Resource\AbstractResou * * @param \Magento\Object $object * @param string $attributeCode - * @return \Magento\Eav\Model\Entity\AbstractEntity + * @return $this * @throws \Exception */ public function saveAttribute(\Magento\Object $object, $attributeCode) @@ -1664,7 +1676,7 @@ abstract class AbstractEntity extends \Magento\Core\Model\Resource\AbstractResou * Delete entity using current object's data * * @param \Magento\Object|int|string $object - * @return \Magento\Eav\Model\Entity\AbstractEntity + * @return $this * @throws \Exception */ public function delete($object) @@ -1698,7 +1710,7 @@ abstract class AbstractEntity extends \Magento\Core\Model\Resource\AbstractResou * After Load Entity process * * @param \Magento\Object $object - * @return \Magento\Eav\Model\Entity\AbstractEntity + * @return $this */ protected function _afterLoad(\Magento\Object $object) { @@ -1712,7 +1724,7 @@ abstract class AbstractEntity extends \Magento\Core\Model\Resource\AbstractResou * Before delete Entity process * * @param \Magento\Object $object - * @return \Magento\Eav\Model\Entity\AbstractEntity + * @return $this */ protected function _beforeSave(\Magento\Object $object) { @@ -1724,7 +1736,7 @@ abstract class AbstractEntity extends \Magento\Core\Model\Resource\AbstractResou * After Save Entity process * * @param \Magento\Object $object - * @return \Magento\Eav\Model\Entity\AbstractEntity + * @return $this */ protected function _afterSave(\Magento\Object $object) { @@ -1736,7 +1748,7 @@ abstract class AbstractEntity extends \Magento\Core\Model\Resource\AbstractResou * Before Delete Entity process * * @param \Magento\Object $object - * @return \Magento\Eav\Model\Entity\AbstractEntity + * @return $this */ protected function _beforeDelete(\Magento\Object $object) { @@ -1748,7 +1760,7 @@ abstract class AbstractEntity extends \Magento\Core\Model\Resource\AbstractResou * After delete entity process * * @param \Magento\Object $object - * @return \Magento\Eav\Model\Entity\AbstractEntity + * @return $this */ protected function _afterDelete(\Magento\Object $object) { @@ -1769,7 +1781,7 @@ abstract class AbstractEntity extends \Magento\Core\Model\Resource\AbstractResou /** * Retrieve default entity attributes * - * @return array + * @return string[] */ protected function _getDefaultAttributes() { @@ -1779,7 +1791,7 @@ abstract class AbstractEntity extends \Magento\Core\Model\Resource\AbstractResou /** * Retrieve default entity static attributes * - * @return array + * @return string[] */ public function getDefaultAttributes() { @@ -1789,11 +1801,11 @@ abstract class AbstractEntity extends \Magento\Core\Model\Resource\AbstractResou /** * Check is attribute value empty * - * @param \Magento\Eav\Model\Entity\Attribute\AbstractAttribute $attribute + * @param AbstractAttribute $attribute * @param mixed $value * @return bool */ - protected function _isAttributeValueEmpty(\Magento\Eav\Model\Entity\Attribute\AbstractAttribute $attribute, $value) + protected function _isAttributeValueEmpty(AbstractAttribute $attribute, $value) { return $attribute->isValueEmpty($value); } diff --git a/app/code/Magento/Eav/Model/Entity/Attribute.php b/app/code/Magento/Eav/Model/Entity/Attribute.php index a5abf0dd0d47ae91385de70bbc3d912f58a8f014..21e8828fe202457330d38c50b74d26d6b944d6b6 100644 --- a/app/code/Magento/Eav/Model/Entity/Attribute.php +++ b/app/code/Magento/Eav/Model/Entity/Attribute.php @@ -23,7 +23,9 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Eav\Model\Entity; +use Magento\Eav\Exception; /** * EAV Entity attribute model @@ -34,8 +36,6 @@ * @package Magento_Eav * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\Eav\Model\Entity; - class Attribute extends \Magento\Eav\Model\Entity\Attribute\AbstractAttribute { /** @@ -57,6 +57,10 @@ class Attribute extends \Magento\Eav\Model\Entity\Attribute\AbstractAttribute protected $_eventObject = 'attribute'; const CACHE_TAG = 'EAV_ATTRIBUTE'; + + /** + * @var string + */ protected $_cacheTag = 'EAV_ATTRIBUTE'; /** @@ -176,7 +180,7 @@ class Attribute extends \Magento\Eav\Model\Entity\Attribute\AbstractAttribute /** * Load entity_attribute_id into $this by $this->attribute_set_id * - * @return \Magento\Core\Model\AbstractModel + * @return $this */ public function loadEntityAttributeIdBySet() { @@ -195,7 +199,8 @@ class Attribute extends \Magento\Eav\Model\Entity\Attribute\AbstractAttribute /** * Prepare data for save * - * @return \Magento\Eav\Model\Entity\Attribute + * @return $this + * @throws Exception */ protected function _beforeSave() { @@ -203,7 +208,7 @@ class Attribute extends \Magento\Eav\Model\Entity\Attribute\AbstractAttribute if (isset($this->_data['attribute_code']) && $this->_catalogProductFactory->create()->isReservedAttribute($this) ) { - throw new \Magento\Eav\Exception(__('The attribute code \'%1\' is reserved by system. Please try another attribute code', $this->_data['attribute_code'])); + throw new Exception(__('The attribute code \'%1\' is reserved by system. Please try another attribute code', $this->_data['attribute_code'])); } /** @@ -214,7 +219,7 @@ class Attribute extends \Magento\Eav\Model\Entity\Attribute\AbstractAttribute 'StringLength', array('max' => self::ATTRIBUTE_CODE_MAX_LENGTH)) ) { - throw new \Magento\Eav\Exception(__('Maximum length of attribute code must be less than %1 symbols', self::ATTRIBUTE_CODE_MAX_LENGTH)); + throw new Exception(__('Maximum length of attribute code must be less than %1 symbols', self::ATTRIBUTE_CODE_MAX_LENGTH)); } $defaultValue = $this->getDefaultValue(); @@ -224,7 +229,7 @@ class Attribute extends \Magento\Eav\Model\Entity\Attribute\AbstractAttribute if (!\Zend_Locale_Format::isNumber($defaultValue, array('locale' => $this->_locale->getLocaleCode())) ) { - throw new \Magento\Eav\Exception(__('Invalid default decimal value')); + throw new Exception(__('Invalid default decimal value')); } try { @@ -233,7 +238,7 @@ class Attribute extends \Magento\Eav\Model\Entity\Attribute\AbstractAttribute ); $this->setDefaultValue($filter->filter($defaultValue)); } catch (\Exception $e) { - throw new \Magento\Eav\Exception(__('Invalid default decimal value')); + throw new Exception(__('Invalid default decimal value')); } } @@ -253,7 +258,7 @@ class Attribute extends \Magento\Eav\Model\Entity\Attribute\AbstractAttribute $defaultValue = $this->_locale->date($defaultValue, $format, null, false)->toValue(); $this->setDefaultValue($defaultValue); } catch (\Exception $e) { - throw new \Magento\Eav\Exception(__('Invalid default date')); + throw new Exception(__('Invalid default date')); } } } @@ -270,7 +275,7 @@ class Attribute extends \Magento\Eav\Model\Entity\Attribute\AbstractAttribute /** * Save additional data * - * @return \Magento\Eav\Model\Entity\Attribute + * @return $this */ protected function _afterSave() { @@ -373,7 +378,7 @@ class Attribute extends \Magento\Eav\Model\Entity\Attribute\AbstractAttribute /** * Return array of labels of stores * - * @return array + * @return string[] */ public function getStoreLabels() { @@ -387,6 +392,7 @@ class Attribute extends \Magento\Eav\Model\Entity\Attribute\AbstractAttribute /** * Return store label of attribute * + * @param int|null $storeId * @return string */ public function getStoreLabel($storeId = null) diff --git a/app/code/Magento/Eav/Model/Entity/Attribute/AbstractAttribute.php b/app/code/Magento/Eav/Model/Entity/Attribute/AbstractAttribute.php index 57ee87290010c735db8c95964391147bceeadb53..3612ed9b62040304c109415fb5247380eef330f9 100644 --- a/app/code/Magento/Eav/Model/Entity/Attribute/AbstractAttribute.php +++ b/app/code/Magento/Eav/Model/Entity/Attribute/AbstractAttribute.php @@ -23,17 +23,15 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ - +namespace Magento\Eav\Model\Entity\Attribute; /** * Entity/Attribute/Model - attribute abstract * * @category Magento * @package Magento_Eav - * @author Magento Core Team <core@magentocommerce.com> + * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\Eav\Model\Entity\Attribute; - abstract class AbstractAttribute extends \Magento\Core\Model\AbstractModel implements \Magento\Eav\Model\Entity\Attribute\AttributeInterface @@ -158,6 +156,8 @@ abstract class AbstractAttribute /** * Initialize resource model + * + * @return void */ protected function _construct() { @@ -167,10 +167,10 @@ abstract class AbstractAttribute /** * Load attribute data by code * - * @param mixed $entityType + * @param string|int|\Magento\Eav\Model\Entity\Type $entityType * @param string $code - * @return \Magento\Eav\Model\Entity\Attribute\AbstractAttribute - * @throws \Magento\Core\Exception + * @return $this + * @throws \Magento\Eav\Exception */ public function loadByCode($entityType, $code) { @@ -206,7 +206,7 @@ abstract class AbstractAttribute * Specify attribute identifier * * @param int $data - * @return \Magento\Eav\Model\Entity\Attribute\AbstractAttribute + * @return $this */ public function setAttributeId($data) { @@ -224,83 +224,139 @@ abstract class AbstractAttribute return $this->_getData('attribute_id'); } + /** + * @param string $data + * @return $this + */ public function setAttributeCode($data) { return $this->setData('attribute_code', $data); } + /** + * @return string + */ public function getAttributeCode() { return $this->_getData('attribute_code'); } + /** + * @param array $data + * @return $this + */ public function setAttributeModel($data) { return $this->setData('attribute_model', $data); } + /** + * @return array + */ public function getAttributeModel() { return $this->_getData('attribute_model'); } + /** + * @param string $data + * @return $this + */ public function setBackendType($data) { return $this->setData('backend_type', $data); } + /** + * @return string + */ public function getBackendType() { return $this->_getData('backend_type'); } + /** + * @param string $data + * @return $this + */ public function setBackendModel($data) { return $this->setData('backend_model', $data); } + /** + * @return string + */ public function getBackendModel() { return $this->_getData('backend_model'); } + /** + * @param string $data + * @return $this + */ public function setBackendTable($data) { return $this->setData('backend_table', $data); } + /** + * @return bool + */ public function getIsVisibleOnFront() { return $this->_getData('is_visible_on_front'); } + /** + * @return string|int|bool|float + */ public function getDefaultValue() { return $this->_getData('default_value'); } + /** + * @return int + */ public function getAttributeSetId() { return $this->_getData('attribute_set_id'); } + /** + * @param int $id + * @return $this + */ public function setAttributeSetId($id) { $this->_data['attribute_set_id'] = $id; return $this; } + /** + * @return int|string + */ public function getEntityTypeId() { return $this->_getData('entity_type_id'); } + /** + * @param int|string $id + * @return $this + */ public function setEntityTypeId($id) { $this->_data['entity_type_id'] = $id; return $this; } + /** + * @param string $type + * @return $this + */ public function setEntityType($type) { $this->setData('entity_type', $type); @@ -328,7 +384,7 @@ abstract class AbstractAttribute * Set attribute name * * @param string $name - * @return \Magento\Eav\Model\Entity\Attribute\AbstractAttribute + * @return $this */ public function setName($name) { @@ -349,7 +405,7 @@ abstract class AbstractAttribute * Set attribute entity instance * * @param \Magento\Eav\Model\Entity\AbstractEntity $entity - * @return \Magento\Eav\Model\Entity\Attribute\AbstractAttribute + * @return $this */ public function setEntity($entity) { @@ -454,21 +510,34 @@ abstract class AbstractAttribute return $input === 'select' || $input === 'multiselect' || $this->_getData('source_model') != ''; } + /** + * @return string + */ protected function _getDefaultBackendModel() { return \Magento\Eav\Model\Entity::DEFAULT_BACKEND_MODEL; } + /** + * @return string + */ protected function _getDefaultFrontendModel() { return \Magento\Eav\Model\Entity::DEFAULT_FRONTEND_MODEL; } + /** + * @return string + */ protected function _getDefaultSourceModel() { return $this->getEntity()->getDefaultAttributeSourceModel(); } + /** + * @param array|null|bool|int|float|string $value + * @return bool + */ public function isValueEmpty($value) { $attrType = $this->getBackend()->getType(); @@ -483,8 +552,8 @@ abstract class AbstractAttribute /** * Check if attribute in specified set * - * @param int|array $setId - * @return boolean + * @param int|int[] $setId + * @return bool */ public function isInSet($setId) { @@ -510,7 +579,7 @@ abstract class AbstractAttribute * * @param int $setId * @param int $groupId - * @return boolean + * @return bool */ public function isInGroup($setId, $groupId) { diff --git a/app/code/Magento/Eav/Model/Entity/Attribute/Backend/AbstractBackend.php b/app/code/Magento/Eav/Model/Entity/Attribute/Backend/AbstractBackend.php index 79c5a39780c6bfe5c4e2abf63013c1f6e5d6cfbe..1f5814663bbe535c04a4af6fc294ba91860e3596 100644 --- a/app/code/Magento/Eav/Model/Entity/Attribute/Backend/AbstractBackend.php +++ b/app/code/Magento/Eav/Model/Entity/Attribute/Backend/AbstractBackend.php @@ -23,7 +23,7 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ - +namespace Magento\Eav\Model\Entity\Attribute\Backend; /** * Entity/Attribute/Model - attribute backend abstract @@ -32,8 +32,6 @@ * @package Magento_Eav * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\Eav\Model\Entity\Attribute\Backend; - abstract class AbstractBackend implements \Magento\Eav\Model\Entity\Attribute\Backend\BackendInterface { @@ -96,7 +94,7 @@ abstract class AbstractBackend * Set attribute instance * * @param \Magento\Eav\Model\Entity\Attribute\AbstractAttribute $attribute - * @return \Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend + * @return $this */ public function setAttribute($attribute) { @@ -127,7 +125,7 @@ abstract class AbstractBackend /** * Check whether the attribute is a real field in the entity table * - * @return boolean + * @return bool */ public function isStatic() { @@ -178,7 +176,7 @@ abstract class AbstractBackend * Set value id * * @param int $valueId - * @return \Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend + * @return $this */ public function setValueId($valueId) { @@ -191,7 +189,7 @@ abstract class AbstractBackend * * @param \Magento\Object $entity * @param int $valueId - * @return \Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend + * @return $this */ public function setEntityValueId($entity, $valueId) { @@ -251,7 +249,7 @@ abstract class AbstractBackend * * @param \Magento\Object $object * @throws \Magento\Eav\Exception - * @return boolean + * @return bool */ public function validate($object) { @@ -284,7 +282,7 @@ abstract class AbstractBackend * After load method * * @param \Magento\Object $object - * @return \Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend + * @return $this */ public function afterLoad($object) { @@ -295,7 +293,7 @@ abstract class AbstractBackend * Before save method * * @param \Magento\Object $object - * @return \Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend + * @return $this */ public function beforeSave($object) { @@ -311,7 +309,7 @@ abstract class AbstractBackend * After save method * * @param \Magento\Object $object - * @return \Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend + * @return $this */ public function afterSave($object) { @@ -322,7 +320,7 @@ abstract class AbstractBackend * Before delete method * * @param \Magento\Object $object - * @return \Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend + * @return $this */ public function beforeDelete($object) { @@ -333,7 +331,7 @@ abstract class AbstractBackend * After delete method * * @param \Magento\Object $object - * @return \Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend + * @return $this */ public function afterDelete($object) { diff --git a/app/code/Magento/Eav/Model/Entity/Attribute/Backend/BackendInterface.php b/app/code/Magento/Eav/Model/Entity/Attribute/Backend/BackendInterface.php index 6bc9c35c9dab41906daf71c4deaeab8eb7ea29bc..380a3fbec05ef8d7b6c4f4eced61cc056cc8226f 100644 --- a/app/code/Magento/Eav/Model/Entity/Attribute/Backend/BackendInterface.php +++ b/app/code/Magento/Eav/Model/Entity/Attribute/Backend/BackendInterface.php @@ -23,7 +23,7 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ - +namespace Magento\Eav\Model\Entity\Attribute\Backend; /** * Entity attribute backend interface @@ -32,26 +32,74 @@ * and performing pre and post actions * */ -namespace Magento\Eav\Model\Entity\Attribute\Backend; - interface BackendInterface { + /** + * @return string + */ public function getTable(); + + /** + * @return bool + */ public function isStatic(); + + /** + * @return string + */ public function getType(); + + /** + * @return string + */ public function getEntityIdField(); + + /** + * @param int $valueId + * @return $this + */ public function setValueId($valueId); + + /** + * @return int + */ public function getValueId(); + + /** + * @param \Magento\Object $object + * @return $this + */ public function afterLoad($object); + + /** + * @param \Magento\Object $object + * @return $this + */ public function beforeSave($object); + + /** + * @param \Magento\Object $object + * @return $this + */ public function afterSave($object); + + /** + * @param \Magento\Object $object + * @return $this + */ public function beforeDelete($object); + + /** + * @param \Magento\Object $object + * @return $this + */ public function afterDelete($object); /** * Get entity value id * * @param \Magento\Object $entity + * @return int */ public function getEntityValueId($entity); @@ -60,6 +108,7 @@ interface BackendInterface * * @param \Magento\Object $entity * @param int $valueId + * @return $this */ public function setEntityValueId($entity, $valueId); diff --git a/app/code/Magento/Eav/Model/Entity/Attribute/Backend/Datetime.php b/app/code/Magento/Eav/Model/Entity/Attribute/Backend/Datetime.php index d17794bc718f34edfd46b99746962c8a8ce30ed4..95a87ce0ed52c94bb6a2178dca0cb30a4eb4935f 100644 --- a/app/code/Magento/Eav/Model/Entity/Attribute/Backend/Datetime.php +++ b/app/code/Magento/Eav/Model/Entity/Attribute/Backend/Datetime.php @@ -23,9 +23,10 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ - namespace Magento\Eav\Model\Entity\Attribute\Backend; +use Magento\Eav\Exception as EavException; + class Datetime extends \Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend { /** @@ -52,8 +53,8 @@ class Datetime extends \Magento\Eav\Model\Entity\Attribute\Backend\AbstractBacke * necessary for further process, else date string * * @param \Magento\Object $object - * @throws \Magento\Eav\Exception - * @return \Magento\Eav\Model\Entity\Attribute\Backend\Datetime + * @throws EavException + * @return $this */ public function beforeSave($object) { @@ -63,7 +64,7 @@ class Datetime extends \Magento\Eav\Model\Entity\Attribute\Backend\AbstractBacke try { $value = $this->formatDate($object->getData($attributeName)); } catch (\Exception $e) { - throw new \Magento\Eav\Exception(__('Invalid date')); + throw new EavException(__('Invalid date')); } if (is_null($value)) { @@ -83,8 +84,8 @@ class Datetime extends \Magento\Eav\Model\Entity\Attribute\Backend\AbstractBacke * string format used from input fields (all date input fields need apply locale settings) * int value can be declared in code (this meen whot we use valid date) * - * @param string | int $date - * @return string + * @param string|int $date + * @return string */ public function formatDate($date) { diff --git a/app/code/Magento/Eav/Model/Entity/Attribute/Frontend/AbstractFrontend.php b/app/code/Magento/Eav/Model/Entity/Attribute/Frontend/AbstractFrontend.php index 6310dfaa8bce9dd5920328053c5c62b67077d026..25134cfde93bb15df9808047843dff73bafde904 100644 --- a/app/code/Magento/Eav/Model/Entity/Attribute/Frontend/AbstractFrontend.php +++ b/app/code/Magento/Eav/Model/Entity/Attribute/Frontend/AbstractFrontend.php @@ -59,7 +59,7 @@ abstract class AbstractFrontend * Set attribute instance * * @param \Magento\Eav\Model\Entity\Attribute\AbstractAttribute $attribute - * @return \Magento\Eav\Model\Entity\Attribute\Frontend\AbstractFrontend + * @return $this */ public function setAttribute($attribute) { @@ -105,7 +105,7 @@ abstract class AbstractFrontend /** * Retrieve attribute value * - * @param $object + * @param \Magento\Object $object * @return mixed */ public function getValue(\Magento\Object $object) @@ -138,7 +138,7 @@ abstract class AbstractFrontend /** * Checks if attribute is visible on frontend * - * @return boolean + * @return bool */ public function isVisible() { @@ -229,7 +229,7 @@ abstract class AbstractFrontend * Retrieve option by option id * * @param int $optionId - * @return mixed|boolean + * @return mixed|bool */ public function getOption($optionId) { diff --git a/app/code/Magento/Eav/Model/Entity/Attribute/Frontend/Datetime.php b/app/code/Magento/Eav/Model/Entity/Attribute/Frontend/Datetime.php index 7bbc2a985581ab8166c753fce047180e94c6ea41..3c48de0b455016358f9f62e74dad72811dda3157 100644 --- a/app/code/Magento/Eav/Model/Entity/Attribute/Frontend/Datetime.php +++ b/app/code/Magento/Eav/Model/Entity/Attribute/Frontend/Datetime.php @@ -49,7 +49,7 @@ class Datetime extends \Magento\Eav\Model\Entity\Attribute\Frontend\AbstractFron /** * Retrieve attribute value * - * @param $object + * @param \Magento\Object $object * @return mixed */ public function getValue(\Magento\Object $object) diff --git a/app/code/Magento/Eav/Model/Entity/Attribute/Group.php b/app/code/Magento/Eav/Model/Entity/Attribute/Group.php index d995aa4f1212f62278386a830e20917562f819fd..f65433c6f840533cfa5c2e265b5a1a96e018d18c 100644 --- a/app/code/Magento/Eav/Model/Entity/Attribute/Group.php +++ b/app/code/Magento/Eav/Model/Entity/Attribute/Group.php @@ -24,6 +24,8 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Eav\Model\Entity\Attribute; + /** * @category Magento * @package Magento_Eav @@ -44,12 +46,12 @@ * @method string getTabGroupCode() * @method \Magento\Eav\Model\Entity\Attribute\Group setTabGroupCode(string $value) */ -namespace Magento\Eav\Model\Entity\Attribute; - class Group extends \Magento\Core\Model\AbstractModel { /** * Resource initialization + * + * @return void */ protected function _construct() { @@ -59,7 +61,7 @@ class Group extends \Magento\Core\Model\AbstractModel /** * Checks if current attribute group exists * - * @return boolean + * @return bool */ public function itemExists() { diff --git a/app/code/Magento/Eav/Model/Entity/Attribute/Option.php b/app/code/Magento/Eav/Model/Entity/Attribute/Option.php index 702524f553751f60b9321bed12197a117fcf75ba..a13bc212944cc43a9dac984b9c842df7dd1ac702 100644 --- a/app/code/Magento/Eav/Model/Entity/Attribute/Option.php +++ b/app/code/Magento/Eav/Model/Entity/Attribute/Option.php @@ -44,6 +44,8 @@ class Option extends \Magento\Core\Model\AbstractModel { /** * Resource initialization + * + * @return void */ public function _construct() { diff --git a/app/code/Magento/Eav/Model/Entity/Attribute/Set.php b/app/code/Magento/Eav/Model/Entity/Attribute/Set.php index c1a452b0f94a6889bec91864b2c66f01068f59cf..3b19e293b122022785af860287e5d4f60c09a315 100644 --- a/app/code/Magento/Eav/Model/Entity/Attribute/Set.php +++ b/app/code/Magento/Eav/Model/Entity/Attribute/Set.php @@ -42,6 +42,8 @@ */ namespace Magento\Eav\Model\Entity\Attribute; +use Magento\Eav\Model\Entity\Type; + class Set extends \Magento\Core\Model\AbstractModel { /** @@ -109,6 +111,7 @@ class Set extends \Magento\Core\Model\AbstractModel /** * Initialize resource model * + * @return void */ protected function _construct() { @@ -119,7 +122,7 @@ class Set extends \Magento\Core\Model\AbstractModel * Init attribute set from skeleton (another attribute set) * * @param int $skeletonId - * @return \Magento\Eav\Model\Entity\Attribute\Set + * @return $this */ public function initFromSkeleton($skeletonId) { @@ -162,7 +165,7 @@ class Set extends \Magento\Core\Model\AbstractModel * Collect data for save * * @param array $data - * @return \Magento\Eav\Model\Entity\Attribute\Set + * @return $this */ public function organizeData($data) { @@ -259,10 +262,10 @@ class Set extends \Magento\Core\Model\AbstractModel /** * Add set info to attributes * - * @param string|\Magento\Eav\Model\Entity\Type $entityType + * @param string|Type $entityType * @param array $attributes * @param int $setId - * @return \Magento\Eav\Model\Entity\Attribute\Set + * @return $this */ public function addSetInfo($entityType, array $attributes, $setId = null) { diff --git a/app/code/Magento/Eav/Model/Entity/Attribute/Source/AbstractSource.php b/app/code/Magento/Eav/Model/Entity/Attribute/Source/AbstractSource.php index ec5f993ec2251ef09692ad736de6c8deb492b29b..15239bc57909753b1b80925cd36d9d13c31fb12e 100644 --- a/app/code/Magento/Eav/Model/Entity/Attribute/Source/AbstractSource.php +++ b/app/code/Magento/Eav/Model/Entity/Attribute/Source/AbstractSource.php @@ -23,7 +23,7 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ - +namespace Magento\Eav\Model\Entity\Attribute\Source; /** * Entity/Attribute/Model - attribute selection source abstract @@ -32,8 +32,6 @@ * @package Magento_Eav * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\Eav\Model\Entity\Attribute\Source; - abstract class AbstractSource implements \Magento\Eav\Model\Entity\Attribute\Source\SourceInterface, \Magento\Core\Model\Option\ArrayInterface { @@ -94,6 +92,10 @@ abstract class AbstractSource return false; } + /** + * @param $value string + * @return null|string + */ public function getOptionId($value) { foreach ($this->getAllOptions() as $option) { @@ -109,7 +111,7 @@ abstract class AbstractSource * * @param \Magento\Eav\Model\Entity\Collection\AbstractCollection $collection * @param string $dir direction - * @return \Magento\Eav\Model\Entity\Attribute\Source\AbstractSource + * @return $this */ public function addValueSortToCollection($collection, $dir = \Magento\Data\Collection::SORT_ORDER_DESC) { return $this; diff --git a/app/code/Magento/Eav/Model/Entity/Attribute/Source/Boolean.php b/app/code/Magento/Eav/Model/Entity/Attribute/Source/Boolean.php index f627788301040eb309de7e07b16dcb3eaa3077d3..3a5db9d3535ff05f766575ddfad714e26e110721 100644 --- a/app/code/Magento/Eav/Model/Entity/Attribute/Source/Boolean.php +++ b/app/code/Magento/Eav/Model/Entity/Attribute/Source/Boolean.php @@ -99,7 +99,7 @@ class Boolean extends \Magento\Eav\Model\Entity\Attribute\Source\AbstractSource /** * Get a text for option value * - * @param string|integer $value + * @param string|int $value * @return string */ public function getOptionText($value) diff --git a/app/code/Magento/Eav/Model/Entity/Attribute/Source/Table.php b/app/code/Magento/Eav/Model/Entity/Attribute/Source/Table.php index c829baf787a4f4e2b3d48cd42d8d617d16c12383..cc598aeea436cfc1c7e5942e5100e1935dfd2365 100644 --- a/app/code/Magento/Eav/Model/Entity/Attribute/Source/Table.php +++ b/app/code/Magento/Eav/Model/Entity/Attribute/Source/Table.php @@ -23,8 +23,6 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ - - namespace Magento\Eav\Model\Entity\Attribute\Source; class Table extends \Magento\Eav\Model\Entity\Attribute\Source\AbstractSource @@ -105,7 +103,7 @@ class Table extends \Magento\Eav\Model\Entity\Attribute\Source\AbstractSource * Get a text for option value * * @param string|integer $value - * @return string + * @return array|string|bool */ public function getOptionText($value) { @@ -141,7 +139,7 @@ class Table extends \Magento\Eav\Model\Entity\Attribute\Source\AbstractSource * @param \Magento\Eav\Model\Entity\Collection\AbstractCollection $collection * @param string $dir * - * @return \Magento\Eav\Model\Entity\Attribute\Source\Table + * @return $this */ public function addValueSortToCollection($collection, $dir = \Magento\DB\Select::SQL_ASC) { diff --git a/app/code/Magento/Eav/Model/Entity/Collection/AbstractCollection.php b/app/code/Magento/Eav/Model/Entity/Collection/AbstractCollection.php index b8126a5d8cd8b1956af938faa99d0524ad2e5331..69fab6c3c3e20ee5e9ceded266c75b5576bada15 100644 --- a/app/code/Magento/Eav/Model/Entity/Collection/AbstractCollection.php +++ b/app/code/Magento/Eav/Model/Entity/Collection/AbstractCollection.php @@ -23,12 +23,13 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Eav\Model\Entity\Collection; + +use Magento\DB\Select; /** * Entity/Attribute/Model - collection abstract */ -namespace Magento\Eav\Model\Entity\Collection; - abstract class AbstractCollection extends \Magento\Data\Collection\Db { /** @@ -97,7 +98,7 @@ abstract class AbstractCollection extends \Magento\Data\Collection\Db /** * Cast map for attribute order * - * @var array + * @var string[] */ protected $_castToIntMap = array( 'validate-digits' @@ -174,6 +175,8 @@ abstract class AbstractCollection extends \Magento\Data\Collection\Db /** * Initialize collection + * + * @return void */ protected function _construct() { @@ -193,7 +196,7 @@ abstract class AbstractCollection extends \Magento\Data\Collection\Db /** * Prepare static entity fields * - * @return \Magento\Eav\Model\Entity\Collection\AbstractCollection + * @return $this */ protected function _prepareStaticFields() { @@ -206,7 +209,7 @@ abstract class AbstractCollection extends \Magento\Data\Collection\Db /** * Init select * - * @return \Magento\Eav\Model\Entity\Collection\AbstractCollection + * @return $this */ protected function _initSelect() { @@ -222,7 +225,7 @@ abstract class AbstractCollection extends \Magento\Data\Collection\Db * * @param string $model * @param string $entityModel - * @return \Magento\Core\Model\Resource\Db\Collection\AbstractCollection + * @return $this */ protected function _init($model, $entityModel) { @@ -237,7 +240,7 @@ abstract class AbstractCollection extends \Magento\Data\Collection\Db * Set entity to use for attributes * * @param \Magento\Eav\Model\Entity\AbstractEntity $entity - * @return \Magento\Eav\Model\Entity\Collection\AbstractCollection + * @return $this * @throws \Magento\Core\Exception */ public function setEntity($entity) @@ -280,7 +283,7 @@ abstract class AbstractCollection extends \Magento\Data\Collection\Db * Set template object for the collection * * @param \Magento\Object $object - * @return \Magento\Eav\Model\Entity\Collection\AbstractCollection + * @return $this */ public function setObject($object = null) { @@ -296,7 +299,7 @@ abstract class AbstractCollection extends \Magento\Data\Collection\Db * Add an object to the collection * * @param \Magento\Object $object - * @return \Magento\Eav\Model\Entity\Collection\AbstractCollection + * @return $this * @throws \Magento\Core\Exception */ public function addItem(\Magento\Object $object) @@ -335,7 +338,7 @@ abstract class AbstractCollection extends \Magento\Data\Collection\Db * @param \Magento\Eav\Model\Entity\Attribute\AttributeInterface|integer|string|array $attribute * @param null|string|array $condition * @param string $joinType - * @return \Magento\Eav\Model\Entity\Collection\AbstractCollection + * @return $this */ public function addAttributeToFilter($attribute, $condition = null, $joinType = 'inner') { @@ -379,7 +382,7 @@ abstract class AbstractCollection extends \Magento\Data\Collection\Db * * @param mixed $attribute * @param mixed $condition - * @return \Magento\Eav\Model\Entity\Collection\AbstractCollection|\Magento\Data\Collection\Db + * @return $this|\Magento\Data\Collection\Db */ public function addFieldToFilter($attribute, $condition = null) { @@ -391,7 +394,7 @@ abstract class AbstractCollection extends \Magento\Data\Collection\Db * * @param string $attribute * @param string $dir - * @return \Magento\Eav\Model\Entity\Collection\AbstractCollection + * @return $this */ public function addAttributeToSort($attribute, $dir = self::SORT_ORDER_ASC) { @@ -457,9 +460,9 @@ abstract class AbstractCollection extends \Magento\Data\Collection\Db * * If $attribute == '*' select all attributes * - * @param array|string|integer|\Magento\Core\Model\Config\Element $attribute + * @param array|string|integer|\Magento\Core\Model\Config\Element $attribute * @param bool|string $joinType flag for joining attribute - * @return \Magento\Eav\Model\Entity\Collection\AbstractCollection + * @return $this * @throws \Magento\Core\Exception */ public function addAttributeToSelect($attribute, $joinType = false) @@ -514,7 +517,7 @@ abstract class AbstractCollection extends \Magento\Data\Collection\Db * Add field to static * * @param string $field - * @return \Magento\Eav\Model\Entity\Collection\AbstractCollection + * @return $this */ public function addStaticField($field) { @@ -535,7 +538,7 @@ abstract class AbstractCollection extends \Magento\Data\Collection\Db * @param string $alias * @param string $expression * @param string $attribute - * @return \Magento\Eav\Model\Entity\Collection\AbstractCollection + * @return $this * @throws \Magento\Core\Exception */ public function addExpressionAttributeToSelect($alias, $expression, $attribute) @@ -643,7 +646,7 @@ abstract class AbstractCollection extends \Magento\Data\Collection\Db * @param string $filter primary key for the joined entity (entity_id default) * @param string $joinType inner|left * @param null $storeId - * @return \Magento\Eav\Model\Entity\Collection\AbstractCollection + * @return $this * @throws \Magento\Core\Exception */ public function joinAttribute($alias, $attribute, $bind, $filter = null, $joinType = 'inner', $storeId = null) @@ -733,7 +736,7 @@ abstract class AbstractCollection extends \Magento\Data\Collection\Db * @param string $bind 'PK(country_id)=FK(shipping_country_id)' * @param string|array $cond "{{table}}.language_code='en'" OR array('language_code'=>'en') * @param string $joinType 'left' - * @return \Magento\Eav\Model\Entity\Collection\AbstractCollection + * @return $this * @throws \Magento\Core\Exception */ public function joinField($alias, $table, $field, $bind, $cond = null, $joinType = 'inner') @@ -797,7 +800,7 @@ abstract class AbstractCollection extends \Magento\Data\Collection\Db * @param string|array $fields * @param null|array $cond * @param string $joinType - * @return \Magento\Eav\Model\Entity\Collection\AbstractCollection + * @return $this * @throws \Magento\Core\Exception */ public function joinTable($table, $bind, $fields = null, $cond = null, $joinType = 'inner') @@ -867,7 +870,7 @@ abstract class AbstractCollection extends \Magento\Data\Collection\Db * Remove an attribute from selection list * * @param string $attribute - * @return \Magento\Eav\Model\Entity\Collection\AbstractCollection + * @return $this */ public function removeAttributeToSelect($attribute = null) { @@ -884,7 +887,7 @@ abstract class AbstractCollection extends \Magento\Data\Collection\Db * * @param integer $pageNum * @param integer $pageSize - * @return \Magento\Eav\Model\Entity\Collection\AbstractCollection + * @return $this */ public function setPage($pageNum, $pageSize) { @@ -897,7 +900,7 @@ abstract class AbstractCollection extends \Magento\Data\Collection\Db * * @param bool $printQuery * @param bool $logQuery - * @return \Magento\Eav\Model\Entity\Collection\AbstractCollection + * @return $this */ public function load($printQuery = false, $logQuery = false) { @@ -941,7 +944,7 @@ abstract class AbstractCollection extends \Magento\Data\Collection\Db * * @param null $limit * @param null $offset - * @return \Magento\Eav\Model\Entity\Collection\AbstractCollection + * @return Select */ protected function _getAllIdsSelect($limit = null, $offset = null) { @@ -971,7 +974,7 @@ abstract class AbstractCollection extends \Magento\Data\Collection\Db /** * Retrieve all ids sql * - * @return array + * @return Select */ public function getAllIdsSql() { @@ -990,6 +993,8 @@ abstract class AbstractCollection extends \Magento\Data\Collection\Db * Save all the entities in the collection * * @todo make batch save directly from collection + * + * @return $this */ public function save() { @@ -1004,6 +1009,8 @@ abstract class AbstractCollection extends \Magento\Data\Collection\Db * Delete all the entities in the collection * * @todo make batch delete directly from collection + * + * @return $this */ public function delete() { @@ -1020,7 +1027,7 @@ abstract class AbstractCollection extends \Magento\Data\Collection\Db * If the imported items already exist, update the data for existing objects * * @param array $arr - * @return \Magento\Eav\Model\Entity\Collection\AbstractCollection + * @return $this */ public function importFromArray($arr) { @@ -1068,7 +1075,7 @@ abstract class AbstractCollection extends \Magento\Data\Collection\Db /** * Set row id field name * @param string $fieldName - * @return \Magento\Eav\Model\Entity\Collection\AbstractCollection + * @return $this */ public function setRowIdFieldName($fieldName) { @@ -1081,7 +1088,7 @@ abstract class AbstractCollection extends \Magento\Data\Collection\Db * * @param bool $printQuery * @param bool $logQuery - * @return \Magento\Eav\Model\Entity\Collection\AbstractCollection + * @return $this * @throws \Exception */ public function _loadEntities($printQuery = false, $logQuery = false) @@ -1122,10 +1129,9 @@ abstract class AbstractCollection extends \Magento\Data\Collection\Db /** * Load attributes into loaded entities * - * * @param bool $printQuery * @param bool $logQuery - * @return \Magento\Eav\Model\Entity\Collection\AbstractCollection + * @return $this * @throws \Exception */ public function _loadAttributes($printQuery = false, $logQuery = false) @@ -1184,8 +1190,8 @@ abstract class AbstractCollection extends \Magento\Data\Collection\Db * Retrieve attributes load select * * @param string $table - * @param array $attributeIds - * @return \Magento\Eav\Model\Entity\Collection\AbstractCollection + * @param string[] $attributeIds + * @return Select */ protected function _getLoadAttributesSelect($table, $attributeIds = array()) { @@ -1205,7 +1211,7 @@ abstract class AbstractCollection extends \Magento\Data\Collection\Db * @param \Magento\DB\Select $select * @param string $table * @param string $type - * @return \Magento\DB\Select + * @return Select */ protected function _addLoadAttributesSelectValues($select, $table, $type) { @@ -1219,7 +1225,7 @@ abstract class AbstractCollection extends \Magento\Data\Collection\Db * $valueInfo is _getLoadAttributesSelect fetch result row * * @param array $valueInfo - * @return \Magento\Eav\Model\Entity\Collection\AbstractCollection + * @return $this * @throws \Magento\Core\Exception */ protected function _setItemAttributeValue($valueInfo) @@ -1302,8 +1308,9 @@ abstract class AbstractCollection extends \Magento\Data\Collection\Db * * @param string $attributeCode * @param string $joinType inner|left - * @return \Magento\Eav\Model\Entity\Collection\AbstractCollection + * @return $this * @throws \Magento\Core\Exception + * @throws \Magento\Eav\Exception */ protected function _addAttributeJoin($attributeCode, $joinType = 'inner') { @@ -1389,7 +1396,7 @@ abstract class AbstractCollection extends \Magento\Data\Collection\Db * @param array $condition * @param string $fieldCode * @param string $fieldAlias - * @return \Magento\Eav\Model\Entity\Collection\AbstractCollection + * @return $this */ protected function _joinAttributeToSelect($method, $attribute, $tableAlias, $condition, $fieldCode, $fieldAlias) { @@ -1451,7 +1458,7 @@ abstract class AbstractCollection extends \Magento\Data\Collection\Db * * @param string|array $attribute * @param string $dir - * @return \Magento\Eav\Model\Entity\Collection\AbstractCollection + * @return $this */ public function setOrder($attribute, $dir = self::SORT_ORDER_ASC) { @@ -1482,7 +1489,7 @@ abstract class AbstractCollection extends \Magento\Data\Collection\Db /** * Treat "order by" items as attributes to sort * - * @return \Magento\Eav\Model\Entity\Collection\AbstractCollection + * @return $this */ protected function _renderOrders() { @@ -1498,7 +1505,7 @@ abstract class AbstractCollection extends \Magento\Data\Collection\Db /** * After load method * - * @return \Magento\Eav\Model\Entity\Collection\AbstractCollection + * @return $this */ protected function _afterLoad() { @@ -1508,7 +1515,7 @@ abstract class AbstractCollection extends \Magento\Data\Collection\Db /** * Reset collection * - * @return \Magento\Eav\Model\Entity\Collection\AbstractCollection + * @return $this */ protected function _reset() { @@ -1527,7 +1534,7 @@ abstract class AbstractCollection extends \Magento\Data\Collection\Db /** * Returns already loaded element ids * - * return array + * @return array */ public function getLoadedIds() { diff --git a/app/code/Magento/Eav/Model/Entity/Increment/AbstractIncrement.php b/app/code/Magento/Eav/Model/Entity/Increment/AbstractIncrement.php index 7099155513b05038c2f4e381b4f10ab3f160aa86..87df302fc8a1dedaac8de24ba524b46e6e82a858 100644 --- a/app/code/Magento/Eav/Model/Entity/Increment/AbstractIncrement.php +++ b/app/code/Magento/Eav/Model/Entity/Increment/AbstractIncrement.php @@ -39,6 +39,11 @@ namespace Magento\Eav\Model\Entity\Increment; abstract class AbstractIncrement extends \Magento\Object implements \Magento\Eav\Model\Entity\Increment\IncrementInterface { + /** + * Get pad length + * + * @return int + */ public function getPadLength() { $padLength = $this->getData('pad_length'); @@ -48,6 +53,11 @@ abstract class AbstractIncrement extends \Magento\Object return $padLength; } + /** + * Get pad char + * + * @return string + */ public function getPadChar() { $padChar = $this->getData('pad_char'); @@ -57,6 +67,12 @@ abstract class AbstractIncrement extends \Magento\Object return $padChar; } + /** + * Pad format + * + * @param mixed $id + * @return string + */ public function format($id) { $result = $this->getPrefix(); @@ -64,6 +80,12 @@ abstract class AbstractIncrement extends \Magento\Object return $result; } + /** + * Frontend format + * + * @param mixed $id + * @return mixed + */ public function frontendFormat($id) { return $id; diff --git a/app/code/Magento/Eav/Model/Entity/Increment/Alphanum.php b/app/code/Magento/Eav/Model/Entity/Increment/Alphanum.php index 663204326c48101e619230aef78aa0fa875e2795..f9dfe1052a8c1eb66702a01002fad13392e66d58 100644 --- a/app/code/Magento/Eav/Model/Entity/Increment/Alphanum.php +++ b/app/code/Magento/Eav/Model/Entity/Increment/Alphanum.php @@ -36,13 +36,26 @@ */ namespace Magento\Eav\Model\Entity\Increment; +use Magento\Eav\Exception; + class Alphanum extends \Magento\Eav\Model\Entity\Increment\AbstractIncrement { + /** + * Get allowed chars + * + * @return string + */ public function getAllowedChars() { return '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'; } + /** + * Get next id + * + * @return string + * @throws Exception + */ public function getNextId() { $lastId = $this->getLastId(); diff --git a/app/code/Magento/Eav/Model/Entity/Increment/Numeric.php b/app/code/Magento/Eav/Model/Entity/Increment/Numeric.php index fc7b792dfb2919abb3331b2d0d6d38c2df8981b1..ef3d5ae58b202b0867f9ee98e00b550e8fa904a2 100644 --- a/app/code/Magento/Eav/Model/Entity/Increment/Numeric.php +++ b/app/code/Magento/Eav/Model/Entity/Increment/Numeric.php @@ -38,6 +38,11 @@ namespace Magento\Eav\Model\Entity\Increment; class Numeric extends \Magento\Eav\Model\Entity\Increment\AbstractIncrement { + /** + * Get next id + * + * @return string + */ public function getNextId() { $last = $this->getLastId(); diff --git a/app/code/Magento/Eav/Model/Entity/Setup.php b/app/code/Magento/Eav/Model/Entity/Setup.php index d9dff25f0579ceb8eb086159f2e2aa2c4b563385..b4ee2645db2a1a85a9872e37fdfadc6bb565abe4 100644 --- a/app/code/Magento/Eav/Model/Entity/Setup.php +++ b/app/code/Magento/Eav/Model/Entity/Setup.php @@ -23,7 +23,7 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ - +namespace Magento\Eav\Model\Entity; /** * EAV Entity Setup Model @@ -32,8 +32,6 @@ * @package Magento_Eav * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\Eav\Model\Entity; - class Setup extends \Magento\Core\Model\Resource\Setup { /** @@ -120,7 +118,7 @@ class Setup extends \Magento\Core\Model\Resource\Setup /** * Clean cache * - * @return \Magento\Eav\Model\Entity\Setup + * @return $this */ public function cleanCache() { @@ -131,7 +129,7 @@ class Setup extends \Magento\Core\Model\Resource\Setup /** * Install Default Group Ids * - * @return \Magento\Eav\Model\Entity\Setup + * @return $this */ public function installDefaultGroupIds() { @@ -165,7 +163,7 @@ class Setup extends \Magento\Core\Model\Resource\Setup * * @param string $code * @param array $params - * @return \Magento\Eav\Model\Entity\Setup + * @return $this */ public function addEntityType($code, array $params) { @@ -208,7 +206,7 @@ class Setup extends \Magento\Core\Model\Resource\Setup * @param string $code * @param string $field * @param string $value - * @return \Magento\Eav\Model\Entity\Setup + * @return $this */ public function updateEntityType($code, $field, $value = null) { @@ -235,7 +233,7 @@ class Setup extends \Magento\Core\Model\Resource\Setup /** * Retrieve Entity Type Id By Id or Code * - * @param mixed $entityTypeId + * @param int|string $entityTypeId * @return int */ public function getEntityTypeId($entityTypeId) @@ -253,8 +251,8 @@ class Setup extends \Magento\Core\Model\Resource\Setup /** * Remove entity type by Id or Code * - * @param mixed $id - * @return \Magento\Eav\Model\Entity\Setup + * @param int|string $id + * @return $this */ public function removeEntityType($id) { @@ -272,7 +270,7 @@ class Setup extends \Magento\Core\Model\Resource\Setup /** * Retrieve Attribute Set Sort order * - * @param mixed $entityTypeId + * @param int|string $entityTypeId * @param int $sortOrder * @return int */ @@ -293,10 +291,10 @@ class Setup extends \Magento\Core\Model\Resource\Setup /** * Add Attribute Set * - * @param mixed $entityTypeId + * @param int|string $entityTypeId * @param string $name * @param int $sortOrder - * @return \Magento\Eav\Model\Entity\Setup + * @return $this */ public function addAttributeSet($entityTypeId, $name, $sortOrder = null) { @@ -321,11 +319,11 @@ class Setup extends \Magento\Core\Model\Resource\Setup /** * Update attribute set data * - * @param mixed $entityTypeId + * @param int|string $entityTypeId * @param int $id * @param string $field * @param mixed $value - * @return \Magento\Eav\Model\Entity\Setup + * @return $this */ public function updateAttributeSet($entityTypeId, $id, $field, $value = null) { @@ -340,8 +338,8 @@ class Setup extends \Magento\Core\Model\Resource\Setup /** * Retrieve Attribute set data by id or name * - * @param mixed $entityTypeId - * @param mixed $id + * @param int|string $entityTypeId + * @param int|string $id * @param string $field * @return mixed */ @@ -357,10 +355,10 @@ class Setup extends \Magento\Core\Model\Resource\Setup /** * Retrieve Attribute Set Id By Id or Name * - * @throws \Magento\Eav\Exception - * @param mixed $entityTypeId - * @param mixed $setId + * @param int|string $entityTypeId + * @param int|string $setId * @return int + * @throws \Magento\Eav\Exception */ public function getAttributeSetId($entityTypeId, $setId) { @@ -377,9 +375,9 @@ class Setup extends \Magento\Core\Model\Resource\Setup /** * Remove Attribute Set * - * @param mixed $entityTypeId - * @param mixed $id - * @return \Magento\Eav\Model\Entity\Setup + * @param int|string $entityTypeId + * @param int|string $id + * @return $this */ public function removeAttributeSet($entityTypeId, $id) { @@ -390,8 +388,9 @@ class Setup extends \Magento\Core\Model\Resource\Setup /** * Set Default Attribute Set to Entity Type * - * @param mixed $entityType - * @return \Magento\Eav\Model\Entity\Setup + * @param int|string $entityType + * @param string $attributeSet + * @return $this */ public function setDefaultSetToEntityType($entityType, $attributeSet = 'Default') { @@ -404,6 +403,7 @@ class Setup extends \Magento\Core\Model\Resource\Setup /** * Get identifiers of all attribute sets * + * @param int|string|null $entityTypeId * @return array */ public function getAllAttributeSetIds($entityTypeId = null) @@ -446,8 +446,8 @@ class Setup extends \Magento\Core\Model\Resource\Setup /** * Retrieve Attribute Group Sort order * - * @param mixed $entityTypeId - * @param mixed $setId + * @param int|string $entityTypeId + * @param int|string $setId * @param int $sortOrder * @return int */ @@ -468,11 +468,11 @@ class Setup extends \Magento\Core\Model\Resource\Setup /** * Add Attribute Group * - * @param mixed $entityTypeId - * @param mixed $setId + * @param int|string $entityTypeId + * @param int|string $setId * @param string $name * @param int $sortOrder - * @return \Magento\Eav\Model\Entity\Setup + * @return $this */ public function addAttributeGroup($entityTypeId, $setId, $name, $sortOrder = null) { @@ -506,12 +506,12 @@ class Setup extends \Magento\Core\Model\Resource\Setup /** * Update Attribute Group Data * - * @param mixed $entityTypeId - * @param mixed $setId - * @param mixed $id + * @param int|string $entityTypeId + * @param int|string $setId + * @param int|string $id * @param string $field * @param mixed $value - * @return \Magento\Eav\Model\Entity\Setup + * @return $this */ public function updateAttributeGroup($entityTypeId, $setId, $id, $field, $value = null) { @@ -527,9 +527,9 @@ class Setup extends \Magento\Core\Model\Resource\Setup /** * Retrieve Attribute Group Data * - * @param mixed $entityTypeId - * @param mixed $setId - * @param mixed $id + * @param int|string $entityTypeId + * @param int|string $setId + * @param int|string $id * @param string $field * @return mixed */ @@ -556,10 +556,10 @@ class Setup extends \Magento\Core\Model\Resource\Setup /** * Retrieve Attribute Group Id by Id or Name * - * @param mixed $entityTypeId - * @param mixed $setId - * @param mixed $groupId - * @return \Magento\Eav\Model\Entity\Setup + * @param int|string $entityTypeId + * @param int|string $setId + * @param int|string $groupId + * @return $this */ public function getAttributeGroupId($entityTypeId, $setId, $groupId) { @@ -580,10 +580,10 @@ class Setup extends \Magento\Core\Model\Resource\Setup /** * Remove Attribute Group By Id or Name * - * @param mixed $entityTypeId - * @param mixed $setId - * @param mixed $id - * @return \Magento\Eav\Model\Entity\Setup + * @param int|string $entityTypeId + * @param int|string $setId + * @param int|string $id + * @return $this */ public function removeAttributeGroup($entityTypeId, $setId, $id) { @@ -690,8 +690,8 @@ class Setup extends \Magento\Core\Model\Resource\Setup * Validate attribute data before insert into table * * @param array $data - * @throws \Magento\Eav\Exception * @return true + * @throws \Magento\Eav\Exception */ protected function _validateAttributeData($data) { @@ -716,7 +716,7 @@ class Setup extends \Magento\Core\Model\Resource\Setup * @param string|integer $entityTypeId * @param string $code * @param array $attr - * @return \Magento\Eav\Model\Entity\Setup + * @return $this */ public function addAttribute($entityTypeId, $code, array $attr) { @@ -770,6 +770,8 @@ class Setup extends \Magento\Core\Model\Resource\Setup * Add Attribure Option * * @param array $option + * @return void + * @throws \Magento\Core\Exception */ public function addAttributeOption($option) { @@ -839,12 +841,12 @@ class Setup extends \Magento\Core\Model\Resource\Setup /** * Update Attribute data and Attribute additional data * - * @param mixed $entityTypeId - * @param mixed $id + * @param int|string $entityTypeId + * @param int|string $id * @param string $field * @param mixed $value * @param int $sortOrder - * @return \Magento\Eav\Model\Entity\Setup + * @return $this */ public function updateAttribute($entityTypeId, $id, $field, $value = null, $sortOrder = null) { @@ -856,12 +858,12 @@ class Setup extends \Magento\Core\Model\Resource\Setup /** * Update Attribute data * - * @param mixed $entityTypeId - * @param mixed $id + * @param int|string $entityTypeId + * @param int|string $id * @param string $field * @param mixed $value * @param int $sortOrder - * @return \Magento\Eav\Model\Entity\Setup + * @return $this */ protected function _updateAttribute($entityTypeId, $id, $field, $value = null, $sortOrder = null) { @@ -902,11 +904,11 @@ class Setup extends \Magento\Core\Model\Resource\Setup /** * Update Attribute Additional data * - * @param mixed $entityTypeId - * @param mixed $id + * @param int|string $entityTypeId + * @param int|string $id * @param string $field * @param mixed $value - * @return \Magento\Eav\Model\Entity\Setup + * @return $this */ protected function _updateAttributeAdditionalData($entityTypeId, $id, $field, $value = null) { @@ -945,8 +947,8 @@ class Setup extends \Magento\Core\Model\Resource\Setup /** * Retrieve Attribute Data By Id or Code * - * @param mixed $entityTypeId - * @param mixed $id + * @param int|string $entityTypeId + * @param int|string $id * @param string $field * @return mixed */ @@ -994,8 +996,8 @@ class Setup extends \Magento\Core\Model\Resource\Setup /** * Retrieve Attribute Id Data By Id or Code * - * @param mixed $entityTypeId - * @param mixed $id + * @param int|string $entityTypeId + * @param int|string $id * @return int */ public function getAttributeId($entityTypeId, $id) @@ -1052,9 +1054,9 @@ class Setup extends \Magento\Core\Model\Resource\Setup /** * Remove Attribute * - * @param mixed $entityTypeId - * @param mixed $code - * @return \Magento\Eav\Model\Entity\Setup + * @param int|string $entityTypeId + * @param int|string $code + * @return $this */ public function removeAttribute($entityTypeId, $code) { @@ -1072,11 +1074,11 @@ class Setup extends \Magento\Core\Model\Resource\Setup /** * Retrieve Attribute Sort Order * - * @param mixed $entityTypeId - * @param mixed $setId - * @param mixed $groupId + * @param int|string $entityTypeId + * @param int|string $setId + * @param int|string $groupId * @param int $sortOrder - * @return \Magento\Eav\Model\Entity\Setup + * @return $this */ public function getAttributeSortOrder($entityTypeId, $setId, $groupId, $sortOrder = null) { @@ -1095,12 +1097,12 @@ class Setup extends \Magento\Core\Model\Resource\Setup /** * Add Attribute to All Groups on Attribute Set * - * @param mixed $entityTypeId - * @param mixed $setId - * @param mixed $groupId - * @param mixed $attributeId + * @param int|string $entityTypeId + * @param int|string $setId + * @param int|string $groupId + * @param int|string $attributeId * @param int $sortOrder - * @return \Magento\Eav\Model\Entity\Setup + * @return $this */ public function addAttributeToSet($entityTypeId, $setId, $groupId, $attributeId, $sortOrder=null) { @@ -1149,7 +1151,7 @@ class Setup extends \Magento\Core\Model\Resource\Setup * @param int|string $groupId * @param int|string $attributeId * @param int $sortOrder - * @return \Magento\Eav\Model\Entity\Setup + * @return $this */ public function addAttributeToGroup($entityType, $setId, $groupId, $attributeId, $sortOrder = null) { @@ -1211,7 +1213,7 @@ class Setup extends \Magento\Core\Model\Resource\Setup * Install entities * * @param array $entities - * @return \Magento\Eav\Model\Entity\Setup + * @return $this */ public function installEntities($entities = null) { @@ -1281,7 +1283,7 @@ class Setup extends \Magento\Core\Model\Resource\Setup * Insert attribute and filter data * * @param array $data - * @return \Magento\Eav\Model\Entity\Setup + * @return $this */ protected function _insertAttribute(array $data) { @@ -1311,9 +1313,9 @@ class Setup extends \Magento\Core\Model\Resource\Setup /** * Insert attribute additional data * - * @param int $entityTypeId + * @param int|string $entityTypeId * @param array $data - * @return \Magento\Eav\Model\Entity\Setup + * @return $this */ protected function _insertAttributeAdditionalData($entityTypeId, array $data) { diff --git a/app/code/Magento/Eav/Model/Entity/Store.php b/app/code/Magento/Eav/Model/Entity/Store.php index 50ae0dd14051b402dd0b06e038f640cfc259bfd3..f13fce5007aacf230f4442bc39267cbbc6ecd02e 100644 --- a/app/code/Magento/Eav/Model/Entity/Store.php +++ b/app/code/Magento/Eav/Model/Entity/Store.php @@ -47,6 +47,8 @@ class Store extends \Magento\Core\Model\AbstractModel { /** * Resource initialization + * + * @return void */ protected function _construct() { @@ -58,7 +60,7 @@ class Store extends \Magento\Core\Model\AbstractModel * * @param int $entityTypeId * @param int $storeId - * @return \Magento\Eav\Model\Entity\Store + * @return $this */ public function loadByEntityStore($entityTypeId, $storeId) { diff --git a/app/code/Magento/Eav/Model/Entity/Type.php b/app/code/Magento/Eav/Model/Entity/Type.php index 0703a304e2f3dfc690eb2ffe9bda583590c8e868..b0d4dc0fd29d5a3c4c04a7be431f980f222d855f 100644 --- a/app/code/Magento/Eav/Model/Entity/Type.php +++ b/app/code/Magento/Eav/Model/Entity/Type.php @@ -24,6 +24,7 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Eav\Model\Entity; /** * Entity type model @@ -58,8 +59,6 @@ * @package Magento_Eav * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\Eav\Model\Entity; - class Type extends \Magento\Core\Model\AbstractModel { /** @@ -134,6 +133,8 @@ class Type extends \Magento\Core\Model\AbstractModel /** * Resource initialization + * + * @return void */ protected function _construct() { @@ -144,7 +145,7 @@ class Type extends \Magento\Core\Model\AbstractModel * Load type by code * * @param string $code - * @return \Magento\Eav\Model\Entity\Type + * @return $this */ public function loadByCode($code) { @@ -287,7 +288,7 @@ class Type extends \Magento\Core\Model\AbstractModel /** * Retrieve entity table prefix name * - * @return string + * @return null|string */ public function getValueTablePrefix() { diff --git a/app/code/Magento/Eav/Model/Form.php b/app/code/Magento/Eav/Model/Form.php index 15a56124867aff0852b5dc52697048e8f4c593dd..8fac6e853c92f613b75d0faec58d3d5f1d84cd3b 100644 --- a/app/code/Magento/Eav/Model/Form.php +++ b/app/code/Magento/Eav/Model/Form.php @@ -23,6 +23,9 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Eav\Model; + +use Magento\App\RequestInterface; /** * EAV Entity Form Model @@ -31,8 +34,6 @@ * @package Magento_Eav * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\Eav\Model; - abstract class Form { /** @@ -108,7 +109,7 @@ abstract class Form /** * Is AJAX request flag * - * @var boolean + * @var bool */ protected $_isAjax = false; @@ -150,7 +151,7 @@ abstract class Form protected $_universalFactory; /** - * @var \Magento\App\RequestInterface + * @var RequestInterface */ protected $_httpRequest; @@ -165,7 +166,7 @@ abstract class Form * @param \Magento\Module\Dir\Reader $modulesReader * @param \Magento\Eav\Model\AttributeDataFactory $attrDataFactory * @param \Magento\Validator\UniversalFactory $universalFactory - * @param \Magento\App\RequestInterface $httpRequest + * @param RequestInterface $httpRequest * @param \Magento\Validator\ConfigFactory $validatorConfigFactory * * @throws \Magento\Core\Exception @@ -176,7 +177,7 @@ abstract class Form \Magento\Module\Dir\Reader $modulesReader, \Magento\Eav\Model\AttributeDataFactory $attrDataFactory, \Magento\Validator\UniversalFactory $universalFactory, - \Magento\App\RequestInterface $httpRequest, + RequestInterface $httpRequest, \Magento\Validator\ConfigFactory $validatorConfigFactory ) { if (empty($this->_moduleName)) { @@ -209,7 +210,7 @@ abstract class Form /** * Get EAV Entity Form Attribute Collection with applied filters * - * @return \Magento\Eav\Model\Resource\Form\Attribute\Collection|mixed + * @return \Magento\Eav\Model\Resource\Form\Attribute\Collection */ protected function _getFilteredFormAttributeCollection() { @@ -224,7 +225,7 @@ abstract class Form * Set current store * * @param \Magento\Core\Model\Store|string|int $store - * @return \Magento\Eav\Model\Form + * @return $this */ public function setStore($store) { @@ -236,7 +237,7 @@ abstract class Form * Set entity instance * * @param \Magento\Core\Model\AbstractModel $entity - * @return \Magento\Eav\Model\Form + * @return $this */ public function setEntity(\Magento\Core\Model\AbstractModel $entity) { @@ -251,7 +252,7 @@ abstract class Form * Set entity type instance * * @param \Magento\Eav\Model\Entity\Type|string|int $entityType - * @return \Magento\Eav\Model\Form + * @return $this */ public function setEntityType($entityType) { @@ -263,7 +264,7 @@ abstract class Form * Set form code * * @param string $formCode - * @return \Magento\Eav\Model\Form + * @return $this */ public function setFormCode($formCode) { @@ -427,7 +428,7 @@ abstract class Form * Prepare request with data and returns it * * @param array $data - * @return \Magento\App\RequestInterface + * @return RequestInterface */ public function prepareRequest(array $data) { @@ -442,12 +443,12 @@ abstract class Form /** * Extract data from request and return associative data array * - * @param \Magento\App\RequestInterface $request + * @param RequestInterface $request * @param string $scope the request scope - * @param boolean $scopeOnly search value only in scope or search value in global too + * @param bool $scopeOnly search value only in scope or search value in global too * @return array */ - public function extractData(\Magento\App\RequestInterface $request, $scope = null, $scopeOnly = true) + public function extractData(RequestInterface $request, $scope = null, $scopeOnly = true) { $data = array(); /** @var $attribute \Magento\Eav\Model\Attribute */ @@ -491,7 +492,7 @@ abstract class Form * Validate data array and return true or array of errors * * @param array $data - * @return boolean|array + * @return bool|array */ public function validateData(array $data) { @@ -510,7 +511,7 @@ abstract class Form * Compact data array to current entity * * @param array $data - * @return \Magento\Eav\Model\Form + * @return $this */ public function compactData(array $data) { @@ -531,7 +532,7 @@ abstract class Form * Restore data array from SESSION to current entity * * @param array $data - * @return \Magento\Eav\Model\Form + * @return $this */ public function restoreData(array $data) { @@ -568,7 +569,7 @@ abstract class Form /** * Restore entity original data * - * @return \Magento\Eav\Model\Form + * @return $this */ public function resetEntityData() { @@ -583,8 +584,8 @@ abstract class Form /** * Set is AJAX Request flag * - * @param boolean $flag - * @return \Magento\Eav\Model\Form + * @param bool $flag + * @return $this */ public function setIsAjaxRequest($flag = true) { @@ -595,7 +596,7 @@ abstract class Form /** * Return is AJAX Request * - * @return boolean + * @return bool */ public function getIsAjaxRequest() { @@ -605,7 +606,7 @@ abstract class Form /** * Set default attribute values for new entity * - * @return \Magento\Eav\Model\Form + * @return $this */ public function initDefaultValues() { @@ -625,7 +626,7 @@ abstract class Form * Combined getter/setter whether to omit invisible attributes during rendering/validation * * @param mixed $setValue - * @return bool|\Magento\Eav\Model\Form + * @return bool|$this */ public function ignoreInvisible($setValue = null) { diff --git a/app/code/Magento/Eav/Model/Form/Element.php b/app/code/Magento/Eav/Model/Form/Element.php index fe7a52458c48f855e8985207b8e5f266a8090838..001b3a4916306fe6a81d9d880d8d0aac396269e0 100644 --- a/app/code/Magento/Eav/Model/Form/Element.php +++ b/app/code/Magento/Eav/Model/Form/Element.php @@ -44,6 +44,8 @@ */ namespace Magento\Eav\Model\Form; +use Magento\Core\Exception; + class Element extends \Magento\Core\Model\AbstractModel { /** @@ -81,6 +83,7 @@ class Element extends \Magento\Core\Model\AbstractModel /** * Initialize resource model * + * @return void */ protected function _construct() { @@ -110,16 +113,16 @@ class Element extends \Magento\Core\Model\AbstractModel /** * Validate data before save data * - * @throws \Magento\Core\Exception - * @return \Magento\Eav\Model\Form\Element + * @throws Exception + * @return $this */ protected function _beforeSave() { if (!$this->getTypeId()) { - throw new \Magento\Core\Exception(__('Invalid form type.')); + throw new Exception(__('Invalid form type.')); } if (!$this->getAttributeId()) { - throw new \Magento\Core\Exception(__('Invalid EAV attribute')); + throw new Exception(__('Invalid EAV attribute')); } return parent::_beforeSave(); diff --git a/app/code/Magento/Eav/Model/Form/Fieldset.php b/app/code/Magento/Eav/Model/Form/Fieldset.php index 6961882752874eeec1a1ea2ad8c9b685e97f85f5..6fdad573e822bfebaab15644bcd0398edfbb6917 100644 --- a/app/code/Magento/Eav/Model/Form/Fieldset.php +++ b/app/code/Magento/Eav/Model/Form/Fieldset.php @@ -71,6 +71,7 @@ class Fieldset extends \Magento\Core\Model\AbstractModel /** * Initialize resource model * + * @return void */ protected function _construct() { diff --git a/app/code/Magento/Eav/Model/Form/Type.php b/app/code/Magento/Eav/Model/Form/Type.php index 86fe7c20efba954439231564405dc818e17764f3..6cac42a4a9e49095b3268057cdaf304d5a96fc2d 100644 --- a/app/code/Magento/Eav/Model/Form/Type.php +++ b/app/code/Magento/Eav/Model/Form/Type.php @@ -24,6 +24,7 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Eav\Model\Form; /** * Eav Form Type Model @@ -44,8 +45,6 @@ * @package Magento_Eav * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\Eav\Model\Form; - class Type extends \Magento\Core\Model\AbstractModel { /** @@ -90,6 +89,8 @@ class Type extends \Magento\Core\Model\AbstractModel /** * Initialize resource model + * + * @return void */ protected function _construct() { @@ -133,7 +134,7 @@ class Type extends \Magento\Core\Model\AbstractModel * Set assigned Eav Entity types * * @param array $entityTypes - * @return \Magento\Eav\Model\Form\Type + * @return $this */ public function setEntityTypes(array $entityTypes) { @@ -145,7 +146,7 @@ class Type extends \Magento\Core\Model\AbstractModel * Assign Entity Type to Form Type * * @param int $entityTypeId - * @return \Magento\Eav\Model\Form\Type + * @return $this */ public function addEntityType($entityTypeId) { @@ -161,7 +162,7 @@ class Type extends \Magento\Core\Model\AbstractModel * Copy Form Type properties from skeleton form type * * @param \Magento\Eav\Model\Form\Type $skeleton - * @return \Magento\Eav\Model\Form\Type + * @return $this */ public function createFromSkeleton(\Magento\Eav\Model\Form\Type $skeleton) { diff --git a/app/code/Magento/Eav/Model/Resource/Attribute.php b/app/code/Magento/Eav/Model/Resource/Attribute.php index 8cd3fddf46aa226fd6ade8343fd8420999c25320..6f2256a2e4dbe3bc302ed7fc9e22f7e2136bcca3 100644 --- a/app/code/Magento/Eav/Model/Resource/Attribute.php +++ b/app/code/Magento/Eav/Model/Resource/Attribute.php @@ -34,6 +34,9 @@ */ namespace Magento\Eav\Model\Resource; +use Magento\Core\Model\AbstractModel; +use Magento\DB\Select; + abstract class Attribute extends \Magento\Eav\Model\Resource\Entity\Attribute { /** @@ -58,10 +61,10 @@ abstract class Attribute extends \Magento\Eav\Model\Resource\Entity\Attribute /** * Perform actions before object save * - * @param \Magento\Core\Model\AbstractModel $object - * @return \Magento\Eav\Model\Resource\Attribute + * @param AbstractModel $object + * @return $this */ - protected function _beforeSave(\Magento\Core\Model\AbstractModel $object) + protected function _beforeSave(AbstractModel $object) { $validateRules = $object->getData('validate_rules'); if (is_array($validateRules)) { @@ -75,8 +78,8 @@ abstract class Attribute extends \Magento\Eav\Model\Resource\Entity\Attribute * * @param string $field * @param mixed $value - * @param \Magento\Core\Model\AbstractModel $object - * @return \Magento\DB\Select + * @param AbstractModel $object + * @return Select */ protected function _getLoadSelect($field, $value, $object) { @@ -107,10 +110,10 @@ abstract class Attribute extends \Magento\Eav\Model\Resource\Entity\Attribute /** * Save attribute/form relations after attribute save * - * @param \Magento\Core\Model\AbstractModel $object - * @return \Magento\Eav\Model\Resource\Attribute + * @param AbstractModel $object + * @return $this */ - protected function _afterSave(\Magento\Core\Model\AbstractModel $object) + protected function _afterSave(AbstractModel $object) { $forms = $object->getData('used_in_forms'); $adapter = $this->_getWriteAdapter(); @@ -195,10 +198,10 @@ abstract class Attribute extends \Magento\Eav\Model\Resource\Entity\Attribute /** * Return forms in which the attribute * - * @param \Magento\Core\Model\AbstractModel $object + * @param AbstractModel $object * @return array */ - public function getUsedInForms(\Magento\Core\Model\AbstractModel $object) + public function getUsedInForms(AbstractModel $object) { $adapter = $this->_getReadAdapter(); $bind = array('attribute_id' => (int)$object->getId()); diff --git a/app/code/Magento/Eav/Model/Resource/Attribute/Collection.php b/app/code/Magento/Eav/Model/Resource/Attribute/Collection.php index 07bde90ef6b81879d987d57e5204e6ea036ae384..0200129248c51d7cc6c8815f680b2e6d81606469 100644 --- a/app/code/Magento/Eav/Model/Resource/Attribute/Collection.php +++ b/app/code/Magento/Eav/Model/Resource/Attribute/Collection.php @@ -33,6 +33,7 @@ * @author Magento Core Team <core@magentocommerce.com> */ namespace Magento\Eav\Model\Resource\Attribute; +use Magento\Core\Model\Website; abstract class Collection extends \Magento\Eav\Model\Resource\Entity\Attribute\Collection @@ -45,7 +46,7 @@ abstract class Collection /** * Current website scope instance * - * @var \Magento\Core\Model\Website + * @var Website */ protected $_website; @@ -134,8 +135,8 @@ abstract class Collection /** * Set Website scope * - * @param \Magento\Core\Model\Website|int $website - * @return \Magento\Eav\Model\Resource\Attribute\Collection + * @param Website|int $website + * @return $this */ public function setWebsite($website) { @@ -147,7 +148,7 @@ abstract class Collection /** * Return current website scope instance * - * @return \Magento\Core\Model\Website + * @return Website */ public function getWebsite() { @@ -160,7 +161,7 @@ abstract class Collection /** * Initialize collection select * - * @return \Magento\Eav\Model\Resource\Attribute\Collection + * @return $this */ protected function _initSelect() { @@ -238,7 +239,7 @@ abstract class Collection * Entity type is defined. * * @param int $type - * @return \Magento\Eav\Model\Resource\Attribute\Collection + * @return $this */ public function setEntityTypeFilter($type) { @@ -248,7 +249,7 @@ abstract class Collection /** * Specify filter by "is_visible" field * - * @return \Magento\Eav\Model\Resource\Attribute\Collection + * @return $this */ public function addVisibleFilter() { @@ -258,7 +259,7 @@ abstract class Collection /** * Exclude system hidden attributes * - * @return \Magento\Eav\Model\Resource\Attribute\Collection + * @return $this */ public function addSystemHiddenFilter() { @@ -272,7 +273,7 @@ abstract class Collection /** * Exclude system hidden attributes but include password hash * - * @return \Magento\Customer\Model\Resource\Attribute\Collection + * @return $this */ public function addSystemHiddenFilterWithPasswordHash() { @@ -291,7 +292,7 @@ abstract class Collection /** * Add exclude hidden frontend input attribute filter to collection * - * @return \Magento\Eav\Model\Resource\Attribute\Collection + * @return $this */ public function addExcludeHiddenFrontendFilter() { diff --git a/app/code/Magento/Eav/Model/Resource/Config.php b/app/code/Magento/Eav/Model/Resource/Config.php index b2fb0b246f2a54ce60c7ff5745962a2909231acc..0114901c0ecb8c52c08a3583fcaf147427d2f74c 100644 --- a/app/code/Magento/Eav/Model/Resource/Config.php +++ b/app/code/Magento/Eav/Model/Resource/Config.php @@ -24,6 +24,7 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Eav\Model\Resource; /** * Eav Resource Config model @@ -32,8 +33,6 @@ * @package Magento_Eav * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\Eav\Model\Resource; - class Config extends \Magento\Core\Model\Resource\Db\AbstractDb { /** @@ -52,6 +51,8 @@ class Config extends \Magento\Core\Model\Resource\Db\AbstractDb /** * Resource initialization + * + * @return void */ protected function _construct() { @@ -61,7 +62,7 @@ class Config extends \Magento\Core\Model\Resource\Db\AbstractDb /** * Load all entity types * - * @return \Magento\Eav\Model\Resource\Config + * @return $this */ protected function _loadTypes() { diff --git a/app/code/Magento/Eav/Model/Resource/Entity/Attribute.php b/app/code/Magento/Eav/Model/Resource/Entity/Attribute.php index f9dc99292734c3bd498715fe650534e113d639f2..8b48fee9d4c69aff702ad8ce18e2beefbc84c013 100644 --- a/app/code/Magento/Eav/Model/Resource/Entity/Attribute.php +++ b/app/code/Magento/Eav/Model/Resource/Entity/Attribute.php @@ -34,6 +34,10 @@ */ namespace Magento\Eav\Model\Resource\Entity; +use Magento\Core\Model\AbstractModel; +use Magento\Eav\Model\Entity\Attribute as EntityAttribute; +use Magento\DB\Select; + class Attribute extends \Magento\Core\Model\Resource\Db\AbstractDb { /** @@ -80,6 +84,7 @@ class Attribute extends \Magento\Core\Model\Resource\Db\AbstractDb /** * Define main table * + * @return void */ protected function _construct() { @@ -89,7 +94,7 @@ class Attribute extends \Magento\Core\Model\Resource\Db\AbstractDb /** * Initialize unique fields * - * @return \Magento\Eav\Model\Resource\Entity\Attribute + * @return $this */ protected function _initUniqueFields() { @@ -104,7 +109,7 @@ class Attribute extends \Magento\Core\Model\Resource\Db\AbstractDb * Load all entity type attributes * * @param int $entityTypeId - * @return \Magento\Eav\Model\Resource\Entity\Attribute + * @return $this */ protected function _loadTypeAttributes($entityTypeId) { @@ -127,12 +132,12 @@ class Attribute extends \Magento\Core\Model\Resource\Db\AbstractDb /** * Load attribute data by attribute code * - * @param \Magento\Eav\Model\Entity\Attribute|\Magento\Core\Model\AbstractModel $object + * @param EntityAttribute|AbstractModel $object * @param int $entityTypeId * @param string $code * @return bool */ - public function loadByCode(\Magento\Core\Model\AbstractModel $object, $entityTypeId, $code) + public function loadByCode(AbstractModel $object, $entityTypeId, $code) { $bind = array(':entity_type_id' => $entityTypeId); $select = $this->_getLoadSelect('attribute_code', $code, $object) @@ -150,10 +155,10 @@ class Attribute extends \Magento\Core\Model\Resource\Db\AbstractDb /** * Retrieve Max Sort order for attribute in group * - * @param \Magento\Core\Model\AbstractModel $object + * @param AbstractModel $object * @return int */ - private function _getMaxSortOrder(\Magento\Core\Model\AbstractModel $object) + private function _getMaxSortOrder(AbstractModel $object) { if (intval($object->getAttributeGroupId()) > 0) { $adapter = $this->_getReadAdapter(); @@ -175,10 +180,10 @@ class Attribute extends \Magento\Core\Model\Resource\Db\AbstractDb /** * Delete entity * - * @param \Magento\Core\Model\AbstractModel $object - * @return \Magento\Eav\Model\Resource\Entity\Attribute + * @param AbstractModel $object + * @return $this */ - public function deleteEntity(\Magento\Core\Model\AbstractModel $object) + public function deleteEntity(AbstractModel $object) { if (!$object->getEntityAttributeId()) { return $this; @@ -194,10 +199,11 @@ class Attribute extends \Magento\Core\Model\Resource\Db\AbstractDb /** * Validate attribute data before save * - * @param \Magento\Eav\Model\Entity\Attribute|\Magento\Core\Model\AbstractModel $object - * @return \Magento\Eav\Model\Resource\Entity\Attribute + * @param EntityAttribute|AbstractModel $object + * @return $this + * @throws \Magento\Core\Exception */ - protected function _beforeSave(\Magento\Core\Model\AbstractModel $object) + protected function _beforeSave(AbstractModel $object) { $frontendLabel = $object->getFrontendLabel(); if (is_array($frontendLabel)) { @@ -223,10 +229,10 @@ class Attribute extends \Magento\Core\Model\Resource\Db\AbstractDb /** * Save additional attribute data after save attribute * - * @param \Magento\Eav\Model\Entity\Attribute|\Magento\Core\Model\AbstractModel $object - * @return \Magento\Eav\Model\Resource\Entity\Attribute + * @param EntityAttribute|AbstractModel $object + * @return $this */ - protected function _afterSave(\Magento\Core\Model\AbstractModel $object) + protected function _afterSave(AbstractModel $object) { $this->_saveStoreLabels($object) ->_saveAdditionalAttributeData($object) @@ -239,10 +245,10 @@ class Attribute extends \Magento\Core\Model\Resource\Db\AbstractDb /** * Save store labels * - * @param \Magento\Eav\Model\Entity\Attribute|\Magento\Core\Model\AbstractModel $object - * @return \Magento\Eav\Model\Resource\Entity\Attribute + * @param EntityAttribute|AbstractModel $object + * @return $this */ - protected function _saveStoreLabels(\Magento\Core\Model\AbstractModel $object) + protected function _saveStoreLabels(AbstractModel $object) { $storeLabels = $object->getStoreLabels(); if (is_array($storeLabels)) { @@ -270,10 +276,10 @@ class Attribute extends \Magento\Core\Model\Resource\Db\AbstractDb /** * Save additional data of attribute * - * @param \Magento\Eav\Model\Entity\Attribute|\Magento\Core\Model\AbstractModel $object - * @return \Magento\Eav\Model\Resource\Entity\Attribute + * @param EntityAttribute|AbstractModel $object + * @return $this */ - protected function _saveAdditionalAttributeData(\Magento\Core\Model\AbstractModel $object) + protected function _saveAdditionalAttributeData(AbstractModel $object) { $additionalTable = $this->getAdditionalAttributeTable($object->getEntityTypeId()); if ($additionalTable) { @@ -297,10 +303,10 @@ class Attribute extends \Magento\Core\Model\Resource\Db\AbstractDb /** * Save in set including * - * @param \Magento\Core\Model\AbstractModel $object - * @return \Magento\Eav\Model\Resource\Entity\Attribute + * @param AbstractModel $object + * @return $this */ - public function saveInSetIncluding(\Magento\Core\Model\AbstractModel $object) + public function saveInSetIncluding(AbstractModel $object) { $attributeId = (int)$object->getId(); $setId = (int)$object->getAttributeSetId(); @@ -334,10 +340,10 @@ class Attribute extends \Magento\Core\Model\Resource\Db\AbstractDb /** * Save attribute options * - * @param \Magento\Eav\Model\Entity\Attribute|\Magento\Core\Model\AbstractModel $object - * @return \Magento\Eav\Model\Resource\Entity\Attribute + * @param EntityAttribute|AbstractModel $object + * @return $this */ - protected function _saveOption(\Magento\Core\Model\AbstractModel $object) + protected function _saveOption(AbstractModel $object) { $option = $object->getOption(); if (!is_array($option)) { @@ -359,7 +365,7 @@ class Attribute extends \Magento\Core\Model\Resource\Db\AbstractDb /** * Save changes of attribute options, return obtained default value * - * @param \Magento\Eav\Model\Entity\Attribute|\Magento\Core\Model\AbstractModel $object + * @param EntityAttribute|AbstractModel $object * @param array $option * @return array */ @@ -382,6 +388,7 @@ class Attribute extends \Magento\Core\Model\Resource\Db\AbstractDb * Check default option value presence * * @param array $values + * @return void * @throws \Magento\Core\Exception */ protected function _checkDefaultOptionValue($values) @@ -394,10 +401,11 @@ class Attribute extends \Magento\Core\Model\Resource\Db\AbstractDb /** * Update attribute default value * - * @param \Magento\Eav\Model\Entity\Attribute|\Magento\Core\Model\AbstractModel $object + * @param EntityAttribute|AbstractModel $object * @param int|string $optionId * @param int $intOptionId * @param array $defaultValue + * @return void */ protected function _updateDefaultValue($object, $optionId, $intOptionId, &$defaultValue) { @@ -414,8 +422,9 @@ class Attribute extends \Magento\Core\Model\Resource\Db\AbstractDb /** * Save attribute default value * - * @param \Magento\Core\Model\AbstractModel $object + * @param AbstractModel $object * @param array $defaultValue + * @return void */ protected function _saveDefaultValue($object, $defaultValue) { @@ -429,7 +438,7 @@ class Attribute extends \Magento\Core\Model\Resource\Db\AbstractDb /** * Save option records * - * @param \Magento\Core\Model\AbstractModel $object + * @param AbstractModel $object * @param int $optionId * @param array $option * @return int|bool @@ -469,6 +478,7 @@ class Attribute extends \Magento\Core\Model\Resource\Db\AbstractDb * * @param int $optionId * @param array $values + * @return void */ protected function _updateAttributeOptionValues($optionId, $values) { @@ -537,9 +547,9 @@ class Attribute extends \Magento\Core\Model\Resource\Db\AbstractDb /** * Retrieve Select For Flat Attribute update * - * @param \Magento\Eav\Model\Entity\Attribute\AbstractAttribute $attribute + * @param EntityAttribute\AbstractAttribute $attribute * @param int $storeId - * @return \Magento\DB\Select + * @return Select */ public function getFlatUpdateSelect(\Magento\Eav\Model\Entity\Attribute\AbstractAttribute $attribute, $storeId) { @@ -557,7 +567,7 @@ class Attribute extends \Magento\Core\Model\Resource\Db\AbstractDb $valueExpr = $adapter->getCheckSql('t2.value_id > 0', 't2.value', 't1.value'); - /** @var $select \Magento\DB\Select */ + /** @var $select Select */ $select = $adapter->select() ->joinLeft( array('t1' => $attribute->getBackend()->getTable()), @@ -588,7 +598,7 @@ class Attribute extends \Magento\Core\Model\Resource\Db\AbstractDb /** * Retrieve additional attribute table name for specified entity type * - * @param integer $entityTypeId + * @param int $entityTypeId * @return string */ public function getAdditionalAttributeTable($entityTypeId) @@ -600,10 +610,10 @@ class Attribute extends \Magento\Core\Model\Resource\Db\AbstractDb * Load additional attribute data. * Load label of current active store * - * @param \Magento\Eav\Model\Entity\Attribute|\Magento\Core\Model\AbstractModel $object - * @return \Magento\Eav\Model\Resource\Entity\Attribute + * @param EntityAttribute|AbstractModel $object + * @return $this */ - protected function _afterLoad(\Magento\Core\Model\AbstractModel $object) + protected function _afterLoad(AbstractModel $object) { /** @var $entityType \Magento\Eav\Model\Entity\Type */ $entityType = $object->getData('entity_type'); @@ -632,7 +642,7 @@ class Attribute extends \Magento\Core\Model\Resource\Db\AbstractDb /** * Retrieve store labels by given attribute id * - * @param integer $attributeId + * @param int $attributeId * @return array */ public function getStoreLabelsByAttributeId($attributeId) diff --git a/app/code/Magento/Eav/Model/Resource/Entity/Attribute/Collection.php b/app/code/Magento/Eav/Model/Resource/Entity/Attribute/Collection.php index f9c2abcfecd8e6eece40b9b9e768ce90ec57b17f..17dfc977b5baa9b77151a7f02ed538dc7d907f45 100644 --- a/app/code/Magento/Eav/Model/Resource/Entity/Attribute/Collection.php +++ b/app/code/Magento/Eav/Model/Resource/Entity/Attribute/Collection.php @@ -34,18 +34,21 @@ */ namespace Magento\Eav\Model\Resource\Entity\Attribute; +use Magento\Eav\Model\Entity\Type; + class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractCollection { /** * Add attribute set info flag * - * @var boolean + * @var bool */ protected $_addSetInfoFlag = false; /** * Resource model initialization * + * @return void */ protected function _construct() { @@ -55,7 +58,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl /** * Return array of fields to load attribute values * - * @return array + * @return string[] */ protected function _getLoadDataFields() { @@ -75,7 +78,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl /** * Specify select columns which are used for load arrtibute values * - * @return \Magento\Eav\Model\Resource\Entity\Attribute\Collection + * @return $this */ public function useLoadDataFields() { @@ -88,12 +91,12 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl /** * Specify attribute entity type filter * - * @param \Magento\Eav\Model\Entity\Type | int $type - * @return \Magento\Eav\Model\Resource\Entity\Attribute\Collection + * @param Type|int $type + * @return $this */ public function setEntityTypeFilter($type) { - if ($type instanceof \Magento\Eav\Model\Entity\Type) { + if ($type instanceof Type) { $additionalTable = $type->getAdditionalAttributeTable(); $id = $type->getId(); } else { @@ -115,7 +118,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl * Specify attribute set filter * * @param int $setId - * @return \Magento\Eav\Model\Resource\Entity\Attribute\Collection + * @return $this */ public function setAttributeSetFilter($setId) { @@ -146,7 +149,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl * Result will be ordered by sort_order * * @param array $setIds - * @return \Magento\Eav\Model\Resource\Entity\Attribute\Collection + * @return $this */ public function setAttributeSetsFilter(array $setIds) { @@ -166,7 +169,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl * Filter for selecting of attributes that is in all sets * * @param array $setIds - * @return \Magento\Eav\Model\Resource\Entity\Attribute\Collection + * @return $this */ public function setInAllAttributeSetsFilter(array $setIds) { @@ -195,7 +198,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl * Exclude attributes filter * * @param array $attributes - * @return \Magento\Eav\Model\Resource\Entity\Attribute\Collection + * @return $this */ public function setAttributesExcludeFilter($attributes) { @@ -205,9 +208,8 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl /** * Specify exclude attribute set filter * - * @param $setId - * @return \Magento\Eav\Model\Resource\Entity\Attribute\Collection - * @return \Magento\Eav\Model\Resource\Entity\Attribute\Collection + * @param int $setId + * @return $this */ public function setExcludeSetFilter($setId) { @@ -224,7 +226,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl * Filter by attribute group id * * @param int $groupId - * @return \Magento\Eav\Model\Resource\Entity\Attribute\Collection + * @return $this */ public function setAttributeGroupFilter($groupId) { @@ -241,7 +243,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl /** * Declare group by attribute id condition for collection select * - * @return \Magento\Eav\Model\Resource\Entity\Attribute\Collection + * @return $this */ public function addAttributeGrouping() { @@ -252,7 +254,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl /** * Specify "is_unique" filter as true * - * @return \Magento\Eav\Model\Resource\Entity\Attribute\Collection + * @return $this */ public function addIsUniqueFilter() { @@ -262,7 +264,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl /** * Specify "is_unique" filter as false * - * @return \Magento\Eav\Model\Resource\Entity\Attribute\Collection + * @return $this */ public function addIsNotUniqueFilter() { @@ -272,7 +274,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl /** * Specify filter to select just attributes with options * - * @return \Magento\Eav\Model\Resource\Entity\Attribute\Collection + * @return $this */ public function addHasOptionsFilter() { @@ -297,7 +299,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl * Apply filter by attribute frontend input type * * @param string $frontendInputType - * @return \Magento\Eav\Model\Resource\Entity\Attribute\Collection + * @return $this */ public function setFrontendInputTypeFilter($frontendInputType) { @@ -308,7 +310,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl * Flag for adding information about attributes sets to result * * @param bool $flag - * @return \Magento\Eav\Model\Resource\Entity\Attribute\Collection + * @return $this */ public function addSetInfo($flag = true) { @@ -319,7 +321,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl /** * Ad information about attribute sets to collection result data * - * @return \Magento\Eav\Model\Resource\Entity\Attribute\Collection + * @return $this */ protected function _addSetInfo() { @@ -385,8 +387,8 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl /** * Specify collection attribute codes filter * - * @param string || array $code - * @return \Magento\Eav\Model\Resource\Entity\Attribute\Collection + * @param string|array $code + * @return $this */ public function setCodeFilter($code) { @@ -403,8 +405,8 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl /** * Add store label to attribute by specified store id * - * @param integer $storeId - * @return \Magento\Eav\Model\Resource\Entity\Attribute\Collection + * @param int $storeId + * @return $this */ public function addStoreLabel($storeId) { diff --git a/app/code/Magento/Eav/Model/Resource/Entity/Attribute/Grid/Collection.php b/app/code/Magento/Eav/Model/Resource/Entity/Attribute/Grid/Collection.php index a9ad2e4002bdf161bdace8ba1a784efb6d2dbed6..0cc90e933799eb19d06c18dd27663faab61fc0b1 100644 --- a/app/code/Magento/Eav/Model/Resource/Entity/Attribute/Grid/Collection.php +++ b/app/code/Magento/Eav/Model/Resource/Entity/Attribute/Grid/Collection.php @@ -33,6 +33,8 @@ */ namespace Magento\Eav\Model\Resource\Entity\Attribute\Grid; +use Magento\Core\Model\Resource\Db\Collection\AbstractCollection; + class Collection extends \Magento\Eav\Model\Resource\Entity\Attribute\Set\Collection { @@ -66,7 +68,7 @@ class Collection /** * Add filter by entity type id to collection * - * @return \Magento\Core\Model\Resource\Db\Collection\AbstractCollection|\Magento\Eav\Model\Resource\Entity\Attribute\Grid\Collection + * @return AbstractCollection|$this */ protected function _initSelect() { diff --git a/app/code/Magento/Eav/Model/Resource/Entity/Attribute/Group.php b/app/code/Magento/Eav/Model/Resource/Entity/Attribute/Group.php index 41446e2c1ad86eaca02b320234de7210e34aa0ee..3c9814c13fdbee848d8907953a89bce843c7a6d0 100644 --- a/app/code/Magento/Eav/Model/Resource/Entity/Attribute/Group.php +++ b/app/code/Magento/Eav/Model/Resource/Entity/Attribute/Group.php @@ -43,6 +43,8 @@ class Group extends \Magento\Core\Model\Resource\Db\AbstractDb /** * Resource initialization + * + * @return void */ protected function _construct() { @@ -53,7 +55,7 @@ class Group extends \Magento\Core\Model\Resource\Db\AbstractDb * Checks if attribute group exists * * @param \Magento\Eav\Model\Entity\Attribute\Group $object - * @return boolean + * @return bool */ public function itemExists($object) { diff --git a/app/code/Magento/Eav/Model/Resource/Entity/Attribute/Group/Collection.php b/app/code/Magento/Eav/Model/Resource/Entity/Attribute/Group/Collection.php index c8889f7836dd712a9d74e723320d907032c88edf..d1ce8c4e087b099af848eb6af54316756376539f 100644 --- a/app/code/Magento/Eav/Model/Resource/Entity/Attribute/Group/Collection.php +++ b/app/code/Magento/Eav/Model/Resource/Entity/Attribute/Group/Collection.php @@ -39,6 +39,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl /** * Init resource model for collection * + * @return void */ protected function _construct() { diff --git a/app/code/Magento/Eav/Model/Resource/Entity/Attribute/Option.php b/app/code/Magento/Eav/Model/Resource/Entity/Attribute/Option.php index 3df648a150803cf385d65bb63b3cbdc43ba23a53..088cb78ed53c277a87f106886886e39c0776ac8a 100644 --- a/app/code/Magento/Eav/Model/Resource/Entity/Attribute/Option.php +++ b/app/code/Magento/Eav/Model/Resource/Entity/Attribute/Option.php @@ -38,6 +38,8 @@ class Option extends \Magento\Core\Model\Resource\Db\AbstractDb { /** * Resource initialization + * + * @return void */ protected function _construct() { diff --git a/app/code/Magento/Eav/Model/Resource/Entity/Attribute/Option/Collection.php b/app/code/Magento/Eav/Model/Resource/Entity/Attribute/Option/Collection.php index 45399e57dda19a85d1d3a877dc8f3cd1ac9be470..30fc7eeb374e9824cf9725d8d95f8480131778bb 100644 --- a/app/code/Magento/Eav/Model/Resource/Entity/Attribute/Option/Collection.php +++ b/app/code/Magento/Eav/Model/Resource/Entity/Attribute/Option/Collection.php @@ -80,6 +80,8 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl /** * Resource initialization + * + * @return void */ protected function _construct() { @@ -91,7 +93,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl * Set attribute filter * * @param int $setId - * @return \Magento\Eav\Model\Resource\Entity\Attribute\Option\Collection + * @return $this */ public function setAttributeFilter($setId) { @@ -103,8 +105,8 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl * Add store filter to collection * * @param int $storeId - * @param boolean $useDefaultValue - * @return \Magento\Eav\Model\Resource\Entity\Attribute\Option\Collection + * @param bool $useDefaultValue + * @return $this */ public function setStoreFilter($storeId = null, $useDefaultValue = true) { @@ -147,7 +149,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl * Add option id(s) frilter to collection * * @param int|array $optionId - * @return \Magento\Eav\Model\Resource\Entity\Attribute\Option\Collection + * @return $this */ public function setIdFilter($optionId) { @@ -169,8 +171,8 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl * Set order by position or alphabetically by values in admin * * @param string $dir direction - * @param boolean $sortAlpha sort alphabetically by values in admin - * @return \Magento\Eav\Model\Resource\Entity\Attribute\Option\Collection + * @param bool $sortAlpha sort alphabetically by values in admin + * @return $this */ public function setPositionOrder($dir = self::SORT_ORDER_ASC, $sortAlpha = false) { diff --git a/app/code/Magento/Eav/Model/Resource/Entity/Attribute/Set.php b/app/code/Magento/Eav/Model/Resource/Entity/Attribute/Set.php index 80f3de983e4a9f9b66d1caadf96e3b30f219e234..6d45164fd0a88550bdbf7b567f70a56deb3c9135 100644 --- a/app/code/Magento/Eav/Model/Resource/Entity/Attribute/Set.php +++ b/app/code/Magento/Eav/Model/Resource/Entity/Attribute/Set.php @@ -56,6 +56,7 @@ class Set extends \Magento\Core\Model\Resource\Db\AbstractDb /** * Initialize connection * + * @return void */ protected function _construct() { diff --git a/app/code/Magento/Eav/Model/Resource/Entity/Attribute/Set/Collection.php b/app/code/Magento/Eav/Model/Resource/Entity/Attribute/Set/Collection.php index 728ad2fce4806a3fd586ae4a64231890fa323502..980ffa845ee1a2a6449eb7d8e1b141d75943a9b7 100644 --- a/app/code/Magento/Eav/Model/Resource/Entity/Attribute/Set/Collection.php +++ b/app/code/Magento/Eav/Model/Resource/Entity/Attribute/Set/Collection.php @@ -38,6 +38,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl /** * Resource initialization * + * @return void */ protected function _construct() { diff --git a/app/code/Magento/Eav/Model/Resource/Entity/Store.php b/app/code/Magento/Eav/Model/Resource/Entity/Store.php index 0dc6b21c402a7bbab5cc1870213e95db952ee8fe..aa608799e36eea030af8e8841897198d2e375a11 100644 --- a/app/code/Magento/Eav/Model/Resource/Entity/Store.php +++ b/app/code/Magento/Eav/Model/Resource/Entity/Store.php @@ -38,6 +38,8 @@ class Store extends \Magento\Core\Model\Resource\Db\AbstractDb { /** * Resource initialization + * + * @return void */ protected function _construct() { @@ -50,7 +52,7 @@ class Store extends \Magento\Core\Model\Resource\Db\AbstractDb * @param \Magento\Object $object * @param int $entityTypeId * @param int $storeId - * @return boolean + * @return bool */ public function loadByEntityStore(\Magento\Core\Model\AbstractModel $object, $entityTypeId, $storeId) { diff --git a/app/code/Magento/Eav/Model/Resource/Entity/Type.php b/app/code/Magento/Eav/Model/Resource/Entity/Type.php index d6d97b2d8fa69d47d238e7f1395b9557cb07a662..851702ca45550a223949450ad980a0a6e0430bca 100644 --- a/app/code/Magento/Eav/Model/Resource/Entity/Type.php +++ b/app/code/Magento/Eav/Model/Resource/Entity/Type.php @@ -38,6 +38,8 @@ class Type extends \Magento\Core\Model\Resource\Db\AbstractDb { /** * Resource initialization + * + * @return void */ protected function _construct() { diff --git a/app/code/Magento/Eav/Model/Resource/Entity/Type/Collection.php b/app/code/Magento/Eav/Model/Resource/Entity/Type/Collection.php index 306d92e28549a6125f77d7e2b0566bfcdc3f87ae..7726d8c897196c41949f068df3a62b072ec10b95 100644 --- a/app/code/Magento/Eav/Model/Resource/Entity/Type/Collection.php +++ b/app/code/Magento/Eav/Model/Resource/Entity/Type/Collection.php @@ -38,6 +38,8 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl { /** * Resource initialization + * + * @return void */ protected function _construct() { diff --git a/app/code/Magento/Eav/Model/Resource/Form/Attribute/Collection.php b/app/code/Magento/Eav/Model/Resource/Form/Attribute/Collection.php index 03ebd3ef9f04ef28a6594d9999c6ed78639941ee..f1c13a50ffc8665497eef8afda33e7b49b4ca3a4 100644 --- a/app/code/Magento/Eav/Model/Resource/Form/Attribute/Collection.php +++ b/app/code/Magento/Eav/Model/Resource/Form/Attribute/Collection.php @@ -102,6 +102,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl /** * Resource initialization * + * @return void * @throws \Magento\Core\Exception */ protected function _construct() diff --git a/app/code/Magento/Eav/Model/Resource/Form/Element.php b/app/code/Magento/Eav/Model/Resource/Form/Element.php index a278639abeee5043fd36cab26bff542c413abc6b..64a2f2d5e187ffd321cc50b77814d91db013eec2 100644 --- a/app/code/Magento/Eav/Model/Resource/Form/Element.php +++ b/app/code/Magento/Eav/Model/Resource/Form/Element.php @@ -38,6 +38,8 @@ class Element extends \Magento\Core\Model\Resource\Db\AbstractDb { /** * Initialize connection and define main table + * + * @return void */ protected function _construct() { diff --git a/app/code/Magento/Eav/Model/Resource/Form/Element/Collection.php b/app/code/Magento/Eav/Model/Resource/Form/Element/Collection.php index e1c2ff41f5180bd77c4b14f29a5a10487bb163f4..dcc599553b77e6b3f2b985824536dd1b45bffaa2 100644 --- a/app/code/Magento/Eav/Model/Resource/Form/Element/Collection.php +++ b/app/code/Magento/Eav/Model/Resource/Form/Element/Collection.php @@ -38,6 +38,8 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl { /** * Initialize collection model + * + * @return void */ protected function _construct() { @@ -121,8 +123,8 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl /** * Load data (join attribute data) * - * @param boolean $printQuery - * @param boolean $logQuery + * @param bool $printQuery + * @param bool $logQuery * @return \Magento\Eav\Model\Resource\Form\Element\Collection */ public function load($printQuery = false, $logQuery = false) diff --git a/app/code/Magento/Eav/Model/Resource/Form/Fieldset.php b/app/code/Magento/Eav/Model/Resource/Form/Fieldset.php index 084260e105adb3d40f7e140c1bd79796ca902a1f..d8b8630501cae37e0ea427c301706f7bd3e78587 100644 --- a/app/code/Magento/Eav/Model/Resource/Form/Fieldset.php +++ b/app/code/Magento/Eav/Model/Resource/Form/Fieldset.php @@ -38,6 +38,8 @@ class Fieldset extends \Magento\Core\Model\Resource\Db\AbstractDb { /** * Initialize connection and define main table + * + * @return void */ protected function _construct() { diff --git a/app/code/Magento/Eav/Model/Resource/Form/Fieldset/Collection.php b/app/code/Magento/Eav/Model/Resource/Form/Fieldset/Collection.php index 419ea5b5573aa9ed301e7e03e3a1abfe7ffbcfaf..dad235ea3535b7433c13ef08f2ed53834cafe161 100644 --- a/app/code/Magento/Eav/Model/Resource/Form/Fieldset/Collection.php +++ b/app/code/Magento/Eav/Model/Resource/Form/Fieldset/Collection.php @@ -34,6 +34,8 @@ */ namespace Magento\Eav\Model\Resource\Form\Fieldset; +use Magento\Eav\Model\Form\Type; + class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractCollection { /** @@ -73,6 +75,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl /** * Initialize collection model * + * @return void */ protected function _construct() { @@ -82,12 +85,12 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl /** * Add Form Type filter to collection * - * @param \Magento\Eav\Model\Form\Type|int $type - * @return \Magento\Eav\Model\Resource\Form\Fieldset\Collection + * @param Type|int $type + * @return $this */ public function addTypeFilter($type) { - if ($type instanceof \Magento\Eav\Model\Form\Type) { + if ($type instanceof Type) { $type = $type->getId(); } @@ -97,7 +100,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl /** * Set order by fieldset sort order * - * @return \Magento\Eav\Model\Resource\Form\Fieldset\Collection + * @return $this */ public function setSortOrder() { @@ -122,7 +125,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl * Set store scope ID * * @param int $storeId - * @return \Magento\Eav\Model\Resource\Form\Fieldset\Collection + * @return $this */ public function setStoreId($storeId) { @@ -133,7 +136,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl /** * Initialize select object * - * @return \Magento\Eav\Model\Resource\Form\Fieldset\Collection + * @return $this */ protected function _initSelect() { diff --git a/app/code/Magento/Eav/Model/Resource/Form/Type.php b/app/code/Magento/Eav/Model/Resource/Form/Type.php index 82d45d83f7793a9ac835dcc5c96e79587e2f0d20..48a5874f0714d3e5e8a2566c43121cd4f4103ad4 100644 --- a/app/code/Magento/Eav/Model/Resource/Form/Type.php +++ b/app/code/Magento/Eav/Model/Resource/Form/Type.php @@ -34,11 +34,14 @@ */ namespace Magento\Eav\Model\Resource\Form; +use Magento\Eav\Model\Form\Type as FormType; + class Type extends \Magento\Core\Model\Resource\Db\AbstractDb { /** * Initialize connection and define main table * + * @return void */ protected function _construct() { @@ -52,10 +55,10 @@ class Type extends \Magento\Core\Model\Resource\Db\AbstractDb /** * Load an object * - * @param \Magento\Eav\Model\Form\Type $object + * @param FormType $object * @param mixed $value * @param string $field field to load by (defaults to model id) - * @return \Magento\Eav\Model\Resource\Form\Type + * @return $this */ public function load(\Magento\Core\Model\AbstractModel $object, $value, $field = null) { @@ -68,7 +71,7 @@ class Type extends \Magento\Core\Model\Resource\Db\AbstractDb /** * Retrieve form type entity types * - * @param \Magento\Eav\Model\Form\Type $object + * @param FormType $object * @return array */ public function getEntityTypes($object) @@ -91,8 +94,8 @@ class Type extends \Magento\Core\Model\Resource\Db\AbstractDb * * @see \Magento\Core\Model\Resource\Db\AbstractDb#_afterSave($object) * - * @param \Magento\Eav\Model\Form\Type $object - * @return \Magento\Eav\Model\Resource\Form\Type + * @param FormType $object + * @return $this */ protected function _afterSave(\Magento\Core\Model\AbstractModel $object) { diff --git a/app/code/Magento/Eav/Model/Resource/Form/Type/Collection.php b/app/code/Magento/Eav/Model/Resource/Form/Type/Collection.php index ca1f61e3e00a7de15e6c67428a6f84548e5466a9..ecb0b8d1ef4c0a789e3988b40c60a99f7baadbcd 100644 --- a/app/code/Magento/Eav/Model/Resource/Form/Type/Collection.php +++ b/app/code/Magento/Eav/Model/Resource/Form/Type/Collection.php @@ -34,11 +34,14 @@ */ namespace Magento\Eav\Model\Resource\Form\Type; +use Magento\Eav\Model\Entity\Type; + class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractCollection { /** * Initialize collection model * + * @return void */ protected function _construct() { @@ -58,12 +61,12 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl /** * Add Entity type filter to collection * - * @param \Magento\Eav\Model\Entity\Type|int $entity - * @return \Magento\Eav\Model\Resource\Form\Type\Collection + * @param Type|int $entity + * @return $this */ public function addEntityTypeFilter($entity) { - if ($entity instanceof \Magento\Eav\Model\Entity\Type) { + if ($entity instanceof Type) { $entity = $entity->getId(); } diff --git a/app/code/Magento/Eav/Model/Validator/Attribute/Backend.php b/app/code/Magento/Eav/Model/Validator/Attribute/Backend.php index c76e9c202b88e3aa1a3fcd5e4cd9236f14e130d0..2a8ee2715114f05d5ce51666ded793915f39d9a2 100644 --- a/app/code/Magento/Eav/Model/Validator/Attribute/Backend.php +++ b/app/code/Magento/Eav/Model/Validator/Attribute/Backend.php @@ -39,7 +39,7 @@ class Backend extends \Magento\Validator\AbstractValidator * Returns true if and only if $value meets the validation requirements. * * @param \Magento\Core\Model\AbstractModel $entity - * @return boolean + * @return bool * @throws \InvalidArgumentException */ public function isValid($entity) diff --git a/app/code/Magento/Eav/Model/Validator/Attribute/Data.php b/app/code/Magento/Eav/Model/Validator/Attribute/Data.php index d96b24907810f45b3769b625466580bf8ea32918..ddc3b2da1c38a65c3d1b482934b3426c178f9e8d 100644 --- a/app/code/Magento/Eav/Model/Validator/Attribute/Data.php +++ b/app/code/Magento/Eav/Model/Validator/Attribute/Data.php @@ -33,6 +33,8 @@ */ namespace Magento\Eav\Model\Validator\Attribute; +use Magento\Eav\Model\Attribute; + class Data extends \Magento\Validator\AbstractValidator { /** @@ -71,8 +73,8 @@ class Data extends \Magento\Validator\AbstractValidator /** * Set list of attributes for validation in isValid method. * - * @param \Magento\Eav\Model\Attribute[] $attributes - * @return \Magento\Eav\Model\Validator\Attribute\Data + * @param Attribute[] $attributes + * @return $this */ public function setAttributes(array $attributes) { @@ -86,7 +88,7 @@ class Data extends \Magento\Validator\AbstractValidator * All attributes not in this list 't be involved in validation. * * @param array $attributesCodes - * @return \Magento\Eav\Model\Validator\Attribute\Data + * @return $this */ public function setAttributesWhiteList(array $attributesCodes) { @@ -100,7 +102,7 @@ class Data extends \Magento\Validator\AbstractValidator * All attributes in this list won't be involved in validation. * * @param array $attributesCodes - * @return \Magento\Eav\Model\Validator\Attribute\Data + * @return $this */ public function setAttributesBlackList(array $attributesCodes) { @@ -112,7 +114,7 @@ class Data extends \Magento\Validator\AbstractValidator * Set data for validation in isValid method. * * @param array $data - * @return \Magento\Eav\Model\Validator\Attribute\Data + * @return $this */ public function setData(array $data) { @@ -128,7 +130,7 @@ class Data extends \Magento\Validator\AbstractValidator */ public function isValid($entity) { - /** @var $attributes \Magento\Eav\Model\Attribute[] */ + /** @var $attributes Attribute[] */ $attributes = $this->_getAttributes($entity); $data = array(); @@ -206,6 +208,7 @@ class Data extends \Magento\Validator\AbstractValidator * * @param string $code * @param array $messages + * @return void */ protected function _addErrorMessages($code, array $messages) { diff --git a/app/code/Magento/Email/Block/Adminhtml/Template.php b/app/code/Magento/Email/Block/Adminhtml/Template.php index acaff915e35e9a18caec56717e736ff9aad57d3c..f454217afa990dfd7c2205d1c20c58cd2ed8ed16 100644 --- a/app/code/Magento/Email/Block/Adminhtml/Template.php +++ b/app/code/Magento/Email/Block/Adminhtml/Template.php @@ -37,6 +37,11 @@ namespace Magento\Email\Block\Adminhtml; class Template extends \Magento\Backend\Block\Template { + /** + * Template list + * + * @var string + */ protected $_template = 'template/list.phtml'; /** diff --git a/app/code/Magento/Email/Block/Adminhtml/Template/Edit.php b/app/code/Magento/Email/Block/Adminhtml/Template/Edit.php index c7a0141372264e66d0e60800861369ff91c37009..4c4775378aa3c1c674df00accd8b874ffe08eb24 100644 --- a/app/code/Magento/Email/Block/Adminhtml/Template/Edit.php +++ b/app/code/Magento/Email/Block/Adminhtml/Template/Edit.php @@ -102,6 +102,11 @@ class Edit extends \Magento\Backend\Block\Widget parent::__construct($context, $data); } + /** + * Prepare layout + * + * @return \Magento\View\Element\AbstractBlock + */ protected function _prepareLayout() { $this->setChild('back_button', @@ -236,46 +241,91 @@ class Edit extends \Magento\Backend\Block\Widget return $options; } + /** + * Get the html element for back button + * + * @return string + */ public function getBackButtonHtml() { return $this->getChildHtml('back_button'); } + /** + * Get the html element for toggle button + * + * @return string + */ public function getToggleButtonHtml() { return $this->getChildHtml('toggle_button'); } + /** + * Get the html element for reset button + * + * @return string + */ public function getResetButtonHtml() { return $this->getChildHtml('reset_button'); } + /** + * Get the html element for to plain button + * + * @return string + */ public function getToPlainButtonHtml() { return $this->getChildHtml('to_plain_button'); } + /** + * Get the 'to html' button + * + * @return string + */ public function getToHtmlButtonHtml() { return $this->getChildHtml('to_html_button'); } + /** + * Get the html element for save button + * + * @return string + */ public function getSaveButtonHtml() { return $this->getChildHtml('save_button'); } + /** + * Get the html element for preview button + * + * @return string + */ public function getPreviewButtonHtml() { return $this->getChildHtml('preview_button'); } + /** + * Get the html element for delete button + * + * @return string + */ public function getDeleteButtonHtml() { return $this->getChildHtml('delete_button'); } + /** + * Get the html element for load button + * + * @return string + */ public function getLoadButtonHtml() { return $this->getChildHtml('load_button'); @@ -334,6 +384,11 @@ class Edit extends \Magento\Backend\Block\Widget return $this->getUrl('adminhtml/*/preview'); } + /** + * Return true if template type is text; return false otherwise + * + * @return bool + */ public function isTextType() { return $this->getEmailTemplate()->isPlain(); diff --git a/app/code/Magento/Email/Block/Adminhtml/Template/Grid/Filter/Type.php b/app/code/Magento/Email/Block/Adminhtml/Template/Grid/Filter/Type.php index 38a74cdc969125794ff89146c046ef0609e4e933..ef111c0bf921c280201451294658f748682ea62d 100644 --- a/app/code/Magento/Email/Block/Adminhtml/Template/Grid/Filter/Type.php +++ b/app/code/Magento/Email/Block/Adminhtml/Template/Grid/Filter/Type.php @@ -36,12 +36,22 @@ namespace Magento\Email\Block\Adminhtml\Template\Grid\Filter; class Type extends \Magento\Backend\Block\Widget\Grid\Column\Filter\Select { + /** + * Email template types + * + * @var array + */ protected static $_types = array( null => null, \Magento\Email\Model\Template::TYPE_HTML => 'HTML', \Magento\Email\Model\Template::TYPE_TEXT => 'Text', ); + /** + * Get options + * + * @return array + */ protected function _getOptions() { $result = array(); @@ -52,7 +62,11 @@ class Type extends \Magento\Backend\Block\Widget\Grid\Column\Filter\Select return $result; } - + /** + * Get condition + * + * @return array|null + */ public function getCondition() { if (is_null($this->getValue())) { diff --git a/app/code/Magento/Email/Block/Adminhtml/Template/Grid/Renderer/Action.php b/app/code/Magento/Email/Block/Adminhtml/Template/Grid/Renderer/Action.php index 10f4c1b9df7802d3540b40aa225008ed25c90b87..bf5e253a6dc0577cce3fa9b9e4b28d504f58e86d 100644 --- a/app/code/Magento/Email/Block/Adminhtml/Template/Grid/Renderer/Action.php +++ b/app/code/Magento/Email/Block/Adminhtml/Template/Grid/Renderer/Action.php @@ -36,6 +36,12 @@ namespace Magento\Email\Block\Adminhtml\Template\Grid\Renderer; class Action extends \Magento\Backend\Block\Widget\Grid\Column\Renderer\Action { + /** + * Render grid column + * + * @param \Magento\Object $row + * @return string + */ public function render(\Magento\Object $row) { $actions = array(); @@ -51,11 +57,23 @@ class Action extends \Magento\Backend\Block\Widget\Grid\Column\Renderer\Action return parent::render($row); } + /** + * Get escaped value + * + * @param string $value + * @return string + */ protected function _getEscapedValue($value) { return addcslashes(htmlspecialchars($value), '\\\''); } + /** + * Convert actions to html + * + * @param array $actions + * @return string + */ protected function _actionsToHtml(array $actions) { $html = array(); diff --git a/app/code/Magento/Email/Block/Adminhtml/Template/Grid/Renderer/Sender.php b/app/code/Magento/Email/Block/Adminhtml/Template/Grid/Renderer/Sender.php index f3897d7082944b85c9e97fc6168f225d3910be87..e90bd3c1e2287111a03adba5f6fdf37bc076db69 100644 --- a/app/code/Magento/Email/Block/Adminhtml/Template/Grid/Renderer/Sender.php +++ b/app/code/Magento/Email/Block/Adminhtml/Template/Grid/Renderer/Sender.php @@ -36,6 +36,12 @@ namespace Magento\Email\Block\Adminhtml\Template\Grid\Renderer; class Sender extends \Magento\Backend\Block\Widget\Grid\Column\Renderer\AbstractRenderer { + /** + * Render grid column + * + * @param \Magento\Object $row + * @return string + */ public function render(\Magento\Object $row) { $str = ''; diff --git a/app/code/Magento/Email/Block/Adminhtml/Template/Grid/Renderer/Type.php b/app/code/Magento/Email/Block/Adminhtml/Template/Grid/Renderer/Type.php index c9c684057ae8f83dc46cfca5bda75a62a7a90cf5..ee1b23251f131c9fd72512712960dfb24fb73896 100644 --- a/app/code/Magento/Email/Block/Adminhtml/Template/Grid/Renderer/Type.php +++ b/app/code/Magento/Email/Block/Adminhtml/Template/Grid/Renderer/Type.php @@ -36,11 +36,22 @@ namespace Magento\Email\Block\Adminhtml\Template\Grid\Renderer; class Type extends \Magento\Backend\Block\Widget\Grid\Column\Renderer\AbstractRenderer { + /** + * Email template types + * + * @var array + */ protected static $_types = array( \Magento\Email\Model\Template::TYPE_HTML => 'HTML', \Magento\Email\Model\Template::TYPE_TEXT => 'Text', ); + /** + * Render grid column + * + * @param \Magento\Object $row + * @return string + */ public function render(\Magento\Object $row) { diff --git a/app/code/Magento/Email/Controller/Adminhtml/Email/Template.php b/app/code/Magento/Email/Controller/Adminhtml/Email/Template.php index 96172ff08e5f31ea843da7c67e300be6d599da7b..a41a6e1d3aeba0f1a75d304e9fd52ab85d1f4455 100644 --- a/app/code/Magento/Email/Controller/Adminhtml/Email/Template.php +++ b/app/code/Magento/Email/Controller/Adminhtml/Email/Template.php @@ -54,6 +54,11 @@ class Template extends \Magento\Backend\App\Action parent::__construct($context); } + /** + * Index action + * + * @return void + */ public function indexAction() { $this->_title->add(__('Email Templates')); @@ -69,6 +74,11 @@ class Template extends \Magento\Backend\App\Action $this->_view->renderLayout(); } + /** + * Grid action + * + * @return void + */ public function gridAction() { $this->_view->loadLayout(false); @@ -78,6 +88,7 @@ class Template extends \Magento\Backend\App\Action /** * New transactional email action * + * @return void */ public function newAction() { @@ -85,8 +96,9 @@ class Template extends \Magento\Backend\App\Action } /** - * Edit transactioanl email action + * Edit transactional email action * + * @return void */ public function editAction() { @@ -110,6 +122,11 @@ class Template extends \Magento\Backend\App\Action $this->_view->renderLayout(); } + /** + * Save transactional email action + * + * @return void + */ public function saveAction() { $request = $this->getRequest(); @@ -153,6 +170,11 @@ class Template extends \Magento\Backend\App\Action } + /** + * Delete transactional email action + * + * @return void + */ public function deleteAction() { $template = $this->_initTemplate('id'); @@ -185,6 +207,11 @@ class Template extends \Magento\Backend\App\Action $this->_redirect('adminhtml/*/'); } + /** + * Preview transactional email action + * + * @return void + */ public function previewAction() { $this->_view->loadLayout('systemPreview'); @@ -194,6 +221,7 @@ class Template extends \Magento\Backend\App\Action /** * Set template data to retrieve it in template info form * + * @return void */ public function defaultTemplateAction() { @@ -239,6 +267,11 @@ class Template extends \Magento\Backend\App\Action return $model; } + /** + * Check if user has enough privileges + * + * @return bool + */ protected function _isAllowed() { return $this->_authorization->isAllowed('Magento_Email::template'); diff --git a/app/code/Magento/Email/Model/Info.php b/app/code/Magento/Email/Model/Info.php index 2771807cd86335a3781b1c9e2ca48834c9537881..ce03de10015f8825a050812501518a3f32680c48 100644 --- a/app/code/Magento/Email/Model/Info.php +++ b/app/code/Magento/Email/Model/Info.php @@ -43,28 +43,28 @@ class Info extends \Magento\Object /** * Name list of "Bcc" recipients * - * @var array + * @var string[] */ protected $_bccNames = array(); /** * Email list of "Bcc" recipients * - * @var array + * @var string[] */ protected $_bccEmails = array(); /** * Name list of "To" recipients * - * @var array + * @var string[] */ protected $_toNames = array(); /** * Email list of "To" recipients * - * @var array + * @var string[] */ protected $_toEmails = array(); @@ -74,7 +74,7 @@ class Info extends \Magento\Object * * @param string $email * @param string|null $name - * @return \Magento\Email\Model\Info + * @return $this */ public function addBcc($email, $name = null) { @@ -88,7 +88,7 @@ class Info extends \Magento\Object * * @param string $email * @param string|null $name - * @return \Magento\Email\Model\Info + * @return $this */ public function addTo($email, $name = null) { @@ -100,7 +100,7 @@ class Info extends \Magento\Object /** * Get the name list of "Bcc" recipients * - * @return array + * @return string[] */ public function getBccNames() { @@ -110,7 +110,7 @@ class Info extends \Magento\Object /** * Get the email list of "Bcc" recipients * - * @return array + * @return string[] */ public function getBccEmails() { @@ -120,7 +120,7 @@ class Info extends \Magento\Object /** * Get the name list of "To" recipients * - * @return array + * @return string[] */ public function getToNames() { @@ -130,7 +130,7 @@ class Info extends \Magento\Object /** * Get the email list of "To" recipients * - * @return array + * @return string[] */ public function getToEmails() { diff --git a/app/code/Magento/Email/Model/Resource/Template/Collection.php b/app/code/Magento/Email/Model/Resource/Template/Collection.php index 757089e275b3a892071ccaabd744a8d142b543da..0d24dd495c00c3bbdd791b574e79b4574c446cd3 100644 --- a/app/code/Magento/Email/Model/Resource/Template/Collection.php +++ b/app/code/Magento/Email/Model/Resource/Template/Collection.php @@ -23,7 +23,7 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ - +namespace Magento\Email\Model\Resource\Template; /** * Templates collection @@ -32,8 +32,6 @@ * @package Magento_Email * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\Email\Model\Resource\Template; - class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractCollection { /** @@ -46,6 +44,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractCol /** * Define resource table * + * @return void */ public function _construct() { diff --git a/app/code/Magento/Email/Model/Sender.php b/app/code/Magento/Email/Model/Sender.php index 3257793d48f100bda51b7a59426958cd4a1ff576..568d3a259c81a0b50170dc7847bd466a577f8f88 100644 --- a/app/code/Magento/Email/Model/Sender.php +++ b/app/code/Magento/Email/Model/Sender.php @@ -66,7 +66,7 @@ class Sender * @param string $sender * @param array $templateParams * @param int $storeId - * @return \Magento\Email\Model\Sender + * @return $this */ public function send($email, $name, $template, $sender, $templateParams, $storeId) { diff --git a/app/code/Magento/Email/Model/Source/Variables.php b/app/code/Magento/Email/Model/Source/Variables.php index 7883218e43b4cf12dafc858028745e1e00214973..4539d2ed5466884b79eb1a196a873647225379de 100644 --- a/app/code/Magento/Email/Model/Source/Variables.php +++ b/app/code/Magento/Email/Model/Source/Variables.php @@ -128,7 +128,7 @@ class Variables implements \Magento\Core\Model\Option\ArrayInterface /** * Retrieve option array of store contact variables * - * @param boolean $withGroup + * @param bool $withGroup * @return array */ public function toOptionArray($withGroup = false) diff --git a/app/code/Magento/Email/Model/Template.php b/app/code/Magento/Email/Model/Template.php index 253424a039b08e6b91721c4c73e43d92b1727e13..dc53c0b5a734a3f91892137abe466e0afdea0676 100644 --- a/app/code/Magento/Email/Model/Template.php +++ b/app/code/Magento/Email/Model/Template.php @@ -26,6 +26,10 @@ namespace Magento\Email\Model; +use Magento\Core\Exception; +use Magento\Email\Model\Template\Filter; +use Magento\Filter\Template as FilterTemplate; + /** * Template model * @@ -82,10 +86,39 @@ class Template extends \Magento\Core\Model\Template */ const XML_PATH_SYSTEM_SMTP_DISABLE = 'system/smtp/disable'; + /** + * Email template filter + * + * @var Filter + */ protected $_templateFilter; + + /** + * Email template preprocessed flag + * + * @var bool + */ protected $_preprocessFlag = false; + + /** + * BCC list + * + * @var array + */ protected $_bcc = array(); + + /** + * Return path + * + * @var string + */ protected $_returnPath = ''; + + /** + * Reply address + * + * @var string + */ protected $_replyTo = ''; /** @@ -179,6 +212,8 @@ class Template extends \Magento\Core\Model\Template /** * Initialize email template model + * + * @return void */ protected function _construct() { @@ -249,10 +284,10 @@ class Template extends \Magento\Core\Model\Template /** * Declare template processing filter * - * @param \Magento\Filter\Template $filter - * @return \Magento\Email\Model\Template + * @param FilterTemplate $filter + * @return $this */ - public function setTemplateFilter(\Magento\Filter\Template $filter) + public function setTemplateFilter(FilterTemplate $filter) { $this->_templateFilter = $filter; return $this; @@ -261,7 +296,7 @@ class Template extends \Magento\Core\Model\Template /** * Get filter object for template processing log * - * @return \Magento\Email\Model\Template\Filter + * @return Filter */ public function getTemplateFilter() { @@ -276,8 +311,8 @@ class Template extends \Magento\Core\Model\Template /** * Load template by code * - * @param string $templateCode - * @return \Magento\Email\Model\Template + * @param string $templateCode + * @return $this */ public function loadByCode($templateCode) { @@ -289,7 +324,7 @@ class Template extends \Magento\Core\Model\Template * Load default email template * * @param string $templateId - * @return \Magento\Email\Model\Template + * @return $this */ public function loadDefault($templateId) { @@ -330,7 +365,7 @@ class Template extends \Magento\Core\Model\Template /** * Return template id * - * return int|null + * @return int|null */ public function getId() { @@ -433,9 +468,9 @@ class Template extends \Magento\Core\Model\Template /** * Get template code for include directive * - * @param string $template - * @param array $variables - * @return string + * @param string $template + * @param array $variables + * @return string */ public function getInclude($template, array $variables) { @@ -452,10 +487,10 @@ class Template extends \Magento\Core\Model\Template * * @SuppressWarnings(PHPMD.CyclomaticComplexity) * @SuppressWarnings(PHPMD.NPathComplexity) - * @param array|string $email E-mail(s) - * @param array|string|null $name receiver name(s) - * @param array $variables template variables - * @return boolean + * @param array|string $email E-mail(s) + * @param array|string|null $name receiver name(s) + * @param array $variables template variables + * @return boolean **/ public function send($email, $name = null, array $variables = array()) { @@ -555,14 +590,14 @@ class Template extends \Magento\Core\Model\Template /** * Send transactional email to recipient * - * @param int|string $templateId - * @param string|array $sender sender information, can be declared as part of config path - * @param string $email recipient email - * @param string $name recipient name - * @param array $vars variables which can be used in template - * @param int|null $storeId - * @return \Magento\Email\Model\Template - * @throws \Magento\Core\Exception + * @param int|string $templateId + * @param string|array $sender sender information, can be declared as part of config path + * @param string $email recipient email + * @param string $name recipient name + * @param array $vars variables which can be used in template + * @param int|null $storeId + * @return $this + * @throws Exception */ public function sendTransactional($templateId, $sender, $email, $name, $vars = array(), $storeId = null) { @@ -578,7 +613,7 @@ class Template extends \Magento\Core\Model\Template } if (!$this->getId()) { - throw new \Magento\Core\Exception(__('Invalid transactional email code: %1', $templateId)); + throw new Exception(__('Invalid transactional email code: %1', $templateId)); } if (!is_array($sender)) { @@ -603,9 +638,9 @@ class Template extends \Magento\Core\Model\Template /** * Process email subject * - * @param array $variables - * @return string - * @throws \Exception + * @param array $variables + * @return string + * @throws \Exception */ public function getProcessedTemplateSubject(array $variables) { @@ -634,7 +669,7 @@ class Template extends \Magento\Core\Model\Template * Add email BCC * * @param string|array $bcc - * @return \Magento\Email\Model\Template + * @return $this */ public function addBcc($bcc) { @@ -646,7 +681,7 @@ class Template extends \Magento\Core\Model\Template * Set Return Path * * @param string $email - * @return \Magento\Email\Model\Template + * @return $this */ public function setReturnPath($email) { @@ -658,7 +693,7 @@ class Template extends \Magento\Core\Model\Template * Add Reply-To header * * @param string $email - * @return \Magento\Email\Model\Template + * @return $this */ public function setReplyTo($email) { @@ -712,17 +747,17 @@ class Template extends \Magento\Core\Model\Template /** * Validate email template code * - * @throws \Magento\Core\Exception + * @throws Exception * @return \Magento\Email\Model\Template */ protected function _beforeSave() { $code = $this->getTemplateCode(); if (empty($code)) { - throw new \Magento\Core\Exception(__('The template Name must not be empty.')); + throw new Exception(__('The template Name must not be empty.')); } if ($this->_getResource()->checkCodeUsage($this)) { - throw new \Magento\Core\Exception(__('Duplicate Of Template Name')); + throw new Exception(__('Duplicate Of Template Name')); } return parent::_beforeSave(); } diff --git a/app/code/Magento/Email/Model/Template/Config/Reader.php b/app/code/Magento/Email/Model/Template/Config/Reader.php index c5a82f2d44eb45f826dfb7403046bce39bc570b2..b2e2dd25decf749f452cf4757de1ea54854a40c8 100644 --- a/app/code/Magento/Email/Model/Template/Config/Reader.php +++ b/app/code/Magento/Email/Model/Template/Config/Reader.php @@ -36,6 +36,16 @@ class Reader extends \Magento\Config\Reader\Filesystem '/config/template' => 'id', ); + /** + * @param \Magento\Config\FileResolverInterface $fileResolver + * @param Converter $converter + * @param SchemaLocator $schemaLocator + * @param \Magento\Config\ValidationStateInterface $validationState + * @param string $fileName + * @param array $idAttributes + * @param string $domDocumentClass + * @param string $defaultScope + */ public function __construct( \Magento\Config\FileResolverInterface $fileResolver, \Magento\Email\Model\Template\Config\Converter $converter, diff --git a/app/code/Magento/Email/Model/Template/Filter.php b/app/code/Magento/Email/Model/Template/Filter.php index 8e98c28d013a7b9f401878f26b3ddbba463b3479..a0bf661a8df9710547e75fb66a87954ec789049b 100644 --- a/app/code/Magento/Email/Model/Template/Filter.php +++ b/app/code/Magento/Email/Model/Template/Filter.php @@ -54,6 +54,11 @@ class Filter extends \Magento\Filter\Template */ protected $_modifiers = array('nl2br' => ''); + /** + * Store id + * + * @var int + */ protected $_storeId = null; /** @@ -165,7 +170,7 @@ class Filter extends \Magento\Filter\Template * Set use absolute links flag * * @param bool $flag - * @return \Magento\Email\Model\Template\Filter + * @return $this */ public function setUseAbsoluteLinks($flag) { @@ -178,7 +183,7 @@ class Filter extends \Magento\Filter\Template * Doesn't set anything intentionally, since SID is not allowed in any kind of emails * * @param bool $flag - * @return \Magento\Email\Model\Template\Filter + * @return $this */ public function setUseSessionInUrl($flag) { @@ -189,8 +194,8 @@ class Filter extends \Magento\Filter\Template /** * Setter * - * @param boolean $plainTemplateMode - * @return \Magento\Email\Model\Template\Filter + * @param bool $plainTemplateMode + * @return $this */ public function setPlainTemplateMode($plainTemplateMode) { @@ -201,8 +206,8 @@ class Filter extends \Magento\Filter\Template /** * Setter * - * @param integer $storeId - * @return \Magento\Email\Model\Template\Filter + * @param int $storeId + * @return $this */ public function setStoreId($storeId) { @@ -211,8 +216,7 @@ class Filter extends \Magento\Filter\Template } /** - * Getter - * if $_storeId is null return Design store id + * Getter. If $_storeId is null, return design store id. * * @return integer */ @@ -229,7 +233,7 @@ class Filter extends \Magento\Filter\Template * * @SuppressWarnings(PHPMD.CyclomaticComplexity) * @SuppressWarnings(PHPMD.NPathComplexity) - * @param array $construction + * @param string[] $construction * @return string */ public function blockDirective($construction) @@ -272,7 +276,7 @@ class Filter extends \Magento\Filter\Template /** * Retrieve layout html directive * - * @param array $construction + * @param string[] $construction * @return string */ public function layoutDirective($construction) @@ -351,7 +355,7 @@ class Filter extends \Magento\Filter\Template /** * Retrieve View URL directive * - * @param array $construction + * @param string[] $construction * @return string */ public function viewDirective($construction) @@ -364,7 +368,7 @@ class Filter extends \Magento\Filter\Template /** * Retrieve media file URL directive * - * @param array $construction + * @param string[] $construction * @return string */ public function mediaDirective($construction) @@ -378,7 +382,7 @@ class Filter extends \Magento\Filter\Template * Retrieve store URL directive * Support url and direct_url properties * - * @param array $construction + * @param string[] $construction * @return string */ public function storeDirective($construction) @@ -416,7 +420,7 @@ class Filter extends \Magento\Filter\Template * Supported options: * allowed_tags - Comma separated html tags that have not to be converted * - * @param array $construction + * @param string[] $construction * @return string */ public function escapehtmlDirective($construction) @@ -437,7 +441,7 @@ class Filter extends \Magento\Filter\Template /** * Var directive with modifiers support * - * @param array $construction + * @param string[] $construction * @return string */ public function varDirective($construction) @@ -515,7 +519,7 @@ class Filter extends \Magento\Filter\Template * {{protocol http="http://url" https="https://url"} * also allow additional parameter "store" * - * @param array $construction + * @param string[] $construction * @return string */ public function protocolDirective($construction) @@ -542,7 +546,7 @@ class Filter extends \Magento\Filter\Template /** * Store config directive * - * @param array $construction + * @param string[] $construction * @return string */ public function configDirective($construction) @@ -559,7 +563,7 @@ class Filter extends \Magento\Filter\Template /** * Custom Variable directive * - * @param array $construction + * @param string[] $construction * @return string */ public function customvarDirective($construction) diff --git a/app/code/Magento/Email/Model/Template/Mailer.php b/app/code/Magento/Email/Model/Template/Mailer.php index 33ba6d37218b1d4b3324c0fa4936da2ab2c2c78d..71ece3a2a82257e778e0875f2177868b07084f21 100644 --- a/app/code/Magento/Email/Model/Template/Mailer.php +++ b/app/code/Magento/Email/Model/Template/Mailer.php @@ -33,11 +33,13 @@ */ namespace Magento\Email\Model\Template; +use Magento\Email\Model\Info; + class Mailer extends \Magento\Object { /** * List of email infos - * @see \Magento\Email\Model\Info + * @see Info * * @var array */ @@ -65,10 +67,10 @@ class Mailer extends \Magento\Object /** * Add new email info to corresponding list * - * @param \Magento\Email\Model\Info $emailInfo - * @return \Magento\Email\Model\Template\Mailer + * @param Info $emailInfo + * @return $this */ - public function addEmailInfo(\Magento\Email\Model\Info $emailInfo) + public function addEmailInfo(Info $emailInfo) { $this->_emailInfos[] = $emailInfo; return $this; diff --git a/app/code/Magento/GoogleAdwords/Helper/Data.php b/app/code/Magento/GoogleAdwords/Helper/Data.php index 1e591c6df9521a49f5d7115e734a506abd2445e0..630af8755126962d90240357ce8b26f4821157d8 100644 --- a/app/code/Magento/GoogleAdwords/Helper/Data.php +++ b/app/code/Magento/GoogleAdwords/Helper/Data.php @@ -122,7 +122,7 @@ class Data extends \Magento\App\Helper\AbstractHelper /** * Retrieve language codes from config * - * @return array + * @return string[] */ public function getLanguageCodes() { diff --git a/app/code/Magento/GoogleAnalytics/Block/Ga.php b/app/code/Magento/GoogleAnalytics/Block/Ga.php index 4ae7079b03e056859bc6563e7fe826bf3db82143..a750442b4ffef255a6f12058a813eca96ce69413 100644 --- a/app/code/Magento/GoogleAnalytics/Block/Ga.php +++ b/app/code/Magento/GoogleAnalytics/Block/Ga.php @@ -23,7 +23,7 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ - +namespace Magento\GoogleAnalytics\Block; /** * GoogleAnalitics Page Block @@ -32,8 +32,6 @@ * @package Magento_GoogleAnalytics * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\GoogleAnalytics\Block; - class Ga extends \Magento\View\Element\Template { /** diff --git a/app/code/Magento/GoogleAnalytics/Helper/Data.php b/app/code/Magento/GoogleAnalytics/Helper/Data.php index efab6e45c169223f98c705aca0e161a716f500bd..ac8f2e4c6df62e668f2ecc3a88f895b4b0bb0702 100644 --- a/app/code/Magento/GoogleAnalytics/Helper/Data.php +++ b/app/code/Magento/GoogleAnalytics/Helper/Data.php @@ -23,7 +23,9 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\GoogleAnalytics\Helper; +use Magento\Core\Model\Store; /** * GoogleAnalytics data helper @@ -31,8 +33,6 @@ * @category Magento * @package Magento_GoogleAnalytics */ -namespace Magento\GoogleAnalytics\Helper; - class Data extends \Magento\App\Helper\AbstractHelper { /** @@ -63,7 +63,7 @@ class Data extends \Magento\App\Helper\AbstractHelper /** * Whether GA is ready to use * - * @param mixed $store + * @param null|string|bool|int|Store $store * @return bool */ public function isGoogleAnalyticsAvailable($store = null) diff --git a/app/code/Magento/GoogleAnalytics/Model/Observer.php b/app/code/Magento/GoogleAnalytics/Model/Observer.php index 2f0c53881df8f64b2b14bfe46ab63adf0f79cdb3..5ced639edb77f58c124ef5ef9238d2b9dca1b80a 100644 --- a/app/code/Magento/GoogleAnalytics/Model/Observer.php +++ b/app/code/Magento/GoogleAnalytics/Model/Observer.php @@ -23,7 +23,9 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\GoogleAnalytics\Model; +use Magento\Event\Observer as EventObserver; /** * Google Analytics module observer @@ -31,8 +33,6 @@ * @category Magento * @package Magento_GoogleAnalytics */ -namespace Magento\GoogleAnalytics\Model; - class Observer { /** @@ -76,9 +76,10 @@ class Observer /** * Add order information into GA block to render on checkout success pages * - * @param \Magento\Event\Observer $observer + * @param EventObserver $observer + * @return void */ - public function setGoogleAnalyticsOnOrderSuccessPageView(\Magento\Event\Observer $observer) + public function setGoogleAnalyticsOnOrderSuccessPageView(EventObserver $observer) { $orderIds = $observer->getEvent()->getOrderIds(); if (empty($orderIds) || !is_array($orderIds)) { @@ -98,9 +99,10 @@ class Observer * There should be no tracking if there is no GA available * This method assumes that the observer instance is run as a "singleton" * - * @param \Magento\Event\Observer $observer + * @param EventObserver $observer + * @return void */ - public function injectAnalyticsInGoogleCheckoutLink(\Magento\Event\Observer $observer) + public function injectAnalyticsInGoogleCheckoutLink(EventObserver $observer) { $block = $observer->getEvent()->getBlock(); if (!$block || !$this->_googleAnalyticsData->isGoogleAnalyticsAvailable()) { diff --git a/app/code/Magento/GoogleCheckout/Model/Api/Xml/AbstractXml.php b/app/code/Magento/GoogleCheckout/Model/Api/Xml/AbstractXml.php index 47e7542bcca6158fe0608b773116edd19de3c2c9..5d7c97f621108ddbdc669376775a5b533e771201 100644 --- a/app/code/Magento/GoogleCheckout/Model/Api/Xml/AbstractXml.php +++ b/app/code/Magento/GoogleCheckout/Model/Api/Xml/AbstractXml.php @@ -36,7 +36,7 @@ require_once('googlecheckout/googlerequest.php'); abstract class AbstractXml extends \Magento\Object { /** - * @var \Magento\Core\Model\Translate + * @var \Magento\TranslateInterface */ protected $_translator; @@ -54,13 +54,13 @@ abstract class AbstractXml extends \Magento\Object /** * @param \Magento\ObjectManager $objectManager - * @param \Magento\Core\Model\Translate $translator + * @param \Magento\TranslateInterface $translator * @param \Magento\Core\Model\Store\Config $coreStoreConfig * @param array $data */ public function __construct( \Magento\ObjectManager $objectManager, - \Magento\Core\Model\Translate $translator, + \Magento\TranslateInterface $translator, \Magento\Core\Model\Store\Config $coreStoreConfig, array $data = array() ) { diff --git a/app/code/Magento/GoogleCheckout/Model/Api/Xml/Callback.php b/app/code/Magento/GoogleCheckout/Model/Api/Xml/Callback.php index 6a290b079ce99c429ee6953bf2ae5e9ec53ddcaa..16660063452caf7404c2b1cf0c61920c3780e90e 100644 --- a/app/code/Magento/GoogleCheckout/Model/Api/Xml/Callback.php +++ b/app/code/Magento/GoogleCheckout/Model/Api/Xml/Callback.php @@ -70,7 +70,7 @@ class Callback extends \Magento\GoogleCheckout\Model\Api\Xml\AbstractXml /** * @param \Magento\ObjectManager $objectManager - * @param \Magento\Core\Model\Translate $translator + * @param \Magento\TranslateInterface $translator * @param \Magento\Core\Model\Store\Config $coreStoreConfig * @param \Magento\Event\ManagerInterface $eventManager * @param \Magento\Core\Helper\Data $coreData @@ -82,7 +82,7 @@ class Callback extends \Magento\GoogleCheckout\Model\Api\Xml\AbstractXml */ public function __construct( \Magento\ObjectManager $objectManager, - \Magento\Core\Model\Translate $translator, + \Magento\TranslateInterface $translator, \Magento\Core\Model\Store\Config $coreStoreConfig, \Magento\Event\ManagerInterface $eventManager, \Magento\Core\Helper\Data $coreData, diff --git a/app/code/Magento/GoogleCheckout/Model/Api/Xml/Checkout.php b/app/code/Magento/GoogleCheckout/Model/Api/Xml/Checkout.php index 645726b737d0baf0c31264bd1cb2e6d4ad54d343..599e97d05a31f81b1f4085c166c6a848227a69a2 100644 --- a/app/code/Magento/GoogleCheckout/Model/Api/Xml/Checkout.php +++ b/app/code/Magento/GoogleCheckout/Model/Api/Xml/Checkout.php @@ -99,7 +99,7 @@ class Checkout extends \Magento\GoogleCheckout\Model\Api\Xml\AbstractXml /** * @param \Magento\ObjectManager $objectManager - * @param \Magento\Core\Model\Translate $translator + * @param \Magento\TranslateInterface $translator * @param \Magento\Core\Model\Store\Config $coreStoreConfig * @param \Magento\Event\ManagerInterface $eventManager * @param \Magento\Customer\Helper\Data $customerData @@ -111,7 +111,7 @@ class Checkout extends \Magento\GoogleCheckout\Model\Api\Xml\AbstractXml */ public function __construct( \Magento\ObjectManager $objectManager, - \Magento\Core\Model\Translate $translator, + \Magento\TranslateInterface $translator, \Magento\Core\Model\Store\Config $coreStoreConfig, \Magento\Event\ManagerInterface $eventManager, \Magento\Customer\Helper\Data $customerData, diff --git a/app/code/Magento/GoogleCheckout/Model/Payment.php b/app/code/Magento/GoogleCheckout/Model/Payment.php index 399b2899581518cd929e321b7ec1905bc9e046d3..6ebdafea5c9025d502f608bc633077e0ea1ef97a 100644 --- a/app/code/Magento/GoogleCheckout/Model/Payment.php +++ b/app/code/Magento/GoogleCheckout/Model/Payment.php @@ -46,7 +46,6 @@ class Payment extends \Magento\Payment\Model\Method\AbstractMethod protected $_canVoid = true; protected $_canUseInternal = false; protected $_canUseCheckout = false; - protected $_canUseForMultishipping = false; /** * @var \Magento\GoogleCheckout\Model\ApiFactory diff --git a/app/code/Magento/GoogleOptimizer/Block/Adminhtml/AbstractTab.php b/app/code/Magento/GoogleOptimizer/Block/Adminhtml/AbstractTab.php index 35265a5025449605a32349cd446d110aebb75337..b6069c8ec6d196906086614f65af78dfa43eec42 100644 --- a/app/code/Magento/GoogleOptimizer/Block/Adminhtml/AbstractTab.php +++ b/app/code/Magento/GoogleOptimizer/Block/Adminhtml/AbstractTab.php @@ -110,7 +110,7 @@ abstract class AbstractTab /** * Can show tab in tabs * - * @return boolean + * @return bool */ public function canShowTab() { @@ -120,7 +120,7 @@ abstract class AbstractTab /** * Tab is hidden * - * @return boolean + * @return bool */ public function isHidden() { diff --git a/app/code/Magento/GoogleOptimizer/Helper/Form.php b/app/code/Magento/GoogleOptimizer/Helper/Form.php index d8c1d908fc0b2ccba6e0683ec92028e7a6e06a77..6a8783e30ac4ec27e8620038ec6717539e331261 100644 --- a/app/code/Magento/GoogleOptimizer/Helper/Form.php +++ b/app/code/Magento/GoogleOptimizer/Helper/Form.php @@ -25,17 +25,21 @@ */ namespace Magento\GoogleOptimizer\Helper; +use Magento\GoogleOptimizer\Model\Code as ModelCode; +use Magento\Data\Form as DataForm; + class Form extends \Magento\App\Helper\AbstractHelper { /** * Prepare form * - * @param \Magento\Data\Form $form - * @param \Magento\GoogleOptimizer\Model\Code|null $experimentCodeModel + * @param DataForm $form + * @param Code|null $experimentCodeModel + * @return void */ public function addGoogleoptimizerFields( - \Magento\Data\Form $form, - \Magento\GoogleOptimizer\Model\Code $experimentCodeModel = null + DataForm $form, + ModelCode $experimentCodeModel = null ) { $fieldset = $form->addFieldset('googleoptimizer_fields', array( 'legend' => __('Google Analytics Content Experiments Code'), diff --git a/app/code/Magento/GoogleOptimizer/Model/Observer/AbstractSave.php b/app/code/Magento/GoogleOptimizer/Model/Observer/AbstractSave.php index 43078e3751e25bb091f9c1e47f897311643bbd76..e204596e2c3c4675d0eeff5d3785999daec06e68 100644 --- a/app/code/Magento/GoogleOptimizer/Model/Observer/AbstractSave.php +++ b/app/code/Magento/GoogleOptimizer/Model/Observer/AbstractSave.php @@ -25,6 +25,8 @@ */ namespace Magento\GoogleOptimizer\Model\Observer; +use Magento\Event\Observer; + abstract class AbstractSave { /** @@ -65,8 +67,8 @@ abstract class AbstractSave /** * Save script after saving entity * - * @param \Magento\Event\Observer $observer - * @return \Magento\GoogleOptimizer\Model\Observer\Category\Save + * @param Observer $observer + * @return $this * @throws \InvalidArgumentException */ public function saveGoogleExperimentScript($observer) @@ -83,12 +85,15 @@ abstract class AbstractSave /** * Init entity * - * @param \Magento\Event\Observer $observer + * @param Observer $observer + * @return void */ abstract protected function _initEntity($observer); /** * Check is Google Experiment enabled + * + * @return void */ protected function _isGoogleExperimentActive() { @@ -97,6 +102,8 @@ abstract class AbstractSave /** * Processes Save event of the entity + * + * @return void */ protected function _processCode() { @@ -117,6 +124,7 @@ abstract class AbstractSave /** * Init request params * + * @return void * @throws \InvalidArgumentException */ protected function _initRequestParams() @@ -140,6 +148,8 @@ abstract class AbstractSave /** * Save code model + * + * @return void */ protected function _saveCode() { @@ -157,6 +167,7 @@ abstract class AbstractSave /** * Load model code * + * @return void * @throws \InvalidArgumentException */ protected function _loadCode() @@ -180,6 +191,7 @@ abstract class AbstractSave /** * Delete model code * + * @return void * @throws \InvalidArgumentException */ protected function _deleteCode() diff --git a/app/code/Magento/GoogleOptimizer/Model/Observer/Block/Category/Tab.php b/app/code/Magento/GoogleOptimizer/Model/Observer/Block/Category/Tab.php index 12a2d1b75538cb1d2abfafad9c13c096e281dbb1..1809b46ac616efe0e579047a0f3f3bc8cb2a8d02 100644 --- a/app/code/Magento/GoogleOptimizer/Model/Observer/Block/Category/Tab.php +++ b/app/code/Magento/GoogleOptimizer/Model/Observer/Block/Category/Tab.php @@ -25,6 +25,8 @@ */ namespace Magento\GoogleOptimizer\Model\Observer\Block\Category; +use Magento\Event\Observer as EventObserver; + class Tab { /** @@ -52,9 +54,10 @@ class Tab /** * Adds Google Experiment tab to the category edit page * - * @param \Magento\Event\Observer $observer + * @param EventObserver $observer + * @return void */ - public function addGoogleExperimentTab(\Magento\Event\Observer $observer) + public function addGoogleExperimentTab(EventObserver $observer) { if ($this->_helper->isGoogleExperimentActive()) { $block = $this->_layout->createBlock( diff --git a/app/code/Magento/GoogleOptimizer/Model/Observer/Category/Save.php b/app/code/Magento/GoogleOptimizer/Model/Observer/Category/Save.php index 3eba65c878d794a9064d287b92765da71066bb49..b101c88567a0f75bad6c5c923bce4b88ece1ee68 100644 --- a/app/code/Magento/GoogleOptimizer/Model/Observer/Category/Save.php +++ b/app/code/Magento/GoogleOptimizer/Model/Observer/Category/Save.php @@ -25,6 +25,8 @@ */ namespace Magento\GoogleOptimizer\Model\Observer\Category; +use Magento\Event\Observer; + class Save extends \Magento\GoogleOptimizer\Model\Observer\AbstractSave { /** @@ -35,7 +37,8 @@ class Save extends \Magento\GoogleOptimizer\Model\Observer\AbstractSave /** * Init entity * - * @param \Magento\Event\Observer $observer + * @param Observer $observer + * @return void */ protected function _initEntity($observer) { @@ -44,6 +47,8 @@ class Save extends \Magento\GoogleOptimizer\Model\Observer\AbstractSave /** * Check is Google Experiment enabled + * + * @return bool */ protected function _isGoogleExperimentActive() { diff --git a/app/code/Magento/GoogleOptimizer/Model/Observer/CmsPage/Save.php b/app/code/Magento/GoogleOptimizer/Model/Observer/CmsPage/Save.php index 9258492b51724737e17270c09e5dfef0492528e9..aa6d9f52e79736362fe2eb038f32b963183640b3 100644 --- a/app/code/Magento/GoogleOptimizer/Model/Observer/CmsPage/Save.php +++ b/app/code/Magento/GoogleOptimizer/Model/Observer/CmsPage/Save.php @@ -25,6 +25,8 @@ */ namespace Magento\GoogleOptimizer\Model\Observer\CmsPage; +use Magento\Event\Observer; + class Save extends \Magento\GoogleOptimizer\Model\Observer\AbstractSave { /** @@ -35,7 +37,8 @@ class Save extends \Magento\GoogleOptimizer\Model\Observer\AbstractSave /** * Init entity * - * @param \Magento\Event\Observer $observer + * @param Observer $observer + * @return void */ protected function _initEntity($observer) { diff --git a/app/code/Magento/GoogleOptimizer/Model/Observer/Product/Save.php b/app/code/Magento/GoogleOptimizer/Model/Observer/Product/Save.php index ffeb5f21674c4c33bcd5fafedc51226d6d8b6349..730775393dd8f2cf93376a4f57978695b1994601 100644 --- a/app/code/Magento/GoogleOptimizer/Model/Observer/Product/Save.php +++ b/app/code/Magento/GoogleOptimizer/Model/Observer/Product/Save.php @@ -25,6 +25,8 @@ */ namespace Magento\GoogleOptimizer\Model\Observer\Product; +use Magento\Event\Observer; + class Save extends \Magento\GoogleOptimizer\Model\Observer\AbstractSave { /** @@ -35,7 +37,8 @@ class Save extends \Magento\GoogleOptimizer\Model\Observer\AbstractSave /** * Init entity * - * @param \Magento\Event\Observer $observer + * @param Observer $observer + * @return void */ protected function _initEntity($observer) { @@ -44,6 +47,8 @@ class Save extends \Magento\GoogleOptimizer\Model\Observer\AbstractSave /** * Check is Google Experiment enabled + * + * @return bool */ protected function _isGoogleExperimentActive() { diff --git a/app/code/Magento/GoogleOptimizer/Model/Resource/Code.php b/app/code/Magento/GoogleOptimizer/Model/Resource/Code.php index 8ebd1f1734da16dba5210a527b508a881c98909c..ce762a66b425982f4a0cfc8cba6719b6cbe7cfd6 100644 --- a/app/code/Magento/GoogleOptimizer/Model/Resource/Code.php +++ b/app/code/Magento/GoogleOptimizer/Model/Resource/Code.php @@ -29,6 +29,8 @@ class Code extends \Magento\Core\Model\Resource\Db\AbstractDb { /** * Resource initialization + * + * @return void */ protected function _construct() { diff --git a/app/code/Magento/GoogleShopping/Block/Adminhtml/Captcha.php b/app/code/Magento/GoogleShopping/Block/Adminhtml/Captcha.php index bee5c26b93a0992baeef70e86af26a2602067244..13abe3b3ac67a604df33a3a1f1a743ec8abadc2c 100644 --- a/app/code/Magento/GoogleShopping/Block/Adminhtml/Captcha.php +++ b/app/code/Magento/GoogleShopping/Block/Adminhtml/Captcha.php @@ -23,7 +23,7 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ - +namespace Magento\GoogleShopping\Block\Adminhtml; /** * Adminhtml Google Content Captcha challenge @@ -32,11 +32,11 @@ * @package Magento_GoogleShopping * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\GoogleShopping\Block\Adminhtml; - class Captcha extends \Magento\Backend\Block\Template { - + /** + * @var string + */ protected $_template = 'captcha.phtml'; /** diff --git a/app/code/Magento/GoogleShopping/Block/Adminhtml/Items.php b/app/code/Magento/GoogleShopping/Block/Adminhtml/Items.php index 07afc23b45551209c3c8954c64d15ef3c761bf2f..7802f85c95919d335a9d6ed9441ed7888047d073 100644 --- a/app/code/Magento/GoogleShopping/Block/Adminhtml/Items.php +++ b/app/code/Magento/GoogleShopping/Block/Adminhtml/Items.php @@ -23,6 +23,7 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\GoogleShopping\Block\Adminhtml; /** * Adminhtml Google Content Items Grids Container @@ -31,11 +32,11 @@ * @package Magento_GoogleShopping * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\GoogleShopping\Block\Adminhtml; - class Items extends \Magento\Backend\Block\Widget\Grid\Container { - + /** + * @var string + */ protected $_template = 'items.phtml'; /** @@ -59,11 +60,10 @@ class Items extends \Magento\Backend\Block\Widget\Grid\Container parent::__construct($context, $data); } - /** * Preparing layout * - * @return \Magento\GoogleShopping\Block\Adminhtml\Items + * @return $this */ protected function _prepareLayout() { diff --git a/app/code/Magento/GoogleShopping/Block/Adminhtml/Items/Item.php b/app/code/Magento/GoogleShopping/Block/Adminhtml/Items/Item.php index c8f0cf7b9441e888e6405c119eef741470a23f3f..51208848fed5d33afc620830b0bc821d7251520d 100644 --- a/app/code/Magento/GoogleShopping/Block/Adminhtml/Items/Item.php +++ b/app/code/Magento/GoogleShopping/Block/Adminhtml/Items/Item.php @@ -23,6 +23,7 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\GoogleShopping\Block\Adminhtml\Items; /** * Google Shopping Items @@ -31,8 +32,6 @@ * @package Magento_GoogleShopping * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\GoogleShopping\Block\Adminhtml\Items; - class Item extends \Magento\Backend\Block\Widget\Grid\Extended { /** @@ -68,7 +67,7 @@ class Item extends \Magento\Backend\Block\Widget\Grid\Extended /** * Prepare grid collection object * - * @return \Magento\GoogleShopping\Block\Adminhtml\Items\Item + * @return $this */ protected function _prepareCollection() { @@ -83,7 +82,7 @@ class Item extends \Magento\Backend\Block\Widget\Grid\Extended /** * Prepare grid columns * - * @return \Magento\GoogleShopping\Block\Adminhtml\Items\Item + * @return $this */ protected function _prepareColumns() { @@ -108,7 +107,7 @@ class Item extends \Magento\Backend\Block\Widget\Grid\Extended /** * Prepare grid massaction actions * - * @return \Magento\GoogleShopping\Block\Adminhtml\Items\Item + * @return $this */ protected function _prepareMassaction() { diff --git a/app/code/Magento/GoogleShopping/Block/Adminhtml/Items/Product.php b/app/code/Magento/GoogleShopping/Block/Adminhtml/Items/Product.php index f181435a6486ce98226ad30d5bc64ddf70a6d3cf..79052366144d34f309238f166092b75aaf91f3e9 100644 --- a/app/code/Magento/GoogleShopping/Block/Adminhtml/Items/Product.php +++ b/app/code/Magento/GoogleShopping/Block/Adminhtml/Items/Product.php @@ -23,6 +23,7 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\GoogleShopping\Block\Adminhtml\Items; /** * Products Grid to add to Google Content @@ -31,8 +32,6 @@ * @package Magento_GoogleShopping * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\GoogleShopping\Block\Adminhtml\Items; - class Product extends \Magento\Backend\Block\Widget\Grid\Extended { /** @@ -99,7 +98,7 @@ class Product extends \Magento\Backend\Block\Widget\Grid\Extended /** * Before rendering html, but after trying to load cache * - * @return \Magento\GoogleShopping\Block\Adminhtml\Items\Product + * @return $this */ protected function _beforeToHtml() { @@ -114,7 +113,7 @@ class Product extends \Magento\Backend\Block\Widget\Grid\Extended /** * Prepare grid collection object * - * @return \Magento\GoogleShopping\Block\Adminhtml\Items\Product + * @return $this */ protected function _prepareCollection() { @@ -142,7 +141,7 @@ class Product extends \Magento\Backend\Block\Widget\Grid\Extended /** * Prepare grid columns * - * @return \Magento\GoogleShopping\Block\Adminhtml\Items\Product + * @return $this */ protected function _prepareColumns() { @@ -202,7 +201,7 @@ class Product extends \Magento\Backend\Block\Widget\Grid\Extended /** * Prepare grid massaction actions * - * @return \Magento\GoogleShopping\Block\Adminhtml\Items\Product + * @return $this */ protected function _prepareMassaction() { @@ -229,7 +228,7 @@ class Product extends \Magento\Backend\Block\Widget\Grid\Extended /** * Get array with product ids, which was exported to Google Content * - * @return array + * @return int[] */ protected function _getGoogleShoppingProductIds() { diff --git a/app/code/Magento/GoogleShopping/Block/Adminhtml/Store/Switcher.php b/app/code/Magento/GoogleShopping/Block/Adminhtml/Store/Switcher.php index 92871b824d5dae3940712e4438cf90c82a9b4882..f01021eb463fbd99dc783cb2ecbabb2863304b46 100644 --- a/app/code/Magento/GoogleShopping/Block/Adminhtml/Store/Switcher.php +++ b/app/code/Magento/GoogleShopping/Block/Adminhtml/Store/Switcher.php @@ -23,6 +23,7 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\GoogleShopping\Block\Adminhtml\Store; /** * Adminhtml GoogleShopping Store Switcher @@ -31,8 +32,6 @@ * @package Magento_GoogleShopping * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\GoogleShopping\Block\Adminhtml\Store; - class Switcher extends \Magento\Backend\Block\Store\Switcher { /** @@ -44,6 +43,8 @@ class Switcher extends \Magento\Backend\Block\Store\Switcher /** * Set overridden params + * + * @return void */ protected function _construct() { diff --git a/app/code/Magento/GoogleShopping/Block/Adminhtml/Types/Edit.php b/app/code/Magento/GoogleShopping/Block/Adminhtml/Types/Edit.php index e809f3732029bd3d60770f2b5841c754fcf3770d..6cb7e0e3b533948e5f76f28cc24d310f667f5c28 100644 --- a/app/code/Magento/GoogleShopping/Block/Adminhtml/Types/Edit.php +++ b/app/code/Magento/GoogleShopping/Block/Adminhtml/Types/Edit.php @@ -23,13 +23,11 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\GoogleShopping\Block\Adminhtml\Types; /** * Adminhtml Google Content Types Mapping form block */ - -namespace Magento\GoogleShopping\Block\Adminhtml\Types; - class Edit extends \Magento\Backend\Block\Widget\Form\Container { /** diff --git a/app/code/Magento/GoogleShopping/Block/Adminhtml/Types/Edit/Attributes.php b/app/code/Magento/GoogleShopping/Block/Adminhtml/Types/Edit/Attributes.php index 5c672c324842b7cf9c4ae4a5034b710ba720d0d1..44f13b22c161265d83510e5da0c7005b875a95a1 100644 --- a/app/code/Magento/GoogleShopping/Block/Adminhtml/Types/Edit/Attributes.php +++ b/app/code/Magento/GoogleShopping/Block/Adminhtml/Types/Edit/Attributes.php @@ -23,6 +23,7 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\GoogleShopping\Block\Adminhtml\Types\Edit; /** * Attributes box for Google Content attributes mapping @@ -31,12 +32,12 @@ * @package Magento_GoogleShopping * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\GoogleShopping\Block\Adminhtml\Types\Edit; - class Attributes extends \Magento\Backend\Block\Widget\Form\Renderer\Fieldset\Element { - + /** + * @var string + */ protected $_template = 'types/edit/attributes.phtml'; /** @@ -160,7 +161,7 @@ class Attributes /** * Build HTML select element of attribute set attributes * - * @param boolean $escapeJsQuotes + * @param bool $escapeJsQuotes * @return string */ public function getAttributesSelectHtml($escapeJsQuotes = false) @@ -197,7 +198,7 @@ class Attributes * Skip attributes not needed for Google Content * * @param int $setId - * @param boolean $escapeJsQuotes + * @param bool $escapeJsQuotes * @return array */ public function _getAttributes($setId, $escapeJsQuotes = false) diff --git a/app/code/Magento/GoogleShopping/Block/Adminhtml/Types/Edit/Form.php b/app/code/Magento/GoogleShopping/Block/Adminhtml/Types/Edit/Form.php index 866b7d32c0b07703bccbc83b2d0d2c9c59968e18..22de2d2926fde2238136cf5fb9368e3353ec3669 100644 --- a/app/code/Magento/GoogleShopping/Block/Adminhtml/Types/Edit/Form.php +++ b/app/code/Magento/GoogleShopping/Block/Adminhtml/Types/Edit/Form.php @@ -23,13 +23,11 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\GoogleShopping\Block\Adminhtml\Types\Edit; /** * Adminhtml Google Content types mapping form block */ - -namespace Magento\GoogleShopping\Block\Adminhtml\Types\Edit; - class Form extends \Magento\Backend\Block\Widget\Form\Generic { /** diff --git a/app/code/Magento/GoogleShopping/Block/Adminhtml/Types/Edit/Select.php b/app/code/Magento/GoogleShopping/Block/Adminhtml/Types/Edit/Select.php index 048b0617a34dd56a41721418b096e1c99bfea6f2..b25265b5eaf84bfa3d669b6b8ca152cc153da25b 100644 --- a/app/code/Magento/GoogleShopping/Block/Adminhtml/Types/Edit/Select.php +++ b/app/code/Magento/GoogleShopping/Block/Adminhtml/Types/Edit/Select.php @@ -23,6 +23,7 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\GoogleShopping\Block\Adminhtml\Types\Edit; /** * Adminhtml Google Content attributes select block @@ -31,11 +32,10 @@ * @package Magento_GoogleShopping * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\GoogleShopping\Block\Adminhtml\Types\Edit; - class Select extends \Magento\Backend\Block\Template { - + /** + * @var string + */ protected $_template = 'types/edit/select.phtml'; - } diff --git a/app/code/Magento/GoogleShopping/Block/Adminhtml/Types/Renderer/Country.php b/app/code/Magento/GoogleShopping/Block/Adminhtml/Types/Renderer/Country.php index e2dbee1d98fd386cb4c6ff60ea66e32c743a274b..3b3d9268aaa3555837dad85afd3e9123a54f94c1 100644 --- a/app/code/Magento/GoogleShopping/Block/Adminhtml/Types/Renderer/Country.php +++ b/app/code/Magento/GoogleShopping/Block/Adminhtml/Types/Renderer/Country.php @@ -23,7 +23,7 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ - +namespace Magento\GoogleShopping\Block\Adminhtml\Types\Renderer; /** * Adminhtml Google Content Item Type Country Renderer @@ -32,8 +32,6 @@ * @package Magento_Adminhtml * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\GoogleShopping\Block\Adminhtml\Types\Renderer; - class Country extends \Magento\Backend\Block\Widget\Grid\Column\Renderer\AbstractRenderer { @@ -44,15 +42,15 @@ class Country */ protected $_config; - /** - * @param \Magento\Backend\Block\Context $context - * @param \Magento\GoogleShopping\Model\Config $config - * @param array $data + /** + * @param \Magento\Backend\Block\Context $context + * @param \Magento\GoogleShopping\Model\Config $config + * @param array $data */ - public function __construct( - \Magento\Backend\Block\Context $context, - \Magento\GoogleShopping\Model\Config $config, - array $data = array() + public function __construct( + \Magento\Backend\Block\Context $context, + \Magento\GoogleShopping\Model\Config $config, + array $data = array() ) { $this->_config = $config; parent::__construct($context, $data); diff --git a/app/code/Magento/GoogleShopping/Block/SiteVerification.php b/app/code/Magento/GoogleShopping/Block/SiteVerification.php index e5a538dc5c87d7396c1d68cc6b893a2d975dcec3..e126a7ecac4ca905d10b61fb84e8947f2b614218 100644 --- a/app/code/Magento/GoogleShopping/Block/SiteVerification.php +++ b/app/code/Magento/GoogleShopping/Block/SiteVerification.php @@ -21,8 +21,8 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ - namespace Magento\GoogleShopping\Block; + use Magento\View\Element\AbstractBlock; /** @@ -48,7 +48,7 @@ class SiteVerification extends \Magento\View\Element\AbstractBlock } /** - * @inheritdoc + * {@inheritdoc} * * @return string */ diff --git a/app/code/Magento/GoogleShopping/Controller/Adminhtml/Googleshopping/Items.php b/app/code/Magento/GoogleShopping/Controller/Adminhtml/Googleshopping/Items.php index 7ebed7d7a60771bc18414970a62c1584159fe327..55a1171577e564b8ee919c74b6ceca0ab49c8a3e 100644 --- a/app/code/Magento/GoogleShopping/Controller/Adminhtml/Googleshopping/Items.php +++ b/app/code/Magento/GoogleShopping/Controller/Adminhtml/Googleshopping/Items.php @@ -23,6 +23,7 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\GoogleShopping\Controller\Adminhtml\Googleshopping; /** * GoogleShopping Admin Items Controller @@ -32,14 +33,12 @@ * @name \Magento\GoogleShopping\Controller\Adminhtml\Googleshopping\Items * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\GoogleShopping\Controller\Adminhtml\Googleshopping; - class Items extends \Magento\Backend\App\Action { /** * Initialize general settings for action * - * @return \Magento\GoogleShopping\Controller\Adminhtml\Googleshopping\Items + * @return $this */ protected function _initAction() { @@ -52,6 +51,8 @@ class Items extends \Magento\Backend\App\Action /** * Manage Items page with two item grids: Magento products and Google Content items + * + * @return void */ public function indexAction() { @@ -99,6 +100,8 @@ class Items extends \Magento\Backend\App\Action /** * Grid with Google Content items + * + * @return void */ public function gridAction() { @@ -123,6 +126,8 @@ class Items extends \Magento\Backend\App\Action /** * Add (export) several products to Google Content + * + * @return void */ public function massAddAction() { @@ -165,6 +170,8 @@ class Items extends \Magento\Backend\App\Action /** * Delete products from Google Content + * + * @return void */ public function massDeleteAction() { @@ -205,6 +212,8 @@ class Items extends \Magento\Backend\App\Action /** * Update items statistics and remove the items which are not available in Google Content + * + * @return void */ public function refreshAction() { @@ -245,6 +254,8 @@ class Items extends \Magento\Backend\App\Action /** * Confirm CAPTCHA + * + * @return void */ public function confirmCaptchaAction() { @@ -298,6 +309,7 @@ class Items extends \Magento\Backend\App\Action * Redirect user to Google Captcha challenge * * @param \Zend_Gdata_App_CaptchaRequiredException $e + * @return void */ protected function _redirectToCaptcha($e) { diff --git a/app/code/Magento/GoogleShopping/Controller/Adminhtml/Googleshopping/Selection.php b/app/code/Magento/GoogleShopping/Controller/Adminhtml/Googleshopping/Selection.php index ae3778f381fbce24838b9b16b71aee072ec98cdf..48880767a85793e98951ecf10eb720ea09f48c00 100644 --- a/app/code/Magento/GoogleShopping/Controller/Adminhtml/Googleshopping/Selection.php +++ b/app/code/Magento/GoogleShopping/Controller/Adminhtml/Googleshopping/Selection.php @@ -23,6 +23,7 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\GoogleShopping\Controller\Adminhtml\Googleshopping; /** * GoogleShopping Products selection grid controller @@ -31,12 +32,12 @@ * @package Magento_GoogleShopping * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\GoogleShopping\Controller\Adminhtml\Googleshopping; - class Selection extends \Magento\Backend\App\Action { /** * Search result grid with available products for Google Content + * + * @return void */ public function searchAction() { @@ -51,6 +52,8 @@ class Selection extends \Magento\Backend\App\Action /** * Grid with available products for Google Content + * + * @return void */ public function gridAction() { diff --git a/app/code/Magento/GoogleShopping/Controller/Adminhtml/Googleshopping/Types.php b/app/code/Magento/GoogleShopping/Controller/Adminhtml/Googleshopping/Types.php index bf72e4884d765e4794128406684897aa141ffe99..0eb1cc36f19d4c2237050e675dc449b8f0127250 100644 --- a/app/code/Magento/GoogleShopping/Controller/Adminhtml/Googleshopping/Types.php +++ b/app/code/Magento/GoogleShopping/Controller/Adminhtml/Googleshopping/Types.php @@ -23,14 +23,13 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ - -/** - * GoogleShopping Admin Item Types Controller -*/ namespace Magento\GoogleShopping\Controller\Adminhtml\Googleshopping; use Magento\App\RequestInterface; +/** + * GoogleShopping Admin Item Types Controller +*/ class Types extends \Magento\Backend\App\Action { /** @@ -74,7 +73,7 @@ class Types extends \Magento\Backend\App\Action /** * Initialize attribute set mapping object * - * @return \Magento\GoogleShopping\Controller\Adminhtml\Googleshopping\Types + * @return $this */ protected function _initItemType() { @@ -92,7 +91,7 @@ class Types extends \Magento\Backend\App\Action /** * Initialize general settings for action * - * @return \Magento\GoogleShopping\Controller\Adminhtml\Googleshopping\Items + * @return $this */ protected function _initAction() { @@ -105,6 +104,8 @@ class Types extends \Magento\Backend\App\Action /** * List of all maps (items) + * + * @return void */ public function indexAction() { @@ -117,6 +118,8 @@ class Types extends \Magento\Backend\App\Action /** * Grid for AJAX request + * + * @return void */ public function gridAction() { @@ -126,6 +129,8 @@ class Types extends \Magento\Backend\App\Action /** * Create new attribute set mapping + * + * @return void */ public function newAction() { @@ -149,6 +154,8 @@ class Types extends \Magento\Backend\App\Action /** * Edit attribute set mapping + * + * @return void */ public function editAction() { @@ -187,6 +194,8 @@ class Types extends \Magento\Backend\App\Action /** * Save attribute set mapping + * + * @return void */ public function saveAction() { @@ -245,6 +254,8 @@ class Types extends \Magento\Backend\App\Action /** * Delete attribute set mapping + * + * @return void */ public function deleteAction() { @@ -265,6 +276,8 @@ class Types extends \Magento\Backend\App\Action /** * Get Google Content attributes list + * + * @return void */ public function loadAttributesAction() { @@ -285,6 +298,8 @@ class Types extends \Magento\Backend\App\Action /** * Get available attribute sets + * + * @return void */ protected function loadAttributeSetsAction() { diff --git a/app/code/Magento/GoogleShopping/Helper/Category.php b/app/code/Magento/GoogleShopping/Helper/Category.php index 55729b7dacab275579bafd54fd0c829f37ff820e..095371631a8c599e7523bc708008e3b1c950088f 100644 --- a/app/code/Magento/GoogleShopping/Helper/Category.php +++ b/app/code/Magento/GoogleShopping/Helper/Category.php @@ -23,6 +23,7 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\GoogleShopping\Helper; /** * Google Product Category helper @@ -31,8 +32,6 @@ * @package Magento_GoogleShopping * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\GoogleShopping\Helper; - class Category { const CATEGORY_APPAREL = 'Apparel & Accessories'; @@ -47,7 +46,8 @@ class Category /** * Retrieve list of Google Product Categories * - * @return array + * @param bool $addOther + * @return string[] */ public function getCategories($addOther = true) { diff --git a/app/code/Magento/GoogleShopping/Helper/Product.php b/app/code/Magento/GoogleShopping/Helper/Product.php index 109c32368872817b281ae66f24e8022c0c0487b2..9196ab269d422227e183cdb37b516ca9e5feec44 100644 --- a/app/code/Magento/GoogleShopping/Helper/Product.php +++ b/app/code/Magento/GoogleShopping/Helper/Product.php @@ -23,6 +23,7 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\GoogleShopping\Helper; /** * Google Content Product Helper @@ -31,8 +32,6 @@ * @package Magento_GoogleShopping * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\GoogleShopping\Helper; - class Product extends \Magento\App\Helper\AbstractHelper { /** diff --git a/app/code/Magento/GoogleShopping/Model/Attribute.php b/app/code/Magento/GoogleShopping/Model/Attribute.php index 76f050ff02523c9447a188f7479fc8f9967f5e85..ee98f4a13c844cdd88730e4acb1d6bd5a199d54e 100644 --- a/app/code/Magento/GoogleShopping/Model/Attribute.php +++ b/app/code/Magento/GoogleShopping/Model/Attribute.php @@ -23,6 +23,7 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\GoogleShopping\Model; /** * Attributes Model @@ -31,14 +32,12 @@ * @package Magento_GoogleShopping * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\GoogleShopping\Model; - class Attribute extends \Magento\Core\Model\AbstractModel { /** * Default ignored attribute codes * - * @var array + * @var string[] */ protected $_ignoredAttributeCodes = array( 'custom_design', @@ -65,7 +64,7 @@ class Attribute extends \Magento\Core\Model\AbstractModel /** * Default ignored attribute types * - * @var array + * @var string[] */ protected $_ignoredAttributeTypes = array('hidden', 'media_image', 'image', 'gallery'); @@ -118,9 +117,11 @@ class Attribute extends \Magento\Core\Model\AbstractModel $this->_gsProduct = $gsProduct; $this->catalogPrice = $catalogPrice; parent::__construct($context, $registry, $resource, $resourceCollection, $data); - } + /** + * @return void + */ protected function _construct() { $this->_init('Magento\GoogleShopping\Model\Resource\Attribute'); @@ -158,8 +159,7 @@ class Attribute extends \Magento\Core\Model\AbstractModel * Check if attribute allowed * * @param \Magento\Eav\Model\Entity\Attribute\AbstractAttribute $attribute - * @param array $attributes - * @return boolean + * @return bool */ protected function _isAllowedAttribute($attribute) { diff --git a/app/code/Magento/GoogleShopping/Model/Attribute/Availability.php b/app/code/Magento/GoogleShopping/Model/Attribute/Availability.php index ad3b0d86dd1dbc3f5fe74697093fbe5d6b04a11a..d09cdaa20e168ee550fd0574f41c26cc0229da45 100644 --- a/app/code/Magento/GoogleShopping/Model/Attribute/Availability.php +++ b/app/code/Magento/GoogleShopping/Model/Attribute/Availability.php @@ -23,6 +23,7 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\GoogleShopping\Model\Attribute; /** * Availability attribute model @@ -31,10 +32,11 @@ * @package Magento_GoogleShopping * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\GoogleShopping\Model\Attribute; - class Availability extends \Magento\GoogleShopping\Model\Attribute\DefaultAttribute { + /** + * @var array + */ protected $_googleAvailabilityMap = array( 0 => 'out of stock', 1 => 'in stock' diff --git a/app/code/Magento/GoogleShopping/Model/Attribute/ContentLanguage.php b/app/code/Magento/GoogleShopping/Model/Attribute/ContentLanguage.php index 79f0efcaab0f2c38a8d709e3443a5d16421acde8..01a96861e447af791dfcc5cb62c65a13e8373bd9 100644 --- a/app/code/Magento/GoogleShopping/Model/Attribute/ContentLanguage.php +++ b/app/code/Magento/GoogleShopping/Model/Attribute/ContentLanguage.php @@ -23,6 +23,7 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\GoogleShopping\Model\Attribute; /** * Content language attribute's model @@ -31,8 +32,6 @@ * @package Magento_GoogleShopping * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\GoogleShopping\Model\Attribute; - class ContentLanguage extends \Magento\GoogleShopping\Model\Attribute\DefaultAttribute { /** diff --git a/app/code/Magento/GoogleShopping/Model/Attribute/Destinations.php b/app/code/Magento/GoogleShopping/Model/Attribute/Destinations.php index 3e6b35ced1e167e97d1f505e09c424eb9bb44297..fb3a8378f17b9c69214fe3ac55d55308faa35280 100644 --- a/app/code/Magento/GoogleShopping/Model/Attribute/Destinations.php +++ b/app/code/Magento/GoogleShopping/Model/Attribute/Destinations.php @@ -23,6 +23,7 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\GoogleShopping\Model\Attribute; /** * Control (destinations) attribute model @@ -31,8 +32,6 @@ * @package Magento_GoogleShopping * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\GoogleShopping\Model\Attribute; - class Destinations extends \Magento\GoogleShopping\Model\Attribute\DefaultAttribute { /** diff --git a/app/code/Magento/GoogleShopping/Model/Attribute/GoogleProductCategory.php b/app/code/Magento/GoogleShopping/Model/Attribute/GoogleProductCategory.php index 0150b87380a6bba4260e4cb21bb89bd80d72ef8e..6258d88110c99a88786097945f30ffc6498a508b 100644 --- a/app/code/Magento/GoogleShopping/Model/Attribute/GoogleProductCategory.php +++ b/app/code/Magento/GoogleShopping/Model/Attribute/GoogleProductCategory.php @@ -23,6 +23,7 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\GoogleShopping\Model\Attribute; /** * GoogleProductCategory attribute model @@ -31,8 +32,6 @@ * @package Magento_GoogleShopping * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\GoogleShopping\Model\Attribute; - class GoogleProductCategory extends \Magento\GoogleShopping\Model\Attribute\DefaultAttribute { /** diff --git a/app/code/Magento/GoogleShopping/Model/Attribute/ImageLink.php b/app/code/Magento/GoogleShopping/Model/Attribute/ImageLink.php index 317b7152f714add0f7e05b032112e115bbca1ee2..f05d2814fc7c25b54d8da4062781cfc514ddc257 100644 --- a/app/code/Magento/GoogleShopping/Model/Attribute/ImageLink.php +++ b/app/code/Magento/GoogleShopping/Model/Attribute/ImageLink.php @@ -23,6 +23,7 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\GoogleShopping\Model\Attribute; /** * Image link attribute model @@ -31,8 +32,6 @@ * @package Magento_GoogleShopping * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\GoogleShopping\Model\Attribute; - class ImageLink extends \Magento\GoogleShopping\Model\Attribute\DefaultAttribute { /** diff --git a/app/code/Magento/GoogleShopping/Model/Attribute/Link.php b/app/code/Magento/GoogleShopping/Model/Attribute/Link.php index 397ab5fb10f00480c909aeb428f49fca795ef495..a5cdea272839ded0a3d866922e9d328cf3e2ba94 100644 --- a/app/code/Magento/GoogleShopping/Model/Attribute/Link.php +++ b/app/code/Magento/GoogleShopping/Model/Attribute/Link.php @@ -23,6 +23,7 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\GoogleShopping\Model\Attribute; /** * Link attribute model @@ -31,8 +32,6 @@ * @package Magento_GoogleShopping * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\GoogleShopping\Model\Attribute; - class Link extends \Magento\GoogleShopping\Model\Attribute\DefaultAttribute { /** diff --git a/app/code/Magento/GoogleShopping/Model/Attribute/Price.php b/app/code/Magento/GoogleShopping/Model/Attribute/Price.php index 6c698d44e61f9729b130115dc4d36430040e6c4a..969735df7c3cad839553ad74134ad0677ccaabdf 100644 --- a/app/code/Magento/GoogleShopping/Model/Attribute/Price.php +++ b/app/code/Magento/GoogleShopping/Model/Attribute/Price.php @@ -23,6 +23,7 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\GoogleShopping\Model\Attribute; /** * Price attribute model @@ -31,8 +32,6 @@ * @package Magento_GoogleShopping * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\GoogleShopping\Model\Attribute; - class Price extends \Magento\GoogleShopping\Model\Attribute\DefaultAttribute { /** diff --git a/app/code/Magento/GoogleShopping/Model/Attribute/ProductType.php b/app/code/Magento/GoogleShopping/Model/Attribute/ProductType.php index ce24e44f5c5cc1ff4409f5d398715ec75ee56d7e..0d28c42396b7b179983bd3d3084efe4e3d9c90c1 100644 --- a/app/code/Magento/GoogleShopping/Model/Attribute/ProductType.php +++ b/app/code/Magento/GoogleShopping/Model/Attribute/ProductType.php @@ -23,6 +23,7 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\GoogleShopping\Model\Attribute; /** * ProductType attribute model @@ -31,8 +32,6 @@ * @package Magento_GoogleShopping * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\GoogleShopping\Model\Attribute; - class ProductType extends \Magento\GoogleShopping\Model\Attribute\DefaultAttribute { /** diff --git a/app/code/Magento/GoogleShopping/Model/Attribute/TargetCountry.php b/app/code/Magento/GoogleShopping/Model/Attribute/TargetCountry.php index d013b8bafa41da9b3c7124545ec42682feb8302f..ecffcee6fcd48dabb65f145b1b0e44bf29d3959f 100644 --- a/app/code/Magento/GoogleShopping/Model/Attribute/TargetCountry.php +++ b/app/code/Magento/GoogleShopping/Model/Attribute/TargetCountry.php @@ -23,6 +23,7 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\GoogleShopping\Model\Attribute; /** * Target country attribute model @@ -31,8 +32,6 @@ * @package Magento_GoogleShopping * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\GoogleShopping\Model\Attribute; - class TargetCountry extends \Magento\GoogleShopping\Model\Attribute\DefaultAttribute { /** diff --git a/app/code/Magento/GoogleShopping/Model/Attribute/Tax.php b/app/code/Magento/GoogleShopping/Model/Attribute/Tax.php index 9d35aa31adcb48823741f3ff655ab4a0930675ef..67dbaf904c7dac4cd70486a21aa0a1abf774d54e 100644 --- a/app/code/Magento/GoogleShopping/Model/Attribute/Tax.php +++ b/app/code/Magento/GoogleShopping/Model/Attribute/Tax.php @@ -23,6 +23,7 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\GoogleShopping\Model\Attribute; /** * Tax attribute model @@ -31,8 +32,6 @@ * @package Magento_GoogleShopping * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\GoogleShopping\Model\Attribute; - class Tax extends \Magento\GoogleShopping\Model\Attribute\DefaultAttribute { /** @@ -143,7 +142,7 @@ class Tax extends \Magento\GoogleShopping\Model\Attribute\DefaultAttribute * * @param string $state * @param string $zip - * @return array + * @return string[] */ protected function _parseRegions($state, $zip) { @@ -154,7 +153,7 @@ class Tax extends \Magento\GoogleShopping\Model\Attribute\DefaultAttribute * Retrieve array of regions characterized by provided zip code * * @param string $zip - * @return array + * @return string[] */ protected function _parseZip($zip) { diff --git a/app/code/Magento/GoogleShopping/Model/AttributeFactory.php b/app/code/Magento/GoogleShopping/Model/AttributeFactory.php index 726f0737b4beaf616c9c814e9f7a8f8cdb87e8a8..0692f2ed7163cbeb5b9668ff75db5c5ba7bb0818 100644 --- a/app/code/Magento/GoogleShopping/Model/AttributeFactory.php +++ b/app/code/Magento/GoogleShopping/Model/AttributeFactory.php @@ -23,6 +23,7 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\GoogleShopping\Model; /** * Attributes Factory @@ -31,8 +32,6 @@ * @package Magento_GoogleShopping * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\GoogleShopping\Model; - class AttributeFactory { /** diff --git a/app/code/Magento/GoogleShopping/Model/Config.php b/app/code/Magento/GoogleShopping/Model/Config.php index 59fd2210160d0d8bdd82f7e79e3a26e42eadb5ac..91739a6b3ce6bcd51f0fa8d7f62a04130f025009 100644 --- a/app/code/Magento/GoogleShopping/Model/Config.php +++ b/app/code/Magento/GoogleShopping/Model/Config.php @@ -23,6 +23,7 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\GoogleShopping\Model; /** * Google Content Config model @@ -31,8 +32,6 @@ * @package Magento_GoogleShopping * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\GoogleShopping\Model; - class Config extends \Magento\Object { /** @@ -279,7 +278,7 @@ class Config extends \Magento\Object /** * Get array of base attribute names * - * @return array + * @return string[] */ public function getBaseAttributes() { diff --git a/app/code/Magento/GoogleShopping/Model/Flag.php b/app/code/Magento/GoogleShopping/Model/Flag.php index f489afd8ad1f81a5dcb4b46799bef83a82d7bc70..18eb91e618bbb167a4f76e2f7254700b7b5d2fd7 100644 --- a/app/code/Magento/GoogleShopping/Model/Flag.php +++ b/app/code/Magento/GoogleShopping/Model/Flag.php @@ -23,7 +23,7 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ - +namespace Magento\GoogleShopping\Model; /** * Google shopping synchronization operations flag @@ -32,8 +32,6 @@ * @package Magento_GoogleShopping * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\GoogleShopping\Model; - class Flag extends \Magento\Core\Model\Flag { /** @@ -50,6 +48,8 @@ class Flag extends \Magento\Core\Model\Flag /** * Lock flag + * + * @return void */ public function lock() { @@ -69,6 +69,8 @@ class Flag extends \Magento\Core\Model\Flag /** * Unlock flag + * + * @return void */ public function unlock() { diff --git a/app/code/Magento/GoogleShopping/Model/Item.php b/app/code/Magento/GoogleShopping/Model/Item.php index 7d2d357fd8a720c9873534e7c561ef00f027659e..55e11ba0c93a902ee681fb148026b84dc5cd4544 100644 --- a/app/code/Magento/GoogleShopping/Model/Item.php +++ b/app/code/Magento/GoogleShopping/Model/Item.php @@ -23,6 +23,9 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\GoogleShopping\Model; + +use Magento\Catalog\Model\Product as CatalogModelProduct; /** * Google Content Item Types Model @@ -31,8 +34,6 @@ * @package Magento_GoogleShopping * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\GoogleShopping\Model; - class Item extends \Magento\Core\Model\AbstractModel { /** @@ -106,7 +107,9 @@ class Item extends \Magento\Core\Model\AbstractModel parent::__construct($context, $registry, $resource, $resourceCollection, $data); } - + /** + * @return void + */ protected function _construct() { parent::_construct(); @@ -130,7 +133,7 @@ class Item extends \Magento\Core\Model\AbstractModel * Set Service Item Instance * * @param \Magento\GoogleShopping\Model\Service\Item $service - * @return \Magento\GoogleShopping\Model\Item + * @return $this */ public function setServiceItem($service) { @@ -151,10 +154,10 @@ class Item extends \Magento\Core\Model\AbstractModel /** * Save item to Google Content * - * @param \Magento\Catalog\Model\Product $product - * @return \Magento\GoogleShopping\Model\Item + * @param CatalogModelProduct $product + * @return $this */ - public function insertItem(\Magento\Catalog\Model\Product $product) + public function insertItem(CatalogModelProduct $product) { $this->setProduct($product); $this->getServiceItem() @@ -167,7 +170,7 @@ class Item extends \Magento\Core\Model\AbstractModel /** * Update Item data * - * @return \Magento\GoogleShopping\Model\Item + * @return $this */ public function updateItem() { @@ -181,7 +184,7 @@ class Item extends \Magento\Core\Model\AbstractModel /** * Delete Item from Google Content * - * @return \Magento\GoogleShopping\Model\Item + * @return $this */ public function deleteItem() { @@ -192,8 +195,8 @@ class Item extends \Magento\Core\Model\AbstractModel /** * Load Item Model by Product * - * @param \Magento\Catalog\Model\Product $product - * @return \Magento\GoogleShopping\Model\Item + * @param CatalogModelProduct $product + * @return $this */ public function loadByProduct($product) { @@ -229,7 +232,7 @@ class Item extends \Magento\Core\Model\AbstractModel /** * Product Getter. Load product if not exist. * - * @return \Magento\Catalog\Model\Product + * @return CatalogModelProduct */ public function getProduct() { @@ -244,10 +247,10 @@ class Item extends \Magento\Core\Model\AbstractModel /** * Product Setter. * - * @param \Magento\Catalog\Model\Product - * @return \Magento\GoogleShopping\Model\Item + * @param CatalogModelProduct $product + * @return $this */ - public function setProduct(\Magento\Catalog\Model\Product $product) + public function setProduct(CatalogModelProduct $product) { $this->setData('product', $product); $this->setProductId($product->getId()); diff --git a/app/code/Magento/GoogleShopping/Model/MassOperations.php b/app/code/Magento/GoogleShopping/Model/MassOperations.php index ece47613361dedc8053c98f035cdb637515d3831..74695060e8bdbe3ad5136f54a7335ed989877406 100644 --- a/app/code/Magento/GoogleShopping/Model/MassOperations.php +++ b/app/code/Magento/GoogleShopping/Model/MassOperations.php @@ -23,6 +23,10 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\GoogleShopping\Model; + +use Magento\Core\Exception as CoreException; +use Magento\GoogleShopping\Model\Resource\Item\Collection as ItemCollection; /** * Controller for mass opertions with items @@ -31,8 +35,6 @@ * @package Magento_GoogleShopping * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\GoogleShopping\Model; - class MassOperations { /** @@ -153,11 +155,11 @@ class MassOperations /** * Add product to Google Content. * - * @param array $productIds + * @param int[] $productIds * @param int $storeId * @throws \Zend_Gdata_App_CaptchaRequiredException - * @throws \Magento\Core\Exception - * @return \Magento\GoogleShopping\Model\MassOperations + * @throws CoreException + * @return $this */ public function addProducts($productIds, $storeId) { @@ -187,7 +189,7 @@ class MassOperations $message = __("The Google Content item for product '%1' (in '%2' store) already exists.", $product->getName(), $this->_storeManager->getStore($product->getStoreId())->getName()); } $errors[] = $message; - } catch (\Magento\Core\Exception $e) { + } catch (CoreException $e) { $errors[] = __('The product "%1" cannot be added to Google Content. %2', $product->getName(), $e->getMessage()); } catch (\Exception $e) { $this->_logger->logException($e); @@ -226,10 +228,10 @@ class MassOperations /** * Update Google Content items. * - * @param array|\Magento\GoogleShopping\Model\Resource\Item\Collection $items + * @param int[]|ItemCollection $items * @throws \Zend_Gdata_App_CaptchaRequiredException - * @throws \Magento\Core\Exception - * @return \Magento\GoogleShopping\Model\MassOperations + * @throws CoreException + * @return $this */ public function synchronizeItems($items) { @@ -270,7 +272,7 @@ class MassOperations $errors[] = $this->_gleShoppingData ->parseGdataExceptionMessage($e->getMessage(), $item->getProduct()); $totalFailed++; - } catch (\Magento\Core\Exception $e) { + } catch (CoreException $e) { $errors[] = __('The item "%1" cannot be updated at Google Content. %2', $item->getProduct()->getName(), $e->getMessage()); $totalFailed++; } catch (\Exception $e) { @@ -301,9 +303,9 @@ class MassOperations /** * Remove Google Content items. * - * @param array|\Magento\GoogleShopping\Model\Resource\Item\Collection $items + * @param int[]|ItemCollection $items * @throws \Zend_Gdata_App_CaptchaRequiredException - * @return \Magento\GoogleShopping\Model\MassOperations + * @return $this */ public function deleteItems($items) { @@ -356,14 +358,14 @@ class MassOperations /** * Return items collection by IDs * - * @param array|\Magento\GoogleShopping\Model\Resource\Item\Collection $items - * @throws \Magento\Core\Exception - * @return null|\Magento\GoogleShopping\Model\Resource\Item\Collection + * @param int[]|ItemCollection $items + * @throws CoreException + * @return null|ItemCollection */ protected function _getItemsCollection($items) { $itemsCollection = null; - if ($items instanceof \Magento\GoogleShopping\Model\Resource\Item\Collection) { + if ($items instanceof ItemCollection) { $itemsCollection = $items; } else if (is_array($items)) { $itemsCollection = $this->_collectionFactory->create()->addFieldToFilter('item_id', $items); @@ -384,6 +386,8 @@ class MassOperations /** * Provides general error information + * + * @return void */ protected function _addGeneralError() { diff --git a/app/code/Magento/GoogleShopping/Model/Resource/Item/Collection.php b/app/code/Magento/GoogleShopping/Model/Resource/Item/Collection.php index 3293aa42ae0b6afe5cc84c806036712308d878dd..7c5661aae954b12802b335e3a8be7463166e043f 100644 --- a/app/code/Magento/GoogleShopping/Model/Resource/Item/Collection.php +++ b/app/code/Magento/GoogleShopping/Model/Resource/Item/Collection.php @@ -23,6 +23,7 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\GoogleShopping\Model\Resource\Item; /** * Google Content items collection @@ -31,8 +32,6 @@ * @package Magento_GoogleShopping * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\GoogleShopping\Model\Resource\Item; - class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractCollection { /** @@ -74,6 +73,9 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl parent::__construct($entityFactory, $logger, $fetchStrategy, $eventManager, $connection, $resource); } + /** + * @return void + */ protected function _construct() { $this->_init('Magento\GoogleShopping\Model\Item', 'Magento\GoogleShopping\Model\Resource\Item'); @@ -82,7 +84,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl /** * Init collection select * - * @return \Magento\GoogleShopping\Model\Resource\Item\Collection + * @return $this */ protected function _initSelect() { @@ -95,7 +97,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl * Filter collection by specified store ids * * @param array|int $storeIds - * @return \Magento\GoogleShopping\Model\Resource\Item\Collection + * @return $this */ public function addStoreFilter($storeIds) { @@ -107,7 +109,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl * Filter collection by specified product id * * @param int $productId - * @return \Magento\GoogleShopping\Model\Resource\Item\Collection + * @return $this */ public function addProductFilterId($productId) { @@ -121,7 +123,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl * @see self::_getConditionSql for $condition * @param string $field * @param null|string|array $condition - * @return \Magento\Eav\Model\Entity\Collection\AbstractCollection + * @return $this */ public function addFieldToFilter($field, $condition=null) { @@ -139,7 +141,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl /** * Join product and type data * - * @return \Magento\GoogleShopping\Model\Resource\Item\Collection + * @return $this */ protected function _joinTables() { diff --git a/app/code/Magento/GoogleShopping/Model/Service.php b/app/code/Magento/GoogleShopping/Model/Service.php index 4f9a47d2a89e8be172f53ad4404b619015e4c428..af05e102dce160f76499824f282083684aa24b28 100644 --- a/app/code/Magento/GoogleShopping/Model/Service.php +++ b/app/code/Magento/GoogleShopping/Model/Service.php @@ -23,6 +23,7 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\GoogleShopping\Model; /** * Google Content Item Types Model @@ -31,8 +32,6 @@ * @package Magento_GoogleShopping * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\GoogleShopping\Model; - class Service extends \Magento\Object { /** @@ -107,7 +106,7 @@ class Service extends \Magento\Object * @param int $storeId * @param string $loginToken * @param string $loginCaptcha - * @throws \Magento\Core\Exception on http connection failure + * @throws \Magento\Core\Exception On http connection failure * @return \Zend_Http_Client */ public function getClient($storeId = null, $loginToken = null, $loginCaptcha = null) @@ -143,7 +142,7 @@ class Service extends \Magento\Object * Set Google Content Client Instance * * @param \Zend_Http_Client $client - * @return \Magento\GoogleShopping\Model\Service + * @return $this */ public function setClient($client) { @@ -176,7 +175,7 @@ class Service extends \Magento\Object * Set Google Content Service Instance * * @param \Magento\Gdata\Gshopping\Content $service - * @return \Magento\GoogleShopping\Model\Service + * @return $this */ public function setService($service) { diff --git a/app/code/Magento/GoogleShopping/Model/Service/Item.php b/app/code/Magento/GoogleShopping/Model/Service/Item.php index 7bb83c7f890ae1dc2e9027417a9b01403f0f6b17..97fb4588e4671bb2017cae6bd4c0470699cf728c 100644 --- a/app/code/Magento/GoogleShopping/Model/Service/Item.php +++ b/app/code/Magento/GoogleShopping/Model/Service/Item.php @@ -23,6 +23,7 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\GoogleShopping\Model\Service; /** * Google Content Item Model @@ -31,8 +32,6 @@ * @package Magento_GoogleShopping * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\GoogleShopping\Model\Service; - class Item extends \Magento\GoogleShopping\Model\Service { /** @@ -88,7 +87,7 @@ class Item extends \Magento\GoogleShopping\Model\Service * Insert Item into Google Content * * @param \Magento\GoogleShopping\Model\Item $item - * @return \Magento\GoogleShopping\Model\Service\Item + * @return $this */ public function insert($item) { @@ -115,7 +114,7 @@ class Item extends \Magento\GoogleShopping\Model\Service * Update Item data in Google Content * * @param \Magento\GoogleShopping\Model\Item $item - * @return \Magento\GoogleShopping\Model\Service\Item + * @return $this */ public function update($item) { @@ -137,7 +136,7 @@ class Item extends \Magento\GoogleShopping\Model\Service * Delete Item from Google Content * * @param \Magento\GoogleShopping\Model\Item $item - * @return \Magento\GoogleShopping\Model\Service\Item + * @return $this */ public function delete($item) { @@ -152,7 +151,7 @@ class Item extends \Magento\GoogleShopping\Model\Service * Convert Google Content date format to unix timestamp * Ex. 2008-12-08T16:57:23Z -> 2008-12-08 16:57:23 * - * @param string Google Content datetime + * @param string $gContentDate Google Content datetime * @return int */ public function convertContentDateToTimestamp($gContentDate) diff --git a/app/code/Magento/GoogleShopping/Model/Source/Accounttype.php b/app/code/Magento/GoogleShopping/Model/Source/Accounttype.php index 65b0104788f5a98a10a85c994bb541bc82c0de92..d11cd661133653b7a3bcba357b9db0d86b09828f 100644 --- a/app/code/Magento/GoogleShopping/Model/Source/Accounttype.php +++ b/app/code/Magento/GoogleShopping/Model/Source/Accounttype.php @@ -23,6 +23,7 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\GoogleShopping\Model\Source; /** * Google Data Api account types Source @@ -31,8 +32,6 @@ * @package Magento_GoogleShopping * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\GoogleShopping\Model\Source; - class Accounttype implements \Magento\Core\Model\Option\ArrayInterface { /** diff --git a/app/code/Magento/GoogleShopping/Model/Source/Authtype.php b/app/code/Magento/GoogleShopping/Model/Source/Authtype.php index 6b3263c810e787b4a2576f0bc1fe0b6a61540a09..3878f89c57f8807f43d27cca880234c687c3c867 100644 --- a/app/code/Magento/GoogleShopping/Model/Source/Authtype.php +++ b/app/code/Magento/GoogleShopping/Model/Source/Authtype.php @@ -23,6 +23,7 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\GoogleShopping\Model\Source; /** * Google Data Api authorization types Source @@ -31,8 +32,6 @@ * @package Magento_GoogleShopping * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\GoogleShopping\Model\Source; - class Authtype implements \Magento\Core\Model\Option\ArrayInterface { /** diff --git a/app/code/Magento/GoogleShopping/Model/Source/Country.php b/app/code/Magento/GoogleShopping/Model/Source/Country.php index 84a739c556fc6cf93a1af5e6e6731e1d0baf2475..6a7f0677af413c30de8b60d6ddf279c550fb38be 100644 --- a/app/code/Magento/GoogleShopping/Model/Source/Country.php +++ b/app/code/Magento/GoogleShopping/Model/Source/Country.php @@ -23,6 +23,7 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\GoogleShopping\Model\Source; /** * Google Content Target country Source @@ -31,8 +32,6 @@ * @package Magento_GoogleShopping * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\GoogleShopping\Model\Source; - class Country implements \Magento\Core\Model\Option\ArrayInterface { /** diff --git a/app/code/Magento/GoogleShopping/Model/Source/Destinationstates.php b/app/code/Magento/GoogleShopping/Model/Source/Destinationstates.php index 2d4d6d86305d2deb526072069e7ad8cd62747e45..855425ececa87c4e81cd43cd99f5f811ba8e306a 100644 --- a/app/code/Magento/GoogleShopping/Model/Source/Destinationstates.php +++ b/app/code/Magento/GoogleShopping/Model/Source/Destinationstates.php @@ -23,6 +23,7 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\GoogleShopping\Model\Source; /** * Google Data Api destination states @@ -31,8 +32,6 @@ * @package Magento_GoogleShopping * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\GoogleShopping\Model\Source; - class Destinationstates implements \Magento\Core\Model\Option\ArrayInterface { /** diff --git a/app/code/Magento/GoogleShopping/Model/Source/Statuses.php b/app/code/Magento/GoogleShopping/Model/Source/Statuses.php index 1f2a0a741d5c976e9fa14c4e55d9ffde61cbfd34..cd9a2efd155a80500a54324603f6a76fbae96392 100644 --- a/app/code/Magento/GoogleShopping/Model/Source/Statuses.php +++ b/app/code/Magento/GoogleShopping/Model/Source/Statuses.php @@ -23,6 +23,7 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\GoogleShopping\Model\Source; /** * Google Content Item statues Source @@ -31,8 +32,6 @@ * @package Magento_GoogleShopping * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\GoogleShopping\Model\Source; - class Statuses { /** diff --git a/app/code/Magento/GoogleShopping/Model/Type.php b/app/code/Magento/GoogleShopping/Model/Type.php index 50055f649b2a44058b8edb1ac656e19a1a8842c6..833885012a45c05706243336680be85475959546 100644 --- a/app/code/Magento/GoogleShopping/Model/Type.php +++ b/app/code/Magento/GoogleShopping/Model/Type.php @@ -23,6 +23,10 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\GoogleShopping\Model; + +use Magento\Catalog\Model\Product as CatalogModelProduct; +use Magento\Gdata\Gshopping\Entry; /** * Google Content Item Types Model @@ -31,8 +35,6 @@ * @package Magento_GoogleShopping * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\GoogleShopping\Model; - class Type extends \Magento\Core\Model\AbstractModel { /** @@ -105,6 +107,9 @@ class Type extends \Magento\Core\Model\AbstractModel parent::__construct($context, $registry, $resource, $resourceCollection, $data); } + /** + * @return void + */ protected function _construct() { $this->_init('Magento\GoogleShopping\Model\Resource\Type'); @@ -126,8 +131,9 @@ class Type extends \Magento\Core\Model\AbstractModel /** * Prepare Entry data and attributes before saving in Google Content * - * @param \Magento\Gdata\Gshopping\Entry $entry - * @return \Magento\Gdata\Gshopping\Entry + * @param CatalogModelProduct $entry + * @param Entry $entry + * @return Entry */ public function convertProductToEntry($product, $entry) { @@ -147,10 +153,10 @@ class Type extends \Magento\Core\Model\AbstractModel /** * Return Product attribute values array * - * @param \Magento\Catalog\Model\Product $product + * @param CatalogModelProduct $product * @return array Product attribute values */ - protected function _getAttributesMapByProduct(\Magento\Catalog\Model\Product $product) + protected function _getAttributesMapByProduct(CatalogModelProduct $product) { $result = array(); $group = $this->_config->getAttributeGroupsFlat(); @@ -246,9 +252,9 @@ class Type extends \Magento\Core\Model\AbstractModel /** * Remove attributes which were removed from mapping. * - * @param \Magento\Gdata\Gshopping\Entry $entry - * @param array $existAttributes - * @return \Magento\Gdata\Gshopping\Entry + * @param Entry $entry + * @param string[] $existAttributes + * @return Entry */ protected function _removeNonexistentAttributes($entry, $existAttributes) { diff --git a/app/code/Magento/GroupedProduct/Model/Resource/Indexer/Stock/Grouped.php b/app/code/Magento/GroupedProduct/Model/Resource/Indexer/Stock/Grouped.php index 3b6586d84a043034d34fcb8ad067b485e2ea231d..39d5f8fdf4887f9a23a4bf60f9295bfa1d7252bb 100644 --- a/app/code/Magento/GroupedProduct/Model/Resource/Indexer/Stock/Grouped.php +++ b/app/code/Magento/GroupedProduct/Model/Resource/Indexer/Stock/Grouped.php @@ -34,14 +34,13 @@ */ namespace Magento\GroupedProduct\Model\Resource\Indexer\Stock; -class Grouped - extends \Magento\CatalogInventory\Model\Resource\Indexer\Stock\DefaultStock +class Grouped extends \Magento\CatalogInventory\Model\Resource\Indexer\Stock\DefaultStock { /** * Reindex stock data for defined configurable product ids * * @param int|array $entityIds - * @return \Magento\GroupedProduct\Model\Resource\Indexer\Stock\Grouped + * @return $this */ public function reindexEntity($entityIds) { diff --git a/app/code/Magento/Log/Model/Cron.php b/app/code/Magento/Log/Model/Cron.php index e91a67a935d27e3590489c3e2e2cfd3e1cea2a2a..e2a34618db1addc65dd3a9c6414adcf91e9a1240 100644 --- a/app/code/Magento/Log/Model/Cron.php +++ b/app/code/Magento/Log/Model/Cron.php @@ -56,7 +56,7 @@ class Cron extends \Magento\Core\Model\AbstractModel protected $_coreStoreConfig; /** - * @var \Magento\Core\Model\Translate + * @var \Magento\TranslateInterface */ protected $_translate; @@ -81,7 +81,7 @@ class Cron extends \Magento\Core\Model\AbstractModel * @param \Magento\Email\Model\TemplateFactory $templateFactory * @param \Magento\Log\Model\Log $log * @param \Magento\Core\Model\StoreManagerInterface $storeManager - * @param \Magento\Core\Model\Translate $translate + * @param \Magento\TranslateInterface $translate * @param \Magento\Core\Model\Store\Config $coreStoreConfig * @param \Magento\Core\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection @@ -93,7 +93,7 @@ class Cron extends \Magento\Core\Model\AbstractModel \Magento\Email\Model\TemplateFactory $templateFactory, \Magento\Log\Model\Log $log, \Magento\Core\Model\StoreManagerInterface $storeManager, - \Magento\Core\Model\Translate $translate, + \Magento\TranslateInterface $translate, \Magento\Core\Model\Store\Config $coreStoreConfig, \Magento\Core\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, diff --git a/app/code/Magento/Multishipping/Block/Checkout/Addresses.php b/app/code/Magento/Multishipping/Block/Checkout/Addresses.php index 6c089de62afc0a39ac59fd3d27874f92826b382c..803b20dc4c50bbe3f4054a3c4b6548f7baf617cf 100644 --- a/app/code/Magento/Multishipping/Block/Checkout/Addresses.php +++ b/app/code/Magento/Multishipping/Block/Checkout/Addresses.php @@ -184,7 +184,7 @@ class Addresses extends \Magento\Sales\Block\Items\AbstractItems */ public function getBackUrl() { - return $this->getUrl('*/cart/'); + return $this->getUrl('checkout/cart/'); } /** diff --git a/app/code/Magento/Multishipping/Block/Checkout/Billing.php b/app/code/Magento/Multishipping/Block/Checkout/Billing.php index 55fc5a4cf353fbdc7432c59dfb019a14f61cba3d..2f9d70364b18cd5b2425ab864deb9f152537f752 100644 --- a/app/code/Magento/Multishipping/Block/Checkout/Billing.php +++ b/app/code/Magento/Multishipping/Block/Checkout/Billing.php @@ -45,11 +45,17 @@ class Billing extends \Magento\Payment\Block\Form\Container */ protected $_checkoutSession; + /** + * @var \Magento\Payment\Model\Method\SpecificationInterface + */ + protected $paymentSpecification; + /** * @param \Magento\View\Element\Template\Context $context * @param \Magento\Payment\Helper\Data $paymentHelper * @param \Magento\Multishipping\Model\Checkout\Type\Multishipping $multishipping * @param \Magento\Checkout\Model\Session $checkoutSession + * @param \Magento\Payment\Model\Method\SpecificationInterface $paymentSpecification * @param array $data */ public function __construct( @@ -57,10 +63,12 @@ class Billing extends \Magento\Payment\Block\Form\Container \Magento\Payment\Helper\Data $paymentHelper, \Magento\Multishipping\Model\Checkout\Type\Multishipping $multishipping, \Magento\Checkout\Model\Session $checkoutSession, + \Magento\Payment\Model\Method\SpecificationInterface $paymentSpecification, array $data = array() ) { $this->_multishipping = $multishipping; $this->_checkoutSession = $checkoutSession; + $this->paymentSpecification = $paymentSpecification; parent::__construct($context, $paymentHelper, $data); $this->_isScopePrivate = true; } @@ -88,7 +96,8 @@ class Billing extends \Magento\Payment\Block\Form\Container */ protected function _canUseMethod($method) { - return $method && $method->canUseForMultishipping() && parent::_canUseMethod($method); + return $method && $this->paymentSpecification->isSatisfiedBy($method->getCode()) + && parent::_canUseMethod($method); } /** diff --git a/app/code/Magento/Multishipping/Controller/Checkout.php b/app/code/Magento/Multishipping/Controller/Checkout.php index 9b1642fd76ca3603fcaeb39fd10a9030747da1df..9ba3998023516536dd7173701e7ad4e61302a502 100644 --- a/app/code/Magento/Multishipping/Controller/Checkout.php +++ b/app/code/Magento/Multishipping/Controller/Checkout.php @@ -414,8 +414,7 @@ class Checkout extends \Magento\Checkout\Controller\Action try { $payment = $this->getRequest()->getPost('payment', array()); - $payment['checks'] = \Magento\Payment\Model\Method\AbstractMethod::CHECK_USE_FOR_MULTISHIPPING - | \Magento\Payment\Model\Method\AbstractMethod::CHECK_USE_FOR_COUNTRY + $payment['checks'] = \Magento\Payment\Model\Method\AbstractMethod::CHECK_USE_FOR_COUNTRY | \Magento\Payment\Model\Method\AbstractMethod::CHECK_USE_FOR_CURRENCY | \Magento\Payment\Model\Method\AbstractMethod::CHECK_ORDER_TOTAL_MIN_MAX | \Magento\Payment\Model\Method\AbstractMethod::CHECK_ZERO_TOTAL; diff --git a/app/code/Magento/Multishipping/Controller/Checkout/Address.php b/app/code/Magento/Multishipping/Controller/Checkout/Address.php index a54a0847a66cc4dc400e8ec96d5c30677711c4a8..5e88dadc4b0d771dfb2d94100dae60e7e82deb60 100644 --- a/app/code/Magento/Multishipping/Controller/Checkout/Address.php +++ b/app/code/Magento/Multishipping/Controller/Checkout/Address.php @@ -112,7 +112,7 @@ class Address extends \Magento\App\Action\Action } if ($this->_getCheckout()->getCustomerDefaultShippingAddress()) { - $addressForm->setBackUrl($this->_url->getUrl('*/multishipping/shipping')); + $addressForm->setBackUrl($this->_url->getUrl('*/checkout/shipping')); } } $this->_view->renderLayout(); @@ -124,7 +124,7 @@ class Address extends \Magento\App\Action\Action $this->_objectManager->create('Magento\Multishipping\Model\Checkout\Type\Multishipping') ->updateQuoteCustomerShippingAddress($addressId); } - $this->_redirect('*/multishipping/shipping'); + $this->_redirect('*/checkout/shipping'); } public function selectBillingAction() diff --git a/app/code/Magento/Multishipping/Model/Checkout/Type/Multishipping.php b/app/code/Magento/Multishipping/Model/Checkout/Type/Multishipping.php index 27a560705c83f3c5f05a75a60da7e2ad2edbf2b1..7654d157f0c1df8e35ee08a7c27d98249f313262 100644 --- a/app/code/Magento/Multishipping/Model/Checkout/Type/Multishipping.php +++ b/app/code/Magento/Multishipping/Model/Checkout/Type/Multishipping.php @@ -76,6 +76,11 @@ class Multishipping extends \Magento\Checkout\Model\Type\AbstractType */ protected $_quote; + /** + * @var \Magento\Payment\Model\Method\SpecificationInterface + */ + protected $paymentSpecification; + /** * @param \Magento\Checkout\Model\Session $checkoutSession * @param \Magento\Customer\Model\Session $customerSession @@ -86,6 +91,7 @@ class Multishipping extends \Magento\Checkout\Model\Type\AbstractType * @param \Magento\Sales\Model\Quote\AddressFactory $addressFactory * @param \Magento\Sales\Model\Convert\Quote $quote * @param \Magento\Core\Model\StoreManagerInterface $storeManager + * @param \Magento\Payment\Model\Method\SpecificationInterface $paymentSpecification * @param array $data */ public function __construct( @@ -98,6 +104,7 @@ class Multishipping extends \Magento\Checkout\Model\Type\AbstractType \Magento\Sales\Model\Quote\AddressFactory $addressFactory, \Magento\Sales\Model\Convert\Quote $quote, \Magento\Core\Model\StoreManagerInterface $storeManager, + \Magento\Payment\Model\Method\SpecificationInterface $paymentSpecification, array $data = array() ) { $this->_eventManager = $eventManager; @@ -106,6 +113,7 @@ class Multishipping extends \Magento\Checkout\Model\Type\AbstractType $this->_addressFactory = $addressFactory; $this->_quote = $quote; $this->_storeManager = $storeManager; + $this->paymentSpecification = $paymentSpecification; parent::__construct($checkoutSession, $customerSession, $orderFactory, $data); $this->_init(); } @@ -463,6 +471,9 @@ class Multishipping extends \Magento\Checkout\Model\Type\AbstractType if (!isset($payment['method'])) { throw new \Magento\Core\Exception(__('Payment method is not defined')); } + if (!$this->paymentSpecification->isSatisfiedBy($payment['method'])) { + throw new \Magento\Core\Exception(__('The requested Payment Method is not available for multishipping.')); + } $quote = $this->getQuote(); $quote->getPayment()->importData($payment); // shipping totals may be affected by payment method @@ -533,9 +544,6 @@ class Multishipping extends \Magento\Checkout\Model\Type\AbstractType protected function _validate() { $quote = $this->getQuote(); - if (!$quote->getIsMultiShipping()) { - throw new \Magento\Core\Exception(__('Invalid checkout type')); - } /** @var $paymentMethod \Magento\Payment\Model\Method\AbstractMethod */ $paymentMethod = $quote->getPayment()->getMethodInstance(); diff --git a/app/code/Magento/Multishipping/Model/Payment/Method/Specification/Enabled.php b/app/code/Magento/Multishipping/Model/Payment/Method/Specification/Enabled.php new file mode 100644 index 0000000000000000000000000000000000000000..4ed3ece8da9073315b25ea5e7862a2392db8d388 --- /dev/null +++ b/app/code/Magento/Multishipping/Model/Payment/Method/Specification/Enabled.php @@ -0,0 +1,47 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Multishipping\Model\Payment\Method\Specification; + +use Magento\Payment\Model\Method\Specification\AbstractSpecification; + +/** + * Enable method specification + */ +class Enabled extends AbstractSpecification +{ + /** + * Allow multiple address flag + */ + const FLAG_ALLOW_MULTIPLE_ADDRESS = 'allow_multiple_address'; + + /** + * {@inheritdoc} + */ + public function isSatisfiedBy($paymentMethod) + { + return isset($this->methodsInfo[$paymentMethod][self::FLAG_ALLOW_MULTIPLE_ADDRESS]) + && $this->methodsInfo[$paymentMethod][self::FLAG_ALLOW_MULTIPLE_ADDRESS]; + } +} diff --git a/app/code/Magento/Multishipping/Model/Payment/Method/Specification/Is3DSecure.php b/app/code/Magento/Multishipping/Model/Payment/Method/Specification/Is3DSecure.php new file mode 100644 index 0000000000000000000000000000000000000000..bf722ea7c7738add99a5862ffeb3f2afd1811084 --- /dev/null +++ b/app/code/Magento/Multishipping/Model/Payment/Method/Specification/Is3DSecure.php @@ -0,0 +1,88 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Multishipping\Model\Payment\Method\Specification; + +use Magento\Payment\Model\Method\Specification\AbstractSpecification; +use Magento\Payment\Model\Config as PaymentConfig; +use Magento\Core\Model\Store\ConfigInterface as StoreConfig; + +/** + * 3D secure specification + */ +class Is3DSecure extends AbstractSpecification +{ + /** + * Allow multiple address with 3d secure flag + */ + const FLAG_ALLOW_MULTIPLE_WITH_3DSECURE = 'allow_multiple_with_3dsecure'; + + /**#@+ + * 3D Secure card validation store config paths + */ + const PATH_PAYMENT_3DSECURE = 'payment/%s/enable3ds'; + const PATH_PAYMENT_CENTINEL = 'payment/%s/centinel'; + /**#@-*/ + + /** + * Store config + * + * @var StoreConfig + */ + protected $storeConfig; + + /** + * Construct + * + * @param PaymentConfig $paymentConfig + * @param StoreConfig $storeConfig + */ + public function __construct(PaymentConfig $paymentConfig, StoreConfig $storeConfig) + { + parent::__construct($paymentConfig); + $this->storeConfig = $storeConfig; + } + + /** + * {@inheritdoc} + */ + public function isSatisfiedBy($paymentMethod) + { + $is3DSecureSupported = isset($this->methodsInfo[$paymentMethod][self::FLAG_ALLOW_MULTIPLE_WITH_3DSECURE]) + && $this->methodsInfo[$paymentMethod][self::FLAG_ALLOW_MULTIPLE_WITH_3DSECURE]; + return $is3DSecureSupported || !$this->is3DSecureEnabled($paymentMethod); + } + + /** + * Is 3DSecure enabled for payment method + * + * @param string $paymentMethod + * @return bool + */ + protected function is3DSecureEnabled($paymentMethod) + { + return $this->storeConfig->getConfigFlag(sprintf(self::PATH_PAYMENT_3DSECURE, $paymentMethod)) + || $this->storeConfig->getConfigFlag(sprintf(self::PATH_PAYMENT_CENTINEL, $paymentMethod)); + } +} diff --git a/app/code/Magento/Multishipping/etc/frontend/di.xml b/app/code/Magento/Multishipping/etc/frontend/di.xml index 1aafdd30e2f9a509c106e1c0c6d8c4d35f0423de..ea42a2ca7b490064134c60f49d541675f87189f0 100644 --- a/app/code/Magento/Multishipping/etc/frontend/di.xml +++ b/app/code/Magento/Multishipping/etc/frontend/di.xml @@ -31,4 +31,26 @@ </array> </param> </type> + <type name="Magento\Multishipping\Model\Checkout\Type\Multishipping"> + <param name="paymentSpecification"> + <instance type="Magento\Payment\Model\Method\Specification\Composite" /> + </param> + </type> + <type name="Magento\Multishipping\Block\Checkout\Billing"> + <param name="paymentSpecification"> + <instance type="Magento\Payment\Model\Method\Specification\Composite" /> + </param> + </type> + <type name="Magento\Payment\Model\Method\Specification\Composite"> + <param name="specifications"> + <array> + <item key="enabled"> + <value>Magento\Multishipping\Model\Payment\Method\Specification\Enabled</value> + </item> + <item key="3dsecure"> + <value>\Magento\Multishipping\Model\Payment\Method\Specification\Is3DSecure</value> + </item> + </array> + </param> + </type> </config> diff --git a/app/code/Magento/Newsletter/Model/Subscriber.php b/app/code/Magento/Newsletter/Model/Subscriber.php index 88ed9e1b16e5b1aabac7edbfc2c1283efda0eea4..904d27946bb3cf9a5bde341734f3be254f9bf918 100644 --- a/app/code/Magento/Newsletter/Model/Subscriber.php +++ b/app/code/Magento/Newsletter/Model/Subscriber.php @@ -111,7 +111,7 @@ class Subscriber extends \Magento\Core\Model\AbstractModel /** * Translate * - * @var \Magento\Core\Model\Translate + * @var \Magento\TranslateInterface */ protected $_translate; @@ -146,7 +146,7 @@ class Subscriber extends \Magento\Core\Model\AbstractModel * @param \Magento\Email\Model\TemplateFactory $emailTemplateFactory * @param \Magento\Customer\Model\CustomerFactory $customerFactory * @param \Magento\Core\Model\StoreManagerInterface $storeManager - * @param \Magento\Core\Model\Translate $translate + * @param \Magento\TranslateInterface $translate * @param \Magento\Customer\Model\Session $customerSession * @param \Magento\Core\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection @@ -160,7 +160,7 @@ class Subscriber extends \Magento\Core\Model\AbstractModel \Magento\Email\Model\TemplateFactory $emailTemplateFactory, \Magento\Customer\Model\CustomerFactory $customerFactory, \Magento\Core\Model\StoreManagerInterface $storeManager, - \Magento\Core\Model\Translate $translate, + \Magento\TranslateInterface $translate, \Magento\Customer\Model\Session $customerSession, \Magento\Core\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, diff --git a/app/code/Magento/Ogone/Model/Api.php b/app/code/Magento/Ogone/Model/Api.php index 3023d22cc73770cdd4efb5024cb02481407f48fa..d54fdbcb25dec913b187538b1291d4ded5d12f19 100644 --- a/app/code/Magento/Ogone/Model/Api.php +++ b/app/code/Magento/Ogone/Model/Api.php @@ -54,7 +54,6 @@ class Api extends \Magento\Payment\Model\Method\AbstractMethod protected $_canVoid = false; protected $_canUseInternal = false; protected $_canUseCheckout = true; - protected $_canUseForMultishipping = false; /** * "OUT" hash string components, correspond to the "IN" signature in Ogone. diff --git a/app/code/Magento/PageCache/Controller/Block.php b/app/code/Magento/PageCache/Controller/Block.php index 785a8bc714440b2f0f7cf4694c3ef42b34f3e2da..93acf9c4d12aae5e5bf5d9913630e3af6332fcc9 100644 --- a/app/code/Magento/PageCache/Controller/Block.php +++ b/app/code/Magento/PageCache/Controller/Block.php @@ -48,28 +48,16 @@ class Block extends \Magento\App\Action\Action $this->_view->loadLayout($handles); $data = array(); + $layout = $this->_view->getLayout(); foreach ($blocks as $blockName) { - $blockInstance = $this->_view->getLayout()->getBlock($blockName); + $blockInstance = $layout->getBlock($blockName); if (is_object($blockInstance)) { $data[$blockName] = $blockInstance->toHtml(); } } - $this->setPrivateHeaders(); + $layout->setIsPrivate(); $this->getResponse()->appendBody(json_encode($data)); } - - /** - * Set header parameters for private cache - */ - protected function setPrivateHeaders() - { - $this->getResponse()->setHeader('cache-control', 'private, max-age=' . Data::PRIVATE_MAX_AGE_CACHE, true); - $this->getResponse()->setHeader( - 'expires', - gmdate('D, d M Y H:i:s T', strtotime('+' . Data::PRIVATE_MAX_AGE_CACHE . ' seconds')), - true - ); - } } diff --git a/app/code/Magento/PageCache/Model/App/FrontController/HeaderPlugin.php b/app/code/Magento/PageCache/Model/App/FrontController/HeaderPlugin.php index 8a1d53e3e7abb96f1e29ad8a4df2d1de73891279..6995bbec41c058b04e474a9a1981743391abc6c1 100644 --- a/app/code/Magento/PageCache/Model/App/FrontController/HeaderPlugin.php +++ b/app/code/Magento/PageCache/Model/App/FrontController/HeaderPlugin.php @@ -78,11 +78,12 @@ class HeaderPlugin */ public function afterDispatch(\Magento\App\Response\Http $response) { + if ($this->layout->isPrivate()) { + $this->setPrivateHeaders($response); + return $response; + } if ($this->layout->isCacheable()) { - $response->setHeader('pragma', 'cache', true); - if(!$response->getHeader('cache-control')) { - $this->setPublicHeaders($response); - } + $this->setPublicHeaders($response); } else { $this->setNocacheHeaders($response); } @@ -96,6 +97,7 @@ class HeaderPlugin protected function setPublicHeaders(\Magento\App\Response\Http $response) { $maxAge = $this->helper->getPublicMaxAgeCache(); + $response->setHeader('pragma', 'cache', true); $response->setHeader('cache-control', 'public, max-age=' . $maxAge, true); $response->setHeader( 'expires', @@ -117,4 +119,20 @@ class HeaderPlugin true ); } + + /** + * Set header parameters for private cache + * + * @param \Magento\App\Response\Http $response + */ + protected function setPrivateHeaders(\Magento\App\Response\Http $response) + { + $response->setHeader('pragma', 'cache', true); + $response->setHeader('cache-control', 'private, max-age=' . Data::PRIVATE_MAX_AGE_CACHE, true); + $response->setHeader( + 'expires', + gmdate('D, d M Y H:i:s T', strtotime('+' . Data::PRIVATE_MAX_AGE_CACHE . ' seconds')), + true + ); + } } diff --git a/app/code/Magento/Payment/Helper/Data.php b/app/code/Magento/Payment/Helper/Data.php index 7afe081b5ce937a4fb148a1851997c78431a7071..42ee51a7f76f8d14e26d9bc18917133474125aef 100644 --- a/app/code/Magento/Payment/Helper/Data.php +++ b/app/code/Magento/Payment/Helper/Data.php @@ -70,7 +70,7 @@ class Data extends \Magento\App\Helper\AbstractHelper protected $_appEmulation; /** - * @var \Magento\Core\Model\Config\Initial + * @var \Magento\App\Config\Initial */ protected $_initialConfig; @@ -84,7 +84,7 @@ class Data extends \Magento\App\Helper\AbstractHelper * @param \Magento\App\ConfigInterface $config * @param \Magento\Core\Model\App\Emulation $appEmulation * @param \Magento\Payment\Model\Config $paymentConfig - * @param \Magento\Core\Model\Config\Initial $initialConfig + * @param \Magento\App\Config\Initial $initialConfig */ public function __construct( \Magento\App\Helper\Context $context, @@ -94,7 +94,7 @@ class Data extends \Magento\App\Helper\AbstractHelper \Magento\App\ConfigInterface $config, \Magento\Core\Model\App\Emulation $appEmulation, \Magento\Payment\Model\Config $paymentConfig, - \Magento\Core\Model\Config\Initial $initialConfig + \Magento\App\Config\Initial $initialConfig ) { parent::__construct($context); $this->_coreStoreConfig = $coreStoreConfig; @@ -267,7 +267,7 @@ class Data extends \Magento\App\Helper\AbstractHelper */ public function getPaymentMethods() { - return $this->_initialConfig->getDefault()[self::XML_PATH_PAYMENT_METHODS]; + return $this->_initialConfig->getData('default')[self::XML_PATH_PAYMENT_METHODS]; } /** diff --git a/app/code/Magento/Payment/Model/Cart.php b/app/code/Magento/Payment/Model/Cart.php new file mode 100644 index 0000000000000000000000000000000000000000..b475dad7d4eb92b374dfd5bf2a0fe23118ff4bef --- /dev/null +++ b/app/code/Magento/Payment/Model/Cart.php @@ -0,0 +1,416 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +/** + * Provide methods for collecting cart items information of specific sales model entity + */ +namespace Magento\Payment\Model; + +class Cart +{ + /**#@+ + * Amounts + */ + const AMOUNT_TAX = 'tax'; + const AMOUNT_SHIPPING = 'shipping'; + const AMOUNT_DISCOUNT = 'discount'; + const AMOUNT_SUBTOTAL = 'subtotal'; + /**@@+*/ + + /** + * Sales model + * + * @var \Magento\Payment\Model\Cart\SalesModel\SalesModelInterface + */ + protected $_salesModel; + + /** + * Core event manager proxy + * + * @var \Magento\Event\ManagerInterface + */ + protected $_eventManager; + + /** + * Amounts + * + * @var array + */ + protected $_amounts; + + /** + * Custom items list + * + * @var array + */ + protected $_customItems = array(); + + /** + * Items imported from sales model + * + * @var array + */ + protected $_salesModelItems = array(); + + /** + * Flags that indicates whether discount, shopping and taxes should be transferred as cart item + * + * @var array + */ + protected $_transferFlags = array(); + + /** + * Flags which indicates whether items data is outdated and has to be recollected + * + * @var bool + */ + protected $_itemsCollectingRequired = true; + + /** + * @param \Magento\Payment\Model\Cart\SalesModel\Factory $salesModelFactory + * @param \Magento\Event\ManagerInterface $eventManager + * @param \Magento\Sales\Model\Order|\Magento\Sales\Model\Quote $salesModel + */ + public function __construct( + \Magento\Payment\Model\Cart\SalesModel\Factory $salesModelFactory, + \Magento\Event\ManagerInterface $eventManager, + $salesModel + ) { + $this->_eventManager = $eventManager; + $this->_salesModel = $salesModelFactory->create($salesModel); + $this->_resetAmounts(); + } + + /** + * Return payment cart sales model + * + * @return \Magento\Payment\Model\Cart\SalesModel\SalesModelInterface + */ + public function getSalesModel() + { + return $this->_salesModel; + } + + /** + * Add amount to existing tax amount + * + * @param float $taxAmount + */ + public function addTax($taxAmount) + { + $this->_addAmount(self::AMOUNT_TAX, $taxAmount); + } + + /** + * Set tax. Old value will be overwritten + * + * @param float $taxAmount + */ + public function setTax($taxAmount) + { + $this->_setAmount(self::AMOUNT_TAX, $taxAmount); + } + + /** + * Get tax amount + * + * @return float + */ + public function getTax() + { + return $this->_getAmount(self::AMOUNT_TAX); + } + + /** + * Add amount to existing discount amount + * + * @param float $discountAmount + */ + public function addDiscount($discountAmount) + { + $this->_addAmount(self::AMOUNT_DISCOUNT, $discountAmount); + } + + /** + * Set discount. Old value will be overwritten + * + * @param float $discountAmount + */ + public function setDiscount($discountAmount) + { + $this->_setAmount(self::AMOUNT_DISCOUNT, $discountAmount); + } + + /** + * Get discount amount + * + * @return float + */ + public function getDiscount() + { + return $this->_getAmount(self::AMOUNT_DISCOUNT); + } + + /** + * Add amount to existing shipping amount + * + * @param float $shippingAmount + */ + public function addShipping($shippingAmount) + { + $this->_addAmount(self::AMOUNT_SHIPPING, $shippingAmount); + } + + /** + * Set shipping. Old value will be overwritten + * + * @param float $shippingAmount + */ + public function setShipping($shippingAmount) + { + $this->_setAmount(self::AMOUNT_SHIPPING, $shippingAmount); + } + + /** + * Get shipping amount + * + * @return float + */ + public function getShipping() + { + return $this->_getAmount(self::AMOUNT_SHIPPING); + } + + /** + * Add amount to existing subtotal amount + * + * @param float $subtotalAmount + */ + public function addSubtotal($subtotalAmount) + { + $this->_addAmount(self::AMOUNT_SUBTOTAL, $subtotalAmount); + } + + /** + * Get subtotal amount + * + * @return float + */ + public function getSubtotal() + { + return $this->_getAmount(self::AMOUNT_SUBTOTAL); + } + + /** + * Add custom item (such as discount as line item, shipping as line item, etc) + * + * @param string $name + * @param int $qty + * @param float $amount + * @param string|null $identifier + */ + public function addCustomItem($name, $qty, $amount, $identifier = null) + { + $this->_customItems[] = $this->_createItemFromData($name, $qty, $amount, $identifier); + } + + /** + * Get all cart items + * + * @return array + */ + public function getAllItems() + { + $this->_collectItemsAndAmounts(); + return array_merge($this->_salesModelItems, $this->_customItems); + } + + /** + * Get shipping, tax, subtotal and discount amounts all together + * + * @return array + */ + public function getAmounts() + { + $this->_collectItemsAndAmounts(); + + return $this->_amounts; + } + + /** + * Specify that shipping should be transferred as cart item + */ + public function setTransferShippingAsItem() + { + $this->_setTransferFlag(self::AMOUNT_SHIPPING, true); + } + + /** + * Specify that discount should be transferred as cart item + */ + public function setTransferDiscountAsItem() + { + $this->_setTransferFlag(self::AMOUNT_DISCOUNT, true); + } + + /** + * Collect all items, discounts, taxes, shipping to cart + */ + protected function _collectItemsAndAmounts() + { + if (!$this->_itemsCollectingRequired) { + return; + } + + $this->_itemsCollectingRequired = false; + + $this->_salesModelItems = array(); + $this->_customItems = array(); + + $this->_resetAmounts(); + + $this->_eventManager->dispatch('payment_cart_collect_items_and_amounts', array('cart' => $this)); + + $this->_importItemsFromSalesModel(); + $this->_calculateCustomItemsSubtotal(); + } + + /** + * Import items from sales model + */ + protected function _importItemsFromSalesModel() + { + $this->_salesModelItems = array(); + + foreach ($this->_salesModel->getAllItems() as $item) { + if ($item->getParentItem()) { + continue; + } + + $this->_salesModelItems[] = $this->_createItemFromData($item->getName(), $item->getQty(), + $item->getPrice()); + } + + $this->addSubtotal($this->_salesModel->getBaseSubtotal()); + $this->addTax($this->_salesModel->getBaseTaxAmount()); + $this->addShipping($this->_salesModel->getBaseShippingAmount()); + $this->addDiscount(abs($this->_salesModel->getBaseDiscountAmount())); + } + + /** + * Calculate subtotal from custom items + */ + protected function _calculateCustomItemsSubtotal() + { + if (!empty($this->_transferFlags[self::AMOUNT_DISCOUNT]) && $this->getDiscount()) { + $this->addCustomItem(__('Discount'), 1, -1.00 * $this->getDiscount()); + $this->setDiscount(0); + } + + if (!empty($this->_transferFlags[self::AMOUNT_SHIPPING]) && $this->getShipping()) { + $this->addCustomItem(__('Shipping'), 1, $this->getShipping()); + $this->setShipping(0); + } + + foreach ($this->_customItems as $item) { + $this->_amounts[self::AMOUNT_SUBTOTAL] += $item->getAmount(); + } + } + + /** + * @param string $flagType + * @param bool $value + */ + protected function _setTransferFlag($flagType, $value) + { + $this->_transferFlags[$flagType] = (bool)$value; + $this->_itemsCollectingRequired = true; + } + + /** + * @param string $amountType + * @param float $amount + */ + protected function _setAmount($amountType, $amount) + { + $this->_amounts[$amountType] = (float)$amount; + } + + /** + * @param string $amountType + * @param float $amount + */ + protected function _addAmount($amountType, $amount) + { + $this->_amounts[$amountType] += (float)$amount; + } + + /** + * Get amount of specified type + * + * @param string $amountType + * @return mixed + */ + protected function _getAmount($amountType) + { + return $this->_amounts[$amountType]; + } + + /** + * Create item object from item data + * + * @param string $name + * @param int $qty + * @param float $amount + * @param null|string $identifier + * @return \Magento\Object + */ + protected function _createItemFromData($name, $qty, $amount, $identifier = null) + { + $item = new \Magento\Object(array( + 'name' => $name, + 'qty' => $qty, + 'amount' => (float)$amount, + )); + + if ($identifier) { + $item->setData('id', $identifier); + } + + return $item; + } + + /** + * Set all amount types to zero + */ + protected function _resetAmounts() + { + $this->_amounts = array( + self::AMOUNT_DISCOUNT => 0, + self::AMOUNT_SHIPPING => 0, + self::AMOUNT_SUBTOTAL => 0, + self::AMOUNT_TAX => 0 + ); + } +} diff --git a/app/code/Magento/Payment/Model/Cart/SalesModel/Factory.php b/app/code/Magento/Payment/Model/Cart/SalesModel/Factory.php new file mode 100644 index 0000000000000000000000000000000000000000..b0170f49fc1a23316a45b7011288b320506846bf --- /dev/null +++ b/app/code/Magento/Payment/Model/Cart/SalesModel/Factory.php @@ -0,0 +1,62 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +/** + * Factory for creating payment cart sales models + */ +namespace Magento\Payment\Model\Cart\SalesModel; + +class Factory +{ + /** + * @var \Magento\ObjectManager + */ + protected $_objectManager; + + /** + * @param \Magento\ObjectManager $objectManager + */ + public function __construct(\Magento\ObjectManager $objectManager) + { + $this->_objectManager = $objectManager; + } + + /** + * Wrap sales model with Magento\Payment\Model\Cart\SalesModel\SalesModelInterface + * + * @param \Magento\Sales\Model\Order|\Magento\Sales\Model\Quote $salesModel + * @return \Magento\Payment\Model\Cart\SalesModel\SalesModelInterface + * @throws \InvalidArgumentException + */ + public function create($salesModel) + { + $arguments = array('salesModel' => $salesModel); + if ($salesModel instanceof \Magento\Sales\Model\Quote) { + return $this->_objectManager->create('Magento\Payment\Model\Cart\SalesModel\Quote', $arguments); + } else if ($salesModel instanceof \Magento\Sales\Model\Order) { + return $this->_objectManager->create('Magento\Payment\Model\Cart\SalesModel\Order', $arguments); + } + throw new \InvalidArgumentException('Sales model has bad type!'); + } +} diff --git a/app/code/Magento/Payment/Model/Cart/SalesModel/Order.php b/app/code/Magento/Payment/Model/Cart/SalesModel/Order.php new file mode 100644 index 0000000000000000000000000000000000000000..b13a728ab00e98c2b58ac00187b47ee73e39f751 --- /dev/null +++ b/app/code/Magento/Payment/Model/Cart/SalesModel/Order.php @@ -0,0 +1,122 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +/** + * Wrapper for \Magento\Sales\Model\Order sales model + */ +namespace Magento\Payment\Model\Cart\SalesModel; + +class Order implements \Magento\Payment\Model\Cart\SalesModel\SalesModelInterface +{ + /** + * Sales order model instance + * + * @var \Magento\Sales\Model\Order + */ + protected $_salesModel; + + /** + * @param \Magento\Sales\Model\Order $salesModel + */ + public function __construct(\Magento\Sales\Model\Order $salesModel) + { + $this->_salesModel = $salesModel; + } + + /** + * Get all items from shopping sales model + * + * @return array + */ + public function getAllItems() + { + $resultItems = array(); + + foreach ($this->_salesModel->getAllItems() as $item) { + $resultItems[] = new \Magento\Object(array( + 'parent_item' => $item->getParentItem(), + 'name' => $item->getName(), + 'qty' => (int)$item->getQtyOrdered(), + 'price' => (float)$item->getBasePrice(), + 'original_item' => $item + )); + } + + return $resultItems; + } + + /** + * @return float|null + */ + public function getBaseSubtotal() + { + return $this->_salesModel->getBaseSubtotal(); + } + + /** + * @return float|null + */ + public function getBaseTaxAmount() + { + return $this->_salesModel->getBaseTaxAmount(); + } + + /** + * @return float|null + */ + public function getBaseShippingAmount() + { + return $this->_salesModel->getBaseShippingAmount(); + } + + /** + * @return float|null + */ + public function getBaseDiscountAmount() + { + return $this->_salesModel->getBaseDiscountAmount(); + } + + /** + * Wrapper for \Magento\Object getDataUsingMethod method + * + * @param string $key + * @param mixed $args + * @return mixed + */ + public function getDataUsingMethod($key, $args = null) + { + return $this->_salesModel->getDataUsingMethod($key, $args); + } + + /** + * Return object that contains tax related fields + * + * @return \Magento\Sales\Model\Order + */ + public function getTaxContainer() + { + return $this->_salesModel; + } +} diff --git a/app/code/Magento/Payment/Model/Cart/SalesModel/Quote.php b/app/code/Magento/Payment/Model/Cart/SalesModel/Quote.php new file mode 100644 index 0000000000000000000000000000000000000000..a858337a66cd6bc108fb209e84f8a05f1791a12f --- /dev/null +++ b/app/code/Magento/Payment/Model/Cart/SalesModel/Quote.php @@ -0,0 +1,130 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +/** + * Wrapper for \Magento\Sales\Model\Quote sales model + */ +namespace Magento\Payment\Model\Cart\SalesModel; + +class Quote implements \Magento\Payment\Model\Cart\SalesModel\SalesModelInterface +{ + /** + * Sales quote model instance + * + * @var \Magento\Sales\Model\Quote + */ + protected $_salesModel; + + /** + * @var \Magento\Sales\Model\Quote\Address + */ + protected $_address; + + /** + * @param \Magento\Sales\Model\Quote $salesModel + */ + public function __construct(\Magento\Sales\Model\Quote $salesModel) + { + $this->_salesModel = $salesModel; + $this->_address = $this->_salesModel->getIsVirtual() ? + $this->_salesModel->getBillingAddress() : $this->_salesModel->getShippingAddress(); + } + + /** + * Get all items from shopping sales model + * + * @return array + */ + public function getAllItems() + { + $resultItems = array(); + + foreach ($this->_salesModel->getAllItems() as $item) { + $resultItems[] = new \Magento\Object(array( + 'parent_item' => $item->getParentItem(), + 'name' => $item->getName(), + 'qty' => (int)$item->getTotalQty(), + 'price' => $item->isNominal() ? 0 : (float)$item->getBaseCalculationPrice(), + 'original_item' => $item + )); + } + + return $resultItems; + } + + /** + * @return float|null + */ + public function getBaseSubtotal() + { + return $this->_salesModel->getBaseSubtotal(); + } + + /** + * @return float|null + */ + public function getBaseTaxAmount() + { + return $this->_address->getBaseTaxAmount(); + } + + /** + * @return float|null + */ + public function getBaseShippingAmount() + { + return $this->_address->getBaseShippingAmount(); + } + + /** + * @return float|null + */ + public function getBaseDiscountAmount() + { + return $this->_address->getBaseDiscountAmount(); + } + + /** + * Wrapper for \Magento\Object getDataUsingMethod method + * + * @param string $key + * @param mixed $args + * @return mixed + */ + public function getDataUsingMethod($key, $args = null) + { + return $this->_salesModel->getDataUsingMethod($key, $args); + } + + /** + * Return object that contains tax related fields + * + * @return \Magento\Sales\Model\Quote\Address + */ + public function getTaxContainer() + { + return $this->_salesModel->getIsVirtual() + ? $this->_salesModel->getBillingAddress() : $this->_salesModel->getShippingAddress(); + } +} diff --git a/app/code/Magento/Payment/Model/Cart/SalesModel/SalesModelInterface.php b/app/code/Magento/Payment/Model/Cart/SalesModel/SalesModelInterface.php new file mode 100644 index 0000000000000000000000000000000000000000..32bf03bd825f4805d8c2398a0ce27484c9dcc684 --- /dev/null +++ b/app/code/Magento/Payment/Model/Cart/SalesModel/SalesModelInterface.php @@ -0,0 +1,74 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +/** + * Wrapper interface for accessing sales model data + */ +namespace Magento\Payment\Model\Cart\SalesModel; + +interface SalesModelInterface +{ + /** + * Get all items from shopping sales model + * + * @return array + */ + public function getAllItems(); + + /** + * @return float|null + */ + public function getBaseSubtotal(); + + /** + * @return float|null + */ + public function getBaseTaxAmount(); + + /** + * @return float|null + */ + public function getBaseShippingAmount(); + + /** + * @return float|null + */ + public function getBaseDiscountAmount(); + + /** + * Wrapper for \Magento\Object getDataUsingMethod method + * + * @param string $key + * @param mixed $args + * @return mixed + */ + public function getDataUsingMethod($key, $args = null); + + /** + * Return object that contains tax related fields + * + * @return \Magento\Sales\Model\Order|\Magento\Sales\Model\Quote\Address + */ + public function getTaxContainer(); +} diff --git a/app/code/Magento/Payment/Model/Config.php b/app/code/Magento/Payment/Model/Config.php index 06f16f767f9e10e38c61dbaf79a09b0b070187b4..79c43050cac7c4e6bd02e225ae9b776a8458b816 100644 --- a/app/code/Magento/Payment/Model/Config.php +++ b/app/code/Magento/Payment/Model/Config.php @@ -166,6 +166,16 @@ class Config return $this->_dataStorage->get('credit_cards'); } + /** + * Retrieve array of payment methods information + * + * @return array + */ + public function getMethodsInfo() + { + return $this->_dataStorage->get('methods'); + } + /** * Get payment groups * diff --git a/app/code/Magento/Payment/Model/Config/Converter.php b/app/code/Magento/Payment/Model/Config/Converter.php index e98febd4ab388fb9f433a77073db8dd53a00f399..59a90c2ed22d27be766c62218992b8ed78ea2b9b 100644 --- a/app/code/Magento/Payment/Model/Config/Converter.php +++ b/app/code/Magento/Payment/Model/Config/Converter.php @@ -32,9 +32,22 @@ class Converter implements \Magento\Config\ConverterInterface */ public function convert($source) { - $configs = array(); $xpath = new \DOMXPath($source); + return array( + 'credit_cards' => $this->convertCreditCards($xpath), + 'groups' => $this->convertGroups($xpath), + 'methods' => $this->convertMethods($xpath), + ); + } + /** + * Convert credit cards xml tree to array + * + * @param \DOMXPath $xpath + * @return array + */ + protected function convertCreditCards(\DOMXPath $xpath) + { $creditCards = array(); /** @var \DOMNode $type */ foreach ($xpath->query('/payment/credit_cards/type') as $type) { @@ -57,11 +70,36 @@ class Converter implements \Magento\Config\ConverterInterface $creditCards[$ccId] = $typeArray; } uasort($creditCards, array($this, '_compareCcTypes')); + $config = array(); foreach ($creditCards as $code=>$data) { - $configs['credit_cards'][$code] = $data['name']; + $config[$code] = $data['name']; } + return $config; + } - $configs['groups'] = array(); + /** + * Compare sort order of CC Types + * + * @SuppressWarnings(PHPMD.UnusedPrivateMethod) Used in callback. + * + * @param array $left + * @param array $right + * @return int + */ + private function _compareCcTypes($left, $right) + { + return $left['order'] - $right['order']; + } + + /** + * Convert groups xml tree to array + * + * @param \DOMXPath $xpath + * @return array + */ + protected function convertGroups(\DOMXPath $xpath) + { + $config = array(); /** @var \DOMNode $group */ foreach ($xpath->query('/payment/groups/group') as $group) { $groupAttributes = $group->attributes; @@ -71,27 +109,36 @@ class Converter implements \Magento\Config\ConverterInterface foreach ($group->childNodes as $groupSubNode) { switch ($groupSubNode->nodeName) { case 'label': - $configs['groups'][$id] = $groupSubNode->nodeValue; + $config[$id] = $groupSubNode->nodeValue; break; default: break; } } } - return $configs; + return $config; } /** - * Compare sort order of CC Types - * - * @SuppressWarnings(PHPMD.UnusedPrivateMethod) Used in callback. + * Convert methods xml tree to array * - * @param array $left - * @param array $right - * @return int + * @param \DOMXPath $xpath + * @return array */ - private function _compareCcTypes($left, $right) + protected function convertMethods(\DOMXPath $xpath) { - return $left['order'] - $right['order']; + $config = array(); + /** @var \DOMNode $method */ + foreach ($xpath->query('/payment/methods/method') as $method) { + $name = $method->attributes->getNamedItem('name')->nodeValue; + /** @var $methodSubNode \DOMNode */ + foreach ($method->childNodes as $methodSubNode) { + if ($methodSubNode->nodeType != XML_ELEMENT_NODE) { + continue; + } + $config[$name][$methodSubNode->nodeName] = $methodSubNode->nodeValue; + } + } + return $config; } } diff --git a/app/code/Magento/Payment/Model/Config/Reader.php b/app/code/Magento/Payment/Model/Config/Reader.php index 8b342e9c82718dde683eb3c5ac15a7b6ac2fac82..eec8110e92e33663c5da33ec6f08477bcd0fdc5e 100644 --- a/app/code/Magento/Payment/Model/Config/Reader.php +++ b/app/code/Magento/Payment/Model/Config/Reader.php @@ -35,5 +35,6 @@ class Reader extends \Magento\Config\Reader\Filesystem protected $_idAttributes = array( '/payment/credit_cards/type' => 'id', '/payment/groups/group' => 'id', + '/payment/methods/method' => 'name', ); } diff --git a/app/code/Magento/Payment/Model/Method/AbstractMethod.php b/app/code/Magento/Payment/Model/Method/AbstractMethod.php index 2dde15da781a10b4b9c7f62ce882ca6e62b0ee47..34fba2e5f0f8b7faadeda74ccc2d30e07ad4eb72 100644 --- a/app/code/Magento/Payment/Model/Method/AbstractMethod.php +++ b/app/code/Magento/Payment/Model/Method/AbstractMethod.php @@ -47,7 +47,6 @@ abstract class AbstractMethod extends \Magento\Object const CHECK_USE_FOR_COUNTRY = 1; const CHECK_USE_FOR_CURRENCY = 2; const CHECK_USE_CHECKOUT = 4; - const CHECK_USE_FOR_MULTISHIPPING = 8; const CHECK_USE_INTERNAL = 16; const CHECK_ORDER_TOTAL_MIN_MAX = 32; const CHECK_RECURRING_PROFILES = 64; @@ -83,7 +82,6 @@ abstract class AbstractMethod extends \Magento\Object protected $_canVoid = false; protected $_canUseInternal = true; protected $_canUseCheckout = true; - protected $_canUseForMultishipping = true; protected $_isInitializeNeeded = false; protected $_canFetchTransactionInfo = false; protected $_canReviewPayment = false; @@ -248,16 +246,6 @@ abstract class AbstractMethod extends \Magento\Object return $this->_canUseCheckout; } - /** - * Using for multiple shipping address - * - * @return bool - */ - public function canUseForMultishipping() - { - return $this->_canUseForMultishipping; - } - /** * Can be edit order (renew order) * @@ -733,11 +721,6 @@ abstract class AbstractMethod extends \Magento\Object return false; } } - if ($checksBitMask & self::CHECK_USE_FOR_MULTISHIPPING) { - if (!$this->canUseForMultishipping()) { - return false; - } - } if ($checksBitMask & self::CHECK_USE_INTERNAL) { if (!$this->canUseInternal()) { return false; diff --git a/app/code/Magento/Payment/Model/Method/Specification/AbstractSpecification.php b/app/code/Magento/Payment/Model/Method/Specification/AbstractSpecification.php new file mode 100644 index 0000000000000000000000000000000000000000..bfaae0f0cef98d06ef6a9ce58a7d98cc0548192e --- /dev/null +++ b/app/code/Magento/Payment/Model/Method/Specification/AbstractSpecification.php @@ -0,0 +1,51 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Payment\Model\Method\Specification; + +use Magento\Payment\Model\Method\SpecificationInterface; +use Magento\Payment\Model\Config as PaymentConfig; + +/** + * Abstract specification + */ +abstract class AbstractSpecification implements SpecificationInterface +{ + /** + * Payment methods info + * + * @var array + */ + protected $methodsInfo = array(); + + /** + * Construct + * + * @param PaymentConfig $paymentConfig + */ + public function __construct(PaymentConfig $paymentConfig) + { + $this->methodsInfo = $paymentConfig->getMethodsInfo(); + } +} diff --git a/app/code/Magento/Payment/Model/Method/Specification/Composite.php b/app/code/Magento/Payment/Model/Method/Specification/Composite.php new file mode 100644 index 0000000000000000000000000000000000000000..52c4bfd691291ae832b22536641042eacfa5ec9e --- /dev/null +++ b/app/code/Magento/Payment/Model/Method/Specification/Composite.php @@ -0,0 +1,66 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Payment\Model\Method\Specification; + +use Magento\Payment\Model\Method\SpecificationInterface; + +/** + * Composite specification + */ +class Composite implements SpecificationInterface +{ + /** + * Specifications collection + * + * @var SpecificationInterface[] + */ + protected $specifications = array(); + + /** + * Construct + * + * @param Factory $factory + * @param array $specifications + */ + public function __construct(Factory $factory, $specifications = array()) + { + foreach ($specifications as $specification) { + $this->specifications[] = $factory->create($specification); + } + } + + /** + * {@inheritdoc} + */ + public function isSatisfiedBy($paymentMethod) + { + foreach ($this->specifications as $specification) { + if (!$specification->isSatisfiedBy($paymentMethod)) { + return false; + } + } + return true; + } +} diff --git a/app/code/Magento/Payment/Model/Method/Specification/Factory.php b/app/code/Magento/Payment/Model/Method/Specification/Factory.php new file mode 100644 index 0000000000000000000000000000000000000000..33d97b66061c635933eb56c2dfb5324eaa21f010 --- /dev/null +++ b/app/code/Magento/Payment/Model/Method/Specification/Factory.php @@ -0,0 +1,67 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Payment\Model\Method\Specification; + +use Magento\ObjectManager; +use Magento\Payment\Model\Method\SpecificationInterface; + +/** + * Specification Factory + */ +class Factory +{ + /** + * Object Manager + * + * @var ObjectManager + */ + protected $objectManager; + + /** + * Factory constructor + * + * @param ObjectManager $objectManager + */ + public function __construct(ObjectManager $objectManager) + { + $this->objectManager = $objectManager; + } + + /** + * Create specification instance + * + * @param string $specificationClass + * @return SpecificationInterface + * @throws \InvalidArgumentException + */ + public function create($specificationClass) + { + $specification = $this->objectManager->get($specificationClass); + if (!$specification instanceof SpecificationInterface) { + throw new \InvalidArgumentException('Specification must implement SpecificationInterface'); + } + return $specification; + } +} diff --git a/app/code/Magento/Payment/Model/Method/SpecificationInterface.php b/app/code/Magento/Payment/Model/Method/SpecificationInterface.php new file mode 100644 index 0000000000000000000000000000000000000000..1b8f191d5bb135cb72305e6bd0c3136a41ff6b29 --- /dev/null +++ b/app/code/Magento/Payment/Model/Method/SpecificationInterface.php @@ -0,0 +1,39 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Payment\Model\Method; + +/** + * Interface SpecificationInterface + */ +interface SpecificationInterface +{ + /** + * Check specification is satisfied by payment method + * + * @param string $paymentMethod + * @return bool + */ + public function isSatisfiedBy($paymentMethod); +} diff --git a/app/code/Magento/Payment/etc/payment.xml b/app/code/Magento/Payment/etc/payment.xml index e571145cacd8cb9b0b6a6dcce2da1307ab66a893..48ff0e969d0ed53cd2691a93b19915de2ca250f1 100644 --- a/app/code/Magento/Payment/etc/payment.xml +++ b/app/code/Magento/Payment/etc/payment.xml @@ -58,4 +58,30 @@ <label>Offline Payment Methods</label> </group> </groups> + <methods> + <method name="banktransfer"> + <allow_multiple_address>1</allow_multiple_address> + <allow_multiple_with_3dsecure>1</allow_multiple_with_3dsecure> + </method> + <method name="cashondelivery"> + <allow_multiple_address>1</allow_multiple_address> + <allow_multiple_with_3dsecure>1</allow_multiple_with_3dsecure> + </method> + <method name="ccsave"> + <allow_multiple_address>1</allow_multiple_address> + <allow_multiple_with_3dsecure>1</allow_multiple_with_3dsecure> + </method> + <method name="checkmo"> + <allow_multiple_address>1</allow_multiple_address> + <allow_multiple_with_3dsecure>1</allow_multiple_with_3dsecure> + </method> + <method name="free"> + <allow_multiple_address>1</allow_multiple_address> + <allow_multiple_with_3dsecure>1</allow_multiple_with_3dsecure> + </method> + <method name="purchaseorder"> + <allow_multiple_address>1</allow_multiple_address> + <allow_multiple_with_3dsecure>1</allow_multiple_with_3dsecure> + </method> + </methods> </payment> diff --git a/app/code/Magento/Payment/etc/payment.xsd b/app/code/Magento/Payment/etc/payment.xsd index 9dce596f83fd21b66b0280b231c19d7bbd5a4682..e509452511a4db4d93999855a0c3bfdc79c26d22 100644 --- a/app/code/Magento/Payment/etc/payment.xsd +++ b/app/code/Magento/Payment/etc/payment.xsd @@ -36,6 +36,7 @@ <xs:all> <xs:element name="credit_cards" type="credit_cardsType" minOccurs="0" /> <xs:element name="groups" type="groupsType" minOccurs="0" /> + <xs:element name="methods" type="methodsType" minOccurs="0" /> </xs:all> </xs:complexType> </xs:element> @@ -87,4 +88,28 @@ <xs:attribute name="id" type="xs:ID" use="required" /> </xs:complexType> + <xs:complexType name="methodsType"> + <xs:annotation> + <xs:documentation> + The containing node for a list of payment methods. + </xs:documentation> + </xs:annotation> + <xs:sequence maxOccurs="unbounded"> + <xs:element name="method" type="methodType" /> + </xs:sequence> + </xs:complexType> + + <xs:complexType name="methodType"> + <xs:annotation> + <xs:documentation> + The definition of a payment method. + </xs:documentation> + </xs:annotation> + <xs:all> + <xs:element name="allow_multiple_address" type="xs:integer" minOccurs="0" /> + <xs:element name="allow_multiple_with_3dsecure" type="xs:integer" minOccurs="0" /> + </xs:all> + <xs:attribute name="name" type="xs:ID" use="required" /> + </xs:complexType> + </xs:schema> diff --git a/app/code/Magento/Payment/etc/payment_file.xsd b/app/code/Magento/Payment/etc/payment_file.xsd index 1139fa175cafa4a483e6dd278171fcfb2da37ea8..16387cb919fdcf1887e907c324f7d55f2cb36f21 100644 --- a/app/code/Magento/Payment/etc/payment_file.xsd +++ b/app/code/Magento/Payment/etc/payment_file.xsd @@ -35,7 +35,8 @@ <xs:complexType> <xs:all> <xs:element name="credit_cards" type="credit_cardsType" minOccurs="0" /> - <xs:element name="groups" type="groupsType" minOccurs="0 "/> + <xs:element name="groups" type="groupsType" minOccurs="0"/> + <xs:element name="methods" type="methodsType" minOccurs="0" /> </xs:all> </xs:complexType> </xs:element> @@ -87,4 +88,27 @@ <xs:attribute name="id" type="xs:ID" use="required" /> </xs:complexType> + <xs:complexType name="methodsType"> + <xs:annotation> + <xs:documentation> + The containing node for a list of payment methods. + </xs:documentation> + </xs:annotation> + <xs:sequence maxOccurs="unbounded"> + <xs:element name="method" type="methodType" /> + </xs:sequence> + </xs:complexType> + + <xs:complexType name="methodType"> + <xs:annotation> + <xs:documentation> + The definition of a payment method. + </xs:documentation> + </xs:annotation> + <xs:all> + <xs:element name="allow_multiple_address" type="xs:integer" minOccurs="0" /> + <xs:element name="allow_multiple_with_3dsecure" type="xs:integer" minOccurs="0" /> + </xs:all> + <xs:attribute name="name" type="xs:ID" use="required" /> + </xs:complexType> </xs:schema> diff --git a/app/code/Magento/Paypal/Model/Api/AbstractApi.php b/app/code/Magento/Paypal/Model/Api/AbstractApi.php index 0fb582b16c100f7a14eb8a781dd1a726eddea69f..5202b400cdc19dd38af558b8872f7f5bba5a69c1 100644 --- a/app/code/Magento/Paypal/Model/Api/AbstractApi.php +++ b/app/code/Magento/Paypal/Model/Api/AbstractApi.php @@ -445,7 +445,7 @@ abstract class AbstractApi extends \Magento\Object // always add cart totals, even if line items are not requested if ($this->_lineItemTotalExportMap) { - foreach ($this->_cart->getTotals() as $key => $total) { + foreach ($this->_cart->getAmounts() as $key => $total) { if (isset($this->_lineItemTotalExportMap[$key])) { // !empty($total) $privateKey = $this->_lineItemTotalExportMap[$key]; $request[$privateKey] = $this->_filterAmount($total); @@ -454,7 +454,7 @@ abstract class AbstractApi extends \Magento\Object } // add cart line items - $items = $this->_cart->getItems(); + $items = $this->_cart->getAllItems(); if (empty($items) || !$this->getIsLineItemsEnabled()) { return; } diff --git a/app/code/Magento/Paypal/Model/Api/Nvp.php b/app/code/Magento/Paypal/Model/Api/Nvp.php index 901a183c4aecfeaa136ce3a607131960aef29e01..d9f8a7fd317b9afb36ad856eb0eeeb22277e3a04 100644 --- a/app/code/Magento/Paypal/Model/Api/Nvp.php +++ b/app/code/Magento/Paypal/Model/Api/Nvp.php @@ -30,6 +30,8 @@ */ namespace Magento\Paypal\Model\Api; +use Magento\Payment\Model\Cart; + class Nvp extends \Magento\Paypal\Model\Api\AbstractApi { /** @@ -454,9 +456,9 @@ class Nvp extends \Magento\Paypal\Model\Api\AbstractApi * @var array */ protected $_lineItemTotalExportMap = array( - \Magento\Paypal\Model\Cart::TOTAL_SUBTOTAL => 'ITEMAMT', - \Magento\Paypal\Model\Cart::TOTAL_TAX => 'TAXAMT', - \Magento\Paypal\Model\Cart::TOTAL_SHIPPING => 'SHIPPINGAMT', + Cart::AMOUNT_SUBTOTAL => 'ITEMAMT', + Cart::AMOUNT_TAX => 'TAXAMT', + Cart::AMOUNT_SHIPPING => 'SHIPPINGAMT', ); protected $_lineItemExportItemsFormat = array( 'id' => 'L_NUMBER%d', @@ -1210,7 +1212,7 @@ class Nvp extends \Magento\Paypal\Model\Api\AbstractApi if (!$this->_cart) { return; } - $this->_cart->isDiscountAsItem(true); + $this->_cart->setTransferDiscountAsItem(); return parent::_exportLineItems($request, $i); } diff --git a/app/code/Magento/Paypal/Model/Api/PayflowNvp.php b/app/code/Magento/Paypal/Model/Api/PayflowNvp.php index ee0f5fd805e85cedb660b78cc8f6a9249dce98be..739fbf0d42c3c88ea6a11b7656bc2253ce6b4eca 100644 --- a/app/code/Magento/Paypal/Model/Api/PayflowNvp.php +++ b/app/code/Magento/Paypal/Model/Api/PayflowNvp.php @@ -27,6 +27,8 @@ */ namespace Magento\Paypal\Model\Api; +use Magento\Payment\Model\Cart; + class PayflowNvp extends \Magento\Paypal\Model\Api\Nvp { /**#@+ @@ -295,14 +297,14 @@ class PayflowNvp extends \Magento\Paypal\Model\Api\Nvp * @var array */ protected $_lineItemTotalExportMap = array( - \Magento\Paypal\Model\Cart::TOTAL_TAX => 'TAXAMT', - \Magento\Paypal\Model\Cart::TOTAL_SHIPPING => 'FREIGHTAMT', + Cart::AMOUNT_TAX => 'TAXAMT', + Cart::AMOUNT_SHIPPING => 'FREIGHTAMT', ); protected $_lineItemsExportRequestTotalsFormat = array( - 'amount' => 'PAYMENTREQUEST_%d_ITEMAMT', - \Magento\Paypal\Model\Cart::TOTAL_TAX => 'TAXAMT', - \Magento\Paypal\Model\Cart::TOTAL_SHIPPING => 'FREIGHTAMT', + 'amount' => 'PAYMENTREQUEST_%d_ITEMAMT', + Cart::AMOUNT_TAX => 'TAXAMT', + Cart::AMOUNT_SHIPPING => 'FREIGHTAMT', ); protected $_lineItemExportItemsFormat = array( @@ -694,11 +696,11 @@ class PayflowNvp extends \Magento\Paypal\Model\Api\Nvp return; } - $this->_cart->isDiscountAsItem(true); + $this->_cart->setTransferDiscountAsItem(); // always add cart totals, even if line items are not requested if ($this->_lineItemTotalExportMap) { - foreach ($this->_cart->getTotals() as $key => $total) { + foreach ($this->_cart->getAmounts() as $key => $total) { if (isset($this->_lineItemTotalExportMap[$key])) { // !empty($total) $privateKey = $this->_lineItemTotalExportMap[$key]; $request[$privateKey] = $this->_filterAmount($total); @@ -710,7 +712,7 @@ class PayflowNvp extends \Magento\Paypal\Model\Api\Nvp } // add cart line items - $items = $this->_cart->getItems(); + $items = $this->_cart->getAllItems(); if (empty($items) || !$this->getIsLineItemsEnabled()) { return; } diff --git a/app/code/Magento/Paypal/Model/Api/Standard.php b/app/code/Magento/Paypal/Model/Api/Standard.php index 95a4d4d3034f19e4669a29b2d2547bb7c0431996..4e7cea4487e44f5b572f6f0ac549cfe481ad104d 100644 --- a/app/code/Magento/Paypal/Model/Api/Standard.php +++ b/app/code/Magento/Paypal/Model/Api/Standard.php @@ -29,6 +29,8 @@ */ namespace Magento\Paypal\Model\Api; +use Magento\Payment\Model\Cart; + class Standard extends \Magento\Paypal\Model\Api\AbstractApi { /** @@ -91,10 +93,10 @@ class Standard extends \Magento\Paypal\Model\Api\AbstractApi * @var array */ protected $_lineItemTotalExportMap = array( - \Magento\Paypal\Model\Cart::TOTAL_SUBTOTAL => 'amount', - \Magento\Paypal\Model\Cart::TOTAL_DISCOUNT => 'discount_amount', - \Magento\Paypal\Model\Cart::TOTAL_TAX => 'tax', - \Magento\Paypal\Model\Cart::TOTAL_SHIPPING => 'shipping', + Cart::AMOUNT_SUBTOTAL => 'amount', + Cart::AMOUNT_DISCOUNT => 'discount_amount', + Cart::AMOUNT_TAX => 'tax', + Cart::AMOUNT_SHIPPING => 'shipping', ); /** @@ -198,7 +200,7 @@ class Standard extends \Magento\Paypal\Model\Api\AbstractApi return; } if ($this->getIsLineItemsEnabled()) { - $this->_cart->isShippingAsItem(true); + $this->_cart->setTransferShippingAsItem(); } return parent::_exportLineItems($request, $i); } diff --git a/app/code/Magento/Paypal/Model/Cart.php b/app/code/Magento/Paypal/Model/Cart.php index eb3e72ae8d1273557b1f9c509d5631fa962bd0d3..fd7cae4ad446f7d58c27137a9082c29c56b7c662 100644 --- a/app/code/Magento/Paypal/Model/Cart.php +++ b/app/code/Magento/Paypal/Model/Cart.php @@ -30,368 +30,50 @@ */ namespace Magento\Paypal\Model; -class Cart +class Cart extends \Magento\Payment\Model\Cart { /** - * Totals that PayPal suppports when passing shopping cart - */ - const TOTAL_SUBTOTAL = 'subtotal'; - const TOTAL_DISCOUNT = 'discount'; - const TOTAL_TAX = 'tax'; - const TOTAL_SHIPPING = 'shipping'; - - /** - * Order or quote instance - * - * @var \Magento\Sales\Model\Quote|\Magento\Sales\Model\Order - */ - protected $_salesEntity; - - /** - * Rendered cart items - * Array of \Magento\Objects - * - * @var array - */ - protected $_items = array(); - - /** - * Rendered cart totals - * Associative array with the keys from constants above - * - * @var array - */ - protected $_totals = array(); - - /** - * Set of optional descriptions for the item that may replace a total and composed of several amounts - * Array of strings - * - * @var array - */ - protected $_totalLineItemDescriptions = array(); - - /** - * Lazy initialization indicator for rendering - * - * @var bool - */ - protected $_shouldRender = true; - - /** - * Validation result for the rendered cart items - * - * @var bool - */ - protected $_areItemsValid = false; - - /** - * Validation result for the rendered totals - * - * @var bool - */ - protected $_areTotalsValid = false; - - /** - * Whether to render discount total as a line item - * Use case: WPP - * - * @var bool - */ - protected $_isDiscountAsItem = false; - - /** - * Whether to render shipping total as a line item - * Use case: WPS - * * @var bool */ - protected $_isShippingAsItem = false; + protected $_areAmountsValid = false; /** - * Core event manager proxy + * Get shipping, tax, subtotal and discount amounts all together * - * @var \Magento\Event\ManagerInterface - */ - protected $_eventManager; - - /** - * @var \Magento\Core\Model\StoreManagerInterface - */ - protected $_storeManager; - - /** - * @param \Magento\Event\ManagerInterface $eventManager - * @param \Magento\Core\Model\StoreManagerInterface $storeManager - * @param array $params - * @throws \Exception - */ - public function __construct( - \Magento\Event\ManagerInterface $eventManager, - \Magento\Core\Model\StoreManagerInterface $storeManager, - $params = array() - ) { - $this->_eventManager = $eventManager; - $this->_storeManager = $storeManager; - $salesEntity = array_shift($params); - if (is_object($salesEntity) - && (($salesEntity instanceof \Magento\Sales\Model\Order) - || ($salesEntity instanceof \Magento\Sales\Model\Quote)) - ) { - $this->_salesEntity = $salesEntity; - } else { - throw new \Exception('Invalid sales entity provided.'); - } - } - - /** - * Getter for the current sales entity - * - * @return \Magento\Sales\Model\Order - * @return \Magento\Sales\Model\Quote - */ - public function getSalesEntity() - { - return $this->_salesEntity; - } - - /** - * Render and get line items - * By default returns false if the items are invalid - * - * @param bool $bypassValidation - * @return array|false - */ - public function getItems($bypassValidation = false) - { - $this->_render(); - if (!$bypassValidation && !$this->_areItemsValid) { - return false; - } - return $this->_items; - } - - /** - * Render and get totals - * If the totals are invalid for any reason, they will be merged into one amount (subtotal is utilized for it) - * An option to substract discount from the subtotal is available - * - * @param bool $mergeDiscount * @return array */ - public function getTotals($mergeDiscount = false) + public function getAmounts() { - $this->_render(); + $this->_collectItemsAndAmounts(); - // cut down totals to one total if they are invalid - if (!$this->_areTotalsValid) { - $totals = array(self::TOTAL_SUBTOTAL => - $this->_totals[self::TOTAL_SUBTOTAL] + $this->_totals[self::TOTAL_TAX] - ); - if (!$this->_isShippingAsItem) { - $totals[self::TOTAL_SUBTOTAL] += $this->_totals[self::TOTAL_SHIPPING]; - } - if (!$this->_isDiscountAsItem) { - $totals[self::TOTAL_SUBTOTAL] -= $this->_totals[self::TOTAL_DISCOUNT]; - } - return $totals; - } elseif ($mergeDiscount) { - $totals = $this->_totals; - unset($totals[self::TOTAL_DISCOUNT]); - if (!$this->_isDiscountAsItem) { - $totals[self::TOTAL_SUBTOTAL] -= $this->_totals[self::TOTAL_DISCOUNT]; - } - return $totals; - } - return $this->_totals; - } - - /** - * Add a line item - * - * @param string $name - * @param numeric $qty - * @param float $amount - * @param string $identifier - * @return \Magento\Object - */ - public function addItem($name, $qty, $amount, $identifier = null) - { - $this->_shouldRender = true; - $item = new \Magento\Object(array( - 'name' => $name, - 'qty' => $qty, - 'amount' => (float)$amount, - )); - if ($identifier) { - $item->setData('id', $identifier); - } - $this->_items[] = $item; - return $item; - } + if (!$this->_areAmountsValid) { + $subtotal = $this->getSubtotal() + $this->getTax(); - /** - * Remove item from cart by identifier - * - * @param string $identifier - * @return bool - */ - public function removeItem($identifier) - { - foreach ($this->_items as $key => $item) { - if ($item->getId() == $identifier) { - unset($this->_items[$key]); - return true; + if (empty($this->_transferFlags[self::AMOUNT_SHIPPING])) { + $subtotal += $this->getShipping(); } - } - return false; - } - /** - * Compound the specified amount with the specified total - * - * @param string $code - * @param float $amount - * @param string $lineItemDescription - * @return \Magento\Paypal\Model\Cart - */ - public function updateTotal($code, $amount, $lineItemDescription = null) - { - $this->_shouldRender = true; - if (isset($this->_totals[$code])) { - $this->_totals[$code] += $amount; - if ($lineItemDescription) { - $this->_totalLineItemDescriptions[$code][] = $lineItemDescription; + if (empty($this->_transferFlags[self::AMOUNT_DISCOUNT])) { + $subtotal -= $this->getDiscount(); } - } - return $this; - } - - /** - * Get/Set whether to render the discount total as a line item - * - * @param $setValue - * @return bool|\Magento\Paypal\Model\Cart - */ - public function isDiscountAsItem($setValue = null) - { - return $this->_totalAsItem('_isDiscountAsItem', $setValue); - } - - /** - * Get/Set whether to render the discount total as a line item - * - * @param $setValue - * @return bool|\Magento\Paypal\Model\Cart - */ - public function isShippingAsItem($setValue = null) - { - return $this->_totalAsItem('_isShippingAsItem', $setValue); - } - - /** - * (re)Render all items and totals - */ - protected function _render() - { - if (!$this->_shouldRender) { - return; - } - - // regular items from the sales entity - $this->_items = array(); - foreach ($this->_salesEntity->getAllItems() as $item) { - if (!$item->getParentItem()) { - $this->_addRegularItem($item); - } - } - end($this->_items); - $lastRegularItemKey = key($this->_items); - - // regular totals - if ($this->_salesEntity instanceof \Magento\Sales\Model\Order) { - $shippingDescription = $this->_salesEntity->getShippingDescription(); - $this->_totals = array( - self::TOTAL_SUBTOTAL => $this->_salesEntity->getBaseSubtotal(), - self::TOTAL_TAX => $this->_salesEntity->getBaseTaxAmount(), - self::TOTAL_SHIPPING => $this->_salesEntity->getBaseShippingAmount(), - self::TOTAL_DISCOUNT => abs($this->_salesEntity->getBaseDiscountAmount()), - ); - $this->_applyHiddenTaxWorkaround($this->_salesEntity); - } else { - $address = $this->_salesEntity->getIsVirtual() ? - $this->_salesEntity->getBillingAddress() : $this->_salesEntity->getShippingAddress(); - $shippingDescription = $address->getShippingDescription(); - $this->_totals = array ( - self::TOTAL_SUBTOTAL => $this->_salesEntity->getBaseSubtotal(), - self::TOTAL_TAX => $address->getBaseTaxAmount(), - self::TOTAL_SHIPPING => $address->getBaseShippingAmount(), - self::TOTAL_DISCOUNT => abs($address->getBaseDiscountAmount()), - ); - $this->_applyHiddenTaxWorkaround($address); - } - $originalDiscount = $this->_totals[self::TOTAL_DISCOUNT]; - - // arbitrary items, total modifications - $this->_eventManager->dispatch('paypal_prepare_line_items', array('paypal_cart' => $this)); - - // distinguish original discount among the others - if ($originalDiscount > 0.0001 && isset($this->_totalLineItemDescriptions[self::TOTAL_DISCOUNT])) { - $discountToDisplay = $this->_storeManager->getStore()->convertPrice($originalDiscount, true, false); - $this->_totalLineItemDescriptions[self::TOTAL_DISCOUNT][] = __('Discount (%1)', $discountToDisplay); - } - // discount, shipping as items - if ($this->_isDiscountAsItem && $this->_totals[self::TOTAL_DISCOUNT]) { - $this->addItem(__('Discount'), 1, -1.00 * $this->_totals[self::TOTAL_DISCOUNT], - $this->_renderTotalLineItemDescriptions(self::TOTAL_DISCOUNT) - ); - } - $shippingItemId = $this->_renderTotalLineItemDescriptions(self::TOTAL_SHIPPING, $shippingDescription); - if ($this->_isShippingAsItem && (float)$this->_totals[self::TOTAL_SHIPPING]) { - $this->addItem(__('Shipping'), 1, (float)$this->_totals[self::TOTAL_SHIPPING], - $shippingItemId + return array( + self::AMOUNT_SUBTOTAL => $subtotal ); } - // compound non-regular items into subtotal - foreach ($this->_items as $key => $item) { - if ($key > $lastRegularItemKey && $item->getAmount() != 0) { - $this->_totals[self::TOTAL_SUBTOTAL] += $item->getAmount(); - } - } - - $this->_validate(); - // if cart items are invalid, prepare cart for transfer without line items - if (!$this->_areItemsValid) { - $this->removeItem($shippingItemId); - } - - $this->_shouldRender = false; + return $this->_amounts; } /** - * Merge multiple descriptions by a total code into a string - * - * @param string $code - * @param string $prepend - * @param string $append - * @param string $glue - * @return string + * Calculate subtotal from custom items */ - protected function _renderTotalLineItemDescriptions($code, $prepend = '', $append = '', $glue = '; ') + protected function _calculateCustomItemsSubtotal() { - $result = array(); - if ($prepend) { - $result[] = $prepend; - } - if (isset($this->_totalLineItemDescriptions[$code])) { - $result = array_merge($this->_totalLineItemDescriptions[$code]); - } - if ($append) { - $result[] = $append; - } - return implode($glue, $result); + parent::_calculateCustomItemsSubtotal(); + $this->_applyHiddenTaxWorkaround($this->_salesModel); + + $this->_validate(); } /** @@ -399,93 +81,87 @@ class Cart */ protected function _validate() { - $this->_areItemsValid = false; - $this->_areTotalsValid = false; + $areItemsValid = false; + $this->_areAmountsValid = false; - $referenceAmount = $this->_salesEntity->getBaseGrandTotal(); + $referenceAmount = $this->_salesModel->getDataUsingMethod('base_grand_total'); $itemsSubtotal = 0; - foreach ($this->_items as $i) { - $itemsSubtotal = $itemsSubtotal + $i['qty'] * $i['amount']; + foreach ($this->getAllItems() as $i) { + $itemsSubtotal = $itemsSubtotal + $i->getQty() * $i->getAmount(); } - $sum = $itemsSubtotal + $this->_totals[self::TOTAL_TAX]; - if (!$this->_isShippingAsItem) { - $sum += $this->_totals[self::TOTAL_SHIPPING]; + + $sum = $itemsSubtotal + $this->getTax(); + + if (empty($this->_transferFlags[self::AMOUNT_SHIPPING])) { + $sum += $this->getShipping(); } - if (!$this->_isDiscountAsItem) { - $sum -= $this->_totals[self::TOTAL_DISCOUNT]; + + if (empty($this->_transferFlags[self::AMOUNT_DISCOUNT])) { + $sum -= $this->getDiscount(); + // PayPal requires to have discount less than items subtotal + $this->_areAmountsValid = round($this->getDiscount(), 4) < round($itemsSubtotal, 4); + } else { + $this->_areAmountsValid = $itemsSubtotal > 0.00001; } + /** * numbers are intentionally converted to strings because of possible comparison error * see http://php.net/float */ // match sum of all the items and totals to the reference amount if (sprintf('%.4F', $sum) == sprintf('%.4F', $referenceAmount)) { - $this->_areItemsValid = true; + $areItemsValid = true; } - // PayPal requires to have discount less than items subtotal - if (!$this->_isDiscountAsItem) { - $this->_areTotalsValid = round($this->_totals[self::TOTAL_DISCOUNT], 4) < round($itemsSubtotal, 4); - } else { - $this->_areTotalsValid = $itemsSubtotal > 0.00001; - } + $areItemsValid = $areItemsValid && $this->_areAmountsValid; - $this->_areItemsValid = $this->_areItemsValid && $this->_areTotalsValid; + if (!$areItemsValid) { + $this->_salesModelItems = array(); + $this->_customItems = array(); + } } /** - * Add a usual line item with amount and qty - * - * @param \Magento\Object $salesItem - * @return \Magento\Object + * Import items from sales model with workarounds for PayPal */ - protected function _addRegularItem(\Magento\Object $salesItem) + protected function _importItemsFromSalesModel() { - if ($this->_salesEntity instanceof \Magento\Sales\Model\Order) { - $qty = (int) $salesItem->getQtyOrdered(); - $amount = (float) $salesItem->getBasePrice(); - // TODO: nominal item for order - } else { - $qty = (int) $salesItem->getTotalQty(); - $amount = $salesItem->isNominal() ? 0 : (float) $salesItem->getBaseCalculationPrice(); - } - // workaround in case if item subtotal precision is not compatible with PayPal (.2) - $subAggregatedLabel = ''; - if ($amount - round($amount, 2)) { - $amount = $amount * $qty; - $subAggregatedLabel = ' x' . $qty; - $qty = 1; - } + $this->_salesModelItems = array(); - // aggregate item price if item qty * price does not match row total - if (($amount * $qty) != $salesItem->getBaseRowTotal()) { - $amount = (float) $salesItem->getBaseRowTotal(); - $subAggregatedLabel = ' x' . $qty; - $qty = 1; - } + foreach ($this->_salesModel->getAllItems() as $item) { + if ($item->getParentItem()) { + continue; + } - return $this->addItem($salesItem->getName() . $subAggregatedLabel, $qty, $amount, $salesItem->getSku()); - } + $amount = $item->getPrice(); + $qty = $item->getQty(); - /** - * Get/Set for the specified variable. - * If the value changes, the re-rendering is commenced - * - * @param string $var - * @param $setValue - * @return bool|\Magento\Paypal\Model\Cart - */ - private function _totalAsItem($var, $setValue = null) - { - if (null !== $setValue) { - if ($setValue != $this->$var) { - $this->_shouldRender = true; + $subAggregatedLabel = ''; + + // workaround in case if item subtotal precision is not compatible with PayPal (.2) + if ($amount - round($amount, 2)) { + $amount = $amount * $qty; + $subAggregatedLabel = ' x' . $qty; + $qty = 1; } - $this->$var = $setValue; - return $this; + + // aggregate item price if item qty * price does not match row total + $itemBaseRowTotal = $item->getOriginalItem()->getBaseRowTotal(); + if (($amount * $qty) != $itemBaseRowTotal) { + $amount = (float)$itemBaseRowTotal; + $subAggregatedLabel = ' x' . $qty; + $qty = 1; + } + + $this->_salesModelItems[] = $this->_createItemFromData($item->getName() . $subAggregatedLabel, $qty, + $amount); } - return $this->$var; + + $this->addSubtotal($this->_salesModel->getBaseSubtotal()); + $this->addTax($this->_salesModel->getBaseTaxAmount()); + $this->addShipping($this->_salesModel->getBaseShippingAmount()); + $this->addDiscount(abs($this->_salesModel->getBaseDiscountAmount())); } /** @@ -507,11 +183,12 @@ class Cart * - run shopping cart and estimate shipping * - go to PayPal * - * @param \Magento\Core\Model\AbstractModel $salesEntity + * @param \Magento\Payment\Model\Cart\SalesModel\SalesModelInterface $salesEntity */ - private function _applyHiddenTaxWorkaround($salesEntity) + protected function _applyHiddenTaxWorkaround(\Magento\Payment\Model\Cart\SalesModel\SalesModelInterface $salesEntity) { - $this->_totals[self::TOTAL_TAX] += (float)$salesEntity->getBaseHiddenTaxAmount(); - $this->_totals[self::TOTAL_TAX] += (float)$salesEntity->getBaseShippingHiddenTaxAmnt(); + $dataContainer = $salesEntity->getTaxContainer(); + $this->addTax((float)$dataContainer->getBaseHiddenTaxAmount()); + $this->addTax((float)$dataContainer->getBaseShippingHiddenTaxAmnt()); } } diff --git a/app/code/Magento/Paypal/Model/Direct.php b/app/code/Magento/Paypal/Model/Direct.php index 5c968fb79c6c08f31e961e62ce2151d4607ff9d3..1871b9e74a17f70e7006b8e61c1bc33f8b81d8c2 100644 --- a/app/code/Magento/Paypal/Model/Direct.php +++ b/app/code/Magento/Paypal/Model/Direct.php @@ -53,7 +53,6 @@ class Direct extends \Magento\Payment\Model\Method\Cc protected $_canVoid = true; protected $_canUseInternal = true; protected $_canUseCheckout = true; - protected $_canUseForMultishipping = true; protected $_canSaveCc = false; protected $_canFetchTransactionInfo = true; protected $_canReviewPayment = true; @@ -420,8 +419,9 @@ class Direct extends \Magento\Payment\Model\Method\Cc } // add line items - $parameters = array('params' => array($order)); - $api->setPaypalCart($this->_cartFactory->create($parameters)) + $cart = $this->_cartFactory->create(array('salesModel' => $order)); + + $api->setPaypalCart($cart) ->setIsLineItemsEnabled($this->_pro->getConfig()->lineItemsEnabled); // call api and import transaction and other payment information diff --git a/app/code/Magento/Paypal/Model/Express.php b/app/code/Magento/Paypal/Model/Express.php index 7cb8a293c27faafdc6f011b884024bafe3511e43..69ef88849e7efd4900d538a62d7e01240aca36fd 100644 --- a/app/code/Magento/Paypal/Model/Express.php +++ b/app/code/Magento/Paypal/Model/Express.php @@ -67,7 +67,6 @@ class Express extends \Magento\Payment\Model\Method\AbstractMethod protected $_canVoid = true; protected $_canUseInternal = false; protected $_canUseCheckout = true; - protected $_canUseForMultishipping = false; protected $_canFetchTransactionInfo = true; protected $_canCreateBillingAgreement = true; protected $_canReviewPayment = true; @@ -614,7 +613,9 @@ class Express extends \Magento\Payment\Model\Method\AbstractMethod // prepare api call $token = $payment->getAdditionalInformation(\Magento\Paypal\Model\Express\Checkout::PAYMENT_INFO_TRANSPORT_TOKEN); - $parameters = array('params' => array($order)); + + $cart = $this->_cartFactory->create(array('salesModel' => $order)); + $api = $this->_pro->getApi() ->setToken($token) ->setPayerId($payment-> @@ -624,7 +625,7 @@ class Express extends \Magento\Payment\Model\Method\AbstractMethod ->setNotifyUrl($this->_urlBuilder->getUrl('paypal/ipn/')) ->setInvNum($order->getIncrementId()) ->setCurrencyCode($order->getBaseCurrencyCode()) - ->setPaypalCart($this->_cartFactory->create($parameters)) + ->setPaypalCart($cart) ->setIsLineItemsEnabled($this->_pro->getConfig()->lineItemsEnabled); if ($order->getIsVirtual()) { $api->setAddress($order->getBillingAddress())->setSuppressShipping(true); diff --git a/app/code/Magento/Paypal/Model/Express/Checkout.php b/app/code/Magento/Paypal/Model/Express/Checkout.php index 52d4ee2b5d65cbbc39bd7cc353ead08c99ececc2..f50b0ed184460abd22420bcd877dd753e8c3790b 100644 --- a/app/code/Magento/Paypal/Model/Express/Checkout.php +++ b/app/code/Magento/Paypal/Model/Express/Checkout.php @@ -451,13 +451,14 @@ class Checkout } // add line items - $parameters = array('params' => array($this->_quote)); - $paypalCart = $this->_cartFactory->create($parameters); - $this->_api->setPaypalCart($paypalCart) + /** @var $cart \Magento\Payment\Model\Cart */ + $cart = $this->_cartFactory->create(array('salesModel' => $this->_quote)); + $this->_api->setPaypalCart($cart) ->setIsLineItemsEnabled($this->_config->lineItemsEnabled); // add shipping options if needed and line items are available - if ($this->_config->lineItemsEnabled && $this->_config->transferShippingOptions && $paypalCart->getItems()) { + $cartItems = $cart->getAllItems(); + if ($this->_config->lineItemsEnabled && $this->_config->transferShippingOptions && !empty($cartItems)) { if (!$this->_quote->getIsVirtual() && !$this->_quote->hasNominalItems()) { $options = $this->_prepareShippingOptions($address, true); if ($options) { diff --git a/app/code/Magento/Paypal/Model/Hostedpro.php b/app/code/Magento/Paypal/Model/Hostedpro.php index 601ac2c65e51f8b5e516c4694515f103d899ad20..ba34e09d5e66ddc5d81e094dc32f0b739ff65293 100644 --- a/app/code/Magento/Paypal/Model/Hostedpro.php +++ b/app/code/Magento/Paypal/Model/Hostedpro.php @@ -67,7 +67,6 @@ class Hostedpro extends \Magento\Paypal\Model\Direct * Availability options */ protected $_canUseInternal = false; - protected $_canUseForMultishipping = false; protected $_canSaveCc = false; protected $_isInitializeNeeded = true; /**#@-*/ diff --git a/app/code/Magento/Paypal/Model/Method/Agreement.php b/app/code/Magento/Paypal/Model/Method/Agreement.php index e28db8951fc4b2bf04821f121e8c2e42d87a8d7a..ee4a9496cafe160fec8d34893be9e0974a50213f 100644 --- a/app/code/Magento/Paypal/Model/Method/Agreement.php +++ b/app/code/Magento/Paypal/Model/Method/Agreement.php @@ -348,7 +348,8 @@ class Agreement extends \Magento\Sales\Model\Payment\Method\Billing\AbstractAgre ) ); - $parameters = array('params' => array($order)); + $cart = $this->_cartFactory->create(array('salesModel' => $order)); + $proConfig = $this->_pro->getConfig(); $api = $this->_pro->getApi() ->setReferenceId($billingAgreement->getReferenceId()) @@ -356,7 +357,7 @@ class Agreement extends \Magento\Sales\Model\Payment\Method\Billing\AbstractAgre ->setAmount($amount) ->setCurrencyCode($payment->getOrder()->getBaseCurrencyCode()) ->setNotifyUrl($this->_urlBuilder->getUrl('paypal/ipn/')) - ->setPaypalCart($this->_cartFactory->create($parameters)) + ->setPaypalCart($cart) ->setIsLineItemsEnabled($proConfig->lineItemsEnabled) ->setInvNum($order->getIncrementId()); diff --git a/app/code/Magento/Paypal/Model/Payflowlink.php b/app/code/Magento/Paypal/Model/Payflowlink.php index 889ef28538263a945d1a83b65cad9709b14b5d81..513ebc7a402ec66c761f889efdd24ffe2525e305 100644 --- a/app/code/Magento/Paypal/Model/Payflowlink.php +++ b/app/code/Magento/Paypal/Model/Payflowlink.php @@ -91,7 +91,6 @@ class Payflowlink extends \Magento\Paypal\Model\Payflowpro * Availability options */ protected $_canUseInternal = false; - protected $_canUseForMultishipping = false; protected $_isInitializeNeeded = true; /**#@-*/ diff --git a/app/code/Magento/Paypal/Model/Payflowpro.php b/app/code/Magento/Paypal/Model/Payflowpro.php index 038dc3e5d98e7a9755784665dfe333832d4f6cba..801b8f7cbabbafc21ef7ecf6bc26d5b2785ca621 100644 --- a/app/code/Magento/Paypal/Model/Payflowpro.php +++ b/app/code/Magento/Paypal/Model/Payflowpro.php @@ -83,7 +83,6 @@ class Payflowpro extends \Magento\Payment\Model\Method\Cc protected $_canVoid = true; protected $_canUseInternal = true; protected $_canUseCheckout = true; - protected $_canUseForMultishipping = true; protected $_canSaveCc = false; protected $_isProxy = false; protected $_canFetchTransactionInfo = true; diff --git a/app/code/Magento/Paypal/Model/Standard.php b/app/code/Magento/Paypal/Model/Standard.php index 01f905f49f7fbc70c8f811fc1f568485ddbfb099..0734dd826d71535e882b39974a4d22eba1d3bd12 100644 --- a/app/code/Magento/Paypal/Model/Standard.php +++ b/app/code/Magento/Paypal/Model/Standard.php @@ -48,7 +48,6 @@ class Standard extends \Magento\Payment\Model\Method\AbstractMethod protected $_isInitializeNeeded = true; protected $_canUseInternal = false; - protected $_canUseForMultishipping = false; /** * Config instance @@ -234,8 +233,8 @@ class Standard extends \Magento\Payment\Model\Method\AbstractMethod } // add cart totals and line items - $parameters = array('params' => array($order)); - $api->setPaypalCart($this->_cartFactory->create($parameters)) + $cart = $this->_cartFactory->create(array('salesModel' => $order)); + $api->setPaypalCart($cart) ->setIsLineItemsEnabled($this->_config->lineItemsEnabled); $api->setCartSummary($this->_getAggregatedCartSummary()); $api->setLocale($api->getLocaleCode()); diff --git a/app/code/Magento/Paypal/etc/payment.xml b/app/code/Magento/Paypal/etc/payment.xml index ffffd11fc6fabac4e0cac85342f5ffc98e327fc5..4e21c0e33aceef9b1754e6a65608fc79ff40b8ed 100644 --- a/app/code/Magento/Paypal/etc/payment.xml +++ b/app/code/Magento/Paypal/etc/payment.xml @@ -40,5 +40,31 @@ <label>PayPal</label> </group> </groups> + <methods> + <method name="paypal_direct"> + <allow_multiple_address>1</allow_multiple_address> + <allow_multiple_with_3dsecure>1</allow_multiple_with_3dsecure> + </method> + <method name="paypal_billing_agreement"> + <allow_multiple_address>1</allow_multiple_address> + <allow_multiple_with_3dsecure>1</allow_multiple_with_3dsecure> + </method> + <method name="payflow_direct"> + <allow_multiple_address>1</allow_multiple_address> + <allow_multiple_with_3dsecure>1</allow_multiple_with_3dsecure> + </method> + <method name="payflow_express"> + <allow_multiple_address>1</allow_multiple_address> + <allow_multiple_with_3dsecure>1</allow_multiple_with_3dsecure> + </method> + <method name="payflow_advanced"> + <allow_multiple_address>1</allow_multiple_address> + <allow_multiple_with_3dsecure>1</allow_multiple_with_3dsecure> + </method> + <method name="payflowpro"> + <allow_multiple_address>1</allow_multiple_address> + <allow_multiple_with_3dsecure>1</allow_multiple_with_3dsecure> + </method> + </methods> </payment> diff --git a/app/code/Magento/ProductAlert/Model/Observer.php b/app/code/Magento/ProductAlert/Model/Observer.php index 1debd07cbdd52331bb96d625df8382a912b36d27..70442dd02bd69d97ca9ee4a3c98bf64a5fed975e 100644 --- a/app/code/Magento/ProductAlert/Model/Observer.php +++ b/app/code/Magento/ProductAlert/Model/Observer.php @@ -122,7 +122,7 @@ class Observer protected $_stockColFactory; /** - * @var \Magento\Core\Model\Translate + * @var \Magento\TranslateInterface */ protected $_translate; @@ -145,7 +145,7 @@ class Observer * @param \Magento\Catalog\Model\ProductFactory $productFactory * @param \Magento\Core\Model\DateFactory $dateFactory * @param \Magento\ProductAlert\Model\Resource\Stock\CollectionFactory $stockColFactory - * @param \Magento\Core\Model\Translate $translate + * @param \Magento\TranslateInterface $translate * @param \Magento\Email\Model\TemplateFactory $templateFactory * @param \Magento\ProductAlert\Model\EmailFactory $emailFactory */ @@ -158,7 +158,7 @@ class Observer \Magento\Catalog\Model\ProductFactory $productFactory, \Magento\Core\Model\DateFactory $dateFactory, \Magento\ProductAlert\Model\Resource\Stock\CollectionFactory $stockColFactory, - \Magento\Core\Model\Translate $translate, + \Magento\TranslateInterface $translate, \Magento\Email\Model\TemplateFactory $templateFactory, \Magento\ProductAlert\Model\EmailFactory $emailFactory ) { diff --git a/app/code/Magento/Reports/Block/Adminhtml/Config/Form/Field/MtdStart.php b/app/code/Magento/Reports/Block/Adminhtml/Config/Form/Field/MtdStart.php index 84ec3022df2f2bb2bb99074f2943fa52cd01ea5c..a03c06aaaa3ef9802bd59e61186c20d32b1dd0f2 100644 --- a/app/code/Magento/Reports/Block/Adminhtml/Config/Form/Field/MtdStart.php +++ b/app/code/Magento/Reports/Block/Adminhtml/Config/Form/Field/MtdStart.php @@ -23,20 +23,22 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Reports\Block\Adminhtml\Config\Form\Field; + +use Magento\Data\Form\Element\AbstractElement; /** * Dashboard Month-To-Date Day starts Field Renderer * - * @category Magento - * @package Magento_Reports * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\Reports\Block\Adminhtml\Config\Form\Field; - class MtdStart extends \Magento\Backend\Block\System\Config\Form\Field { - - protected function _getElementHtml(\Magento\Data\Form\Element\AbstractElement $element) + /** + * @param AbstractElement $element + * @return string + */ + protected function _getElementHtml(AbstractElement $element) { $_days = array(); for ($i = 1; $i <= 31; $i++) { diff --git a/app/code/Magento/Reports/Block/Adminhtml/Config/Form/Field/YtdStart.php b/app/code/Magento/Reports/Block/Adminhtml/Config/Form/Field/YtdStart.php index 9de8369c74b016bc77ec902b4a00800a379f713c..5e2f21d66c09557df5046cc1c0ccb20b2c556aac 100644 --- a/app/code/Magento/Reports/Block/Adminhtml/Config/Form/Field/YtdStart.php +++ b/app/code/Magento/Reports/Block/Adminhtml/Config/Form/Field/YtdStart.php @@ -23,19 +23,22 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Reports\Block\Adminhtml\Config\Form\Field; + +use Magento\Data\Form\Element\AbstractElement; /** * Dashboard Year-To-Date Month and Day starts Field Renderer * - * @category Magento - * @package Magento_Reports * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\Reports\Block\Adminhtml\Config\Form\Field; - class YtdStart extends \Magento\Backend\Block\System\Config\Form\Field { - protected function _getElementHtml(\Magento\Data\Form\Element\AbstractElement $element) + /** + * @param AbstractElement $element + * @return string + */ + protected function _getElementHtml(AbstractElement $element) { $_months = array(); for ($i = 1; $i <= 12; $i++) { diff --git a/app/code/Magento/Reports/Block/Adminhtml/Customer/Accounts.php b/app/code/Magento/Reports/Block/Adminhtml/Customer/Accounts.php index 77383280d1ed88f3dc688d1acc5d4a1d9c515113..6e87e8abc84314511d4182864de90926891d368c 100644 --- a/app/code/Magento/Reports/Block/Adminhtml/Customer/Accounts.php +++ b/app/code/Magento/Reports/Block/Adminhtml/Customer/Accounts.php @@ -23,21 +23,23 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Reports\Block\Adminhtml\Customer; /** * Backend new accounts report page content block * - * @category Magento - * @package Magento_Reports * @author Magento Core Team <core@magentocommerce.com> */ - -namespace Magento\Reports\Block\Adminhtml\Customer; - class Accounts extends \Magento\Backend\Block\Widget\Grid\Container { + /** + * @var string + */ protected $_blockGroup = 'Magento_Reports'; + /** + * @return void + */ protected function _construct() { $this->_blockGroup = 'Magento_Reports'; diff --git a/app/code/Magento/Reports/Block/Adminhtml/Customer/Orders.php b/app/code/Magento/Reports/Block/Adminhtml/Customer/Orders.php index cd3ab4a91c73f96c1a63d886f21670e33f421cf1..8ed1e0c6b90d8bf248e74e6b0a7206e3c5d39a6d 100644 --- a/app/code/Magento/Reports/Block/Adminhtml/Customer/Orders.php +++ b/app/code/Magento/Reports/Block/Adminhtml/Customer/Orders.php @@ -23,17 +23,13 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Reports\Block\Adminhtml\Customer; /** * Backend customers by orders report content block * - * @category Magento - * @package Magento_Reports * @author Magento Core Team <core@magentocommerce.com> */ - -namespace Magento\Reports\Block\Adminhtml\Customer; - class Orders extends \Magento\Backend\Block\Widget\Grid\Container { /** @@ -43,6 +39,9 @@ class Orders extends \Magento\Backend\Block\Widget\Grid\Container */ protected $_blockGroup = 'Magento_Reports'; + /** + * @return void + */ protected function _construct() { $this->_blockGroup = 'Magento_Reports'; diff --git a/app/code/Magento/Reports/Block/Adminhtml/Customer/Totals.php b/app/code/Magento/Reports/Block/Adminhtml/Customer/Totals.php index ab930a2fbb14ff8a84e5cf3f0f19f53d64b4e8e8..8a7b75c5dab42d0ad61789b7149a04c6ba29817c 100644 --- a/app/code/Magento/Reports/Block/Adminhtml/Customer/Totals.php +++ b/app/code/Magento/Reports/Block/Adminhtml/Customer/Totals.php @@ -23,21 +23,23 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Reports\Block\Adminhtml\Customer; /** * Backend customers by totals report content block * - * @category Magento - * @package Magento_Reports * @author Magento Core Team <core@magentocommerce.com> */ - -namespace Magento\Reports\Block\Adminhtml\Customer; - class Totals extends \Magento\Backend\Block\Widget\Grid\Container { + /** + * @var string + */ protected $_blockGroup = 'Magento_Reports'; + /** + * @return void + */ protected function _construct() { $this->_blockGroup = 'Magento_Reports'; diff --git a/app/code/Magento/Reports/Block/Adminhtml/Filter/Form.php b/app/code/Magento/Reports/Block/Adminhtml/Filter/Form.php index 0efac69ac6d52ca5441e441abf10e1a694242d07..a3f0fc364827817a67a6087c2a2f18f425edebc1 100644 --- a/app/code/Magento/Reports/Block/Adminhtml/Filter/Form.php +++ b/app/code/Magento/Reports/Block/Adminhtml/Filter/Form.php @@ -23,38 +23,42 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Reports\Block\Adminhtml\Filter; /** * Adminhtml report filter form * - * @category Magento - * @package Magento_Reports * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\Reports\Block\Adminhtml\Filter; - class Form extends \Magento\Backend\Block\Widget\Form\Generic { /** * Report type options + * + * @var array */ protected $_reportTypeOptions = array(); /** * Report field visibility + * + * @var array */ protected $_fieldVisibility = array(); /** * Report field opions + * + * @var array */ protected $_fieldOptions = array(); /** * Set field visibility * - * @param string Field id - * @param bool Field visibility + * @param string $fieldId + * @param bool $visibility + * @return void */ public function setFieldVisibility($fieldId, $visibility) { @@ -64,8 +68,8 @@ class Form extends \Magento\Backend\Block\Widget\Form\Generic /** * Get field visibility * - * @param string Field id - * @param bool Default field visibility + * @param string $fieldId + * @param bool $defaultVisibility * @return bool */ public function getFieldVisibility($fieldId, $defaultVisibility = true) @@ -82,6 +86,8 @@ class Form extends \Magento\Backend\Block\Widget\Form\Generic * @param string $fieldId Field id * @param mixed $option Field option name * @param mixed $value Field option value + * + * @return void */ public function setFieldOption($fieldId, $option, $value = null) { @@ -103,7 +109,7 @@ class Form extends \Magento\Backend\Block\Widget\Form\Generic * * @param string $key * @param string $value - * @return \Magento\Reports\Block\Adminhtml\Filter\Form + * @return $this */ public function addReportTypeOption($key, $value) { @@ -191,7 +197,7 @@ class Form extends \Magento\Backend\Block\Widget\Form\Generic } /** - * Initialize form fileds values + * Initialize form fields values * Method will be called after prepareForm and can be used for field values initialization * * @return \Magento\Backend\Block\Widget\Form diff --git a/app/code/Magento/Reports/Block/Adminhtml/Grid.php b/app/code/Magento/Reports/Block/Adminhtml/Grid.php index 187aadd134e320d2ad570e48f5c03078b3ba8bde..c9ec1cc0f009a39981e261b61cb62afc4ae49c10 100644 --- a/app/code/Magento/Reports/Block/Adminhtml/Grid.php +++ b/app/code/Magento/Reports/Block/Adminhtml/Grid.php @@ -23,16 +23,13 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Reports\Block\Adminhtml; /** * Backend report grid block * - * @category Magento - * @package Magento_Reports * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\Reports\Block\Adminhtml; - class Grid extends \Magento\Backend\Block\Widget\Grid { /** @@ -202,7 +199,7 @@ class Grid extends \Magento\Backend\Block\Widget\Grid /** * Set filter values * - * @param mixed $data + * @param string $data * @return \Magento\Backend\Block\Widget\Grid|\Magento\Reports\Block\Adminhtml\Grid */ protected function _setFilterValues($data) @@ -216,7 +213,8 @@ class Grid extends \Magento\Backend\Block\Widget\Grid /** * Set visibility of store switcher * - * @param boolean $visible + * @param bool $visible + * @return void */ public function setStoreSwitcherVisibility($visible=true) { @@ -226,7 +224,7 @@ class Grid extends \Magento\Backend\Block\Widget\Grid /** * Return visibility of store switcher * - * @return boolean + * @return bool */ public function getStoreSwitcherVisibility() { @@ -246,7 +244,8 @@ class Grid extends \Magento\Backend\Block\Widget\Grid /** * Set visibility of date filter * - * @param boolean $visible + * @param bool $visible + * @return void */ public function setDateFilterVisibility($visible=true) { @@ -256,7 +255,7 @@ class Grid extends \Magento\Backend\Block\Widget\Grid /** * Return visibility of date filter * - * @return boolean + * @return bool */ public function getDateFilterVisibility() { @@ -295,6 +294,8 @@ class Grid extends \Magento\Backend\Block\Widget\Grid /** * Return refresh button html + * + * @return string */ public function getRefreshButtonHtml() { @@ -306,6 +307,7 @@ class Grid extends \Magento\Backend\Block\Widget\Grid * * @param string $name * @param string $value + * @return void */ public function setFilter($name, $value) { @@ -334,6 +336,7 @@ class Grid extends \Magento\Backend\Block\Widget\Grid * Set sub-report rows count * * @param int $size + * @return void */ public function setSubReportSize($size) { @@ -362,6 +365,8 @@ class Grid extends \Magento\Backend\Block\Widget\Grid /** * Prepare grid filter buttons + * + * @return void */ protected function _prepareFilterButtons() { diff --git a/app/code/Magento/Reports/Block/Adminhtml/Grid/AbstractGrid.php b/app/code/Magento/Reports/Block/Adminhtml/Grid/AbstractGrid.php index f4e7c602b3011e1b84622b47206879e06002216c..081037061d1e2e5ba764a3c02bf3ff3e3f749b51 100644 --- a/app/code/Magento/Reports/Block/Adminhtml/Grid/AbstractGrid.php +++ b/app/code/Magento/Reports/Block/Adminhtml/Grid/AbstractGrid.php @@ -29,9 +29,24 @@ namespace Magento\Reports\Block\Adminhtml\Grid; class AbstractGrid extends \Magento\Backend\Block\Widget\Grid\Extended { + /** + * @var string + */ protected $_resourceCollectionName = ''; + + /** + * @var null + */ protected $_currentCurrencyCode = null; + + /** + * @var array + */ protected $_storeIds = array(); + + /** + * @var null + */ protected $_aggregatedColumns = null; /** @@ -77,6 +92,9 @@ class AbstractGrid extends \Magento\Backend\Block\Widget\Grid\Extended parent::__construct($context, $backendHelper, $data); } + /** + * @return void + */ protected function _construct() { parent::_construct(); @@ -89,11 +107,17 @@ class AbstractGrid extends \Magento\Backend\Block\Widget\Grid\Extended $this->setEmptyCellLabel(__('We couldn\'t find records for this period.')); } + /** + * @return string; + */ public function getResourceCollectionName() { return $this->_resourceCollectionName; } + /** + * @return \Magento\Data\Collection + */ public function getCollection() { if (is_null($this->_collection)) { @@ -102,6 +126,9 @@ class AbstractGrid extends \Magento\Backend\Block\Widget\Grid\Extended return $this->_collection; } + /** + * @return array + */ protected function _getAggregatedColumns() { if (is_null($this->_aggregatedColumns)) { @@ -123,9 +150,9 @@ class AbstractGrid extends \Magento\Backend\Block\Widget\Grid\Extended * It stands for conditional visibility of the column depending on filter field values * Value of visibility_filter supports (filter_field_name => filter_field_value) pairs * - * @param string $columnId - * @param array $column - * @return \Magento\Reports\Block\Adminhtml\Grid\AbstractGrid + * @param string $columnId + * @param array $column + * @return \Magento\Reports\Block\Adminhtml\Grid\AbstractGrid */ public function addColumn($columnId, $column) { @@ -157,7 +184,7 @@ class AbstractGrid extends \Magento\Backend\Block\Widget\Grid\Extended /** * Get allowed store ids array intersected with selected scope in store switcher * - * @return array + * @return array */ protected function _getStoreIds() { @@ -181,6 +208,9 @@ class AbstractGrid extends \Magento\Backend\Block\Widget\Grid\Extended return $storeIds; } + /** + * @return $this|\Magento\Backend\Block\Widget\Grid + */ protected function _prepareCollection() { $filterData = $this->getFilterData(); @@ -250,6 +280,9 @@ class AbstractGrid extends \Magento\Backend\Block\Widget\Grid\Extended return parent::_prepareCollection(); } + /** + * @return int + */ public function getCountTotals() { if (!$this->getTotals()) { @@ -275,6 +308,9 @@ class AbstractGrid extends \Magento\Backend\Block\Widget\Grid\Extended return parent::getCountTotals(); } + /** + * @return array + */ public function getSubTotals() { $filterData = $this->getFilterData(); @@ -292,12 +328,20 @@ class AbstractGrid extends \Magento\Backend\Block\Widget\Grid\Extended return parent::getSubTotals(); } + /** + * @param mixed $storeIds + * + * @return $this + */ public function setStoreIds($storeIds) { $this->_storeIds = $storeIds; return $this; } + /** + * @return string + */ public function getCurrentCurrencyCode() { if (is_null($this->_currentCurrencyCode)) { @@ -311,7 +355,7 @@ class AbstractGrid extends \Magento\Backend\Block\Widget\Grid\Extended /** * Get currency rate (base to given currency) * - * @param string|\Magento\Directory\Model\Currency $currencyCode + * @param string|\Magento\Directory\Model\Currency $toCurrency * @return double */ public function getRate($toCurrency) @@ -324,7 +368,7 @@ class AbstractGrid extends \Magento\Backend\Block\Widget\Grid\Extended * * @param \Magento\Reports\Model\Resource\Report\Collection\AbstractCollection $collection * @param \Magento\Object $filterData - * @return \Magento\Reports\Block\Adminhtml\Grid\AbstractGrid + * @return $this */ protected function _addOrderStatusFilter($collection, $filterData) { @@ -338,7 +382,7 @@ class AbstractGrid extends \Magento\Backend\Block\Widget\Grid\Extended * * @param \Magento\Reports\Model\Resource\Report\Collection\AbstractCollection $collection * @param \Magento\Object $filterData - * @return \Magento\Reports\Block\Adminhtml\Grid\AbstractGrid + * @return $this */ protected function _addCustomFilter($collection, $filterData) { diff --git a/app/code/Magento/Reports/Block/Adminhtml/Grid/Column/Renderer/Blanknumber.php b/app/code/Magento/Reports/Block/Adminhtml/Grid/Column/Renderer/Blanknumber.php index beaee6e8061e300994cb60136d5d278418376f7a..2e9e13ab748d9821638cf042024a8e12496c0c7b 100644 --- a/app/code/Magento/Reports/Block/Adminhtml/Grid/Column/Renderer/Blanknumber.php +++ b/app/code/Magento/Reports/Block/Adminhtml/Grid/Column/Renderer/Blanknumber.php @@ -23,19 +23,20 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Reports\Block\Adminhtml\Grid\Column\Renderer; /** * Adminhtml grid item renderer number or blank line * - * @category Magento - * @package Magento_Reports * @author Magento Core Team <core@magentocommerce.com> */ - -namespace Magento\Reports\Block\Adminhtml\Grid\Column\Renderer; - class Blanknumber extends \Magento\Backend\Block\Widget\Grid\Column\Renderer\Number { + /** + * @param \Magento\Object $row + * + * @return string + */ protected function _getValue(\Magento\Object $row) { $data = parent::_getValue($row); diff --git a/app/code/Magento/Reports/Block/Adminhtml/Grid/Column/Renderer/Currency.php b/app/code/Magento/Reports/Block/Adminhtml/Grid/Column/Renderer/Currency.php index e45c3804d7cd5fabad81cc4f6f48c6116972c712..dd167bac5036f6130b3bafec74b3fd0a2eeaabe8 100644 --- a/app/code/Magento/Reports/Block/Adminhtml/Grid/Column/Renderer/Currency.php +++ b/app/code/Magento/Reports/Block/Adminhtml/Grid/Column/Renderer/Currency.php @@ -23,25 +23,21 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Reports\Block\Adminhtml\Grid\Column\Renderer; /** * Adminhtml grid item renderer currency * - * @category Magento - * @package Magento_Reports * @author Magento Core Team <core@magentocommerce.com> */ - -namespace Magento\Reports\Block\Adminhtml\Grid\Column\Renderer; - class Currency extends \Magento\Backend\Block\Widget\Grid\Column\Renderer\Currency { /** * Renders grid column * - * @param \Magento\Object $row - * @return string + * @param \Magento\Object $row + * @return string */ public function render(\Magento\Object $row) { diff --git a/app/code/Magento/Reports/Block/Adminhtml/Grid/Column/Renderer/Customer.php b/app/code/Magento/Reports/Block/Adminhtml/Grid/Column/Renderer/Customer.php index 63dc72f2912a22fc14459808f625459cbc6f77df..03117b6dbcbf01adc5170629e2316dd61a5ef66b 100644 --- a/app/code/Magento/Reports/Block/Adminhtml/Grid/Column/Renderer/Customer.php +++ b/app/code/Magento/Reports/Block/Adminhtml/Grid/Column/Renderer/Customer.php @@ -23,25 +23,21 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ - +namespace Magento\Reports\Block\Adminhtml\Grid\Column\Renderer; /** * Adminhtml Report Customers Reviews renderer * - * @category Magento - * @package Magento_Reports * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\Reports\Block\Adminhtml\Grid\Column\Renderer; - class Customer extends \Magento\Backend\Block\Widget\Grid\Column\Renderer\AbstractRenderer { /** * Renders grid column * - * @param \Magento\Object $row - * @return string + * @param \Magento\Object $row + * @return string */ public function render(\Magento\Object $row) { diff --git a/app/code/Magento/Reports/Block/Adminhtml/Grid/Column/Renderer/Product.php b/app/code/Magento/Reports/Block/Adminhtml/Grid/Column/Renderer/Product.php index ecd9d6b6fe912f63bca536d5c75ee1e24ed30d54..c25b88a338c1fefc40342fa2da8448a86a30e2fe 100644 --- a/app/code/Magento/Reports/Block/Adminhtml/Grid/Column/Renderer/Product.php +++ b/app/code/Magento/Reports/Block/Adminhtml/Grid/Column/Renderer/Product.php @@ -23,25 +23,21 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ - +namespace Magento\Reports\Block\Adminhtml\Grid\Column\Renderer; /** * Adminhtml Report Products Reviews renderer * - * @category Magento - * @package Magento_Reports * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\Reports\Block\Adminhtml\Grid\Column\Renderer; - class Product extends \Magento\Backend\Block\Widget\Grid\Column\Renderer\AbstractRenderer { /** * Renders grid column * - * @param \Magento\Object $row - * @return string + * @param \Magento\Object $row + * @return string */ public function render(\Magento\Object $row) { diff --git a/app/code/Magento/Reports/Block/Adminhtml/Grid/Shopcart.php b/app/code/Magento/Reports/Block/Adminhtml/Grid/Shopcart.php index 931dc0493c580794778a5351bcc08bb04bf96a27..8a5c0d7309130352d7124edf486a93a26eccbfac 100644 --- a/app/code/Magento/Reports/Block/Adminhtml/Grid/Shopcart.php +++ b/app/code/Magento/Reports/Block/Adminhtml/Grid/Shopcart.php @@ -23,16 +23,13 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Reports\Block\Adminhtml\Grid; /** * Adminhtml shopping carts report grid block * - * @category Magento - * @package Magento_Reports * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\Reports\Block\Adminhtml\Grid; - class Shopcart extends \Magento\Backend\Block\Widget\Grid\Extended { /** @@ -46,10 +43,10 @@ class Shopcart extends \Magento\Backend\Block\Widget\Grid\Extended protected $_storeIds = array(); /** - * storeIds setter + * StoreIds setter * - * @param array $storeIds - * @return \Magento\Reports\Block\Adminhtml\Grid\Shopcart + * @param array $storeIds + * @return $this */ public function setStoreIds($storeIds) { @@ -76,7 +73,7 @@ class Shopcart extends \Magento\Backend\Block\Widget\Grid\Extended /** * Get currency rate (base to given currency) * - * @param string|\Magento\Directory\Model\Currency $currencyCode + * @param string|\Magento\Directory\Model\Currency $toCurrency * @return double */ public function getRate($toCurrency) diff --git a/app/code/Magento/Reports/Block/Adminhtml/Product.php b/app/code/Magento/Reports/Block/Adminhtml/Product.php index fa970adf30b89b5affafeebfc0f649f1f629cfda..9f0bb8332fc71538e64567c7554eb6c956578a14 100644 --- a/app/code/Magento/Reports/Block/Adminhtml/Product.php +++ b/app/code/Magento/Reports/Block/Adminhtml/Product.php @@ -23,19 +23,18 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Reports\Block\Adminhtml; /** * Adminhtml products report page content block * - * @category Magento - * @package Magento_Reports * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\Reports\Block\Adminhtml; - class Product extends \Magento\Backend\Block\Widget\Grid\Container { - + /** + * @return void + */ protected function _construct() { $this->_blockGroup = 'Magento_Reports'; diff --git a/app/code/Magento/Reports/Block/Adminhtml/Product/Downloads.php b/app/code/Magento/Reports/Block/Adminhtml/Product/Downloads.php index 5ae74fb92ce566164f66fdb42a21b4ba6ef3b6c9..d10941b57514f8c055ddf6b0fbae6ca8e9fbc0c7 100644 --- a/app/code/Magento/Reports/Block/Adminhtml/Product/Downloads.php +++ b/app/code/Magento/Reports/Block/Adminhtml/Product/Downloads.php @@ -23,19 +23,18 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Reports\Block\Adminhtml\Product; /** * Adminhtml product downloads report * - * @category Magento - * @package Magento_Reports * @author Magento Core Team <core@magentocommerce.com> */ - -namespace Magento\Reports\Block\Adminhtml\Product; - class Downloads extends \Magento\Backend\Block\Widget\Grid\Container { + /** + * @return void + */ protected function _construct() { $this->_blockGroup = 'Magento_Reports'; @@ -45,6 +44,9 @@ class Downloads extends \Magento\Backend\Block\Widget\Grid\Container $this->_removeButton('add'); } + /** + * @return \Magento\View\Element\AbstractBlock + */ protected function _prepareLayout() { $this->setChild('store_switcher', @@ -56,6 +58,9 @@ class Downloads extends \Magento\Backend\Block\Widget\Grid\Container return parent::_prepareLayout(); } + /** + * @return string + */ public function getStoreSwitcherHtml() { if (!$this->_storeManager->isSingleStoreMode()) { @@ -64,6 +69,9 @@ class Downloads extends \Magento\Backend\Block\Widget\Grid\Container return ''; } + /** + * @return string + */ public function getGridHtml() { return $this->getStoreSwitcherHtml() . parent::getGridHtml(); diff --git a/app/code/Magento/Reports/Block/Adminhtml/Product/Downloads/Grid.php b/app/code/Magento/Reports/Block/Adminhtml/Product/Downloads/Grid.php index 37fc636f6e7a4b44301ae18ae02926e0320509ed..27a591f37f2714e9c3f4d2a424ac9731e40ff862 100644 --- a/app/code/Magento/Reports/Block/Adminhtml/Product/Downloads/Grid.php +++ b/app/code/Magento/Reports/Block/Adminhtml/Product/Downloads/Grid.php @@ -23,16 +23,13 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Reports\Block\Adminhtml\Product\Downloads; /** * Adminhtml product downloads report grid * - * @category Magento - * @package Magento_Reports * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\Reports\Block\Adminhtml\Product\Downloads; - class Grid extends \Magento\Backend\Block\Widget\Grid\Extended { /** @@ -56,6 +53,9 @@ class Grid extends \Magento\Backend\Block\Widget\Grid\Extended parent::__construct($context, $backendHelper, $data); } + /** + * @return void + */ protected function _construct() { parent::_construct(); @@ -63,6 +63,9 @@ class Grid extends \Magento\Backend\Block\Widget\Grid\Extended $this->setUseAjax(false); } + /** + * @return \Magento\Backend\Block\Widget\Grid + */ protected function _prepareCollection() { if ($this->getRequest()->getParam('website')) { @@ -91,6 +94,9 @@ class Grid extends \Magento\Backend\Block\Widget\Grid\Extended return parent::_prepareCollection(); } + /** + * @return \Magento\Backend\Block\Widget\Grid\Extended + */ protected function _prepareColumns() { $this->addColumn('name', array( diff --git a/app/code/Magento/Reports/Block/Adminhtml/Product/Downloads/Renderer/Purchases.php b/app/code/Magento/Reports/Block/Adminhtml/Product/Downloads/Renderer/Purchases.php index d2f499668736c6bc4fef025513fd44aaa6f5e342..c215b903ea29beeb72a0a5c1281fce5f5c143ef4 100644 --- a/app/code/Magento/Reports/Block/Adminhtml/Product/Downloads/Renderer/Purchases.php +++ b/app/code/Magento/Reports/Block/Adminhtml/Product/Downloads/Renderer/Purchases.php @@ -23,24 +23,21 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Reports\Block\Adminhtml\Product\Downloads\Renderer; /** * Adminhtml Product Downloads Purchases Renderer * - * @category Magento - * @package Magento_Reports * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\Reports\Block\Adminhtml\Product\Downloads\Renderer; - class Purchases extends \Magento\Backend\Block\Widget\Grid\Column\Renderer\AbstractRenderer { /** * Renders Purchases value * - * @param \Magento\Object $row - * @return string + * @param \Magento\Object $row + * @return string */ public function render(\Magento\Object $row) { diff --git a/app/code/Magento/Reports/Block/Adminhtml/Product/Grid.php b/app/code/Magento/Reports/Block/Adminhtml/Product/Grid.php index 185294d94033bd65596b32c25dda39cb070d9f4c..5c981c4f46f0d181ece7d3b309e773f883f3ec39 100644 --- a/app/code/Magento/Reports/Block/Adminhtml/Product/Grid.php +++ b/app/code/Magento/Reports/Block/Adminhtml/Product/Grid.php @@ -23,16 +23,13 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Reports\Block\Adminhtml\Product; /** * Adminhtml products report grid block * - * @category Magento - * @package Magento_Reports * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\Reports\Block\Adminhtml\Product; - class Grid extends \Magento\Backend\Block\Widget\Grid\Extended { /** @@ -56,6 +53,9 @@ class Grid extends \Magento\Backend\Block\Widget\Grid\Extended parent::__construct($context, $backendHelper, $data); } + /** + * @return void + */ protected function _construct() { parent::_construct(); @@ -64,9 +64,11 @@ class Grid extends \Magento\Backend\Block\Widget\Grid\Extended $this->setDefaultDir('desc'); } + /** + * @return \Magento\Backend\Block\Widget\Grid + */ protected function _prepareCollection() { - $collection = $this->_collectionFactory->create(); $collection->getEntity()->setStore(0); @@ -75,12 +77,18 @@ class Grid extends \Magento\Backend\Block\Widget\Grid\Extended return parent::_prepareCollection(); } + /** + * @return void + */ protected function _afterLoadCollection() { $totalObj = new \Magento\Reports\Model\Totals(); $this->setTotals($totalObj->countTotals($this)); } + /** + * @return \Magento\Backend\Block\Widget\Grid\Extended + */ protected function _prepareColumns() { $this->addColumn('entity_id', array( diff --git a/app/code/Magento/Reports/Block/Adminhtml/Product/Lowstock.php b/app/code/Magento/Reports/Block/Adminhtml/Product/Lowstock.php index 05b6c15c7cbed1bb2d2c858746b49fc4bdac465d..f826e153cac04f31fc9dfe6db644fb676325143a 100644 --- a/app/code/Magento/Reports/Block/Adminhtml/Product/Lowstock.php +++ b/app/code/Magento/Reports/Block/Adminhtml/Product/Lowstock.php @@ -23,19 +23,18 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Reports\Block\Adminhtml\Product; /** * Adminhtml low stock products report content block * - * @category Magento - * @package Magento_Reports * @author Magento Core Team <core@magentocommerce.com> */ - -namespace Magento\Reports\Block\Adminhtml\Product; - class Lowstock extends \Magento\Backend\Block\Widget\Grid\Container { + /** + * @return void + */ protected function _construct() { $this->_blockGroup = 'Magento_Reports'; @@ -45,6 +44,9 @@ class Lowstock extends \Magento\Backend\Block\Widget\Grid\Container $this->_removeButton('add'); } + /** + * @return \Magento\View\Element\AbstractBlock + */ protected function _prepareLayout() { $this->setChild('store_switcher', @@ -57,6 +59,9 @@ class Lowstock extends \Magento\Backend\Block\Widget\Grid\Container return parent::_prepareLayout(); } + /** + * @return string + */ public function getStoreSwitcherHtml() { if ($this->_storeManager->isSingleStoreMode()) { @@ -65,6 +70,9 @@ class Lowstock extends \Magento\Backend\Block\Widget\Grid\Container return $this->getChildHtml('store_switcher'); } + /** + * @return string + */ public function getGridHtml() { return $this->getStoreSwitcherHtml() . parent::getGridHtml(); diff --git a/app/code/Magento/Reports/Block/Adminhtml/Product/Lowstock/Grid.php b/app/code/Magento/Reports/Block/Adminhtml/Product/Lowstock/Grid.php index 2de893c3cabf7db14fbbf34b56501cacef28c7c7..b618ce4637d77aed3c69e561309a7d9a15b52a74 100644 --- a/app/code/Magento/Reports/Block/Adminhtml/Product/Lowstock/Grid.php +++ b/app/code/Magento/Reports/Block/Adminhtml/Product/Lowstock/Grid.php @@ -23,16 +23,13 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Reports\Block\Adminhtml\Product\Lowstock; /** * Adminhtml low stock products report grid block * - * @category Magento - * @package Magento_Reports * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\Reports\Block\Adminhtml\Product\Lowstock; - class Grid extends \Magento\Backend\Block\Widget\Grid { /** diff --git a/app/code/Magento/Reports/Block/Adminhtml/Product/Sold.php b/app/code/Magento/Reports/Block/Adminhtml/Product/Sold.php index 0f869c2587699e860a2d3ef19c04a8adeb8799fb..0a174df9ad8b5572b843e8486b42ef67e7365684 100644 --- a/app/code/Magento/Reports/Block/Adminhtml/Product/Sold.php +++ b/app/code/Magento/Reports/Block/Adminhtml/Product/Sold.php @@ -23,24 +23,24 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ - +namespace Magento\Reports\Block\Adminhtml\Product; /** * Backend Report Sold Product Content Block * - * @category Magento - * @package Magento_Reports * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\Reports\Block\Adminhtml\Product; - class Sold extends \Magento\Backend\Block\Widget\Grid\Container { + /** + * @var string + */ protected $_blockGroup = 'Magento_Reports'; /** * Initialize container block settings * + * @return void */ protected function _construct() { diff --git a/app/code/Magento/Reports/Block/Adminhtml/Product/Viewed.php b/app/code/Magento/Reports/Block/Adminhtml/Product/Viewed.php index 9fcdf3692d34503d94c88fec3e1a783ad34a8728..ce9b9927e328c2e1a1149d67f999902bcd8799d3 100644 --- a/app/code/Magento/Reports/Block/Adminhtml/Product/Viewed.php +++ b/app/code/Magento/Reports/Block/Adminhtml/Product/Viewed.php @@ -23,21 +23,23 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Reports\Block\Adminhtml\Product; /** * Adminhtml most viewed products report content block * - * @category Magento - * @package Magento_Reports * @author Magento Core Team <core@magentocommerce.com> */ - -namespace Magento\Reports\Block\Adminhtml\Product; - class Viewed extends \Magento\Backend\Block\Widget\Grid\Container { + /** + * @var string + */ protected $_template = 'report/grid/container.phtml'; + /** + * @return void + */ protected function _construct() { $this->_blockGroup = 'Magento_Reports'; diff --git a/app/code/Magento/Reports/Block/Adminhtml/Product/Viewed/Grid.php b/app/code/Magento/Reports/Block/Adminhtml/Product/Viewed/Grid.php index f8f9388fa690ba2aca7b8ab10cd7d505614141b0..012d5a514dcef9a0047b1a8b769a6550b891bc10 100644 --- a/app/code/Magento/Reports/Block/Adminhtml/Product/Viewed/Grid.php +++ b/app/code/Magento/Reports/Block/Adminhtml/Product/Viewed/Grid.php @@ -23,16 +23,13 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Reports\Block\Adminhtml\Product\Viewed; /** * Adminhtml most viewed products report grid block * - * @category Magento - * @package Magento_Reports * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\Reports\Block\Adminhtml\Product\Viewed; - class Grid extends \Magento\Reports\Block\Adminhtml\Grid\AbstractGrid { /** @@ -51,6 +48,8 @@ class Grid extends \Magento\Reports\Block\Adminhtml\Grid\AbstractGrid /** * Init grid parameters + * + * @return void */ protected function _construct() { @@ -125,7 +124,7 @@ class Grid extends \Magento\Reports\Block\Adminhtml\Grid\AbstractGrid * * @param \Magento\Reports\Model\Resource\Report\Collection\AbstractCollection $collection * @param \Magento\Object $filterData - * @return \Magento\Reports\Block\Adminhtml\Grid\AbstractGrid + * @return $this * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ protected function _addOrderStatusFilter($collection, $filterData) diff --git a/app/code/Magento/Reports/Block/Adminhtml/Refresh/Statistics.php b/app/code/Magento/Reports/Block/Adminhtml/Refresh/Statistics.php index f1612cfceecb1150c01efbbff33d32d1d61f075c..b26717fa28c929beafc9e95298ee14487de7209a 100644 --- a/app/code/Magento/Reports/Block/Adminhtml/Refresh/Statistics.php +++ b/app/code/Magento/Reports/Block/Adminhtml/Refresh/Statistics.php @@ -23,20 +23,19 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Reports\Block\Adminhtml\Refresh; /** * Report Refresh statistic container * - * @category Magento - * @package Magento_Reports * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\Reports\Block\Adminhtml\Refresh; - class Statistics extends \Magento\Backend\Block\Widget\Grid\Container { - /* + /** * Modify Header and remove button "Add" + * + * @return void */ protected function _construct() { diff --git a/app/code/Magento/Reports/Block/Adminhtml/Review/Customer.php b/app/code/Magento/Reports/Block/Adminhtml/Review/Customer.php index 677260445bad3821ebcc4ed2aaea99d8d24f39c1..38079c1675dff358bb8d19fbe91f7e6fc1825d55 100644 --- a/app/code/Magento/Reports/Block/Adminhtml/Review/Customer.php +++ b/app/code/Magento/Reports/Block/Adminhtml/Review/Customer.php @@ -23,20 +23,18 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Reports\Block\Adminhtml\Review; /** * Adminhtml cms blocks content block * - * @category Magento - * @package Magento_Reports * @author Magento Core Team <core@magentocommerce.com> */ - -namespace Magento\Reports\Block\Adminhtml\Review; - class Customer extends \Magento\Backend\Block\Widget\Grid\Container { - + /** + * @return void + */ protected function _construct() { $this->_blockGroup = 'Magento_Reports'; diff --git a/app/code/Magento/Reports/Block/Adminhtml/Review/Detail.php b/app/code/Magento/Reports/Block/Adminhtml/Review/Detail.php index 20d40f1645c8964b96bfa4d5afa5058e5acc29e0..5c6289720bc4495412e612dad60dc571508a7aa9 100644 --- a/app/code/Magento/Reports/Block/Adminhtml/Review/Detail.php +++ b/app/code/Magento/Reports/Block/Adminhtml/Review/Detail.php @@ -23,17 +23,13 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Reports\Block\Adminhtml\Review; /** * Adminhtml report review product blocks content block * - * @category Magento - * @package Magento_Reports * @author Magento Core Team <core@magentocommerce.com> */ - -namespace Magento\Reports\Block\Adminhtml\Review; - class Detail extends \Magento\Backend\Block\Widget\Grid\Container { /** @@ -55,6 +51,9 @@ class Detail extends \Magento\Backend\Block\Widget\Grid\Container parent::__construct($context, $data); } + /** + * @return void + */ protected function _construct() { $this->_blockGroup = 'Magento_Reports'; diff --git a/app/code/Magento/Reports/Block/Adminhtml/Review/Detail/Grid.php b/app/code/Magento/Reports/Block/Adminhtml/Review/Detail/Grid.php index d28086d5d6e7255657c6b3638e558084dc681898..ef5d9ee3ad54b3f8a552de97dcd85f97aeefc148 100644 --- a/app/code/Magento/Reports/Block/Adminhtml/Review/Detail/Grid.php +++ b/app/code/Magento/Reports/Block/Adminhtml/Review/Detail/Grid.php @@ -23,16 +23,13 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Reports\Block\Adminhtml\Review\Detail; /** * Adminhtml report reviews product grid block * - * @category Magento - * @package Magento_Reports * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\Reports\Block\Adminhtml\Review\Detail; - class Grid extends \Magento\Backend\Block\Widget\Grid\Extended { /** @@ -56,12 +53,20 @@ class Grid extends \Magento\Backend\Block\Widget\Grid\Extended parent::__construct($context, $backendHelper, $data); } + /** + * @return void + */ protected function _construct() { parent::_construct(); $this->setId('reviews_grid'); } + /** + * Apply sorting and filtering to reports review collection + * + * @return $this + */ protected function _prepareCollection() { $collection = $this->_reviewsFactory->create() @@ -74,6 +79,11 @@ class Grid extends \Magento\Backend\Block\Widget\Grid\Extended return $this; } + /** + * Initialize grid report review columns + * + * @return $this + */ protected function _prepareColumns() { diff --git a/app/code/Magento/Reports/Block/Adminhtml/Review/Product.php b/app/code/Magento/Reports/Block/Adminhtml/Review/Product.php index dd0612bf25cd69e7c17d970550cf682b8fbb25f7..8a5597d1281cb1d388a18526efe7e0689f07573d 100644 --- a/app/code/Magento/Reports/Block/Adminhtml/Review/Product.php +++ b/app/code/Magento/Reports/Block/Adminhtml/Review/Product.php @@ -23,19 +23,18 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Reports\Block\Adminhtml\Review; /** * Adminhtml report review product blocks content block * - * @category Magento - * @package Magento_Reports * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\Reports\Block\Adminhtml\Review; - class Product extends \Magento\Backend\Block\Widget\Grid\Container { - + /** + * @return void + */ protected function _construct() { $this->_blockGroup = 'Magento_Reports'; diff --git a/app/code/Magento/Reports/Block/Adminhtml/Sales/Bestsellers.php b/app/code/Magento/Reports/Block/Adminhtml/Sales/Bestsellers.php index ae93629519987dbb792af0e43095927109232234..16b6004fa882d1ff42527f06f245c19027ce5496 100644 --- a/app/code/Magento/Reports/Block/Adminhtml/Sales/Bestsellers.php +++ b/app/code/Magento/Reports/Block/Adminhtml/Sales/Bestsellers.php @@ -23,21 +23,23 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Reports\Block\Adminhtml\Sales; /** * Adminhtml sales report page content block * - * @category Magento - * @package Magento_Reports * @author Magento Core Team <core@magentocommerce.com> */ - -namespace Magento\Reports\Block\Adminhtml\Sales; - class Bestsellers extends \Magento\Backend\Block\Widget\Grid\Container { + /** + * @var string + */ protected $_template = 'report/grid/container.phtml'; + /** + * @return void + */ protected function _construct() { $this->_blockGroup = 'Magento_Reports'; @@ -53,6 +55,9 @@ class Bestsellers extends \Magento\Backend\Block\Widget\Grid\Container )); } + /** + * @return string + */ public function getFilterUrl() { $this->getRequest()->setParam('filter', null); diff --git a/app/code/Magento/Reports/Block/Adminhtml/Sales/Bestsellers/Grid.php b/app/code/Magento/Reports/Block/Adminhtml/Sales/Bestsellers/Grid.php index 9d8fabfb6403fd52f7a57a9323e2423a673e6fcb..7ff9481834be4de548c145aa23f440cf54718d46 100644 --- a/app/code/Magento/Reports/Block/Adminhtml/Sales/Bestsellers/Grid.php +++ b/app/code/Magento/Reports/Block/Adminhtml/Sales/Bestsellers/Grid.php @@ -23,31 +23,40 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Reports\Block\Adminhtml\Sales\Bestsellers; /** * Adminhtml bestsellers report grid block * - * @category Magento - * @package Magento_Reports * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\Reports\Block\Adminhtml\Sales\Bestsellers; - class Grid extends \Magento\Reports\Block\Adminhtml\Grid\AbstractGrid { + /** + * @var string + */ protected $_columnGroupBy = 'period'; + /** + * @return void + */ protected function _construct() { parent::_construct(); $this->setCountTotals(true); } + /** + * @return string + */ public function getResourceCollectionName() { return 'Magento\Sales\Model\Resource\Report\Bestsellers\Collection'; } + /** + * @return \Magento\Backend\Block\Widget\Grid\Extended + */ protected function _prepareColumns() { $this->addColumn('period', array( diff --git a/app/code/Magento/Reports/Block/Adminhtml/Sales/Coupons.php b/app/code/Magento/Reports/Block/Adminhtml/Sales/Coupons.php index 16d8308e7aed221caa1cd4f3d36b737acefc360f..6876642a2dd17d54e93456468baad6cab9280a3a 100644 --- a/app/code/Magento/Reports/Block/Adminhtml/Sales/Coupons.php +++ b/app/code/Magento/Reports/Block/Adminhtml/Sales/Coupons.php @@ -23,21 +23,23 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Reports\Block\Adminhtml\Sales; /** * Adminhtml coupons report page content block * - * @category Magento - * @package Magento_Reports * @author Magento Core Team <core@magentocommerce.com> */ - -namespace Magento\Reports\Block\Adminhtml\Sales; - class Coupons extends \Magento\Backend\Block\Widget\Grid\Container { + /** + * @var string + */ protected $_template = 'report/grid/container.phtml'; + /** + * @return void + */ protected function _construct() { $this->_blockGroup = 'Magento_Reports'; @@ -53,6 +55,9 @@ class Coupons extends \Magento\Backend\Block\Widget\Grid\Container )); } + /** + * @return string + */ public function getFilterUrl() { $this->getRequest()->setParam('filter', null); diff --git a/app/code/Magento/Reports/Block/Adminhtml/Sales/Coupons/Grid.php b/app/code/Magento/Reports/Block/Adminhtml/Sales/Coupons/Grid.php index b5f2dffbc1b81c862eb9917acd2894a9d7ff9c09..b5034ff296a4f2dbee5602836ea7b827d3c09a75 100644 --- a/app/code/Magento/Reports/Block/Adminhtml/Sales/Coupons/Grid.php +++ b/app/code/Magento/Reports/Block/Adminhtml/Sales/Coupons/Grid.php @@ -23,20 +23,23 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Reports\Block\Adminhtml\Sales\Coupons; /** * Adminhtml coupons report grid block * - * @category Magento - * @package Magento_Reports * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\Reports\Block\Adminhtml\Sales\Coupons; - class Grid extends \Magento\Reports\Block\Adminhtml\Grid\AbstractGrid { + /** + * @var string + */ protected $_columnGroupBy = 'period'; + /** + * @return void + */ protected function _construct() { parent::_construct(); @@ -44,6 +47,9 @@ class Grid extends \Magento\Reports\Block\Adminhtml\Grid\AbstractGrid $this->setCountSubTotals(true); } + /** + * @return string + */ public function getResourceCollectionName() { if (($this->getFilterData()->getData('report_type') == 'updated_at_order')) { @@ -53,6 +59,9 @@ class Grid extends \Magento\Reports\Block\Adminhtml\Grid\AbstractGrid } } + /** + * @return \Magento\Backend\Block\Widget\Grid\Extended + */ protected function _prepareColumns() { $this->addColumn('period', array( diff --git a/app/code/Magento/Reports/Block/Adminhtml/Sales/Grid/Column/Renderer/Date.php b/app/code/Magento/Reports/Block/Adminhtml/Sales/Grid/Column/Renderer/Date.php index 14b2109ab7b039175da30c26a65e0a570fc321d3..43f26eeefc9d05f3704079eea8efc469a2fd17d7 100644 --- a/app/code/Magento/Reports/Block/Adminhtml/Sales/Grid/Column/Renderer/Date.php +++ b/app/code/Magento/Reports/Block/Adminhtml/Sales/Grid/Column/Renderer/Date.php @@ -23,12 +23,11 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Reports\Block\Adminhtml\Sales\Grid\Column\Renderer; /** * Adminhtml grid item renderer date */ -namespace Magento\Reports\Block\Adminhtml\Sales\Grid\Column\Renderer; - class Date extends \Magento\Backend\Block\Widget\Grid\Column\Renderer\Date { diff --git a/app/code/Magento/Reports/Block/Adminhtml/Sales/Invoiced.php b/app/code/Magento/Reports/Block/Adminhtml/Sales/Invoiced.php index 097de5ba6aec147792d574e1e3525923a06372bb..b1a837f1670e02877d391747bddd281c774ec8d5 100644 --- a/app/code/Magento/Reports/Block/Adminhtml/Sales/Invoiced.php +++ b/app/code/Magento/Reports/Block/Adminhtml/Sales/Invoiced.php @@ -23,21 +23,23 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Reports\Block\Adminhtml\Sales; /** * Adminhtml invoiced report page content block * - * @category Magento - * @package Magento_Reports * @author Magento Core Team <core@magentocommerce.com> */ - -namespace Magento\Reports\Block\Adminhtml\Sales; - class Invoiced extends \Magento\Backend\Block\Widget\Grid\Container { + /** + * @var string + */ protected $_template = 'report/grid/container.phtml'; + /** + * @return void + */ protected function _construct() { $this->_blockGroup = 'Magento_Reports'; @@ -53,6 +55,9 @@ class Invoiced extends \Magento\Backend\Block\Widget\Grid\Container )); } + /** + * @return string + */ public function getFilterUrl() { $this->getRequest()->setParam('filter', null); diff --git a/app/code/Magento/Reports/Block/Adminhtml/Sales/Invoiced/Grid.php b/app/code/Magento/Reports/Block/Adminhtml/Sales/Invoiced/Grid.php index f41384e35f7df66e929f42230e2c8d0876c0df04..4b3aa4f48ef07654e94d04cd8aa8e10c41670606 100644 --- a/app/code/Magento/Reports/Block/Adminhtml/Sales/Invoiced/Grid.php +++ b/app/code/Magento/Reports/Block/Adminhtml/Sales/Invoiced/Grid.php @@ -23,26 +23,32 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Reports\Block\Adminhtml\Sales\Invoiced; /** * Adminhtml invoiced report grid block * - * @category Magento - * @package Magento_Reports * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\Reports\Block\Adminhtml\Sales\Invoiced; - class Grid extends \Magento\Reports\Block\Adminhtml\Grid\AbstractGrid { + /** + * @var string + */ protected $_columnGroupBy = 'period'; + /** + * @return void + */ protected function _construct() { parent::_construct(); $this->setCountTotals(true); } + /** + * @return string + */ public function getResourceCollectionName() { return ($this->getFilterData()->getData('report_type') == 'created_at_invoice') @@ -50,6 +56,9 @@ class Grid extends \Magento\Reports\Block\Adminhtml\Grid\AbstractGrid : 'Magento\Sales\Model\Resource\Report\Invoiced\Collection\Order'; } + /** + * @return \Magento\Backend\Block\Widget\Grid\Extended + */ protected function _prepareColumns() { $this->addColumn('period', array( diff --git a/app/code/Magento/Reports/Block/Adminhtml/Sales/Refunded.php b/app/code/Magento/Reports/Block/Adminhtml/Sales/Refunded.php index 67e04c041ef569825959c7e827da5d7f47019d07..2eeae7824022bfdb2ad5538754755cca9ae00cea 100644 --- a/app/code/Magento/Reports/Block/Adminhtml/Sales/Refunded.php +++ b/app/code/Magento/Reports/Block/Adminhtml/Sales/Refunded.php @@ -23,21 +23,23 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Reports\Block\Adminhtml\Sales; /** * Adminhtml refunded report page content block * - * @category Magento - * @package Magento_Reports * @author Magento Core Team <core@magentocommerce.com> */ - -namespace Magento\Reports\Block\Adminhtml\Sales; - class Refunded extends \Magento\Backend\Block\Widget\Grid\Container { + /** + * @var string + */ protected $_template = 'report/grid/container.phtml'; + /** + * @return void + */ protected function _construct() { $this->_blockGroup = 'Magento_Reports'; @@ -53,6 +55,9 @@ class Refunded extends \Magento\Backend\Block\Widget\Grid\Container )); } + /** + * @return string + */ public function getFilterUrl() { $this->getRequest()->setParam('filter', null); diff --git a/app/code/Magento/Reports/Block/Adminhtml/Sales/Refunded/Grid.php b/app/code/Magento/Reports/Block/Adminhtml/Sales/Refunded/Grid.php index 4187fc71e7d401bf3029ac32fe02c8ec65796407..ba33d88c9fb048c954482c6f3978bce585c294ca 100644 --- a/app/code/Magento/Reports/Block/Adminhtml/Sales/Refunded/Grid.php +++ b/app/code/Magento/Reports/Block/Adminhtml/Sales/Refunded/Grid.php @@ -23,26 +23,32 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Reports\Block\Adminhtml\Sales\Refunded; /** * Adminhtml refunded report grid block * - * @category Magento - * @package Magento_Reports * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\Reports\Block\Adminhtml\Sales\Refunded; - class Grid extends \Magento\Reports\Block\Adminhtml\Grid\AbstractGrid { + /** + * @var string + */ protected $_columnGroupBy = 'period'; + /** + * @return void + */ protected function _construct() { parent::_construct(); $this->setCountTotals(true); } + /** + * @return string + */ public function getResourceCollectionName() { return ($this->getFilterData()->getData('report_type') == 'created_at_refunded') @@ -50,6 +56,9 @@ class Grid extends \Magento\Reports\Block\Adminhtml\Grid\AbstractGrid : 'Magento\Sales\Model\Resource\Report\Refunded\Collection\Order'; } + /** + * @return \Magento\Backend\Block\Widget\Grid\Extended + */ protected function _prepareColumns() { $this->addColumn('period', array( diff --git a/app/code/Magento/Reports/Block/Adminhtml/Sales/Sales.php b/app/code/Magento/Reports/Block/Adminhtml/Sales/Sales.php index 2042136eff074d37bc35a776a757616c48e2765b..805d4835b2d66a9f92909964dfc58cddea1a82ab 100644 --- a/app/code/Magento/Reports/Block/Adminhtml/Sales/Sales.php +++ b/app/code/Magento/Reports/Block/Adminhtml/Sales/Sales.php @@ -23,21 +23,23 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Reports\Block\Adminhtml\Sales; /** * Adminhtml sales report page content block * - * @category Magento - * @package Magento_Reports * @author Magento Core Team <core@magentocommerce.com> */ - -namespace Magento\Reports\Block\Adminhtml\Sales; - class Sales extends \Magento\Backend\Block\Widget\Grid\Container { + /** + * @var string + */ protected $_template = 'report/grid/container.phtml'; + /** + * @return void + */ protected function _construct() { $this->_blockGroup = 'Magento_Reports'; @@ -53,6 +55,9 @@ class Sales extends \Magento\Backend\Block\Widget\Grid\Container )); } + /** + * @return string + */ public function getFilterUrl() { $this->getRequest()->setParam('filter', null); diff --git a/app/code/Magento/Reports/Block/Adminhtml/Sales/Sales/Grid.php b/app/code/Magento/Reports/Block/Adminhtml/Sales/Sales/Grid.php index 2b62bb8d658f6a5785014a62d8f522677bbf3246..d89ce2186b9192bc3a48eca3611c5571a005b520 100644 --- a/app/code/Magento/Reports/Block/Adminhtml/Sales/Sales/Grid.php +++ b/app/code/Magento/Reports/Block/Adminhtml/Sales/Sales/Grid.php @@ -23,26 +23,32 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Reports\Block\Adminhtml\Sales\Sales; /** * Adminhtml sales report grid block * - * @category Magento - * @package Magento_Reports * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\Reports\Block\Adminhtml\Sales\Sales; - class Grid extends \Magento\Reports\Block\Adminhtml\Grid\AbstractGrid { + /** + * @var string + */ protected $_columnGroupBy = 'period'; + /** + * @return void + */ protected function _construct() { parent::_construct(); $this->setCountTotals(true); } + /** + * @return string + */ public function getResourceCollectionName() { return ($this->getFilterData()->getData('report_type') == 'updated_at_order') @@ -50,6 +56,9 @@ class Grid extends \Magento\Reports\Block\Adminhtml\Grid\AbstractGrid : 'Magento\Sales\Model\Resource\Report\Order\Collection'; } + /** + * @return \Magento\Backend\Block\Widget\Grid\Extended + */ protected function _prepareColumns() { $this->addColumn('period', array( diff --git a/app/code/Magento/Reports/Block/Adminhtml/Sales/Shipping.php b/app/code/Magento/Reports/Block/Adminhtml/Sales/Shipping.php index 01a50d0b5d9102cc7b4c0d2bed7ea5586e4e1e23..1a401e45bd4ea585677471ea8d8ba77874604747 100644 --- a/app/code/Magento/Reports/Block/Adminhtml/Sales/Shipping.php +++ b/app/code/Magento/Reports/Block/Adminhtml/Sales/Shipping.php @@ -23,22 +23,23 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Reports\Block\Adminhtml\Sales; /** * Adminhtml shipping report page content block * - * @category Magento - * @package Magento_Reports * @author Magento Core Team <core@magentocommerce.com> */ - -namespace Magento\Reports\Block\Adminhtml\Sales; - class Shipping extends \Magento\Backend\Block\Widget\Grid\Container { - + /** + * @var string + */ protected $_template = 'report/grid/container.phtml'; + /** + * @return void + */ protected function _construct() { $this->_blockGroup = 'Magento_Reports'; @@ -54,6 +55,9 @@ class Shipping extends \Magento\Backend\Block\Widget\Grid\Container )); } + /** + * @return string + */ public function getFilterUrl() { $this->getRequest()->setParam('filter', null); diff --git a/app/code/Magento/Reports/Block/Adminhtml/Sales/Shipping/Grid.php b/app/code/Magento/Reports/Block/Adminhtml/Sales/Shipping/Grid.php index b7d676a2eff3edc19a298183ab4fd0d0ec3b315b..22be9d78d236f24065d25093fb02443d2baf8f58 100644 --- a/app/code/Magento/Reports/Block/Adminhtml/Sales/Shipping/Grid.php +++ b/app/code/Magento/Reports/Block/Adminhtml/Sales/Shipping/Grid.php @@ -23,20 +23,23 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Reports\Block\Adminhtml\Sales\Shipping; /** * Adminhtml shipping report grid block * - * @category Magento - * @package Magento_Reports * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\Reports\Block\Adminhtml\Sales\Shipping; - class Grid extends \Magento\Reports\Block\Adminhtml\Grid\AbstractGrid { + /** + * @var string + */ protected $_columnGroupBy = 'period'; + /** + * @return void + */ protected function _construct() { parent::_construct(); @@ -44,6 +47,9 @@ class Grid extends \Magento\Reports\Block\Adminhtml\Grid\AbstractGrid $this->setCountSubTotals(true); } + /** + * @return string + */ public function getResourceCollectionName() { return ($this->getFilterData()->getData('report_type') == 'created_at_shipment') @@ -51,6 +57,9 @@ class Grid extends \Magento\Reports\Block\Adminhtml\Grid\AbstractGrid : 'Magento\Sales\Model\Resource\Report\Shipping\Collection\Order'; } + /** + * @return \Magento\Backend\Block\Widget\Grid\Extended + */ protected function _prepareColumns() { $this->addColumn('period', array( @@ -122,5 +131,3 @@ class Grid extends \Magento\Reports\Block\Adminhtml\Grid\AbstractGrid } } - - diff --git a/app/code/Magento/Reports/Block/Adminhtml/Sales/Tax.php b/app/code/Magento/Reports/Block/Adminhtml/Sales/Tax.php index 297b09696cee53ee1bf088c6f203f870fb6e146d..bb1b5827deab23e17c9d7e8223bd1276545e5b43 100644 --- a/app/code/Magento/Reports/Block/Adminhtml/Sales/Tax.php +++ b/app/code/Magento/Reports/Block/Adminhtml/Sales/Tax.php @@ -23,22 +23,23 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Reports\Block\Adminhtml\Sales; /** * Adminhtml tax report page content block * - * @category Magento - * @package Magento_Reports * @author Magento Core Team <core@magentocommerce.com> */ - -namespace Magento\Reports\Block\Adminhtml\Sales; - class Tax extends \Magento\Backend\Block\Widget\Grid\Container { - + /** + * @var string + */ protected $_template = 'report/grid/container.phtml'; + /** + * @return void + */ protected function _construct() { $this->_blockGroup = 'Magento_Reports'; @@ -54,6 +55,9 @@ class Tax extends \Magento\Backend\Block\Widget\Grid\Container )); } + /** + * @return string + */ public function getFilterUrl() { $this->getRequest()->setParam('filter', null); diff --git a/app/code/Magento/Reports/Block/Adminhtml/Sales/Tax/Grid.php b/app/code/Magento/Reports/Block/Adminhtml/Sales/Tax/Grid.php index 44adfe5e890f45ac40d16c67bcf72663f97bc96f..58b1202817bf264715ab0150fe13e4ea39b4092f 100644 --- a/app/code/Magento/Reports/Block/Adminhtml/Sales/Tax/Grid.php +++ b/app/code/Magento/Reports/Block/Adminhtml/Sales/Tax/Grid.php @@ -23,18 +23,18 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Reports\Block\Adminhtml\Sales\Tax; /** * Adminhtml tax report grid block * - * @category Magento - * @package Magento_Reports * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\Reports\Block\Adminhtml\Sales\Tax; - class Grid extends \Magento\Reports\Block\Adminhtml\Grid\AbstractGrid { + /** + * @var string + */ protected $_columnGroupBy = 'period'; /** @@ -71,6 +71,9 @@ class Grid extends \Magento\Reports\Block\Adminhtml\Grid\AbstractGrid ); } + /** + * @return void + */ protected function _construct() { parent::_construct(); @@ -78,6 +81,9 @@ class Grid extends \Magento\Reports\Block\Adminhtml\Grid\AbstractGrid $this->setCountSubTotals(true); } + /** + * @return string + */ public function getResourceCollectionName() { return ($this->getFilterData()->getData('report_type') == 'updated_at_order') @@ -85,6 +91,9 @@ class Grid extends \Magento\Reports\Block\Adminhtml\Grid\AbstractGrid : 'Magento\Tax\Model\Resource\Report\Collection'; } + /** + * @return \Magento\Backend\Block\Widget\Grid\Extended + */ protected function _prepareColumns() { $this->addColumn('period', array( @@ -152,8 +161,7 @@ class Grid extends \Magento\Reports\Block\Adminhtml\Grid\AbstractGrid } /** - * Preparing collection - * Filter canceled statuses for orders in taxes + * Preparing collection. Filter canceled statuses for orders in taxes * * @return \Magento\Reports\Block\Adminhtml\Sales\Tax\Grid */ diff --git a/app/code/Magento/Reports/Block/Adminhtml/Search.php b/app/code/Magento/Reports/Block/Adminhtml/Search.php index c8da700516071ea45eeb05a0841fc6c8a63ada66..686b6a7ecf65e3cdb4ab822210d81ac9f2ce27f1 100644 --- a/app/code/Magento/Reports/Block/Adminhtml/Search.php +++ b/app/code/Magento/Reports/Block/Adminhtml/Search.php @@ -23,22 +23,19 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Reports\Block\Adminhtml; /** * Adminhtml search report page content block * - * @category Magento - * @package Magento_Reports * @author Magento Core Team <core@magentocommerce.com> */ - -namespace Magento\Reports\Block\Adminhtml; - class Search extends \Magento\Backend\Block\Widget\Grid\Container { /** * Initialize Grid Container * + * @return void */ protected function _construct() { diff --git a/app/code/Magento/Reports/Block/Adminhtml/Shopcart/Abandoned.php b/app/code/Magento/Reports/Block/Adminhtml/Shopcart/Abandoned.php index 6d90173c95b31e4248e0b312b22d4173e4d0ca4c..ebf6fa28372a3b55f42ffb3d94e36bb1ef6a698a 100644 --- a/app/code/Magento/Reports/Block/Adminhtml/Shopcart/Abandoned.php +++ b/app/code/Magento/Reports/Block/Adminhtml/Shopcart/Abandoned.php @@ -23,19 +23,18 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Reports\Block\Adminhtml\Shopcart; /** * Adminhtml abandoned shopping cart report page content block * - * @category Magento - * @package Magento_Reports * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\Reports\Block\Adminhtml\Shopcart; - class Abandoned extends \Magento\Backend\Block\Widget\Grid\Container { - + /** + * @return void + */ protected function _construct() { $this->_blockGroup = 'Magento_Reports'; @@ -45,6 +44,9 @@ class Abandoned extends \Magento\Backend\Block\Widget\Grid\Container $this->_removeButton('add'); } + /** + * @return \Magento\View\Element\AbstractBlock + */ protected function _prepareLayout() { $this->setChild('store_switcher', @@ -57,6 +59,9 @@ class Abandoned extends \Magento\Backend\Block\Widget\Grid\Container return parent::_prepareLayout(); } + /** + * @return string + */ public function getStoreSwitcherHtml() { if ($this->_storeManager->isSingleStoreMode()) { @@ -65,6 +70,9 @@ class Abandoned extends \Magento\Backend\Block\Widget\Grid\Container return $this->getChildHtml('store_switcher'); } + /** + * @return string + */ public function getGridHtml() { return $this->getStoreSwitcherHtml() . parent::getGridHtml(); diff --git a/app/code/Magento/Reports/Block/Adminhtml/Shopcart/Abandoned/Grid.php b/app/code/Magento/Reports/Block/Adminhtml/Shopcart/Abandoned/Grid.php index ff7f09092ab171a262dca979a5e982ee1f1fd7d3..51daaf028a0c09090a46cbaad5708f43cff802de 100644 --- a/app/code/Magento/Reports/Block/Adminhtml/Shopcart/Abandoned/Grid.php +++ b/app/code/Magento/Reports/Block/Adminhtml/Shopcart/Abandoned/Grid.php @@ -23,16 +23,13 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Reports\Block\Adminhtml\Shopcart\Abandoned; /** * Adminhtml abandoned shopping carts report grid block * - * @category Magento - * @package Magento_Reports * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\Reports\Block\Adminhtml\Shopcart\Abandoned; - class Grid extends \Magento\Reports\Block\Adminhtml\Grid\Shopcart { /** @@ -56,12 +53,18 @@ class Grid extends \Magento\Reports\Block\Adminhtml\Grid\Shopcart parent::__construct($context, $backendHelper, $data); } + /** + * @return void + */ protected function _construct() { parent::_construct(); $this->setId('gridAbandoned'); } + /** + * @return \Magento\Backend\Block\Widget\Grid + */ protected function _prepareCollection() { /** @var $collection \Magento\Reports\Model\Resource\Quote\Collection */ @@ -83,6 +86,9 @@ class Grid extends \Magento\Reports\Block\Adminhtml\Grid\Shopcart return parent::_prepareCollection(); } + /** + * @return $this + */ protected function _addColumnFilterToCollection($column) { $field = ( $column->getFilterIndex() ) ? $column->getFilterIndex() : $column->getIndex(); @@ -96,6 +102,9 @@ class Grid extends \Magento\Reports\Block\Adminhtml\Grid\Shopcart return $this; } + /** + * @return \Magento\Backend\Block\Widget\Grid\Extended + */ protected function _prepareColumns() { $this->addColumn('customer_name', array( @@ -198,6 +207,9 @@ class Grid extends \Magento\Reports\Block\Adminhtml\Grid\Shopcart return parent::_prepareColumns(); } + /** + * @return string + */ public function getRowUrl($row) { return $this->getUrl('customer/index/edit', array('id'=>$row->getCustomerId(), 'active_tab'=>'cart')); diff --git a/app/code/Magento/Reports/Block/Adminhtml/Shopcart/Customer.php b/app/code/Magento/Reports/Block/Adminhtml/Shopcart/Customer.php index 3e364feecceef994e73f17ae4b9823b4f0431936..fe9ecd35f679a9649ba9c0e82412792abfb6cf4b 100644 --- a/app/code/Magento/Reports/Block/Adminhtml/Shopcart/Customer.php +++ b/app/code/Magento/Reports/Block/Adminhtml/Shopcart/Customer.php @@ -23,19 +23,18 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Reports\Block\Adminhtml\Shopcart; /** * Adminhtml Shopping cart customers report page content block * - * @category Magento - * @package Magento_Reports * @author Magento Core Team <core@magentocommerce.com> */ - -namespace Magento\Reports\Block\Adminhtml\Shopcart; - class Customer extends \Magento\Backend\Block\Widget\Grid\Container { + /** + * @return void + */ protected function _construct() { $this->_blockGroup = 'Magento_Reports'; diff --git a/app/code/Magento/Reports/Block/Adminhtml/Shopcart/Customer/Grid.php b/app/code/Magento/Reports/Block/Adminhtml/Shopcart/Customer/Grid.php index 0505ca3af83c8ea71f0508117e1dd563207ff5ae..59f8759abdf9b4878a57812d8b4403abbd48ee14 100644 --- a/app/code/Magento/Reports/Block/Adminhtml/Shopcart/Customer/Grid.php +++ b/app/code/Magento/Reports/Block/Adminhtml/Shopcart/Customer/Grid.php @@ -23,16 +23,13 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Reports\Block\Adminhtml\Shopcart\Customer; /** * Adminhtml items in carts report grid block * - * @category Magento - * @package Magento_Reports * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\Reports\Block\Adminhtml\Shopcart\Customer; - class Grid extends \Magento\Reports\Block\Adminhtml\Grid\Shopcart { /** @@ -56,12 +53,18 @@ class Grid extends \Magento\Reports\Block\Adminhtml\Grid\Shopcart parent::__construct($context, $backendHelper, $data); } + /** + * @return void + */ protected function _construct() { parent::_construct(); $this->setId('grid'); } + /** + * @return \Magento\Backend\Block\Widget\Grid + */ protected function _prepareCollection() { //TODO: add full name logic @@ -73,11 +76,17 @@ class Grid extends \Magento\Reports\Block\Adminhtml\Grid\Shopcart return parent::_prepareCollection(); } + /** + * @return \Magento\Backend\Block\Widget\Grid|void + */ protected function _afterLoadCollection() { $this->getCollection()->addCartInfo(); } + /** + * @return \Magento\Backend\Block\Widget\Grid\Extended + */ protected function _prepareColumns() { $this->addColumn('entity_id', array( diff --git a/app/code/Magento/Reports/Block/Adminhtml/Shopcart/Product.php b/app/code/Magento/Reports/Block/Adminhtml/Shopcart/Product.php index 4fab70354f50b993a876415060e9e3c656b69561..1c807ec9482645dc9d68fc7633a3ce7c59925f3a 100644 --- a/app/code/Magento/Reports/Block/Adminhtml/Shopcart/Product.php +++ b/app/code/Magento/Reports/Block/Adminhtml/Shopcart/Product.php @@ -23,19 +23,18 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Reports\Block\Adminhtml\Shopcart; /** * Adminhtml Shopping cart products report page content block * - * @category Magento - * @package Magento_Reports * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\Reports\Block\Adminhtml\Shopcart; - class Product extends \Magento\Backend\Block\Widget\Grid\Container { - + /** + * @return void + */ protected function _construct() { $this->_blockGroup = 'Magento_Reports'; diff --git a/app/code/Magento/Reports/Block/Adminhtml/Shopcart/Product/Grid.php b/app/code/Magento/Reports/Block/Adminhtml/Shopcart/Product/Grid.php index a90e69386d318784a5d9bd929c432e794fc287b9..40ce896921dc4b76c2e5c7fa6eea7a6417d2e349 100644 --- a/app/code/Magento/Reports/Block/Adminhtml/Shopcart/Product/Grid.php +++ b/app/code/Magento/Reports/Block/Adminhtml/Shopcart/Product/Grid.php @@ -23,16 +23,13 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Reports\Block\Adminhtml\Shopcart\Product; /** * Adminhtml products in carts report grid block * - * @category Magento - * @package Magento_Reports * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\Reports\Block\Adminhtml\Shopcart\Product; - class Grid extends \Magento\Reports\Block\Adminhtml\Grid\Shopcart { /** @@ -56,12 +53,18 @@ class Grid extends \Magento\Reports\Block\Adminhtml\Grid\Shopcart parent::__construct($context, $backendHelper, $data); } + /** + * @return void + */ protected function _construct() { parent::_construct(); $this->setId('gridProducts'); } + /** + * @return \Magento\Backend\Block\Widget\Grid + */ protected function _prepareCollection() { /** @var $collection \Magento\Reports\Model\Resource\Quote\Collection */ @@ -72,6 +75,9 @@ class Grid extends \Magento\Reports\Block\Adminhtml\Grid\Shopcart return parent::_prepareCollection(); } + /** + * @return \Magento\Backend\Block\Widget\Grid\Extended + */ protected function _prepareColumns() { $this->addColumn('entity_id', array( @@ -126,6 +132,9 @@ class Grid extends \Magento\Reports\Block\Adminhtml\Grid\Shopcart return parent::_prepareColumns(); } + /** + * @return string + */ public function getRowUrl($row) { return $this->getUrl('catalog/product/edit', array('id'=>$row->getEntityId())); diff --git a/app/code/Magento/Reports/Block/Adminhtml/Wishlist.php b/app/code/Magento/Reports/Block/Adminhtml/Wishlist.php index c040035c8382ebdc29eb3b005a964d95db10eef6..75170a8c4ce821563464802eda6d0a2bb76f5383 100644 --- a/app/code/Magento/Reports/Block/Adminhtml/Wishlist.php +++ b/app/code/Magento/Reports/Block/Adminhtml/Wishlist.php @@ -23,26 +23,48 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Reports\Block\Adminhtml; /** * Adminhtml wishlist report page content block * - * @category Magento - * @package Magento_Reports * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\Reports\Block\Adminhtml; - class Wishlist extends \Magento\Backend\Block\Template { - + /** + * @var + */ public $wishlists_count; + + /** + * @var + */ public $items_bought; + + /** + * @var + */ public $shared_count; + + /** + * @var + */ public $referrals_count; + + /** + * @var + */ public $conversions_count; + + /** + * @var + */ public $customer_with_wishlist; + /** + * @var string + */ protected $_template = 'report/wishlist.phtml'; /** @@ -66,6 +88,9 @@ class Wishlist extends \Magento\Backend\Block\Template parent::__construct($context, $data); } + /** + * @return $this + */ public function _beforeToHtml() { $this->setChild( diff --git a/app/code/Magento/Reports/Block/Adminhtml/Wishlist/Grid.php b/app/code/Magento/Reports/Block/Adminhtml/Wishlist/Grid.php index e51e4034265e992128cae58ae0422e2dde3121a5..95933e10043072982c225676eeab119cff8d8e41 100644 --- a/app/code/Magento/Reports/Block/Adminhtml/Wishlist/Grid.php +++ b/app/code/Magento/Reports/Block/Adminhtml/Wishlist/Grid.php @@ -23,16 +23,13 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Reports\Block\Adminhtml\Wishlist; /** * Adminhtml wishlist report grid block * - * @category Magento - * @package Magento_Reports * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\Reports\Block\Adminhtml\Wishlist; - class Grid extends \Magento\Backend\Block\Widget\Grid\Extended { /** @@ -56,6 +53,9 @@ class Grid extends \Magento\Backend\Block\Widget\Grid\Extended parent::__construct($context, $backendHelper, $data); } + /** + * @return void + */ protected function _construct() { parent::_construct(); @@ -64,6 +64,9 @@ class Grid extends \Magento\Backend\Block\Widget\Grid\Extended $this->setDefaultDir('desc'); } + /** + * @return $this|\Magento\Backend\Block\Widget\Grid + */ protected function _prepareCollection() { @@ -79,6 +82,9 @@ class Grid extends \Magento\Backend\Block\Widget\Grid\Extended return $this; } + /** + * @return \Magento\Backend\Block\Widget\Grid\Extended + */ protected function _prepareColumns() { $this->addColumn('entity_id', array( diff --git a/app/code/Magento/Reports/Block/Product/AbstractProduct.php b/app/code/Magento/Reports/Block/Product/AbstractProduct.php index 03ab396976e89ddfa49916649abb74092a2a9c1d..227028ef78689d4f1214edc7fb295452672eb1d2 100644 --- a/app/code/Magento/Reports/Block/Product/AbstractProduct.php +++ b/app/code/Magento/Reports/Block/Product/AbstractProduct.php @@ -23,17 +23,14 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Reports\Block\Product; /** * Reports Recently Products Abstract Block * - * @category Magento - * @package Magento_Reports * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\Reports\Block\Product; - abstract class AbstractProduct extends \Magento\Catalog\Block\Product\AbstractProduct { /** diff --git a/app/code/Magento/Reports/Block/Product/Compared.php b/app/code/Magento/Reports/Block/Product/Compared.php index 26a602676d62f2f14aaa37f73816616212d9bcaa..7e1b5d48399c4251a45e0b0a437a2de923bb978d 100644 --- a/app/code/Magento/Reports/Block/Product/Compared.php +++ b/app/code/Magento/Reports/Block/Product/Compared.php @@ -23,16 +23,13 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Reports\Block\Product; /** * Reports Recently Compared Products Block * - * @category Magento - * @package Magento_Reports * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\Reports\Block\Product; - class Compared extends \Magento\Reports\Block\Product\AbstractProduct { const XML_PATH_RECENTLY_COMPARED_COUNT = 'catalog/recently_products/compared_count'; diff --git a/app/code/Magento/Reports/Block/Product/Viewed.php b/app/code/Magento/Reports/Block/Product/Viewed.php index 679586f4c0c2f07e25e8230ecb2ce7832a412665..c905ee8b5e2157ffa7410103b45b4cf99736373d 100644 --- a/app/code/Magento/Reports/Block/Product/Viewed.php +++ b/app/code/Magento/Reports/Block/Product/Viewed.php @@ -23,16 +23,13 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Reports\Block\Product; /** * Reports Recently Viewed Products Block * - * @category Magento - * @package Magento_Reports * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\Reports\Block\Product; - class Viewed extends \Magento\Reports\Block\Product\AbstractProduct { const XML_PATH_RECENTLY_VIEWED_COUNT = 'catalog/recently_products/viewed_count'; @@ -59,6 +56,8 @@ class Viewed extends \Magento\Reports\Block\Product\AbstractProduct /** * Added predefined ids support + * + * @return int */ public function getCount() { diff --git a/app/code/Magento/Reports/Block/Product/Widget/Compared.php b/app/code/Magento/Reports/Block/Product/Widget/Compared.php index 564c3749d7fa6af61c8499ad0a462c0ac0b281c4..9a97085dc71b729e9366c1c27e10d1dd8bb27db7 100644 --- a/app/code/Magento/Reports/Block/Product/Widget/Compared.php +++ b/app/code/Magento/Reports/Block/Product/Widget/Compared.php @@ -23,16 +23,13 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Reports\Block\Product\Widget; /** * Reports Recently Compared Products Widget * - * @category Magento - * @package Magento_Reports * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\Reports\Block\Product\Widget; - class Compared extends \Magento\Reports\Block\Product\Compared implements \Magento\Widget\Block\BlockInterface @@ -40,6 +37,7 @@ class Compared /** * Internal constructor * + * @return void */ protected function _construct() { diff --git a/app/code/Magento/Reports/Block/Product/Widget/Viewed.php b/app/code/Magento/Reports/Block/Product/Widget/Viewed.php index 44eaa7c0e0f602e939c0b6c8b37fd099fe506004..291b6a444370b18d73265ca20d21745794d8ff88 100644 --- a/app/code/Magento/Reports/Block/Product/Widget/Viewed.php +++ b/app/code/Magento/Reports/Block/Product/Widget/Viewed.php @@ -23,16 +23,13 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Reports\Block\Product\Widget; /** * Reports Recently Viewed Products Widget * - * @category Magento - * @package Magento_Reports * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\Reports\Block\Product\Widget; - class Viewed extends \Magento\Reports\Block\Product\Viewed implements \Magento\Widget\Block\BlockInterface @@ -40,6 +37,7 @@ class Viewed /** * Internal constructor * + * @return void */ protected function _construct() { diff --git a/app/code/Magento/Reports/Controller/Adminhtml/Index.php b/app/code/Magento/Reports/Controller/Adminhtml/Index.php index f74044ba2f3889622519962ec186feafff45b9aa..6ab0ab0683c048a45133484ba9005df0227ad47b 100644 --- a/app/code/Magento/Reports/Controller/Adminhtml/Index.php +++ b/app/code/Magento/Reports/Controller/Adminhtml/Index.php @@ -33,6 +33,8 @@ */ namespace Magento\Reports\Controller\Adminhtml; +use Magento\App\ResponseInterface; + class Index extends \Magento\Backend\App\Action { /** @@ -52,6 +54,11 @@ class Index extends \Magento\Backend\App\Action parent::__construct($context); } + /** + * Add reports to breadcrumb + * + * @return $this + */ public function _initAction() { $this->_view->loadLayout(); @@ -59,7 +66,11 @@ class Index extends \Magento\Backend\App\Action return $this; } - + /** + * Search terms report action + * + * @return void + */ public function searchAction() { $this->_title->add(__('Search Terms Report')); @@ -74,6 +85,8 @@ class Index extends \Magento\Backend\App\Action /** * Export search report grid to CSV format + * + * @return ResponseInterface */ public function exportSearchCsvAction() { @@ -84,6 +97,8 @@ class Index extends \Magento\Backend\App\Action /** * Export search report to Excel XML format + * + * @return ResponseInterface */ public function exportSearchExcelAction() { @@ -92,6 +107,11 @@ class Index extends \Magento\Backend\App\Action return $this->_fileFactory->create('search.xml', $content->getExcelFile(), \Magento\App\Filesystem::VAR_DIR); } + /** + * Determine if action is allowed for reports module + * + * @return bool + */ protected function _isAllowed() { switch ($this->getRequest()->getActionName()) { diff --git a/app/code/Magento/Reports/Controller/Adminhtml/Report/Customer.php b/app/code/Magento/Reports/Controller/Adminhtml/Report/Customer.php index d1a1d76fd83e8d26e8cf5e2134773d24e9afc2b8..4b76d4ae1f18116dc6bb39ecacc5dba16d1e7d64 100644 --- a/app/code/Magento/Reports/Controller/Adminhtml/Report/Customer.php +++ b/app/code/Magento/Reports/Controller/Adminhtml/Report/Customer.php @@ -34,6 +34,9 @@ */ namespace Magento\Reports\Controller\Adminhtml\Report; +use Magento\App\ResponseInterface; +use Magento\Backend\Block\Widget\Grid\ExportInterface; + class Customer extends \Magento\Backend\App\Action { /** @@ -53,6 +56,11 @@ class Customer extends \Magento\Backend\App\Action parent::__construct($context); } + /** + * Add reports and customer breadcrumbs + * + * @return $this + */ public function _initAction() { $act = $this->getRequest()->getActionName(); @@ -72,6 +80,11 @@ class Customer extends \Magento\Backend\App\Action return $this; } + /** + * New accounts action + * + * @return void + */ public function accountsAction() { $this->_title->add(__('New Accounts Report')); @@ -87,24 +100,28 @@ class Customer extends \Magento\Backend\App\Action /** * Export new accounts report grid to CSV format + * + * @return ResponseInterface */ public function exportAccountsCsvAction() { $this->_view->loadLayout(); $fileName = 'new_accounts.csv'; - /** @var \Magento\Backend\Block\Widget\Grid\ExportInterface $exportBlock */ + /** @var ExportInterface $exportBlock */ $exportBlock = $this->_view->getLayout()->getChildBlock('adminhtml.report.grid', 'grid.export'); return $this->_fileFactory->create($fileName, $exportBlock->getCsvFile(), \Magento\App\Filesystem::VAR_DIR); } /** * Export new accounts report grid to Excel XML format + * + * @return ResponseInterface */ public function exportAccountsExcelAction() { $this->_view->loadLayout(); $fileName = 'new_accounts.xml'; - /** @var \Magento\Backend\Block\Widget\Grid\ExportInterface $exportBlock */ + /** @var ExportInterface $exportBlock */ $exportBlock = $this->_view->getLayout()->getChildBlock('adminhtml.report.grid', 'grid.export'); return $this->_fileFactory->create( $fileName, @@ -113,6 +130,11 @@ class Customer extends \Magento\Backend\App\Action ); } + /** + * Customers by number of orders action + * + * @return void + */ public function ordersAction() { $this->_title->add(__('Order Count Report')); @@ -126,28 +148,37 @@ class Customer extends \Magento\Backend\App\Action /** * Export customers most ordered report to CSV format + * + * @return ResponseInterface */ public function exportOrdersCsvAction() { $this->_view->loadLayout(); $fileName = 'customers_orders.csv'; - /** @var \Magento\Backend\Block\Widget\Grid\ExportInterface $exportBlock */ + /** @var ExportInterface $exportBlock */ $exportBlock = $this->_view->getLayout()->getChildBlock('adminhtml.report.grid', 'grid.export'); return $this->_fileFactory->create($fileName, $exportBlock->getCsvFile()); } /** * Export customers most ordered report to Excel XML format + * + * @return ResponseInterface */ public function exportOrdersExcelAction() { $this->_view->loadLayout(); $fileName = 'customers_orders.xml'; - /** @var \Magento\Backend\Block\Widget\Grid\ExportInterface $exportBlock */ + /** @var ExportInterface $exportBlock */ $exportBlock = $this->_view->getLayout()->getChildBlock('adminhtml.report.grid', 'grid.export'); return $this->_fileFactory->create($fileName, $exportBlock->getExcelFile($fileName)); } + /** + * Customers by orders total action + * + * @return void + */ public function totalsAction() { $this->_title->add(__('Order Total Report')); @@ -161,28 +192,37 @@ class Customer extends \Magento\Backend\App\Action /** * Export customers biggest totals report to CSV format + * + * @return ResponseInterface */ public function exportTotalsCsvAction() { $this->_view->loadLayout(); $fileName = 'customer_totals.csv'; - /** @var \Magento\Backend\Block\Widget\Grid\ExportInterface $exportBlock */ + /** @var ExportInterface $exportBlock */ $exportBlock = $this->_view->getLayout()->getChildBlock('adminhtml.report.grid', 'grid.export'); return $this->_fileFactory->create($fileName, $exportBlock->getCsvFile()); } /** * Export customers biggest totals report to Excel XML format + * + * @return ResponseInterface */ public function exportTotalsExcelAction() { $this->_view->loadLayout(); $fileName = 'customer_totals.xml'; - /** @var \Magento\Backend\Block\Widget\Grid\ExportInterface $exportBlock */ + /** @var ExportInterface $exportBlock */ $exportBlock = $this->_view->getLayout()->getChildBlock('adminhtml.report.grid', 'grid.export'); return $this->_fileFactory->create($fileName, $exportBlock->getExcelFile($fileName)); } + /** + * Determine if action is allowed for reports module + * + * @return bool + */ protected function _isAllowed() { switch ($this->getRequest()->getActionName()) { diff --git a/app/code/Magento/Reports/Controller/Adminhtml/Report/Product.php b/app/code/Magento/Reports/Controller/Adminhtml/Report/Product.php index 1059c09cb17ecd74aa4b960ae129bdb541a78566..3a5c2752a826a594def9b9d897c074f96d4ac6a3 100644 --- a/app/code/Magento/Reports/Controller/Adminhtml/Report/Product.php +++ b/app/code/Magento/Reports/Controller/Adminhtml/Report/Product.php @@ -34,12 +34,16 @@ */ namespace Magento\Reports\Controller\Adminhtml\Report; -class Product extends \Magento\Reports\Controller\Adminhtml\Report\AbstractReport +use Magento\App\ResponseInterface; +use Magento\Backend\Block\Widget\Grid\ExportInterface; +use Magento\Reports\Model\Flag; + +class Product extends AbstractReport { /** * Add report/products breadcrumbs * - * @return \Magento\Reports\Controller\Adminhtml\Report\Product + * @return $this */ public function _initAction() { @@ -54,6 +58,7 @@ class Product extends \Magento\Reports\Controller\Adminhtml\Report\AbstractRepor /** * Sold Products Report Action * + * @return void */ public function soldAction() { @@ -70,12 +75,13 @@ class Product extends \Magento\Reports\Controller\Adminhtml\Report\AbstractRepor /** * Export Sold Products report to CSV format action * + * @return ResponseInterface */ public function exportSoldCsvAction() { $this->_view->loadLayout(); $fileName = 'products_ordered.csv'; - /** @var \Magento\Backend\Block\Widget\Grid\ExportInterface $exportBlock */ + /** @var ExportInterface $exportBlock */ $exportBlock = $this->_view->getLayout()->getChildBlock('adminhtml.report.grid', 'grid.export'); return $this->_fileFactory->create($fileName, $exportBlock->getCsvFile()); } @@ -83,12 +89,13 @@ class Product extends \Magento\Reports\Controller\Adminhtml\Report\AbstractRepor /** * Export Sold Products report to XML format action * + * @return ResponseInterface */ public function exportSoldExcelAction() { $this->_view->loadLayout(); $fileName = 'products_ordered.xml'; - /** @var \Magento\Backend\Block\Widget\Grid\ExportInterface $exportBlock */ + /** @var ExportInterface $exportBlock */ $exportBlock = $this->_view->getLayout()->getChildBlock('adminhtml.report.grid', 'grid.export'); return $this->_fileFactory->create($fileName, $exportBlock->getExcelFile($fileName)); } @@ -96,12 +103,13 @@ class Product extends \Magento\Reports\Controller\Adminhtml\Report\AbstractRepor /** * Most viewed products * + * @return void */ public function viewedAction() { $this->_title->add(__('Product Views Report')); - $this->_showLastExecutionTime(\Magento\Reports\Model\Flag::REPORT_PRODUCT_VIEWED_FLAG_CODE, 'viewed'); + $this->_showLastExecutionTime(Flag::REPORT_PRODUCT_VIEWED_FLAG_CODE, 'viewed'); $this->_initAction() ->_setActiveMenu('Magento_Reports::report_products_viewed') @@ -124,6 +132,7 @@ class Product extends \Magento\Reports\Controller\Adminhtml\Report\AbstractRepor /** * Export products most viewed report to CSV format * + * @return ResponseInterface */ public function exportViewedCsvAction() { @@ -136,6 +145,7 @@ class Product extends \Magento\Reports\Controller\Adminhtml\Report\AbstractRepor /** * Export products most viewed report to XML format * + * @return ResponseInterface */ public function exportViewedExcelAction() { @@ -148,6 +158,7 @@ class Product extends \Magento\Reports\Controller\Adminhtml\Report\AbstractRepor /** * Low stock action * + * @return void */ public function lowstockAction() { @@ -165,6 +176,7 @@ class Product extends \Magento\Reports\Controller\Adminhtml\Report\AbstractRepor /** * Export low stock products report to CSV format * + * @return ResponseInterface */ public function exportLowstockCsvAction() { @@ -178,6 +190,7 @@ class Product extends \Magento\Reports\Controller\Adminhtml\Report\AbstractRepor /** * Export low stock products report to XML format * + * @return ResponseInterface */ public function exportLowstockExcelAction() { @@ -191,6 +204,7 @@ class Product extends \Magento\Reports\Controller\Adminhtml\Report\AbstractRepor /** * Downloads action * + * @return void */ public function downloadsAction() { @@ -211,6 +225,7 @@ class Product extends \Magento\Reports\Controller\Adminhtml\Report\AbstractRepor /** * Export products downloads report to CSV format * + * @return ResponseInterface */ public function exportDownloadsCsvAction() { @@ -225,6 +240,7 @@ class Product extends \Magento\Reports\Controller\Adminhtml\Report\AbstractRepor /** * Export products downloads report to XLS format * + * @return ResponseInterface */ public function exportDownloadsExcelAction() { diff --git a/app/code/Magento/Reports/Controller/Adminhtml/Report/Review.php b/app/code/Magento/Reports/Controller/Adminhtml/Report/Review.php index 9bde9bd8683007831111555b835130cf3d2bbff2..3027aaa53e971d766b937f9a9d9b9d33003bdb54 100644 --- a/app/code/Magento/Reports/Controller/Adminhtml/Report/Review.php +++ b/app/code/Magento/Reports/Controller/Adminhtml/Report/Review.php @@ -33,6 +33,8 @@ */ namespace Magento\Reports\Controller\Adminhtml\Report; +use Magento\App\ResponseInterface; + class Review extends \Magento\Backend\App\Action { /** @@ -52,6 +54,11 @@ class Review extends \Magento\Backend\App\Action parent::__construct($context); } + /** + * Add reports and reviews breadcrumbs + * + * @return $this + */ public function _initAction() { $this->_view->loadLayout(); @@ -66,6 +73,11 @@ class Review extends \Magento\Backend\App\Action return $this; } + /** + * Customer Reviews Report action + * + * @return void + */ public function customerAction() { $this->_title->add(__('Customer Reviews Report')); @@ -81,6 +93,8 @@ class Review extends \Magento\Backend\App\Action /** * Export review customer report to CSV format + * + * @return ResponseInterface */ public function exportCustomerCsvAction() { @@ -94,6 +108,8 @@ class Review extends \Magento\Backend\App\Action /** * Export review customer report to Excel XML format + * + * @return ResponseInterface */ public function exportCustomerExcelAction() { @@ -106,6 +122,11 @@ class Review extends \Magento\Backend\App\Action } + /** + * Product reviews report action + * + * @return void + */ public function productAction() { $this->_title->add(__('Product Reviews Report')); @@ -121,6 +142,8 @@ class Review extends \Magento\Backend\App\Action /** * Export review product report to CSV format + * + * @return ResponseInterface */ public function exportProductCsvAction() { @@ -134,6 +157,8 @@ class Review extends \Magento\Backend\App\Action /** * Export review product report to Excel XML format + * + * @return ResponseInterface */ public function exportProductExcelAction() { @@ -145,6 +170,11 @@ class Review extends \Magento\Backend\App\Action return $this->_fileFactory->create($fileName, $exportBlock->getExcelFile(), \Magento\App\Filesystem::VAR_DIR); } + /** + * Details action + * + * @return void + */ public function productDetailAction() { $this->_title->add(__('Details')); @@ -161,6 +191,8 @@ class Review extends \Magento\Backend\App\Action /** * Export review product detail report to CSV format + * + * @return ResponseInterface */ public function exportProductDetailCsvAction() { @@ -173,6 +205,8 @@ class Review extends \Magento\Backend\App\Action /** * Export review product detail report to ExcelXML format + * + * @return ResponseInterface */ public function exportProductDetailExcelAction() { @@ -183,6 +217,11 @@ class Review extends \Magento\Backend\App\Action return $this->_fileFactory->create($fileName, $content, \Magento\App\Filesystem::VAR_DIR); } + /** + * Determine if action is allowed for reports module + * + * @return bool + */ protected function _isAllowed() { switch ($this->getRequest()->getActionName()) { diff --git a/app/code/Magento/Reports/Controller/Adminhtml/Report/Sales.php b/app/code/Magento/Reports/Controller/Adminhtml/Report/Sales.php index 247370e1ec7eed5575f2395660889fc7431031ab..fd93b94475cd399467aa90034b9b73fa5464835c 100644 --- a/app/code/Magento/Reports/Controller/Adminhtml/Report/Sales.php +++ b/app/code/Magento/Reports/Controller/Adminhtml/Report/Sales.php @@ -33,12 +33,15 @@ */ namespace Magento\Reports\Controller\Adminhtml\Report; -class Sales extends \Magento\Reports\Controller\Adminhtml\Report\AbstractReport +use Magento\App\ResponseInterface; +use Magento\Reports\Model\Flag; + +class Sales extends AbstractReport { /** * Add report/sales breadcrumbs * - * @return \Magento\Reports\Controller\Adminhtml\Report\Sales + * @return $this */ public function _initAction() { @@ -47,11 +50,16 @@ class Sales extends \Magento\Reports\Controller\Adminhtml\Report\AbstractReport return $this; } + /** + * Sales report action + * + * @return void + */ public function salesAction() { $this->_title->add(__('Sales Report')); - $this->_showLastExecutionTime(\Magento\Reports\Model\Flag::REPORT_ORDER_FLAG_CODE, 'sales'); + $this->_showLastExecutionTime(Flag::REPORT_ORDER_FLAG_CODE, 'sales'); $this->_initAction() ->_setActiveMenu('Magento_Reports::report_salesroot_sales') @@ -68,11 +76,16 @@ class Sales extends \Magento\Reports\Controller\Adminhtml\Report\AbstractReport $this->_view->renderLayout(); } + /** + * Best sellers report action + * + * @return void + */ public function bestsellersAction() { $this->_title->add(__('Best Sellers Report')); - $this->_showLastExecutionTime(\Magento\Reports\Model\Flag::REPORT_BESTSELLERS_FLAG_CODE, 'bestsellers'); + $this->_showLastExecutionTime(Flag::REPORT_BESTSELLERS_FLAG_CODE, 'bestsellers'); $this->_initAction() ->_setActiveMenu('Magento_Reports::report_products_bestsellers') @@ -91,6 +104,8 @@ class Sales extends \Magento\Reports\Controller\Adminhtml\Report\AbstractReport /** * Export bestsellers report grid to CSV format + * + * @return ResponseInterface */ public function exportBestsellersCsvAction() { @@ -102,6 +117,8 @@ class Sales extends \Magento\Reports\Controller\Adminhtml\Report\AbstractReport /** * Export bestsellers report grid to Excel XML format + * + * @return ResponseInterface */ public function exportBestsellersExcelAction() { @@ -114,7 +131,7 @@ class Sales extends \Magento\Reports\Controller\Adminhtml\Report\AbstractReport /** * Refresh statistics for last 25 hours * - * @return \Magento\Reports\Controller\Adminhtml\Report\Sales + * @return void */ public function refreshRecentAction() { @@ -124,7 +141,7 @@ class Sales extends \Magento\Reports\Controller\Adminhtml\Report\AbstractReport /** * Refresh statistics for all period * - * @return \Magento\Reports\Controller\Adminhtml\Report\Sales + * @return void */ public function refreshLifetimeAction() { @@ -133,6 +150,8 @@ class Sales extends \Magento\Reports\Controller\Adminhtml\Report\AbstractReport /** * Export sales report grid to CSV format + * + * @return ResponseInterface */ public function exportSalesCsvAction() { @@ -144,6 +163,8 @@ class Sales extends \Magento\Reports\Controller\Adminhtml\Report\AbstractReport /** * Export sales report grid to Excel XML format + * + * @return ResponseInterface */ public function exportSalesExcelAction() { @@ -153,11 +174,16 @@ class Sales extends \Magento\Reports\Controller\Adminhtml\Report\AbstractReport return $this->_fileFactory->create($fileName, $grid->getExcelFile($fileName)); } + /** + * Tax report action + * + * @return void + */ public function taxAction() { $this->_title->add(__('Tax Report')); - $this->_showLastExecutionTime(\Magento\Reports\Model\Flag::REPORT_TAX_FLAG_CODE, 'tax'); + $this->_showLastExecutionTime(Flag::REPORT_TAX_FLAG_CODE, 'tax'); $this->_initAction() ->_setActiveMenu('Magento_Reports::report_salesroot_tax') @@ -176,6 +202,8 @@ class Sales extends \Magento\Reports\Controller\Adminhtml\Report\AbstractReport /** * Export tax report grid to CSV format + * + * @return ResponseInterface */ public function exportTaxCsvAction() { @@ -187,6 +215,8 @@ class Sales extends \Magento\Reports\Controller\Adminhtml\Report\AbstractReport /** * Export tax report grid to Excel XML format + * + * @return ResponseInterface */ public function exportTaxExcelAction() { @@ -196,11 +226,16 @@ class Sales extends \Magento\Reports\Controller\Adminhtml\Report\AbstractReport return $this->_fileFactory->create($fileName, $grid->getExcelFile($fileName)); } + /** + * Shipping report action + * + * @return void + */ public function shippingAction() { $this->_title->add(__('Shipping Report')); - $this->_showLastExecutionTime(\Magento\Reports\Model\Flag::REPORT_SHIPPING_FLAG_CODE, 'shipping'); + $this->_showLastExecutionTime(Flag::REPORT_SHIPPING_FLAG_CODE, 'shipping'); $this->_initAction() ->_setActiveMenu('Magento_Reports::report_salesroot_shipping') @@ -219,6 +254,8 @@ class Sales extends \Magento\Reports\Controller\Adminhtml\Report\AbstractReport /** * Export shipping report grid to CSV format + * + * @return ResponseInterface */ public function exportShippingCsvAction() { @@ -230,6 +267,8 @@ class Sales extends \Magento\Reports\Controller\Adminhtml\Report\AbstractReport /** * Export shipping report grid to Excel XML format + * + * @return ResponseInterface */ public function exportShippingExcelAction() { @@ -239,11 +278,16 @@ class Sales extends \Magento\Reports\Controller\Adminhtml\Report\AbstractReport return $this->_fileFactory->create($fileName, $grid->getExcelFile($fileName)); } + /** + * Invoice report action + * + * @return void + */ public function invoicedAction() { $this->_title->add(__('Invoice Report')); - $this->_showLastExecutionTime(\Magento\Reports\Model\Flag::REPORT_INVOICE_FLAG_CODE, 'invoiced'); + $this->_showLastExecutionTime(Flag::REPORT_INVOICE_FLAG_CODE, 'invoiced'); $this->_initAction() ->_setActiveMenu('Magento_Reports::report_salesroot_invoiced') @@ -262,6 +306,8 @@ class Sales extends \Magento\Reports\Controller\Adminhtml\Report\AbstractReport /** * Export invoiced report grid to CSV format + * + * @return ResponseInterface */ public function exportInvoicedCsvAction() { @@ -273,6 +319,8 @@ class Sales extends \Magento\Reports\Controller\Adminhtml\Report\AbstractReport /** * Export invoiced report grid to Excel XML format + * + * @return ResponseInterface */ public function exportInvoicedExcelAction() { @@ -282,11 +330,16 @@ class Sales extends \Magento\Reports\Controller\Adminhtml\Report\AbstractReport return $this->_fileFactory->create($fileName, $grid->getExcelFile($fileName)); } + /** + * Refunds report action + * + * @return void + */ public function refundedAction() { $this->_title->add(__('Refunds Report')); - $this->_showLastExecutionTime(\Magento\Reports\Model\Flag::REPORT_REFUNDED_FLAG_CODE, 'refunded'); + $this->_showLastExecutionTime(Flag::REPORT_REFUNDED_FLAG_CODE, 'refunded'); $this->_initAction() ->_setActiveMenu('Magento_Reports::report_salesroot_refunded') @@ -305,6 +358,8 @@ class Sales extends \Magento\Reports\Controller\Adminhtml\Report\AbstractReport /** * Export refunded report grid to CSV format + * + * @return ResponseInterface */ public function exportRefundedCsvAction() { @@ -316,6 +371,8 @@ class Sales extends \Magento\Reports\Controller\Adminhtml\Report\AbstractReport /** * Export refunded report grid to Excel XML format + * + * @return ResponseInterface */ public function exportRefundedExcelAction() { @@ -325,11 +382,16 @@ class Sales extends \Magento\Reports\Controller\Adminhtml\Report\AbstractReport return $this->_fileFactory->create($fileName, $grid->getExcelFile($fileName)); } + /** + * Coupons report action + * + * @return void + */ public function couponsAction() { $this->_title->add(__('Coupons Report')); - $this->_showLastExecutionTime(\Magento\Reports\Model\Flag::REPORT_COUPONS_FLAG_CODE, 'coupons'); + $this->_showLastExecutionTime(Flag::REPORT_COUPONS_FLAG_CODE, 'coupons'); $this->_initAction() ->_setActiveMenu('Magento_Reports::report_salesroot_coupons') @@ -348,6 +410,8 @@ class Sales extends \Magento\Reports\Controller\Adminhtml\Report\AbstractReport /** * Export coupons report grid to CSV format + * + * @return ResponseInterface */ public function exportCouponsCsvAction() { @@ -359,6 +423,8 @@ class Sales extends \Magento\Reports\Controller\Adminhtml\Report\AbstractReport /** * Export coupons report grid to Excel XML format + * + * @return ResponseInterface */ public function exportCouponsExcelAction() { @@ -368,11 +434,21 @@ class Sales extends \Magento\Reports\Controller\Adminhtml\Report\AbstractReport return $this->_fileFactory->create($fileName, $grid->getExcelFile($fileName)); } + /** + * Refresh report statistics action + * + * @return void + */ public function refreshStatisticsAction() { $this->_forward('index', 'report_statistics'); } + /** + * Determine if action is allowed for reports module + * + * @return bool + */ protected function _isAllowed() { switch ($this->getRequest()->getActionName()) { diff --git a/app/code/Magento/Reports/Controller/Adminhtml/Report/Shopcart.php b/app/code/Magento/Reports/Controller/Adminhtml/Report/Shopcart.php index 406631bd41d33f446c6f6dbff501ad78a7c917fe..581290bd523c1ea9465c98423c2a25178da83b41 100644 --- a/app/code/Magento/Reports/Controller/Adminhtml/Report/Shopcart.php +++ b/app/code/Magento/Reports/Controller/Adminhtml/Report/Shopcart.php @@ -33,6 +33,8 @@ */ namespace Magento\Reports\Controller\Adminhtml\Report; +use Magento\App\ResponseInterface; + class Shopcart extends \Magento\Backend\App\Action { /** @@ -52,6 +54,11 @@ class Shopcart extends \Magento\Backend\App\Action parent::__construct($context); } + /** + * Add reports and shopping cart breadcrumbs + * + * @return $this + */ public function _initAction() { $this->_view->loadLayout(); @@ -60,6 +67,11 @@ class Shopcart extends \Magento\Backend\App\Action return $this; } + /** + * Customer shopping carts action + * + * @return void + */ public function customerAction() { $this->_title->add(__('Customer Shopping Carts')); @@ -77,6 +89,8 @@ class Shopcart extends \Magento\Backend\App\Action /** * Export shopcart customer report to CSV format + * + * @return ResponseInterface */ public function exportCustomerCsvAction() { @@ -89,6 +103,8 @@ class Shopcart extends \Magento\Backend\App\Action /** * Export shopcart customer report to Excel XML format + * + * @return ResponseInterface */ public function exportCustomerExcelAction() { @@ -99,6 +115,11 @@ class Shopcart extends \Magento\Backend\App\Action return $this->_fileFactory->create($fileName, $content); } + /** + * Products in carts action + * + * @return void + */ public function productAction() { $this->_title->add(__('Products in Carts')); @@ -114,6 +135,8 @@ class Shopcart extends \Magento\Backend\App\Action /** * Export products report grid to CSV format + * + * @return ResponseInterface */ public function exportProductCsvAction() { @@ -126,6 +149,8 @@ class Shopcart extends \Magento\Backend\App\Action /** * Export products report to Excel XML format + * + * @return ResponseInterface */ public function exportProductExcelAction() { @@ -136,6 +161,11 @@ class Shopcart extends \Magento\Backend\App\Action return $this->_fileFactory->create($fileName, $content); } + /** + * Abandoned carts action + * + * @return void + */ public function abandonedAction() { $this->_title->add(__('Abandoned Carts')); @@ -151,6 +181,8 @@ class Shopcart extends \Magento\Backend\App\Action /** * Export abandoned carts report grid to CSV format + * + * @return ResponseInterface */ public function exportAbandonedCsvAction() { @@ -163,6 +195,8 @@ class Shopcart extends \Magento\Backend\App\Action /** * Export abandoned carts report to Excel XML format + * + * @return ResponseInterface */ public function exportAbandonedExcelAction() { @@ -173,6 +207,11 @@ class Shopcart extends \Magento\Backend\App\Action return $this->_fileFactory->create($fileName, $content); } + /** + * Determine if action is allowed for reports module + * + * @return bool + */ protected function _isAllowed() { switch ($this->getRequest()->getActionName()) { diff --git a/app/code/Magento/Reports/Controller/Adminhtml/Report/Statistics.php b/app/code/Magento/Reports/Controller/Adminhtml/Report/Statistics.php index 4d23affb4cc052fe7231e95fa82a5227afbd48cb..81ab1acf65c0d1a4db3076c8e05b4c46b968845a 100644 --- a/app/code/Magento/Reports/Controller/Adminhtml/Report/Statistics.php +++ b/app/code/Magento/Reports/Controller/Adminhtml/Report/Statistics.php @@ -33,12 +33,15 @@ */ namespace Magento\Reports\Controller\Adminhtml\Report; +use Magento\Backend\Model\Auth\Session as AuthSession; +use Magento\Backend\Model\Session; + class Statistics extends \Magento\Backend\App\Action { /** * Admin session model * - * @var null|\Magento\Backend\Model\Auth\Session + * @var null|AuthSession */ protected $_adminSession = null; @@ -57,6 +60,11 @@ class Statistics extends \Magento\Backend\App\Action parent::__construct($context); } + /** + * Add reports and statistics breadcrumbs + * + * @return $this + */ public function _initAction() { $this->_view->loadLayout(); @@ -65,6 +73,12 @@ class Statistics extends \Magento\Backend\App\Action return $this; } + /** + * Report statistics action initialization operations + * + * @param array|\Magento\Object $blocks + * @return $this + */ public function _initReportAction($blocks) { if (!is_array($blocks)) { @@ -99,6 +113,7 @@ class Statistics extends \Magento\Backend\App\Action * Retrieve array of collection names by code specified in request * * @return array + * @throws \Exception */ protected function _getCollectionNames() { @@ -133,7 +148,7 @@ class Statistics extends \Magento\Backend\App\Action /** * Refresh statistics for last 25 hours * - * @return \Magento\Reports\Controller\Adminhtml\Report\Sales + * @return void */ public function refreshRecentAction() { @@ -162,7 +177,7 @@ class Statistics extends \Magento\Backend\App\Action /** * Refresh statistics for all period * - * @return \Magento\Reports\Controller\Adminhtml\Report\Sales + * @return void */ public function refreshLifetimeAction() { @@ -186,6 +201,11 @@ class Statistics extends \Magento\Backend\App\Action } } + /** + * Refresh statistics action + * + * @return void + */ public function indexAction() { $this->_title->add(__('Refresh Statistics')); @@ -196,6 +216,11 @@ class Statistics extends \Magento\Backend\App\Action $this->_view->renderLayout(); } + /** + * Determine if action is allowed for reports module + * + * @return bool + */ protected function _isAllowed() { return $this->_authorization->isAllowed('Magento_Reports::statistics'); @@ -204,7 +229,7 @@ class Statistics extends \Magento\Backend\App\Action /** * Retrieve admin session model * - * @return \Magento\Backend\Model\Auth\Session + * @return AuthSession|Session|mixed|null */ protected function _getSession() { diff --git a/app/code/Magento/Reports/Helper/Data.php b/app/code/Magento/Reports/Helper/Data.php index cfea39e6d265b75c66b50ff87f4fa0b442187109..652eba4e87a75277f3715d64390738fb5347bd08 100644 --- a/app/code/Magento/Reports/Helper/Data.php +++ b/app/code/Magento/Reports/Helper/Data.php @@ -29,6 +29,9 @@ */ namespace Magento\Reports\Helper; +use Magento\Data\Collection; +use Magento\Stdlib\DateTime; + class Data extends \Magento\App\Helper\AbstractHelper { const REPORT_PERIOD_TYPE_DAY = 'day'; @@ -63,7 +66,7 @@ class Data extends \Magento\App\Helper\AbstractHelper public function getIntervals($from, $to, $period = self::REPORT_PERIOD_TYPE_DAY) { $intervals = array(); - if (!$from && !$to){ + if (!$from && !$to) { return $intervals; } @@ -74,14 +77,14 @@ class Data extends \Magento\App\Helper\AbstractHelper } if ($period == self::REPORT_PERIOD_TYPE_MONTH) { - $dateStart = new \Zend_Date(date("Y-m", $start->getTimestamp()), \Magento\Stdlib\DateTime::DATE_INTERNAL_FORMAT); + $dateStart = new \Zend_Date(date("Y-m", $start->getTimestamp()), DateTime::DATE_INTERNAL_FORMAT); } if ($period == self::REPORT_PERIOD_TYPE_YEAR) { - $dateStart = new \Zend_Date(date("Y", $start->getTimestamp()), \Magento\Stdlib\DateTime::DATE_INTERNAL_FORMAT); + $dateStart = new \Zend_Date(date("Y", $start->getTimestamp()), DateTime::DATE_INTERNAL_FORMAT); } - $dateEnd = new \Zend_Date($to, \Magento\Stdlib\DateTime::DATE_INTERNAL_FORMAT); + $dateEnd = new \Zend_Date($to, DateTime::DATE_INTERNAL_FORMAT); while ($dateStart->compare($dateEnd) <= 0) { switch ($period) { @@ -103,6 +106,15 @@ class Data extends \Magento\App\Helper\AbstractHelper return $intervals; } + /** + * Add items to interval collection + * + * @param Collection $collection + * @param string $from + * @param string $to + * @param string $periodType + * @return void + */ public function prepareIntervalsCollection($collection, $from, $to, $periodType = self::REPORT_PERIOD_TYPE_DAY) { $intervals = $this->getIntervals($from, $to, $periodType); diff --git a/app/code/Magento/Reports/Model/Config.php b/app/code/Magento/Reports/Model/Config.php index a52fc887079fc388676560487fe4936643a7aace..649deea47081190e7e2c9430aee1f9435efce0ee 100644 --- a/app/code/Magento/Reports/Model/Config.php +++ b/app/code/Magento/Reports/Model/Config.php @@ -23,12 +23,11 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Reports\Model; /** * Configuration for reports */ -namespace Magento\Reports\Model; - class Config extends \Magento\Object { /** @@ -56,6 +55,11 @@ class Config extends \Magento\Object $this->_storeManager = $storeManager; } + /** + * Return reports global configuration + * + * @return string + */ public function getGlobalConfig() { $dom = new \DOMDocument(); @@ -69,6 +73,11 @@ class Config extends \Magento\Object return $dom->saveXML(); } + /** + * Return reports language + * + * @return string + */ public function getLanguage() { return file_get_contents( @@ -76,6 +85,11 @@ class Config extends \Magento\Object ); } + /** + * Return reports dashboard + * + * @return string + */ public function getDashboard() { return file_get_contents( diff --git a/app/code/Magento/Reports/Model/Event.php b/app/code/Magento/Reports/Model/Event.php index c2746c48b036070432ed237dc4f67a7c04b9aa9d..6b689ebf08a9f59c1df5f2153db59a3b75e23df8 100644 --- a/app/code/Magento/Reports/Model/Event.php +++ b/app/code/Magento/Reports/Model/Event.php @@ -23,6 +23,7 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Reports\Model; /** * Events model @@ -46,8 +47,6 @@ * @package Magento_Reports * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\Reports\Model; - class Event extends \Magento\Core\Model\AbstractModel { const EVENT_PRODUCT_VIEW = 1; @@ -93,6 +92,7 @@ class Event extends \Magento\Core\Model\AbstractModel /** * Initialize resource * + * @return void */ protected function _construct() { @@ -102,7 +102,7 @@ class Event extends \Magento\Core\Model\AbstractModel /** * Before Event save process * - * @return \Magento\Reports\Model\Event + * @return $this */ protected function _beforeSave() { @@ -117,7 +117,7 @@ class Event extends \Magento\Core\Model\AbstractModel * @param int $visitorId * @param int $customerId * @param array $types - * @return \Magento\Reports\Model\Event + * @return $this */ public function updateCustomerType($visitorId, $customerId, $types = null) { @@ -139,7 +139,7 @@ class Event extends \Magento\Core\Model\AbstractModel /** * Clean events (visitors) * - * @return \Magento\Reports\Model\Event + * @return $this */ public function clean() { diff --git a/app/code/Magento/Reports/Model/Event/Observer.php b/app/code/Magento/Reports/Model/Event/Observer.php index 95d1a6679d085752fa41d842b0e26fe647803a01..ba157a7c30e209146c3b30de54b91300e47eb131 100644 --- a/app/code/Magento/Reports/Model/Event/Observer.php +++ b/app/code/Magento/Reports/Model/Event/Observer.php @@ -23,17 +23,11 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ - +namespace Magento\Reports\Model\Event; /** * Reports Event observer model - * - * @category Magento - * @package Magento_Reports - * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\Reports\Model\Event; - class Observer { /** @@ -121,7 +115,7 @@ class Observer * Customer login action * * @param \Magento\Event\Observer $observer - * @return \Magento\Reports\Model\Event\Observer + * @return $this */ public function customerLogin(\Magento\Event\Observer $observer) { @@ -150,7 +144,7 @@ class Observer * Customer logout processing * * @param \Magento\Event\Observer $observer - * @return \Magento\Reports\Model\Event\Observer + * @return $this */ public function customerLogout(\Magento\Event\Observer $observer) { @@ -169,7 +163,7 @@ class Observer * View Catalog Product action * * @param \Magento\Event\Observer $observer - * @return \Magento\Reports\Model\Event\Observer + * @return Observer */ public function catalogProductView(\Magento\Event\Observer $observer) { @@ -188,7 +182,7 @@ class Observer * Send Product link to friends action * * @param \Magento\Event\Observer $observer - * @return \Magento\Reports\Model\Event\Observer + * @return Observer */ public function sendfriendProduct(\Magento\Event\Observer $observer) { @@ -203,7 +197,7 @@ class Observer * Reset count of compared products cache * * @param \Magento\Event\Observer $observer - * @return \Magento\Reports\Model\Event\Observer + * @return $this */ public function catalogProductCompareRemoveProduct(\Magento\Event\Observer $observer) { @@ -220,7 +214,7 @@ class Observer * Reset count of compared products cache * * @param \Magento\Event\Observer $observer - * @return \Magento\Reports\Model\Event\Observer + * @return $this */ public function catalogProductCompareClear(\Magento\Event\Observer $observer) { @@ -237,7 +231,7 @@ class Observer * Reset count of compared products cache * * @param \Magento\Event\Observer $observer - * @return unknown + * @return Observer */ public function catalogProductCompareAddProduct(\Magento\Event\Observer $observer) { @@ -256,7 +250,7 @@ class Observer * Add product to shopping cart action * * @param \Magento\Event\Observer $observer - * @return \Magento\Reports\Model\Event\Observer + * @return $this */ public function checkoutCartAddProduct(\Magento\Event\Observer $observer) { @@ -272,7 +266,7 @@ class Observer * Add product to wishlist action * * @param \Magento\Event\Observer $observer - * @return \Magento\Reports\Model\Event\Observer + * @return Observer */ public function wishlistAddProduct(\Magento\Event\Observer $observer) { @@ -285,7 +279,7 @@ class Observer * Share customer wishlist action * * @param \Magento\Event\Observer $observer - * @return \Magento\Reports\Model\Event\Observer + * @return Observer */ public function wishlistShare(\Magento\Event\Observer $observer) { diff --git a/app/code/Magento/Reports/Model/Event/Type.php b/app/code/Magento/Reports/Model/Event/Type.php index a037c95654920c6c5340ef52d80c93b403e7356b..1459460b87859296aaf8018cab2f4e1e36e9878a 100644 --- a/app/code/Magento/Reports/Model/Event/Type.php +++ b/app/code/Magento/Reports/Model/Event/Type.php @@ -23,6 +23,7 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Reports\Model\Event; /** * Event type model @@ -38,11 +39,11 @@ * @package Magento_Reports * @author Magento Core Team <core@magentocommerce.com> */ - -namespace Magento\Reports\Model\Event; - class Type extends \Magento\Core\Model\AbstractModel { + /** + * @return void + */ protected function _construct() { $this->_init('Magento\Reports\Model\Resource\Event\Type'); diff --git a/app/code/Magento/Reports/Model/Flag.php b/app/code/Magento/Reports/Model/Flag.php index efa85acd5256de3c941786e01052eb57e8dfe183..4b10aa29ef1dcf255c2fa1978098b9524c1571e7 100644 --- a/app/code/Magento/Reports/Model/Flag.php +++ b/app/code/Magento/Reports/Model/Flag.php @@ -23,7 +23,7 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ - +namespace Magento\Reports\Model; /** * Report Flag Model @@ -32,8 +32,6 @@ * @package Magento_Reports * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\Reports\Model; - class Flag extends \Magento\Core\Model\Flag { const REPORT_ORDER_FLAG_CODE = 'report_order_aggregated'; @@ -49,7 +47,7 @@ class Flag extends \Magento\Core\Model\Flag * Setter for flag code * * @param string $code - * @return \Magento\Reports\Model\Flag + * @return $this */ public function setReportFlagCode($code) { diff --git a/app/code/Magento/Reports/Model/Grouped/Collection.php b/app/code/Magento/Reports/Model/Grouped/Collection.php index d53241373b5b8391196c3b45ce85a63d25a9ad0a..5fc275af3838c0c01c601c75b7facea79429e1f5 100644 --- a/app/code/Magento/Reports/Model/Grouped/Collection.php +++ b/app/code/Magento/Reports/Model/Grouped/Collection.php @@ -25,6 +25,8 @@ */ namespace Magento\Reports\Model\Grouped; +use Magento\Data\Collection\Db; + class Collection extends \Magento\Data\Collection //\Magento\Core\Model\Resource\Db\Collection\AbstractCollection { @@ -46,7 +48,7 @@ class Collection * Set column to group by * * @param string $column - * @return \Magento\Reports\Model\Grouped\Collection + * @return $this */ public function setColumnGroupBy($column) { @@ -57,9 +59,9 @@ class Collection /** * Load collection * - * @param boolean $printQuery - * @param boolean $logQuery - * @return \Magento\Reports\Model\Grouped\Collection + * @param bool $printQuery + * @param bool $logQuery + * @return $this */ public function load($printQuery = false, $logQuery = false) { @@ -81,8 +83,8 @@ class Collection /** * Setter for resource collection * - * @param \Magento\Data\Collection\Db $collection - * @return \Magento\Reports\Model\Grouped\Collection + * @param Db $collection + * @return $this */ public function setResourceCollection($collection) { @@ -93,7 +95,7 @@ class Collection /** * Merge empty data collection with resource collection * - * @return \Magento\Reports\Model\Grouped\Collection + * @return $this */ protected function _mergeWithEmptyData() { @@ -119,7 +121,7 @@ class Collection /** * Group data in resource collection * - * @return \Magento\Reports\Model\Grouped\Collection + * @return $this */ protected function _groupResourceData() { diff --git a/app/code/Magento/Reports/Model/Item.php b/app/code/Magento/Reports/Model/Item.php index 7dca34206a064a6fe6e933ee32cd2968879aee62..b7a12dd95aabdb116bbac6810855ce5c36a0cd86 100644 --- a/app/code/Magento/Reports/Model/Item.php +++ b/app/code/Magento/Reports/Model/Item.php @@ -27,39 +27,78 @@ namespace Magento\Reports\Model; class Item extends \Magento\Object { + /** @var bool */ protected $_isEmpty = false; + + /** @var array */ protected $_children = array(); + /** + * Set is empty indicator + * + * @param bool $flag + * @return $this + */ public function setIsEmpty($flag = true) { $this->_isEmpty = $flag; return $this; } + /** + * Get is empty indicator + * + * @return bool + */ public function getIsEmpty() { return $this->_isEmpty; } + /** + * @return void + */ public function hasIsEmpty() {} + /** + * Get children + * + * @return array + */ public function getChildren() { return $this->_children; } + /** + * Set children + * + * @param $children + * @return $this + */ public function setChildren($children) { $this->_children = $children; return $this; } + /** + * Indicator of whether or not children are present + * + * @return bool + */ public function hasChildren() { return (count($this->_children) > 0) ? true : false; } + /** + * Add child to array of items + * + * @param array $child + * @return $this + */ public function addChild($child) { $this->_children[] = $child; diff --git a/app/code/Magento/Reports/Model/Plugin/Log.php b/app/code/Magento/Reports/Model/Plugin/Log.php index 393734b8222c62171af1663039fcf6c00cc3f24c..1d8f77b0e786a7d9a1196c141dfbaa847fcba192 100644 --- a/app/code/Magento/Reports/Model/Plugin/Log.php +++ b/app/code/Magento/Reports/Model/Plugin/Log.php @@ -58,8 +58,7 @@ class Log } /** - * Clean events by old visitors - * after plugin for clean method + * Clean events by old visitors after plugin for clean method * * @see Global Log Clean Settings * diff --git a/app/code/Magento/Reports/Model/Product/Index/AbstractIndex.php b/app/code/Magento/Reports/Model/Product/Index/AbstractIndex.php index 8b6426f053dadf07e6ef6b71dcd8860ddc7748c8..c5246434b7635eba2841d8d63ef62c6f3d8e573e 100644 --- a/app/code/Magento/Reports/Model/Product/Index/AbstractIndex.php +++ b/app/code/Magento/Reports/Model/Product/Index/AbstractIndex.php @@ -186,7 +186,7 @@ abstract class AbstractIndex extends \Magento\Core\Model\AbstractModel /** * On customer loggin merge visitor/customer index * - * @return \Magento\Reports\Model\Product\Index\AbstractIndex + * @return $this */ public function updateCustomerFromVisitor() { @@ -197,7 +197,7 @@ abstract class AbstractIndex extends \Magento\Core\Model\AbstractModel /** * Purge visitor data by customer (logout) * - * @return \Magento\Reports\Model\Product\Index\AbstractIndex + * @return $this */ public function purgeVisitorByCustomer() { @@ -218,7 +218,7 @@ abstract class AbstractIndex extends \Magento\Core\Model\AbstractModel /** * Calculate count of product index items cache * - * @return \Magento\Reports\Model\Product\Index\AbstractIndex + * @return $this */ public function calculate() { @@ -263,7 +263,7 @@ abstract class AbstractIndex extends \Magento\Core\Model\AbstractModel /** * Clean index (visitors) * - * @return \Magento\Reports\Model\Product\Index\AbstractIndex + * @return $this */ public function clean() { @@ -273,8 +273,8 @@ abstract class AbstractIndex extends \Magento\Core\Model\AbstractModel /** * Add product ids to current visitor/customer log - * @param array $productIds - * @return \Magento\Reports\Model\Product\Index\AbstractIndex + * @param string[] $productIds + * @return $this */ public function registerIds($productIds) { diff --git a/app/code/Magento/Reports/Model/Product/Index/Compared.php b/app/code/Magento/Reports/Model/Product/Index/Compared.php index 288d3cf1a67dea404bb42046e5417ec1c0e741b8..45441c54499720b4a54d76c5ae29b636c70eff3e 100644 --- a/app/code/Magento/Reports/Model/Product/Index/Compared.php +++ b/app/code/Magento/Reports/Model/Product/Index/Compared.php @@ -23,7 +23,7 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ - +namespace Magento\Reports\Model\Product\Index; /** * Catalog Compared Product Index Model @@ -42,8 +42,6 @@ * @package Magento_Reports * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\Reports\Model\Product\Index; - class Compared extends \Magento\Reports\Model\Product\Index\AbstractIndex { /** @@ -106,6 +104,8 @@ class Compared extends \Magento\Reports\Model\Product\Index\AbstractIndex /** * Initialize resource model + * + * @return void */ protected function _construct() { diff --git a/app/code/Magento/Reports/Model/Product/Index/Viewed.php b/app/code/Magento/Reports/Model/Product/Index/Viewed.php index 4444cf0697630f27f5b1cd07c4e6ea9aa42a89c9..dfad9fc98d043fca17e96cc26711538009e6291f 100644 --- a/app/code/Magento/Reports/Model/Product/Index/Viewed.php +++ b/app/code/Magento/Reports/Model/Product/Index/Viewed.php @@ -23,7 +23,7 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ - +namespace Magento\Reports\Model\Product\Index; /** * Catalog Viewed Product Index @@ -42,8 +42,6 @@ * @package Magento_Reports * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\Reports\Model\Product\Index; - class Viewed extends \Magento\Reports\Model\Product\Index\AbstractIndex { /** @@ -56,6 +54,7 @@ class Viewed extends \Magento\Reports\Model\Product\Index\AbstractIndex /** * Initialize resource model * + * @return void */ protected function _construct() { diff --git a/app/code/Magento/Reports/Model/Resource/Accounts/Collection.php b/app/code/Magento/Reports/Model/Resource/Accounts/Collection.php index a980d85dcd9db2212dfbb28ac6229e84d41ce4ae..5e82713591aa8862c3d51818b4cd40a8755ef7e2 100644 --- a/app/code/Magento/Reports/Model/Resource/Accounts/Collection.php +++ b/app/code/Magento/Reports/Model/Resource/Accounts/Collection.php @@ -36,13 +36,12 @@ namespace Magento\Reports\Model\Resource\Accounts; class Collection extends \Magento\Reports\Model\Resource\Customer\Collection { - /** * Join created_at and accounts fields * * @param string $fromDate * @param string $toDate - * @return \Magento\Reports\Model\Resource\Accounts\Collection + * @return $this */ protected function _joinFields($fromDate = '', $toDate = '') { @@ -61,7 +60,7 @@ class Collection extends \Magento\Reports\Model\Resource\Customer\Collection * * @param string $fromDate * @param string $toDate - * @return \Magento\Reports\Model\Resource\Accounts\Collection + * @return $this */ public function setDateRange($fromDate, $toDate) { @@ -74,7 +73,7 @@ class Collection extends \Magento\Reports\Model\Resource\Customer\Collection * Set store ids to final result * * @param array $storeIds - * @return \Magento\Reports\Model\Resource\Accounts\Collection + * @return $this */ public function setStoreIds($storeIds) { diff --git a/app/code/Magento/Reports/Model/Resource/Customer/Collection.php b/app/code/Magento/Reports/Model/Resource/Customer/Collection.php index 8c1008154b03aa6832abcf5629dafd877cbf7635..81ff2e1de067aaffb325b98c42a27a68875990eb 100644 --- a/app/code/Magento/Reports/Model/Resource/Customer/Collection.php +++ b/app/code/Magento/Reports/Model/Resource/Customer/Collection.php @@ -38,14 +38,14 @@ class Collection extends \Magento\Customer\Model\Resource\Customer\Collection /** * Add order statistics flag * - * @var boolean + * @var bool */ protected $_addOrderStatistics = false; /** * Add order statistics is filter flag * - * @var boolean + * @var bool */ protected $_addOrderStatFilter = false; @@ -142,7 +142,7 @@ class Collection extends \Magento\Customer\Model\Resource\Customer\Collection /** * Add cart info to collection * - * @return \Magento\Reports\Model\Resource\Customer\Collection + * @return $this */ public function addCartInfo() { @@ -168,7 +168,7 @@ class Collection extends \Magento\Customer\Model\Resource\Customer\Collection /** * Add customer name to results * - * @return \Magento\Reports\Model\Resource\Customer\Collection + * @return $this */ public function addCustomerName() { @@ -181,7 +181,7 @@ class Collection extends \Magento\Customer\Model\Resource\Customer\Collection * * @param string $fromDate * @param string $toDate - * @return \Magento\Reports\Model\Resource\Customer\Collection + * @return $this */ public function joinOrders($fromDate = '', $toDate = '') { @@ -202,7 +202,7 @@ class Collection extends \Magento\Customer\Model\Resource\Customer\Collection /** * Add orders count * - * @return \Magento\Reports\Model\Resource\Customer\Collection + * @return $this */ public function addOrdersCount() { @@ -215,11 +215,10 @@ class Collection extends \Magento\Customer\Model\Resource\Customer\Collection } /** - * Order summary info for each customer - * such as orders_count, orders_avg_amount, orders_total_amount + * Order summary info for each customer such as orders_count, orders_avg_amount, orders_total_amount * * @param int $storeId - * @return \Magento\Reports\Model\Resource\Customer\Collection + * @return $this */ public function addSumAvgTotals($storeId = 0) { @@ -245,7 +244,7 @@ class Collection extends \Magento\Customer\Model\Resource\Customer\Collection * Order by total amount * * @param string $dir - * @return \Magento\Reports\Model\Resource\Customer\Collection + * @return $this */ public function orderByTotalAmount($dir = self::SORT_ORDER_DESC) { @@ -257,8 +256,8 @@ class Collection extends \Magento\Customer\Model\Resource\Customer\Collection /** * Add order statistics * - * @param boolean $isFilter - * @return \Magento\Reports\Model\Resource\Customer\Collection + * @param bool $isFilter + * @return $this */ public function addOrdersStatistics($isFilter = false) { @@ -270,7 +269,7 @@ class Collection extends \Magento\Customer\Model\Resource\Customer\Collection /** * Add orders statistics to collection items * - * @return \Magento\Reports\Model\Resource\Customer\Collection + * @return $this */ protected function _addOrdersStatistics() { @@ -306,7 +305,7 @@ class Collection extends \Magento\Customer\Model\Resource\Customer\Collection /** * Collection after load operations like adding orders statistics * - * @return \Magento\Reports\Model\Resource\Customer\Collection + * @return $this */ protected function _afterLoad() { @@ -318,7 +317,7 @@ class Collection extends \Magento\Customer\Model\Resource\Customer\Collection * Order by customer registration * * @param string $dir - * @return \Magento\Reports\Model\Resource\Customer\Collection + * @return $this */ public function orderByCustomerRegistration($dir = self::SORT_ORDER_DESC) { diff --git a/app/code/Magento/Reports/Model/Resource/Customer/Orders/Collection.php b/app/code/Magento/Reports/Model/Resource/Customer/Orders/Collection.php index 4de1970371f8da24f48f954d92de1be2e897592c..39c7dd1870564e71d2a6ae15d712e4231636adb6 100644 --- a/app/code/Magento/Reports/Model/Resource/Customer/Orders/Collection.php +++ b/app/code/Magento/Reports/Model/Resource/Customer/Orders/Collection.php @@ -41,7 +41,7 @@ class Collection extends \Magento\Reports\Model\Resource\Order\Collection * * @param string $fromDate * @param string $toDate - * @return \Magento\Reports\Model\Resource\Customer\Orders\Collection + * @return $this */ protected function _joinFields($fromDate = '', $toDate = '') { @@ -57,7 +57,7 @@ class Collection extends \Magento\Reports\Model\Resource\Order\Collection * * @param string $fromDate * @param string $toDate - * @return \Magento\Reports\Model\Resource\Customer\Orders\Collection + * @return $this */ public function setDateRange($fromDate, $toDate) { @@ -70,7 +70,7 @@ class Collection extends \Magento\Reports\Model\Resource\Order\Collection * Set store filter to collection * * @param array $storeIds - * @return \Magento\Reports\Model\Resource\Customer\Orders\Collection + * @return $this */ public function setStoreIds($storeIds) { diff --git a/app/code/Magento/Reports/Model/Resource/Customer/Totals/Collection.php b/app/code/Magento/Reports/Model/Resource/Customer/Totals/Collection.php index bb057b22f8b2c73be4b93cdfcda025d32493e7a1..6a7d9df7d17a39565c1b7cb4228ae381fbfc8272 100644 --- a/app/code/Magento/Reports/Model/Resource/Customer/Totals/Collection.php +++ b/app/code/Magento/Reports/Model/Resource/Customer/Totals/Collection.php @@ -41,7 +41,7 @@ class Collection extends \Magento\Reports\Model\Resource\Order\Collection * * @param string $fromDate * @param string $toDate - * @return \Magento\Reports\Model\Resource\Customer\Totals\Collection + * @return $this */ protected function _joinFields($fromDate = '', $toDate = '') { @@ -57,7 +57,7 @@ class Collection extends \Magento\Reports\Model\Resource\Order\Collection * * @param string $fromDate * @param string $toDate - * @return \Magento\Reports\Model\Resource\Customer\Totals\Collection + * @return $this */ public function setDateRange($fromDate, $toDate) { @@ -70,7 +70,7 @@ class Collection extends \Magento\Reports\Model\Resource\Order\Collection * Set store filter collection * * @param array $storeIds - * @return \Magento\Reports\Model\Resource\Customer\Totals\Collection + * @return $this */ public function setStoreIds($storeIds) { diff --git a/app/code/Magento/Reports/Model/Resource/Customer/Totals/Collection/Initial.php b/app/code/Magento/Reports/Model/Resource/Customer/Totals/Collection/Initial.php index fa4c2f2df5d0cc9dd6092dfb1208738c640d0f3e..167481779e0affdefb2bdc399c631070bbcb3206 100644 --- a/app/code/Magento/Reports/Model/Resource/Customer/Totals/Collection/Initial.php +++ b/app/code/Magento/Reports/Model/Resource/Customer/Totals/Collection/Initial.php @@ -37,8 +37,9 @@ namespace Magento\Reports\Model\Resource\Customer\Totals\Collection; class Initial extends \Magento\Reports\Model\Resource\Report\Collection { - /* + /** * Report sub-collection class name + * * @var string */ protected $_reportCollection = 'Magento\Reports\Model\Resource\Customer\Totals\Collection'; diff --git a/app/code/Magento/Reports/Model/Resource/Entity/Summary/Collection/AbstractCollection.php b/app/code/Magento/Reports/Model/Resource/Entity/Summary/Collection/AbstractCollection.php index 316d838cf99d01269b7029b319f4d61876f06ed9..87943b1d7f9d577c79dcc17b4ea09d04f2f3dd30 100644 --- a/app/code/Magento/Reports/Model/Resource/Entity/Summary/Collection/AbstractCollection.php +++ b/app/code/Magento/Reports/Model/Resource/Entity/Summary/Collection/AbstractCollection.php @@ -66,7 +66,7 @@ class AbstractCollection extends \Magento\Data\Collection * @param string $periodType * @param string|int|null $customStart * @param string|int|null $customEnd - * @return \Magento\Reports\Model\Resource\Entity\Summary\Collection\AbstractCollection + * @return $this */ public function setSelectPeriod($periodType, $customStart = null, $customEnd = null) { @@ -102,7 +102,6 @@ class AbstractCollection extends \Magento\Data\Collection } - return $this; } @@ -110,7 +109,7 @@ class AbstractCollection extends \Magento\Data\Collection * Set date period * * @param int $period - * @return \Magento\Reports\Model\Resource\Entity\Summary\Collection\AbstractCollection + * @return $this */ public function setDatePeriod($period) { @@ -121,7 +120,7 @@ class AbstractCollection extends \Magento\Data\Collection * Set store filter * * @param int $storeId - * @return \Magento\Reports\Model\Resource\Entity\Summary\Collection\AbstractCollection + * @return $this */ public function setStoreFilter($storeId) { @@ -144,7 +143,7 @@ class AbstractCollection extends \Magento\Data\Collection /** * Init collection * - * @return \Magento\Reports\Model\Resource\Entity\Summary\Collection\AbstractCollection + * @return $this */ protected function _initCollection() { diff --git a/app/code/Magento/Reports/Model/Resource/Event.php b/app/code/Magento/Reports/Model/Resource/Event.php index d3afdf6ea62aa8b69e6b4ccc1ad5aa08dd682462..62baac03b37b4fb902d1497b3ac1e6c3885a19c7 100644 --- a/app/code/Magento/Reports/Model/Resource/Event.php +++ b/app/code/Magento/Reports/Model/Resource/Event.php @@ -64,8 +64,7 @@ class Event extends \Magento\Core\Model\Resource\Db\AbstractDb } /** - * Initialize main table and identifier field. - * Set main entity table name and primary key field name. + * Initialize main table and identifier field. Set main entity table name and primary key field name. * * @return void */ @@ -81,7 +80,7 @@ class Event extends \Magento\Core\Model\Resource\Db\AbstractDb * @param int $visitorId * @param int $customerId * @param array $types - * @return \Magento\Reports\Model\Resource\Event + * @return $this */ public function updateCustomerType(\Magento\Reports\Model\Event $model, $visitorId, $customerId, $types = array()) { @@ -108,7 +107,7 @@ class Event extends \Magento\Core\Model\Resource\Db\AbstractDb * @param int $eventSubjectId * @param int $subtype * @param array $skipIds - * @return \Magento\Reports\Model\Resource\Event + * @return $this */ public function applyLogToCollection(\Magento\Data\Collection\Db $collection, $eventTypeId, $eventSubjectId, $subtype, $skipIds = array()) @@ -145,7 +144,7 @@ class Event extends \Magento\Core\Model\Resource\Db\AbstractDb /** * Obtain all current store ids, depending on configuration * - * @param array $predefinedStoreIds + * @param null|array $predefinedStoreIds * @return array */ public function getCurrentStoreIds(array $predefinedStoreIds = null) @@ -188,7 +187,7 @@ class Event extends \Magento\Core\Model\Resource\Db\AbstractDb * Clean report event table * * @param \Magento\Reports\Model\Event $object - * @return \Magento\Reports\Model\Resource\Event + * @return $this */ public function clean(\Magento\Reports\Model\Event $object) { diff --git a/app/code/Magento/Reports/Model/Resource/Event/Collection.php b/app/code/Magento/Reports/Model/Resource/Event/Collection.php index a818c90bf59be44da1d2aa4831b3afd4b5f2936c..f1e80b94d6131b1fcf24b9f8a474990ec6390c05 100644 --- a/app/code/Magento/Reports/Model/Resource/Event/Collection.php +++ b/app/code/Magento/Reports/Model/Resource/Event/Collection.php @@ -46,6 +46,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl /** * Resource initializations * + * @return void */ protected function _construct() { @@ -56,7 +57,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl * Add store ids filter * * @param array $storeIds - * @return \Magento\Reports\Model\Resource\Event\Collection + * @return $this */ public function addStoreFilter(array $storeIds) { @@ -70,9 +71,9 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl * @param int $typeId * @param int $subjectId * @param int $subtype - * @param int|array $ignore + * @param null|int|array $ignore * @param int $limit - * @return \Magento\Reports\Model\Resource\Event\Collection + * @return $this */ public function addRecentlyFiler($typeId, $subjectId, $subtype = 0, $ignore = null, $limit = 15) { diff --git a/app/code/Magento/Reports/Model/Resource/Event/Type.php b/app/code/Magento/Reports/Model/Resource/Event/Type.php index afa8d59fc8506a6133890e1b28eda13a4e279cb7..7ec67e7afc4e94bcb1b2d566a3d01bfd7ba116d7 100644 --- a/app/code/Magento/Reports/Model/Resource/Event/Type.php +++ b/app/code/Magento/Reports/Model/Resource/Event/Type.php @@ -37,8 +37,9 @@ namespace Magento\Reports\Model\Resource\Event; class Type extends \Magento\Core\Model\Resource\Db\AbstractDb { /** - * Main table initialization + * Main table initialization * + * @return void */ protected function _construct() { diff --git a/app/code/Magento/Reports/Model/Resource/Event/Type/Collection.php b/app/code/Magento/Reports/Model/Resource/Event/Type/Collection.php index 98adb3e39f3ce4809f71505b832bfae9c7d26484..524ca542b15f590357ab6d01de12a60960bc0b81 100644 --- a/app/code/Magento/Reports/Model/Resource/Event/Type/Collection.php +++ b/app/code/Magento/Reports/Model/Resource/Event/Type/Collection.php @@ -39,6 +39,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl /** * Resource initialization * + * @return void */ protected function _construct() { diff --git a/app/code/Magento/Reports/Model/Resource/Helper.php b/app/code/Magento/Reports/Model/Resource/Helper.php index 413204ec974e5ebbb80927143e7a2d6719d58f39..5ece08bb394877d8758797df63495098a3e9796e 100644 --- a/app/code/Magento/Reports/Model/Resource/Helper.php +++ b/app/code/Magento/Reports/Model/Resource/Helper.php @@ -69,7 +69,7 @@ class Helper extends \Magento\Core\Model\Resource\Helper * @param string $column * @param string $mainTable * @param string $aggregationTable - * @return \Magento\Core\Model\Resource\Helper + * @return $this */ public function updateReportRatingPos($type, $column, $mainTable, $aggregationTable) { diff --git a/app/code/Magento/Reports/Model/Resource/HelperInterface.php b/app/code/Magento/Reports/Model/Resource/HelperInterface.php index 42b52490ff3bee069536aef05af3be0842e5ac1e..0729ee7da037b896abbc6efb1e39971d17f8c148 100644 --- a/app/code/Magento/Reports/Model/Resource/HelperInterface.php +++ b/app/code/Magento/Reports/Model/Resource/HelperInterface.php @@ -36,6 +36,7 @@ interface HelperInterface * * @param string $mainTable * @param array $data + * $param mixed $matchFields * @return string */ public function mergeVisitorProductIndex($mainTable, $data, $matchFields); diff --git a/app/code/Magento/Reports/Model/Resource/Order/Collection.php b/app/code/Magento/Reports/Model/Resource/Order/Collection.php index 017810a7a31ac511925befdec248e0c3194f1db6..2d23d1878fd34b1c173cc93132d26c207e1cbae6 100644 --- a/app/code/Magento/Reports/Model/Resource/Order/Collection.php +++ b/app/code/Magento/Reports/Model/Resource/Order/Collection.php @@ -23,23 +23,21 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Reports\Model\Resource\Order; +use Magento\DB\Select; /** * Reports orders collection * - * @category Magento - * @package Magento_Reports * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\Reports\Model\Resource\Order; - class Collection extends \Magento\Sales\Model\Resource\Order\Collection { /** * Is live * - * @var boolean + * @var bool */ protected $_isLive = false; @@ -127,7 +125,7 @@ class Collection extends \Magento\Sales\Model\Resource\Order\Collection * Check range for live mode * * @param unknown_type $range - * @return \Magento\Reports\Model\Resource\Order\Collection + * @return $this */ public function checkIsLive($range) { @@ -138,7 +136,7 @@ class Collection extends \Magento\Sales\Model\Resource\Order\Collection /** * Retrieve is live flag for rep * - * @return boolean + * @return bool */ public function isLive() { @@ -207,7 +205,7 @@ class Collection extends \Magento\Sales\Model\Resource\Order\Collection * @param mixed $customStart * @param mixed $customEnd * @param int $isFilter - * @return \Magento\Reports\Model\Resource\Order\Collection + * @return $this */ protected function _prepareSummaryLive($range, $customStart, $customEnd, $isFilter = 0) { @@ -263,7 +261,7 @@ class Collection extends \Magento\Sales\Model\Resource\Order\Collection * @param string $range * @param mixed $customStart * @param mixed $customEnd - * @return \Magento\Reports\Model\Resource\Order\Collection + * @return $this */ protected function _prepareSummaryAggregated($range, $customStart, $customEnd) { @@ -391,7 +389,7 @@ class Collection extends \Magento\Sales\Model\Resource\Order\Collection * @param string $range * @param string $customStart * @param string $customEnd - * @param boolean $returnObjects + * @param bool $returnObjects * @return array */ public function getDateRange($range, $customStart, $customEnd, $returnObjects = false) @@ -470,7 +468,7 @@ class Collection extends \Magento\Sales\Model\Resource\Order\Collection * Calculate totals report * * @param int $isFilter - * @return \Magento\Reports\Model\Resource\Order\Collection + * @return $this */ public function calculateTotals($isFilter = 0) { @@ -487,7 +485,7 @@ class Collection extends \Magento\Sales\Model\Resource\Order\Collection * Calculate totals live report * * @param int $isFilter - * @return \Magento\Reports\Model\Resource\Order\Collection + * @return $this */ protected function _calculateTotalsLive($isFilter = 0) { @@ -539,7 +537,7 @@ class Collection extends \Magento\Sales\Model\Resource\Order\Collection * Calculate totals aggregated report * * @param int $isFilter - * @return \Magento\Reports\Model\Resource\Order\Collection + * @return $this */ protected function _calculateTotalsAggregated($isFilter = 0) { @@ -568,7 +566,7 @@ class Collection extends \Magento\Sales\Model\Resource\Order\Collection * Calculate lifitime sales * * @param int $isFilter - * @return \Magento\Reports\Model\Resource\Order\Collection + * @return $this */ public function calculateSales($isFilter = 0) { @@ -626,7 +624,7 @@ class Collection extends \Magento\Sales\Model\Resource\Order\Collection * * @param string $fromDate * @param string $toDate - * @return \Magento\Reports\Model\Resource\Order\Collection + * @return $this */ public function setDateRange($fromDate, $toDate) { @@ -648,7 +646,7 @@ class Collection extends \Magento\Sales\Model\Resource\Order\Collection * Set store filter collection * * @param array $storeIds - * @return \Magento\Reports\Model\Resource\Order\Collection + * @return $this */ public function setStoreIds($storeIds) { @@ -694,7 +692,7 @@ class Collection extends \Magento\Sales\Model\Resource\Order\Collection /** * Add group By customer attribute * - * @return \Magento\Reports\Model\Resource\Order\Collection + * @return $this */ public function groupByCustomer() { @@ -708,7 +706,7 @@ class Collection extends \Magento\Sales\Model\Resource\Order\Collection * Join Customer Name (concat) * * @param string $alias - * @return \Magento\Reports\Model\Resource\Order\Collection + * @return $this */ public function joinCustomerName($alias = 'name') { @@ -721,7 +719,7 @@ class Collection extends \Magento\Sales\Model\Resource\Order\Collection /** * Add Order count field to select * - * @return \Magento\Reports\Model\Resource\Order\Collection + * @return $this */ public function addOrdersCount() { @@ -735,8 +733,8 @@ class Collection extends \Magento\Sales\Model\Resource\Order\Collection /** * Add revenue * - * @param boolean $convertCurrency - * @return \Magento\Reports\Model\Resource\Order\Collection + * @param bool $convertCurrency + * @return $this */ public function addRevenueToSelect($convertCurrency = false) { @@ -757,7 +755,7 @@ class Collection extends \Magento\Sales\Model\Resource\Order\Collection * Add summary average totals * * @param int $storeId - * @return \Magento\Reports\Model\Resource\Order\Collection + * @return $this */ public function addSumAvgTotals($storeId = 0) { @@ -787,7 +785,7 @@ class Collection extends \Magento\Sales\Model\Resource\Order\Collection * Sort order by total amount * * @param string $dir - * @return \Magento\Reports\Model\Resource\Order\Collection + * @return $this */ public function orderByTotalAmount($dir = self::SORT_ORDER_DESC) { @@ -798,8 +796,8 @@ class Collection extends \Magento\Sales\Model\Resource\Order\Collection /** * Order by orders count * - * @param unknown_type $dir - * @return \Magento\Reports\Model\Resource\Order\Collection + * @param string $dir + * @return $this */ public function orderByOrdersCount($dir = self::SORT_ORDER_DESC) { @@ -810,8 +808,8 @@ class Collection extends \Magento\Sales\Model\Resource\Order\Collection /** * Order by customer registration * - * @param unknown_type $dir - * @return \Magento\Reports\Model\Resource\Order\Collection + * @param string $dir + * @return $this */ public function orderByCustomerRegistration($dir = self::SORT_ORDER_DESC) { @@ -823,7 +821,7 @@ class Collection extends \Magento\Sales\Model\Resource\Order\Collection * Sort order by order created_at date * * @param string $dir - * @return \Magento\Reports\Model\Resource\Order\Collection + * @return $this */ public function orderByCreatedAt($dir = self::SORT_ORDER_DESC) { @@ -834,7 +832,7 @@ class Collection extends \Magento\Sales\Model\Resource\Order\Collection /** * Get select count sql * - * @return unknown + * @return Select */ public function getSelectCountSql() { @@ -853,7 +851,7 @@ class Collection extends \Magento\Sales\Model\Resource\Order\Collection /** * Initialize initial fields to select * - * @return \Magento\Reports\Model\Resource\Order\Collection + * @return $this */ protected function _initInitialFieldsToSelect() { @@ -865,7 +863,7 @@ class Collection extends \Magento\Sales\Model\Resource\Order\Collection * Add period filter by created_at attribute * * @param string $period - * @return \Magento\Reports\Model\Resource\Order\Collection + * @return $this */ public function addCreateAtPeriodFilter($period) { diff --git a/app/code/Magento/Reports/Model/Resource/Product/Collection.php b/app/code/Magento/Reports/Model/Resource/Product/Collection.php index c5fff5ee05fbfa4d28ac580ee74f04b4f373ef75..27e1e15bdb5e4f89ea71617ed388c040018ffdf4 100644 --- a/app/code/Magento/Reports/Model/Resource/Product/Collection.php +++ b/app/code/Magento/Reports/Model/Resource/Product/Collection.php @@ -158,7 +158,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Product\Collection * Set Type for COUNT SQL Select * * @param int $type - * @return \Magento\Reports\Model\Resource\Product\Collection + * @return $this */ public function setSelectCountSqlType($type) { @@ -170,7 +170,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Product\Collection * Set product entity id * * @param $entityId - * @return \Magento\Reports\Model\Resource\Product\Collection + * @return $this */ public function setProductEntityId($entityId) { @@ -192,7 +192,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Product\Collection * Set product entity table name * * @param string $value - * @return \Magento\Reports\Model\Resource\Product\Collection + * @return $this */ public function setProductEntityTableName($value) { @@ -214,7 +214,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Product\Collection * Set product entity type id * * @param int $value - * @return \Magento\Reports\Model\Resource\Product\Collection + * @return $this */ public function setProductEntityTypeId($value) { @@ -223,7 +223,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Product\Collection } /** - * Get product entity tyoe id + * Get product entity type id * * @return int */ @@ -235,7 +235,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Product\Collection /** * Join fields * - * @return \Magento\Reports\Model\Resource\Product\Collection + * @return $this */ protected function _joinFields() { @@ -251,7 +251,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Product\Collection /** * Get select count sql * - * @return unknown + * @return string */ public function getSelectCountSql() { @@ -284,7 +284,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Product\Collection /** * Add carts count * - * @return \Magento\Reports\Model\Resource\Product\Collection + * @return $this */ public function addCartsCount() { @@ -310,7 +310,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Product\Collection * * @param string $from * @param string $to - * @return \Magento\Reports\Model\Resource\Product\Collection + * @return $this */ public function addOrdersCount($from = '', $to = '') { @@ -345,7 +345,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Product\Collection * * @param string $from * @param string $to - * @return \Magento\Reports\Model\Resource\Product\Collection + * @return $this */ public function addOrderedQty($from = '', $to = '') { @@ -406,7 +406,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Product\Collection * * @param string $attribute * @param string $dir - * @return \Magento\Reports\Model\Resource\Product\Collection + * @return $this */ public function setOrder($attribute, $dir = self::SORT_ORDER_DESC) { @@ -424,7 +424,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Product\Collection * * @param string $from * @param string $to - * @return \Magento\Reports\Model\Resource\Product\Collection + * @return $this */ public function addViewsCount($from = '', $to = '') { @@ -465,9 +465,9 @@ class Collection extends \Magento\Catalog\Model\Resource\Product\Collection /** * Prepare between sql * - * @param string $fieldName Field name with table suffix ('created_at' or 'main_table.created_at') - * @param string $from - * @param string $to + * @param string $fieldName Field name with table suffix ('created_at' or 'main_table.created_at') + * @param string $from + * @param string $to * @return string Formatted sql string */ protected function _prepareBetweenSql($fieldName, $from, $to) @@ -482,9 +482,9 @@ class Collection extends \Magento\Catalog\Model\Resource\Product\Collection /** * Add store restrictions to product collection * - * @param array $storeIds - * @param array $websiteIds - * @return \Magento\Reports\Model\Resource\Product\Collection + * @param array $storeIds + * @param array $websiteIds + * @return $this */ public function addStoreRestrictions($storeIds, $websiteIds) { diff --git a/app/code/Magento/Reports/Model/Resource/Product/Downloads/Collection.php b/app/code/Magento/Reports/Model/Resource/Product/Downloads/Collection.php index deb99172ff7019215b0642d38522a6af291e1ac2..be7e89c82d2ba38fb0a6829a1ded4aa4629220f9 100644 --- a/app/code/Magento/Reports/Model/Resource/Product/Downloads/Collection.php +++ b/app/code/Magento/Reports/Model/Resource/Product/Downloads/Collection.php @@ -46,7 +46,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Product\Collection /** * Add downloads summary grouping by product * - * @return \Magento\Reports\Model\Resource\Product\Downloads\Collection + * @return $this */ public function addSummary() { @@ -82,7 +82,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Product\Collection * * @param string $attribute * @param string $dir - * @return \Magento\Reports\Model\Resource\Product\Downloads\Collection + * @return $this */ public function setOrder($attribute, $dir = self::SORT_ORDER_DESC) { @@ -98,8 +98,8 @@ class Collection extends \Magento\Catalog\Model\Resource\Product\Collection * Add filtering * * @param string $field - * @param string $condition - * @return \Magento\Reports\Model\Resource\Product\Downloads\Collection + * @param null|string $condition + * @return $this */ public function addFieldToFilter($field, $condition = null) { diff --git a/app/code/Magento/Reports/Model/Resource/Product/Index/AbstractIndex.php b/app/code/Magento/Reports/Model/Resource/Product/Index/AbstractIndex.php index acab8a9c67ec10d8e11ed544890ac1a95b4f51a4..b18180085f4178d093b4168cfc66e618571f24cf 100644 --- a/app/code/Magento/Reports/Model/Resource/Product/Index/AbstractIndex.php +++ b/app/code/Magento/Reports/Model/Resource/Product/Index/AbstractIndex.php @@ -60,7 +60,7 @@ abstract class AbstractIndex extends \Magento\Core\Model\Resource\Db\AbstractDb * Update Customer from visitor (Customer logged in) * * @param \Magento\Reports\Model\Product\Index\AbstractIndex $object - * @return \Magento\Reports\Model\Resource\Product\Index\AbstractIndex + * @return $this */ public function updateCustomerFromVisitor(\Magento\Reports\Model\Product\Index\AbstractIndex $object) { @@ -119,7 +119,7 @@ abstract class AbstractIndex extends \Magento\Core\Model\Resource\Db\AbstractDb * Purge visitor data by customer (logout) * * @param \Magento\Reports\Model\Product\Index\AbstractIndex $object - * @return \Magento\Reports\Model\Resource\Product\Index\AbstractIndex + * @return $this */ public function purgeVisitorByCustomer(\Magento\Reports\Model\Product\Index\AbstractIndex $object) { @@ -140,8 +140,8 @@ abstract class AbstractIndex extends \Magento\Core\Model\Resource\Db\AbstractDb /** * Save Product Index data (forced save) * - * @param \Magento\Reports\Model\Product\Index\AbstractIndex $object - * @return \Magento\Reports\Model\Resource\Product\Index\AbstractIndex + * @param \Magento\Core\Model\AbstractModel $object + * @return $this|\Magento\Core\Model\Resource\Db\AbstractDb */ public function save(\Magento\Core\Model\AbstractModel $object) { @@ -174,7 +174,7 @@ abstract class AbstractIndex extends \Magento\Core\Model\Resource\Db\AbstractDb /** * Clean index (visitor) * - * @return \Magento\Reports\Model\Resource\Product\Index\AbstractIndex + * @return $this */ public function clean() { @@ -205,10 +205,9 @@ abstract class AbstractIndex extends \Magento\Core\Model\Resource\Db\AbstractDb /** * Add information about product ids to visitor/customer * - * * @param \Magento\Object|\Magento\Reports\Model\Product\Index\AbstractIndex $object * @param array $productIds - * @return \Magento\Reports\Model\Resource\Product\Index\AbstractIndex + * @return $this */ public function registerIds(\Magento\Object $object, $productIds) { diff --git a/app/code/Magento/Reports/Model/Resource/Product/Index/Collection/AbstractCollection.php b/app/code/Magento/Reports/Model/Resource/Product/Index/Collection/AbstractCollection.php index 2a620de31410a653b68efadb5fd44fd4ae34a1c4..4ae66cb46255174279652c075b0aa2bd729ad6d9 100644 --- a/app/code/Magento/Reports/Model/Resource/Product/Index/Collection/AbstractCollection.php +++ b/app/code/Magento/Reports/Model/Resource/Product/Index/Collection/AbstractCollection.php @@ -121,14 +121,13 @@ abstract class AbstractCollection /** * Retrieve Product Index table name - * */ abstract protected function _getTableName(); /** * Join index table * - * @return \Magento\Reports\Model\Resource\Product\Index\Collection\AbstractCollection + * @return $this */ protected function _joinIdxTable() { @@ -151,7 +150,7 @@ abstract class AbstractCollection /** * Add Viewed Products Index to Collection * - * @return \Magento\Reports\Model\Resource\Product\Index\Collection\AbstractCollection + * @return $this */ public function addIndexFilter() { @@ -166,7 +165,7 @@ abstract class AbstractCollection * Add filter by product ids * * @param array $ids - * @return \Magento\Reports\Model\Resource\Product\Index\Collection\AbstractCollection + * @return $this */ public function addFilterByIds($ids) { @@ -202,7 +201,7 @@ abstract class AbstractCollection * Set customer id, that will be used in 'whereCondition' * * @param int $id - * @return \Magento\Reports\Model\Resource\Product\Index\Collection\AbstractCollection + * @return $this */ public function setCustomerId($id) { @@ -214,7 +213,7 @@ abstract class AbstractCollection * Add order by "added at" * * @param string $dir - * @return \Magento\Reports\Model\Resource\Product\Index\Collection\AbstractCollection + * @return $this */ public function setAddedAtOrder($dir = self::SORT_ORDER_DESC) { @@ -228,7 +227,7 @@ abstract class AbstractCollection * Add exclude Product Ids * * @param int|array $productIds - * @return \Magento\Reports\Model\Resource\Product\Index\Collection\AbstractCollection + * @return $this */ public function excludeProductIds($productIds) { diff --git a/app/code/Magento/Reports/Model/Resource/Product/Index/Compared.php b/app/code/Magento/Reports/Model/Resource/Product/Index/Compared.php index c05da97ff0ddea6a413ec1f31d7ee0039247074e..e926fbfc08fff22ffba96f006ebff26d3c2e2fc5 100644 --- a/app/code/Magento/Reports/Model/Resource/Product/Index/Compared.php +++ b/app/code/Magento/Reports/Model/Resource/Product/Index/Compared.php @@ -39,6 +39,7 @@ class Compared extends \Magento\Reports\Model\Resource\Product\Index\AbstractInd /** * Initialize connection and main resource table * + * @return void */ protected function _construct() { diff --git a/app/code/Magento/Reports/Model/Resource/Product/Index/Viewed.php b/app/code/Magento/Reports/Model/Resource/Product/Index/Viewed.php index caa864f84400083a29feeef37471ac6916c31e68..1d561f9b6202c4fe2f4468685cde75c8dc47fb01 100644 --- a/app/code/Magento/Reports/Model/Resource/Product/Index/Viewed.php +++ b/app/code/Magento/Reports/Model/Resource/Product/Index/Viewed.php @@ -39,6 +39,7 @@ class Viewed extends \Magento\Reports\Model\Resource\Product\Index\AbstractIndex /** * Initialize connection and main resource table * + * @return void */ protected function _construct() { diff --git a/app/code/Magento/Reports/Model/Resource/Product/Lowstock/Collection.php b/app/code/Magento/Reports/Model/Resource/Product/Lowstock/Collection.php index 6a54c0ef4dd3988c6a0a0b4d64573ec339b91931..6e53922d83fcbd09280b3c34043fb9b17d19c1e5 100644 --- a/app/code/Magento/Reports/Model/Resource/Product/Lowstock/Collection.php +++ b/app/code/Magento/Reports/Model/Resource/Product/Lowstock/Collection.php @@ -179,7 +179,7 @@ class Collection extends \Magento\Reports\Model\Resource\Product\Collection * * @param string $field * @param string $alias - * @return \Magento\Reports\Model\Resource\Product\Lowstock\Collection + * @return $this */ protected function _addInventoryItemFieldToSelect($field, $alias = null) { @@ -253,7 +253,7 @@ class Collection extends \Magento\Reports\Model\Resource\Product\Collection * Add filter by product type(s) * * @param array|string $typeFilter - * @return \Magento\Reports\Model\Resource\Product\Lowstock\Collection + * @return $this */ public function filterByProductType($typeFilter) { @@ -265,10 +265,9 @@ class Collection extends \Magento\Reports\Model\Resource\Product\Collection } /** - * Add filter by product types from config - * Only types witch has QTY parameter + * Add filter by product types from config - only types which have QTY parameter * - * @return \Magento\Reports\Model\Resource\Product\Lowstock\Collection + * @return $this */ public function filterByIsQtyProductTypes() { @@ -281,8 +280,8 @@ class Collection extends \Magento\Reports\Model\Resource\Product\Collection /** * Add Use Manage Stock Condition to collection * - * @param int|null $storeId - * @return \Magento\Reports\Model\Resource\Product\Lowstock\Collection + * @param null|int $storeId + * @return $this */ public function useManageStockFilter($storeId = null) { @@ -299,8 +298,8 @@ class Collection extends \Magento\Reports\Model\Resource\Product\Collection /** * Add Notify Stock Qty Condition to collection * - * @param int $storeId - * @return \Magento\Reports\Model\Resource\Product\Lowstock\Collection + * @param null|int $storeId + * @return $this */ public function useNotifyStockQtyFilter($storeId = null) { diff --git a/app/code/Magento/Reports/Model/Resource/Product/Sold/Collection.php b/app/code/Magento/Reports/Model/Resource/Product/Sold/Collection.php index fd71c2d479f4fff33af235805491e88198e66367..eab02e934c0d81a9fa01a11c5ce5f84dca946d35 100644 --- a/app/code/Magento/Reports/Model/Resource/Product/Sold/Collection.php +++ b/app/code/Magento/Reports/Model/Resource/Product/Sold/Collection.php @@ -41,7 +41,7 @@ class Collection extends \Magento\Reports\Model\Resource\Product\Collection * * @param int $from * @param int $to - * @return \Magento\Reports\Model\Resource\Product\Sold\Collection + * @return $this */ public function setDateRange($from, $to) { @@ -56,7 +56,7 @@ class Collection extends \Magento\Reports\Model\Resource\Product\Collection * Set store filter to collection * * @param array $storeIds - * @return \Magento\Reports\Model\Resource\Product\Sold\Collection + * @return $this */ public function setStoreIds($storeIds) { @@ -69,7 +69,7 @@ class Collection extends \Magento\Reports\Model\Resource\Product\Collection /** * Add website product limitation * - * @return \Magento\Reports\Model\Resource\Product\Sold\Collection + * @return $this */ protected function _productLimitationJoinWebsite() { diff --git a/app/code/Magento/Reports/Model/Resource/Product/Sold/Collection/Initial.php b/app/code/Magento/Reports/Model/Resource/Product/Sold/Collection/Initial.php index ae19c08612f96d60ce7c0e3f0b833ebc227b284d..1e46772307f9a3d41390cf5a148c0e6971c42f54 100644 --- a/app/code/Magento/Reports/Model/Resource/Product/Sold/Collection/Initial.php +++ b/app/code/Magento/Reports/Model/Resource/Product/Sold/Collection/Initial.php @@ -38,6 +38,7 @@ class Initial extends \Magento\Reports\Model\Resource\Report\Collection { /* * Report sub-collection class name + * * @var string */ protected $_reportCollection = 'Magento\Reports\Model\Resource\Product\Sold\Collection'; diff --git a/app/code/Magento/Reports/Model/Resource/Quote/Collection.php b/app/code/Magento/Reports/Model/Resource/Quote/Collection.php index 0f405ad11979228e786f515105c23bc920879576..1308c8143723575dad88bd6404eff64e7a45352e 100644 --- a/app/code/Magento/Reports/Model/Resource/Quote/Collection.php +++ b/app/code/Magento/Reports/Model/Resource/Quote/Collection.php @@ -39,6 +39,9 @@ class Collection extends \Magento\Sales\Model\Resource\Quote\Collection const SELECT_COUNT_SQL_TYPE_CART = 1; + /** + * @var int + */ protected $_selectCountSqlType = 0; /** @@ -84,7 +87,7 @@ class Collection extends \Magento\Sales\Model\Resource\Quote\Collection * Set type for COUNT SQL select * * @param int $type - * @return \Magento\Reports\Model\Resource\Quote\Collection + * @return $this */ public function setSelectCountSqlType($type) { @@ -97,7 +100,7 @@ class Collection extends \Magento\Sales\Model\Resource\Quote\Collection * * @param array $storeIds * @param string $filter - * @return \Magento\Reports\Model\Resource\Quote\Collection + * @return $this */ public function prepareForAbandonedReport($storeIds, $filter = null) { @@ -117,7 +120,7 @@ class Collection extends \Magento\Sales\Model\Resource\Quote\Collection /** * Prepare select query for products in carts report * - * @return \Magento\Reports\Model\Resource\Quote\Collection + * @return $this */ public function prepareForProductsInCarts() { @@ -177,7 +180,7 @@ class Collection extends \Magento\Sales\Model\Resource\Quote\Collection * Add store ids to filter * * @param array $storeIds - * @return \Magento\Reports\Model\Resource\Quote\Collection + * @return $this */ public function addStoreFilter($storeIds) { @@ -189,7 +192,7 @@ class Collection extends \Magento\Sales\Model\Resource\Quote\Collection * Add customer data * * @param unknown_type $filter - * @return \Magento\Reports\Model\Resource\Quote\Collection + * @return $this */ public function addCustomerData($filter = null) { @@ -253,8 +256,8 @@ class Collection extends \Magento\Sales\Model\Resource\Quote\Collection * Add subtotals * * @param array $storeIds - * @param array $filter - * @return \Magento\Reports\Model\Resource\Quote\Collection + * @param null|array $filter + * @return $this */ public function addSubtotal($storeIds = '', $filter = null) { @@ -290,7 +293,7 @@ class Collection extends \Magento\Sales\Model\Resource\Quote\Collection /** * Get select count sql * - * @return unknown + * @return string */ public function getSelectCountSql() { diff --git a/app/code/Magento/Reports/Model/Resource/Refresh/Collection.php b/app/code/Magento/Reports/Model/Resource/Refresh/Collection.php index a2fd44a8dac1ba6e4038418e12eab80f27de9036..44d3aded3ac8b22fe45d517e3e8d288733943922 100644 --- a/app/code/Magento/Reports/Model/Resource/Refresh/Collection.php +++ b/app/code/Magento/Reports/Model/Resource/Refresh/Collection.php @@ -36,7 +36,6 @@ namespace Magento\Reports\Model\Resource\Refresh; class Collection extends \Magento\Data\Collection { - /** * @var \Magento\Core\Model\LocaleInterface */ @@ -65,8 +64,8 @@ class Collection extends \Magento\Data\Collection /** * Get if updated * - * @param $reportCode - * @return string|Zend_Date + * @param string $reportCode + * @return string|\Zend_Date */ protected function _getUpdatedAt($reportCode) { @@ -82,7 +81,10 @@ class Collection extends \Magento\Data\Collection /** * Load data - * @return \Magento\Reports\Model\Resource\Refresh\Collection|\Magento\Data\Collection + * + * @param bool $printQuery + * @param bool $logQuery + * @return $this */ public function loadData($printQuery = false, $logQuery = false) { diff --git a/app/code/Magento/Reports/Model/Resource/Report/AbstractReport.php b/app/code/Magento/Reports/Model/Resource/Report/AbstractReport.php index c5e6bd058d7df10caf53ad936a61e70c34e0a2eb..9f209b021953e0bea96cb701aaed678221665770 100644 --- a/app/code/Magento/Reports/Model/Resource/Report/AbstractReport.php +++ b/app/code/Magento/Reports/Model/Resource/Report/AbstractReport.php @@ -100,7 +100,7 @@ abstract class AbstractReport extends \Magento\Core\Model\Resource\Db\AbstractDb * * @param string $code * @param mixed $value - * @return \Magento\Reports\Model\Resource\Report\AbstractReport + * @return $this */ protected function _setFlagData($code, $value = null) { @@ -142,7 +142,7 @@ abstract class AbstractReport extends \Magento\Core\Model\Resource\Db\AbstractDb * Truncate table * * @param string $table - * @return \Magento\Reports\Model\Resource\Report\AbstractReport + * @return $this */ protected function _truncateTable($table) { @@ -157,14 +157,14 @@ abstract class AbstractReport extends \Magento\Core\Model\Resource\Db\AbstractDb /** * Clear report table by specified date range. * If specified source table parameters, - * condition will be generated by source table subselect. + * condition will be generated by source table sub-select. * * @param string $table - * @param string|null $from - * @param string|null $to - * @param \Zend_Db_Select|string|null $subSelect + * @param null|string $from + * @param null|string $to + * @param null|\Zend_Db_Select|string $subSelect * @param bool $doNotUseTruncate - * @return \Magento\Reports\Model\Resource\Report\AbstractReport + * @return $this */ protected function _clearTableByDateRange($table, $from = null, $to = null, $subSelect = null, $doNotUseTruncate = false @@ -197,8 +197,8 @@ abstract class AbstractReport extends \Magento\Core\Model\Resource\Db\AbstractDb * @param string $table * @param string $column * @param string $whereColumn - * @param string|null $from - * @param string|null $to + * @param null|string $from + * @param null|string $to * @param array $additionalWhere * @param string $alias * @return \Magento\DB\Select @@ -240,14 +240,11 @@ abstract class AbstractReport extends \Magento\Core\Model\Resource\Db\AbstractDb } /** - * Make condition for using in where section - * from select statement with single date column - * - * @result string|false + * Make condition for using in where section from select statement with single date column * * @param \Magento\DB\Select $select * @param string $periodColumn - * @return string + * @return array|bool|string */ protected function _makeConditionFromDateRangeSelect($select, $periodColumn) { @@ -360,7 +357,7 @@ abstract class AbstractReport extends \Magento\Core\Model\Resource\Db\AbstractDb * * @param mixed $dateFrom * @param mixed $dateTo - * @return \Magento\Reports\Model\Resource\Report\AbstractReport + * @return $this */ protected function _checkDates(&$dateFrom, &$dateTo) { @@ -380,9 +377,9 @@ abstract class AbstractReport extends \Magento\Core\Model\Resource\Db\AbstractDb * * @param string|array $table * @param string $column - * @param mixed $from - * @param mixed $to - * @param int|string|\Magento\Core\Model\Store|null $store + * @param null|mixed $from + * @param null|mixed $to + * @param null|int|string|\Magento\Core\Model\Store $store * @return string */ public function getStoreTZOffsetQuery($table, $column, $from = null, $to = null, $store = null) @@ -474,7 +471,7 @@ abstract class AbstractReport extends \Magento\Core\Model\Resource\Db\AbstractDb /** * Retrieve store timezone offset from UTC in the form acceptable by SQL's CONVERT_TZ() * - * @param mixed $store + * @param null|mixed $store * @return string */ protected function _getStoreTimezoneUtcOffset($store = null) @@ -486,7 +483,7 @@ abstract class AbstractReport extends \Magento\Core\Model\Resource\Db\AbstractDb * Retrieve date in UTC timezone * * @param mixed $date - * @return \Zend_Date|null + * @return null|\Zend_Date */ protected function _dateToUtc($date) { diff --git a/app/code/Magento/Reports/Model/Resource/Report/Collection.php b/app/code/Magento/Reports/Model/Resource/Report/Collection.php index 88915b040ba77b6f35215e49c631c174e4c00e56..6cb15dd1b90a827649aef5666cf7563ae1974612 100644 --- a/app/code/Magento/Reports/Model/Resource/Report/Collection.php +++ b/app/code/Magento/Reports/Model/Resource/Report/Collection.php @@ -129,7 +129,7 @@ class Collection extends \Magento\Data\Collection * Set period * * @param int $period - * @return \Magento\Reports\Model\Resource\Report\Collection + * @return $this */ public function setPeriod($period) { @@ -142,7 +142,7 @@ class Collection extends \Magento\Data\Collection * * @param int $fromDate * @param int $toDate - * @return \Magento\Reports\Model\Resource\Report\Collection + * @return $this */ public function setInterval($fromDate, $toDate) { @@ -290,7 +290,7 @@ class Collection extends \Magento\Data\Collection * Set store ids * * @param array $storeIds - * @return \Magento\Reports\Model\Resource\Report\Collection + * @return $this */ public function setStoreIds($storeIds) { @@ -322,7 +322,7 @@ class Collection extends \Magento\Data\Collection * Set page size * * @param int $size - * @return \Magento\Reports\Model\Resource\Report\Collection + * @return $this */ public function setPageSize($size) { @@ -401,7 +401,7 @@ class Collection extends \Magento\Data\Collection * * @param bool $printQuery * @param bool $logQuery - * @return \Magento\Reports\Model\Resource\Report\Collection|\Magento\Data\Collection + * @return $this * * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ diff --git a/app/code/Magento/Reports/Model/Resource/Report/Collection/AbstractCollection.php b/app/code/Magento/Reports/Model/Resource/Report/Collection/AbstractCollection.php index be5030fb15657a2757fa579ebd557862afd675c1..afb1b6fab838d971c34ce7fc976a7dd4ab0da50e 100644 --- a/app/code/Magento/Reports/Model/Resource/Report/Collection/AbstractCollection.php +++ b/app/code/Magento/Reports/Model/Resource/Report/Collection/AbstractCollection.php @@ -89,7 +89,7 @@ class AbstractCollection extends \Magento\Core\Model\Resource\Db\Collection\Abst * Set array of columns that should be aggregated * * @param array $columns - * @return \Magento\Sales\Model\Resource\Report\Collection\AbstractCollection + * @return $this */ public function setAggregatedColumns(array $columns) { @@ -112,7 +112,7 @@ class AbstractCollection extends \Magento\Core\Model\Resource\Db\Collection\Abst * * @param mixed $from * @param mixed $to - * @return \Magento\Sales\Model\Resource\Report\Collection\AbstractCollection + * @return $this */ public function setDateRange($from = null, $to = null) { @@ -125,7 +125,7 @@ class AbstractCollection extends \Magento\Core\Model\Resource\Db\Collection\Abst * Set period * * @param string $period - * @return \Magento\Sales\Model\Resource\Report\Collection\AbstractCollection + * @return $this */ public function setPeriod($period) { @@ -136,7 +136,7 @@ class AbstractCollection extends \Magento\Core\Model\Resource\Db\Collection\Abst /** * Apply date range filter * - * @return \Magento\Sales\Model\Resource\Report\Collection\AbstractCollection + * @return $this */ protected function _applyDateRangeFilter() { @@ -155,7 +155,7 @@ class AbstractCollection extends \Magento\Core\Model\Resource\Db\Collection\Abst * Set store ids * * @param mixed $storeIds (null, int|string, array, array may contain null) - * @return \Magento\Sales\Model\Resource\Report\Collection\AbstractCollection + * @return $this */ public function addStoreFilter($storeIds) { @@ -167,7 +167,7 @@ class AbstractCollection extends \Magento\Core\Model\Resource\Db\Collection\Abst * Apply stores filter to select object * * @param \Zend_Db_Select $select - * @return \Magento\Sales\Model\Resource\Report\Collection\AbstractCollection + * @return $this */ protected function _applyStoresFilterToSelect(\Zend_Db_Select $select) { @@ -197,7 +197,7 @@ class AbstractCollection extends \Magento\Core\Model\Resource\Db\Collection\Abst /** * Apply stores filter * - * @return \Magento\Sales\Model\Resource\Report\Collection\AbstractCollection + * @return $this */ protected function _applyStoresFilter() { @@ -207,8 +207,8 @@ class AbstractCollection extends \Magento\Core\Model\Resource\Db\Collection\Abst /** * Getter/Setter for isTotals * - * @param null|boolean $flag - * @return \Magento\Sales\Model\Resource\Report\Collection\AbstractCollection + * @param null|bool $flag + * @return $this */ public function isTotals($flag = null) { @@ -222,8 +222,8 @@ class AbstractCollection extends \Magento\Core\Model\Resource\Db\Collection\Abst /** * Getter/Setter for isSubTotals * - * @param null|boolean $flag - * @return \Magento\Sales\Model\Resource\Report\Collection\AbstractCollection + * @param null|bool $flag + * @return $this */ public function isSubTotals($flag = null) { @@ -237,7 +237,7 @@ class AbstractCollection extends \Magento\Core\Model\Resource\Db\Collection\Abst /** * Custom filters application ability * - * @return \Magento\Reports\Model\Resource\Report\Collection\AbstractCollection + * @return $this */ protected function _applyCustomFilter() { @@ -247,7 +247,7 @@ class AbstractCollection extends \Magento\Core\Model\Resource\Db\Collection\Abst /** * Apply filters common to reports * - * @return \Magento\Core\Model\Resource\Db\Collection\AbstractCollection + * @return $this */ protected function _initSelect() { diff --git a/app/code/Magento/Reports/Model/Resource/Report/Product/Viewed.php b/app/code/Magento/Reports/Model/Resource/Report/Product/Viewed.php index 5919d38ea1910d2a5c8908f93ad558be91ad167b..4bdb317bf657e4db5ac7808944c0cd70ba82660b 100644 --- a/app/code/Magento/Reports/Model/Resource/Report/Product/Viewed.php +++ b/app/code/Magento/Reports/Model/Resource/Report/Product/Viewed.php @@ -89,6 +89,7 @@ class Viewed extends \Magento\Sales\Model\Resource\Report\AbstractReport /** * Model initialization * + * @return void */ protected function _construct() { @@ -98,9 +99,9 @@ class Viewed extends \Magento\Sales\Model\Resource\Report\AbstractReport /** * Aggregate products view data * - * @param mixed $from - * @param mixed $to - * @return \Magento\Sales\Model\Resource\Report\Bestsellers + * @param null|mixed $from + * @param null|mixed $to + * @return $this */ public function aggregate($from = null, $to = null) { diff --git a/app/code/Magento/Reports/Model/Resource/Report/Product/Viewed/Collection.php b/app/code/Magento/Reports/Model/Resource/Report/Product/Viewed/Collection.php index 8f4bfd8d130df11ff9f2ba84659e532852913e4f..8cadfde86f3bd54c0ca8ff29d73c1cadcef8e1fe 100644 --- a/app/code/Magento/Reports/Model/Resource/Report/Product/Viewed/Collection.php +++ b/app/code/Magento/Reports/Model/Resource/Report/Product/Viewed/Collection.php @@ -126,7 +126,7 @@ class Collection /** * Init collection select * - * @return \Magento\Reports\Model\Resource\Report\Product\Viewed\Collection + * @return $this */ protected function _initSelect() { @@ -191,7 +191,7 @@ class Collection * Set ids for store restrictions * * @param array $storeIds - * @return \Magento\Reports\Model\Resource\Report\Product\Viewed\Collection + * @return $this */ public function addStoreRestrictions($storeIds) { @@ -213,10 +213,10 @@ class Collection } /** - * Redeclare parent method for applying filters after parent method - * but before adding unions and calculating totals + * Re-declare parent method for applying filters after parent method, but before adding unions and calculating + * totals * - * @return \Magento\Reports\Model\Resource\Report\Product\Viewed\Collection + * @return $this|\Magento\Core\Model\Resource\Db\Collection\AbstractCollection */ protected function _beforeLoad() { diff --git a/app/code/Magento/Reports/Model/Resource/Review/Collection.php b/app/code/Magento/Reports/Model/Resource/Review/Collection.php index 913d9429592eb27e1a46dc89c1fa080d9b102f3b..a3408512fa5941e60ef43db32f8cf1d3fc44049c 100644 --- a/app/code/Magento/Reports/Model/Resource/Review/Collection.php +++ b/app/code/Magento/Reports/Model/Resource/Review/Collection.php @@ -39,6 +39,7 @@ class Collection extends \Magento\Review\Model\Resource\Review\Collection /** * Resource initialization * + * @return void */ protected function _construct() { @@ -46,10 +47,10 @@ class Collection extends \Magento\Review\Model\Resource\Review\Collection } /** - * add product filter + * Add product filter * - * @param unknown_type $productId - * @return \Magento\Reports\Model\Resource\Review\Collection + * @param string $productId + * @return $this */ public function addProductFilter($productId) { @@ -61,7 +62,7 @@ class Collection extends \Magento\Review\Model\Resource\Review\Collection /** * Reset select * - * @return \Magento\Reports\Model\Resource\Review\Collection + * @return $this */ public function resetSelect() { @@ -92,7 +93,7 @@ class Collection extends \Magento\Review\Model\Resource\Review\Collection * * @param string $attribute * @param string $dir - * @return \Magento\Reports\Model\Resource\Review\Collection + * @return $this */ public function setOrder($attribute, $dir = self::SORT_ORDER_DESC) { diff --git a/app/code/Magento/Reports/Model/Resource/Review/Customer/Collection.php b/app/code/Magento/Reports/Model/Resource/Review/Customer/Collection.php index a8a5ae643736d0eaba2fced01c42995898d30b66..40dc41cf89272f7f62ee4fa19819526d9ccf21d3 100644 --- a/app/code/Magento/Reports/Model/Resource/Review/Customer/Collection.php +++ b/app/code/Magento/Reports/Model/Resource/Review/Customer/Collection.php @@ -82,7 +82,7 @@ class Collection extends \Magento\Review\Model\Resource\Review\Collection /** * Init Select * - * @return \Magento\Reports\Model\Resource\Review\Customer\Collection + * @return $this */ protected function _initSelect() { @@ -94,7 +94,7 @@ class Collection extends \Magento\Review\Model\Resource\Review\Collection /** * Join customers * - * @return \Magento\Reports\Model\Resource\Review\Customer\Collection + * @return $this */ protected function _joinCustomers() { diff --git a/app/code/Magento/Reports/Model/Resource/Review/Product/Collection.php b/app/code/Magento/Reports/Model/Resource/Review/Product/Collection.php index b537e3e71454ba4b5d1940b89bf336068193b6e6..c9473649a59cd5724b9b302dbfe70d707cc7bc24 100644 --- a/app/code/Magento/Reports/Model/Resource/Review/Product/Collection.php +++ b/app/code/Magento/Reports/Model/Resource/Review/Product/Collection.php @@ -51,7 +51,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Product\Collection /** * Join review table to result * - * @return \Magento\Reports\Model\Resource\Review\Product\Collection + * @return $this */ protected function _joinReview() { @@ -98,7 +98,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Product\Collection * * @param string $attribute * @param string $dir - * @return \Magento\Reports\Model\Resource\Review\Product\Collection + * @return $this|\Magento\Catalog\Model\Resource\Product\Collection */ public function addAttributeToSort($attribute, $dir = self::SORT_ORDER_ASC) { diff --git a/app/code/Magento/Reports/Model/Resource/Shopcart/Product/Collection.php b/app/code/Magento/Reports/Model/Resource/Shopcart/Product/Collection.php index a4418663ba5f27a116604a4830eb268d37f68688..d3cd1322409ef5f618e1ac7ff81a44b9309469f4 100644 --- a/app/code/Magento/Reports/Model/Resource/Shopcart/Product/Collection.php +++ b/app/code/Magento/Reports/Model/Resource/Shopcart/Product/Collection.php @@ -39,7 +39,7 @@ class Collection extends \Magento\Reports\Model\Resource\Product\Collection /** * Join fields * - * @return \Magento\Reports\Model\Resource\Shopcart\Product\Collection + * @return $this */ protected function _joinFields() { @@ -55,8 +55,8 @@ class Collection extends \Magento\Reports\Model\Resource\Product\Collection * Set date range * * @param string $from - * @param strin $to - * @return \Magento\Reports\Model\Resource\Shopcart\Product\Collection + * @param string $to + * @return $this */ public function setDateRange($from, $to) { diff --git a/app/code/Magento/Reports/Model/Resource/Wishlist/Collection.php b/app/code/Magento/Reports/Model/Resource/Wishlist/Collection.php index 693724dfcef91e7b1e03aa1239edc6ebd0f0765d..ddeeff7e8df376ae269ea90524b111b826487874 100644 --- a/app/code/Magento/Reports/Model/Resource/Wishlist/Collection.php +++ b/app/code/Magento/Reports/Model/Resource/Wishlist/Collection.php @@ -74,6 +74,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl /** * Resource initialization * + * @return void */ protected function _construct() { @@ -93,7 +94,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl } /** - * retrieve wishlist table name + * Retrieve wishlist table name * * @return string */ diff --git a/app/code/Magento/Reports/Model/Resource/Wishlist/Product/Collection.php b/app/code/Magento/Reports/Model/Resource/Wishlist/Product/Collection.php index b374f836b929aa10ca6e548bc16911b6ddb2a6e3..9da32ec284ed3bb2ee676e70a5abdfe65e1f349d 100644 --- a/app/code/Magento/Reports/Model/Resource/Wishlist/Product/Collection.php +++ b/app/code/Magento/Reports/Model/Resource/Wishlist/Product/Collection.php @@ -39,6 +39,7 @@ class Collection extends \Magento\Wishlist\Model\Resource\Item\Collection /** * Resource initialization * + * @return void */ public function _construct() { @@ -48,7 +49,7 @@ class Collection extends \Magento\Wishlist\Model\Resource\Item\Collection /** * Add wishlist count * - * @return \Magento\Reports\Model\Resource\Wishlist\Product\Collection + * @return $this */ public function addWishlistCount() { @@ -66,9 +67,9 @@ class Collection extends \Magento\Wishlist\Model\Resource\Item\Collection } /** - * add customer count to result + * Add customer count to result * - * @return \Magento\Reports\Model\Resource\Wishlist\Product\Collection + * @return $this */ public function getCustomerCount() { @@ -108,7 +109,7 @@ class Collection extends \Magento\Wishlist\Model\Resource\Item\Collection * * @param string $attribute * @param string $dir - * @return \Magento\Reports\Model\Resource\Wishlist\Product\Collection + * @return $this */ public function setOrder($attribute, $dir = self::SORT_ORDER_DESC) { diff --git a/app/code/Magento/Reports/Model/Totals.php b/app/code/Magento/Reports/Model/Totals.php index 287901e911c5570f0ef72459e0b66eeebe89d189..3ff59bab1ae1968ed64f5739119369e51cc4ed2b 100644 --- a/app/code/Magento/Reports/Model/Totals.php +++ b/app/code/Magento/Reports/Model/Totals.php @@ -23,6 +23,7 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Reports\Model; /** * Totals Class @@ -31,8 +32,6 @@ * @package Magento_Reports * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\Reports\Model; - class Totals { /** diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Order.php b/app/code/Magento/Sales/Controller/Adminhtml/Order.php index f5de7c9f885b347a178a8ec941a970bca3741058..a7e82aa7be63774bc61a9bb113dab964ae027677 100644 --- a/app/code/Magento/Sales/Controller/Adminhtml/Order.php +++ b/app/code/Magento/Sales/Controller/Adminhtml/Order.php @@ -57,25 +57,25 @@ class Order extends \Magento\Backend\App\Action protected $_fileFactory; /** - * @var \Magento\Core\Model\Translate + * @var \Magento\Translate\InlineInterface */ - protected $_translator; + protected $_translateInline; /** * @param Action\Context $context * @param \Magento\Core\Model\Registry $coreRegistry * @param \Magento\App\Response\Http\FileFactory $fileFactory - * @param \Magento\Core\Model\Translate $translator + * @param \Magento\Translate\InlineInterface $translateInline */ public function __construct( Action\Context $context, \Magento\Core\Model\Registry $coreRegistry, \Magento\App\Response\Http\FileFactory $fileFactory, - \Magento\Core\Model\Translate $translator + \Magento\Translate\InlineInterface $translateInline ) { $this->_coreRegistry = $coreRegistry; $this->_fileFactory = $fileFactory; - $this->_translator = $translator; + $this->_translateInline = $translateInline; parent::__construct($context); } @@ -381,8 +381,8 @@ class Order extends \Magento\Backend\App\Action $this->_initOrder(); $html = $this->_view->getLayout() ->createBlock('Magento\Sales\Block\Adminhtml\Order\View\Tab\History')->toHtml(); - if ($this->_translator->isAllowed()) { - $this->_translator->processResponseBody($html); + if ($this->_translateInline->isAllowed()) { + $this->_translateInline->processResponseBody($html); } $this->getResponse()->setBody($html); } diff --git a/app/code/Magento/Sales/Model/Order/Pdf/AbstractPdf.php b/app/code/Magento/Sales/Model/Order/Pdf/AbstractPdf.php index 99792b1db71ab42fbb273aeed1cab44e0f70ed1e..cfab231cff5a6b6882dfbf2f2454e14c32fe438f 100644 --- a/app/code/Magento/Sales/Model/Order/Pdf/AbstractPdf.php +++ b/app/code/Magento/Sales/Model/Order/Pdf/AbstractPdf.php @@ -94,7 +94,7 @@ abstract class AbstractPdf extends \Magento\Object protected $_coreStoreConfig; /** - * @var \Magento\Core\Model\Translate + * @var \Magento\TranslateInterface */ protected $_translate; @@ -126,7 +126,7 @@ abstract class AbstractPdf extends \Magento\Object * @param \Magento\Payment\Helper\Data $paymentData * @param \Magento\Stdlib\String $string * @param \Magento\Core\Model\Store\ConfigInterface $coreStoreConfig - * @param \Magento\Core\Model\Translate $translate + * @param \Magento\TranslateInterface $translate * @param \Magento\App\Filesystem $filesystem * @param \Magento\Sales\Model\Order\Pdf\Config $pdfConfig * @param \Magento\Sales\Model\Order\Pdf\Total\Factory $pdfTotalFactory @@ -140,7 +140,7 @@ abstract class AbstractPdf extends \Magento\Object \Magento\Payment\Helper\Data $paymentData, \Magento\Stdlib\String $string, \Magento\Core\Model\Store\ConfigInterface $coreStoreConfig, - \Magento\Core\Model\Translate $translate, + \Magento\TranslateInterface $translate, \Magento\App\Filesystem $filesystem, \Magento\Sales\Model\Order\Pdf\Config $pdfConfig, \Magento\Sales\Model\Order\Pdf\Total\Factory $pdfTotalFactory, diff --git a/app/code/Magento/Sales/Model/Order/Pdf/Creditmemo.php b/app/code/Magento/Sales/Model/Order/Pdf/Creditmemo.php index e1a26fb4a82fbc75f508706b728e0895c60520e3..e73d35fae95a0ac1fb26951f4300476935d1bfca 100644 --- a/app/code/Magento/Sales/Model/Order/Pdf/Creditmemo.php +++ b/app/code/Magento/Sales/Model/Order/Pdf/Creditmemo.php @@ -40,7 +40,7 @@ class Creditmemo extends \Magento\Sales\Model\Order\Pdf\AbstractPdf * @param \Magento\Payment\Helper\Data $paymentData * @param \Magento\Stdlib\String $string * @param \Magento\Core\Model\Store\ConfigInterface $coreStoreConfig - * @param \Magento\Core\Model\Translate $translate + * @param \Magento\TranslateInterface $translate * @param \Magento\App\Filesystem $filesystem * @param \Magento\Sales\Model\Order\Pdf\Config $pdfConfig * @param \Magento\Sales\Model\Order\Pdf\Total\Factory $pdfTotalFactory @@ -55,7 +55,7 @@ class Creditmemo extends \Magento\Sales\Model\Order\Pdf\AbstractPdf \Magento\Payment\Helper\Data $paymentData, \Magento\Stdlib\String $string, \Magento\Core\Model\Store\ConfigInterface $coreStoreConfig, - \Magento\Core\Model\Translate $translate, + \Magento\TranslateInterface $translate, \Magento\App\Filesystem $filesystem, \Magento\Sales\Model\Order\Pdf\Config $pdfConfig, \Magento\Sales\Model\Order\Pdf\Total\Factory $pdfTotalFactory, diff --git a/app/code/Magento/Sales/Model/Order/Pdf/Invoice.php b/app/code/Magento/Sales/Model/Order/Pdf/Invoice.php index 63f57106ff5707ca6dd27e05c3efabad7416c367..e1b5979419a3ee0918c875ac6f59c7bbacfce7db 100644 --- a/app/code/Magento/Sales/Model/Order/Pdf/Invoice.php +++ b/app/code/Magento/Sales/Model/Order/Pdf/Invoice.php @@ -40,7 +40,7 @@ class Invoice extends \Magento\Sales\Model\Order\Pdf\AbstractPdf * @param \Magento\Payment\Helper\Data $paymentData * @param \Magento\Stdlib\String $string * @param \Magento\Core\Model\Store\ConfigInterface $coreStoreConfig - * @param \Magento\Core\Model\Translate $translate + * @param \Magento\TranslateInterface $translate * @param \Magento\App\Filesystem $filesystem, * @param \Magento\Sales\Model\Order\Pdf\Config $pdfConfig * @param \Magento\Sales\Model\Order\Pdf\Total\Factory $pdfTotalFactory @@ -55,7 +55,7 @@ class Invoice extends \Magento\Sales\Model\Order\Pdf\AbstractPdf \Magento\Payment\Helper\Data $paymentData, \Magento\Stdlib\String $string, \Magento\Core\Model\Store\ConfigInterface $coreStoreConfig, - \Magento\Core\Model\Translate $translate, + \Magento\TranslateInterface $translate, \Magento\App\Filesystem $filesystem, \Magento\Sales\Model\Order\Pdf\Config $pdfConfig, \Magento\Sales\Model\Order\Pdf\Total\Factory $pdfTotalFactory, diff --git a/app/code/Magento/Sales/Model/Order/Pdf/Shipment.php b/app/code/Magento/Sales/Model/Order/Pdf/Shipment.php index d005820fdabcb3364d369eb7cf955078584ccb1e..afb01044d651ca73871acc844d64a9faa0b89e94 100644 --- a/app/code/Magento/Sales/Model/Order/Pdf/Shipment.php +++ b/app/code/Magento/Sales/Model/Order/Pdf/Shipment.php @@ -40,7 +40,7 @@ class Shipment extends \Magento\Sales\Model\Order\Pdf\AbstractPdf * @param \Magento\Payment\Helper\Data $paymentData * @param \Magento\Stdlib\String $string * @param \Magento\Core\Model\Store\ConfigInterface $coreStoreConfig - * @param \Magento\Core\Model\Translate $translate + * @param \Magento\TranslateInterface $translate * @param \Magento\App\Filesystem $filesystem * @param \Magento\Sales\Model\Order\Pdf\Config $pdfConfig * @param \Magento\Sales\Model\Order\Pdf\Total\Factory $pdfTotalFactory @@ -55,7 +55,7 @@ class Shipment extends \Magento\Sales\Model\Order\Pdf\AbstractPdf \Magento\Payment\Helper\Data $paymentData, \Magento\Stdlib\String $string, \Magento\Core\Model\Store\ConfigInterface $coreStoreConfig, - \Magento\Core\Model\Translate $translate, + \Magento\TranslateInterface $translate, \Magento\App\Filesystem $filesystem, \Magento\Sales\Model\Order\Pdf\Config $pdfConfig, \Magento\Sales\Model\Order\Pdf\Total\Factory $pdfTotalFactory, diff --git a/app/code/Magento/Sales/Model/Quote.php b/app/code/Magento/Sales/Model/Quote.php index ac36e1945ac20950cf64ad25cb5962c6ca9b40c0..eb5e561234b089af2bfae82d7412beda47c4a729 100644 --- a/app/code/Magento/Sales/Model/Quote.php +++ b/app/code/Magento/Sales/Model/Quote.php @@ -2162,4 +2162,14 @@ class Quote extends \Magento\Core\Model\AbstractModel } return parent::save(); } + + /** + * Check if there are more than one shipping address + * + * @return bool + */ + public function isMultipleShippingAddresses() + { + return \count($this->getAllShippingAddresses()) > 1; + } } diff --git a/app/code/Magento/Sendfriend/Block/Send.php b/app/code/Magento/Sendfriend/Block/Send.php index 6b65cc34b37f48bf560c07e4839b61f8040555d0..730f12990a98bc600c63da62a2487587313307b4 100644 --- a/app/code/Magento/Sendfriend/Block/Send.php +++ b/app/code/Magento/Sendfriend/Block/Send.php @@ -23,7 +23,7 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ - +namespace Magento\Sendfriend\Block; /** * Email to a Friend Block @@ -32,8 +32,6 @@ * @package Magento_Sendfriend * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\Sendfriend\Block; - class Send extends \Magento\View\Element\Template { /** @@ -150,7 +148,7 @@ class Send extends \Magento\View\Element\Template * Set Form data array * * @param array $data - * @return \Magento\Sendfriend\Block\Send + * @return $this */ public function setFormData($data) { diff --git a/app/code/Magento/Sendfriend/Controller/Product.php b/app/code/Magento/Sendfriend/Controller/Product.php index 61c2220522c2de438eb3056957b96889ffea5878..e318cf9579f1a2ae23af1e66c4531ba9ebfb0cbc 100644 --- a/app/code/Magento/Sendfriend/Controller/Product.php +++ b/app/code/Magento/Sendfriend/Controller/Product.php @@ -23,6 +23,10 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Sendfriend\Controller; + +use Magento\App\Action\NotFoundException; +use Magento\App\RequestInterface; /** * Email to a Friend Product Controller @@ -31,11 +35,6 @@ * @package Magento_Sedfriend * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\Sendfriend\Controller; - -use Magento\App\Action\NotFoundException; -use Magento\App\RequestInterface; - class Product extends \Magento\App\Action\Action { /** @@ -150,6 +149,7 @@ class Product extends \Magento\App\Action\Action /** * Show Send to a Friend Form * + * @return void */ public function sendAction() { @@ -188,6 +188,7 @@ class Product extends \Magento\App\Action\Action /** * Send Email Post Action * + * @return void */ public function sendmailAction() { diff --git a/app/code/Magento/Sendfriend/Helper/Data.php b/app/code/Magento/Sendfriend/Helper/Data.php index 54657fd5b81a2436e1ed1a887f263569b0230f19..5f4e907a162487ba2826c0429a9c70ac0e7042a6 100644 --- a/app/code/Magento/Sendfriend/Helper/Data.php +++ b/app/code/Magento/Sendfriend/Helper/Data.php @@ -23,7 +23,7 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ - +namespace Magento\Sendfriend\Helper; /** * Sendfriend Data Helper @@ -32,8 +32,6 @@ * @package Magento_Sendfriend * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\Sendfriend\Helper; - class Data extends \Magento\App\Helper\AbstractHelper { const XML_PATH_ENABLED = 'sendfriend/email/enabled'; diff --git a/app/code/Magento/Sendfriend/Model/Sendfriend.php b/app/code/Magento/Sendfriend/Model/Sendfriend.php index 975e7cb067d829e6ab5b0e47dd64f947df4e380c..7d650e67f9c81c53b6761afc2ccfddb077265435 100644 --- a/app/code/Magento/Sendfriend/Model/Sendfriend.php +++ b/app/code/Magento/Sendfriend/Model/Sendfriend.php @@ -23,6 +23,9 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Sendfriend\Model; + +use Magento\Core\Exception as CoreException; /** * SendFriend Log @@ -38,8 +41,6 @@ * @package Magento_Sendfriend * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\Sendfriend\Model; - class Sendfriend extends \Magento\Core\Model\AbstractModel { /** @@ -59,7 +60,7 @@ class Sendfriend extends \Magento\Core\Model\AbstractModel /** * Sender data array * - * @var array + * @var \Magento\Object|array */ protected $_sender = array(); @@ -118,7 +119,7 @@ class Sendfriend extends \Magento\Core\Model\AbstractModel * @param \Magento\Core\Model\Registry $registry * @param \Magento\Core\Model\StoreManagerInterface $storeManager * @param \Magento\Email\Model\TemplateFactory $templateFactory - * @param \Magento\Core\Model\Translate $translate + * @param \Magento\TranslateInterface $translate * @param \Magento\Catalog\Helper\Image $catalogImage * @param \Magento\Sendfriend\Helper\Data $sendfriendData * @param \Magento\Escaper $escaper @@ -131,7 +132,7 @@ class Sendfriend extends \Magento\Core\Model\AbstractModel \Magento\Core\Model\Registry $registry, \Magento\Core\Model\StoreManagerInterface $storeManager, \Magento\Email\Model\TemplateFactory $templateFactory, - \Magento\Core\Model\Translate $translate, + \Magento\TranslateInterface $translate, \Magento\Catalog\Helper\Image $catalogImage, \Magento\Sendfriend\Helper\Data $sendfriendData, \Magento\Escaper $escaper, @@ -167,6 +168,10 @@ class Sendfriend extends \Magento\Core\Model\AbstractModel return $this->_sendfriendData; } + /** + * @return $this + * @throws CoreException + */ public function send() { if ($this->isExceedLimit()) { @@ -175,7 +180,7 @@ class Sendfriend extends \Magento\Core\Model\AbstractModel ); } - /* @var $translate \Magento\Core\Model\Translate */ + /* @var $translate \Magento\TranslateInterface */ $translate = $this->_translate; $translate->setTranslateInline(false); @@ -223,7 +228,7 @@ class Sendfriend extends \Magento\Core\Model\AbstractModel /** * Validate Form data * - * @return bool|array + * @return bool|string[] */ public function validate() { @@ -272,7 +277,7 @@ class Sendfriend extends \Magento\Core\Model\AbstractModel * Set cookie instance * * @param \Magento\Stdlib\Cookie $cookie - * @return \Magento\Sendfriend\Model\Sendfriend + * @return $this */ public function setCookie($cookie) { @@ -298,7 +303,7 @@ class Sendfriend extends \Magento\Core\Model\AbstractModel * Set Visitor Remote Address * * @param int $ipAddr the IP address on Long Format - * @return \Magento\Sendfriend\Model\Sendfriend + * @return $this */ public function setRemoteAddr($ipAddr) { @@ -320,7 +325,7 @@ class Sendfriend extends \Magento\Core\Model\AbstractModel * Set Website Id * * @param int $id - website id - * @return \Magento\Sendfriend\Model\Sendfriend + * @return $this */ public function setWebsiteId($id) { @@ -342,7 +347,7 @@ class Sendfriend extends \Magento\Core\Model\AbstractModel * Set Recipients * * @param array $recipients - * @return \Magento\Sendfriend\Model\Sendfriend + * @return $this */ public function setRecipients($recipients) { @@ -394,7 +399,7 @@ class Sendfriend extends \Magento\Core\Model\AbstractModel * Set product instance * * @param \Magento\Catalog\Model\Product $product - * @return \Magento\Sendfriend\Model\Sendfriend + * @return $this */ public function setProduct($product) { @@ -420,7 +425,7 @@ class Sendfriend extends \Magento\Core\Model\AbstractModel * Set Sender Information array * * @param array $sender - * @return \Magento\Sendfriend\Model\Sendfriend + * @return $this */ public function setSender($sender) { @@ -596,7 +601,7 @@ class Sendfriend extends \Magento\Core\Model\AbstractModel /** * Register self in global register with name send_to_friend_model * - * @return \Magento\Sendfriend\Model\Sendfriend + * @return $this */ public function register() { diff --git a/app/code/Magento/Shipping/Model/Order/Pdf/Packaging.php b/app/code/Magento/Shipping/Model/Order/Pdf/Packaging.php index 15ccc014ca0fcba9edf617ef4af8d5b826bf3c1a..9892d93a9998d957d3d17961b6aa581e18380b8e 100644 --- a/app/code/Magento/Shipping/Model/Order/Pdf/Packaging.php +++ b/app/code/Magento/Shipping/Model/Order/Pdf/Packaging.php @@ -47,7 +47,7 @@ class Packaging extends \Magento\Sales\Model\Order\Pdf\AbstractPdf * @param \Magento\Payment\Helper\Data $paymentData * @param \Magento\Stdlib\String $string * @param \Magento\Core\Model\Store\ConfigInterface $coreStoreConfig - * @param \Magento\Core\Model\Translate $translate + * @param \Magento\TranslateInterface $translate * @param \Magento\App\Filesystem $filesystem * @param \Magento\Sales\Model\Order\Pdf\Config $pdfConfig * @param \Magento\Sales\Model\Order\Pdf\Total\Factory $pdfTotalFactory @@ -64,7 +64,7 @@ class Packaging extends \Magento\Sales\Model\Order\Pdf\AbstractPdf \Magento\Payment\Helper\Data $paymentData, \Magento\Stdlib\String $string, \Magento\Core\Model\Store\ConfigInterface $coreStoreConfig, - \Magento\Core\Model\Translate $translate, + \Magento\TranslateInterface $translate, \Magento\App\Filesystem $filesystem, \Magento\Sales\Model\Order\Pdf\Config $pdfConfig, \Magento\Sales\Model\Order\Pdf\Total\Factory $pdfTotalFactory, diff --git a/app/code/Magento/Sitemap/Model/Observer.php b/app/code/Magento/Sitemap/Model/Observer.php index 4ca79c30c56b29e5ba766bb410f15c2159a3a3b2..8d1fd206151b5caf5364bda01acb46e49dd85509 100644 --- a/app/code/Magento/Sitemap/Model/Observer.php +++ b/app/code/Magento/Sitemap/Model/Observer.php @@ -80,20 +80,20 @@ class Observer protected $_templateFactory; /** - * @var \Magento\Core\Model\Translate + * @var \Magento\TranslateInterface */ protected $_translateModel; /** * @param \Magento\Core\Model\Store\Config $coreStoreConfig * @param \Magento\Sitemap\Model\Resource\Sitemap\CollectionFactory $collectionFactory - * @param \Magento\Core\Model\Translate $translateModel + * @param \Magento\TranslateInterface $translateModel * @param \Magento\Email\Model\TemplateFactory $templateFactory */ public function __construct( \Magento\Core\Model\Store\Config $coreStoreConfig, \Magento\Sitemap\Model\Resource\Sitemap\CollectionFactory $collectionFactory, - \Magento\Core\Model\Translate $translateModel, + \Magento\TranslateInterface $translateModel, \Magento\Email\Model\TemplateFactory $templateFactory ) { $this->_coreStoreConfig = $coreStoreConfig; diff --git a/app/code/Magento/Theme/Model/Config.php b/app/code/Magento/Theme/Model/Config.php index f40d94b7b6a1bbc3a59f1d22bd8a298c85b92f09..1aa12001593d3830fde554b6b33f15e34aa382ea 100644 --- a/app/code/Magento/Theme/Model/Config.php +++ b/app/code/Magento/Theme/Model/Config.php @@ -32,7 +32,7 @@ namespace Magento\Theme\Model; class Config { /** - * @var \Magento\Core\Model\Config\Storage\WriterInterface + * @var \Magento\App\Config\Storage\WriterInterface */ protected $_configWriter; @@ -65,7 +65,7 @@ class Config /** * @param \Magento\App\Config\ValueInterface $configData - * @param \Magento\Core\Model\Config\Storage\WriterInterface $configWriter + * @param \Magento\App\Config\Storage\WriterInterface $configWriter * @param \Magento\Core\Model\StoreManagerInterface $storeManager * @param \Magento\Event\ManagerInterface $eventManager * @param \Magento\Cache\FrontendInterface $configCache @@ -73,7 +73,7 @@ class Config */ public function __construct( \Magento\App\Config\ValueInterface $configData, - \Magento\Core\Model\Config\Storage\WriterInterface $configWriter, + \Magento\App\Config\Storage\WriterInterface $configWriter, \Magento\Core\Model\StoreManagerInterface $storeManager, \Magento\Event\ManagerInterface $eventManager, \Magento\Cache\FrontendInterface $configCache, @@ -194,7 +194,7 @@ class Config protected function _assignThemeToDefaultScope($themeId, &$isReassigned) { $configPath = \Magento\View\DesignInterface::XML_PATH_THEME_ID; - $this->_configWriter->save($configPath, $themeId, \Magento\Core\Model\ScopeInterface::SCOPE_DEFAULT); + $this->_configWriter->save($configPath, $themeId, \Magento\BaseScopeInterface::SCOPE_DEFAULT); $isReassigned = true; return $this; } diff --git a/app/code/Magento/Widget/Controller/Adminhtml/Widget/Instance.php b/app/code/Magento/Widget/Controller/Adminhtml/Widget/Instance.php index e42599b71a723477f8dd40866c68f49b6b8b8cc7..8f827bebd51e885aa43810305954275088a874cb 100644 --- a/app/code/Magento/Widget/Controller/Adminhtml/Widget/Instance.php +++ b/app/code/Magento/Widget/Controller/Adminhtml/Widget/Instance.php @@ -54,9 +54,9 @@ class Instance extends \Magento\Backend\App\Action protected $mathRandom; /** - * @var \Magento\Core\Model\Translate + * @var \Magento\Translate\InlineInterface */ - protected $_translator; + protected $_translateInline; /** * @param \Magento\Backend\App\Action\Context $context @@ -64,7 +64,7 @@ class Instance extends \Magento\Backend\App\Action * @param \Magento\Widget\Model\Widget\InstanceFactory $widgetFactory * @param \Magento\Logger $logger * @param \Magento\Math\Random $mathRandom - * @param \Magento\Core\Model\Translate $translator + * @param \Magento\Translate\InlineInterface $translateInline */ public function __construct( \Magento\Backend\App\Action\Context $context, @@ -72,9 +72,9 @@ class Instance extends \Magento\Backend\App\Action \Magento\Widget\Model\Widget\InstanceFactory $widgetFactory, \Magento\Logger $logger, \Magento\Math\Random $mathRandom, - \Magento\Core\Model\Translate $translator + \Magento\Translate\InlineInterface $translateInline ) { - $this->_translator = $translator; + $this->_translateInline = $translateInline; $this->_coreRegistry = $coreRegistry; $this->_widgetFactory = $widgetFactory; $this->_logger = $logger; @@ -183,7 +183,7 @@ class Instance extends \Magento\Backend\App\Action */ protected function setBody($body) { - $this->_translator->processResponseBody($body); + $this->_translateInline->processResponseBody($body); $this->getResponse()->setBody($body); } diff --git a/app/code/Magento/Wishlist/Controller/Index.php b/app/code/Magento/Wishlist/Controller/Index.php index d281688e482e20512b1da7b6edcaeb89003df666..ff93087979029f54bcfec4ac2481976ef7c521e2 100644 --- a/app/code/Magento/Wishlist/Controller/Index.php +++ b/app/code/Magento/Wishlist/Controller/Index.php @@ -694,8 +694,8 @@ class Index return; } - $translate = $this->_objectManager->get('Magento\Core\Model\Translate'); - /* @var $translate \Magento\Core\Model\Translate */ + $translate = $this->_objectManager->get('Magento\TranslateInterface'); + /* @var $translate \Magento\TranslateInterface */ $translate->setTranslateInline(false); $sent = 0; diff --git a/app/design/frontend/magento_plushe/js/responsive.js b/app/design/frontend/magento_plushe/js/responsive.js index b9b62dbb614f723ee27ab0004157dfa9f5b373c6..2854be8d71eb30f6a1d8d171c2d4f5baf5f5b5c9 100644 --- a/app/design/frontend/magento_plushe/js/responsive.js +++ b/app/design/frontend/magento_plushe/js/responsive.js @@ -35,12 +35,11 @@ $('.action.showcart').addClass('is-disabled'); $('.action.showcart').on( "click", function() { - if ($(this).hasClass('is-disabled')) { - window.location = $(this).attr("href"); - } + if ($(this).hasClass('is-disabled')) { + window.location = $(this).attr("href"); + } }); - $('.action.toggle.checkout.progress') .on('click.gotoCheckoutProgress', function(e){ var myWrapper = '#checkout-progress-wrapper'; @@ -59,7 +58,7 @@ var productInfoMain = $('.product.info.main'), productInfoAdditional = $("#product-info-additional"); - if(!productInfoAdditional.length) { + if (!productInfoAdditional.length) { var productTitle = productInfoMain.find(".page.title.product").clone(), productStock = productInfoMain.find(".stock:not(.alert)").clone(); @@ -84,7 +83,10 @@ })(); - + var galleryElement = $('[data-role=media-gallery]'); + if (galleryElement.length && galleryElement.data('zoom')) { + galleryElement.zoom('disable'); + } }, // Switch to Desktop Version @@ -104,6 +106,10 @@ })(); + var galleryElement = $('[data-role=media-gallery]'); + if (galleryElement.length && galleryElement.data('zoom')) { + galleryElement.zoom('enable'); + } } }); }); diff --git a/app/etc/di.xml b/app/etc/di.xml index f0700b2a744a7da1beca2a54b85118bb7ef67267..66111870dcb7a8ab3cc8cead550e298e7c256dfc 100644 --- a/app/etc/di.xml +++ b/app/etc/di.xml @@ -96,7 +96,7 @@ <preference for="Magento\View\Design\Theme\Image\PathInterface" type="Magento\Core\Model\Theme\Image\Path" /> <preference for="Magento\Session\Config\ConfigInterface" type="Magento\Core\Model\Session\Config" /> <preference for="Magento\Session\SidResolverInterface" type="Magento\Core\Model\Session\SidResolver\Proxy" /> - <preference for="Magento\TranslateInterface" type="Magento\Core\Model\Translate" /> + <preference for="Magento\TranslateInterface" type="Magento\Translate" /> <preference for="Magento\Config\ScopeListInterface" type="interceptionConfigScope" /> <preference for="Magento\View\Design\Theme\Label\ListInterface" type="Magento\Core\Model\Resource\Theme\Collection" /> <virtualType name="interceptionConfigScope" type="Magento\Config\Scope"> @@ -167,7 +167,7 @@ <value type="argument">Magento\Core\Model\App::PARAM_RUN_TYPE</value> </param> </type> - <type name="Magento\Core\Model\Translate"> + <type name="Magento\Translate"> <param name="cache"> <instance type="Magento\App\Cache\Type\Translate" /> </param> diff --git a/dev/tests/integration/testsuite/Magento/Backend/Model/Translate/InlineTest.php b/dev/tests/integration/testsuite/Magento/Backend/Model/Translate/InlineTest.php index 4e449a74d09774de4583311e90800d156a206ff9..4b79c3fe486eace9e1f90d1ba359b4278373fb33 100644 --- a/dev/tests/integration/testsuite/Magento/Backend/Model/Translate/InlineTest.php +++ b/dev/tests/integration/testsuite/Magento/Backend/Model/Translate/InlineTest.php @@ -35,14 +35,14 @@ namespace Magento\Backend\Model\Translate; class InlineTest extends \PHPUnit_Framework_TestCase { /** - * @var \Magento\Core\Model\Translate\InlineInterface + * @var \Magento\Translate\InlineInterface */ - protected $_translate; + protected $_translateInline; protected function setUp() { - $this->_translate = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() - ->create('Magento\Core\Model\Translate\InlineInterface'); + $this->_translateInline = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + ->create('Magento\Translate\InlineInterface'); } /** @@ -56,7 +56,7 @@ class InlineTest extends \PHPUnit_Framework_TestCase $url = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() ->get('Magento\UrlInterface'); $url->getUrl(\Magento\Backend\App\Area\FrontNameResolver::AREA_CODE . '/ajax/translate'); - $this->_translate->processResponseBody($body, true); + $this->_translateInline->processResponseBody($body, true); $this->assertContains( $url->getUrl(\Magento\Backend\App\Area\FrontNameResolver::AREA_CODE . '/ajax/translate'), $body diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/AttributeTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/AttributeTest.php index adf3ca5cb7fc68d31a2c46956e5a0331e8ed2fda..b0042c805607eb170767a0a03400eb55ce6b93b1 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/AttributeTest.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/AttributeTest.php @@ -111,9 +111,9 @@ class AttributeTest extends \Magento\Backend\Utility\Controller // emulate admin store and design \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\View\DesignInterface') ->setDesignTheme(1); - /** @var \Magento\Core\Model\Translate $translate */ + /** @var \Magento\TranslateInterface $translate */ $translate = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() - ->create('Magento\Core\Model\Translate'); + ->create('Magento\TranslateInterface'); $translate->init(\Magento\Backend\App\Area\FrontNameResolver::AREA_CODE, null); return $translate->translate(array($string)); } diff --git a/dev/tests/integration/testsuite/Magento/Core/Model/Config/DataTest.php b/dev/tests/integration/testsuite/Magento/Core/Model/Config/DataTest.php index 1a4e977e302e8e6968760f4c57da4d89e1dfffd4..37cf45ad2acc76baff3b8d453e9e40854f1c92b9 100644 --- a/dev/tests/integration/testsuite/Magento/Core/Model/Config/DataTest.php +++ b/dev/tests/integration/testsuite/Magento/Core/Model/Config/DataTest.php @@ -39,7 +39,7 @@ class DataTest extends \PHPUnit_Framework_TestCase public static function setUpBeforeClass() { - \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Core\Model\Config\Storage\Writer\Db') + \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Core\Model\Config\Storage\Db') ->save(self::SAMPLE_CONFIG_PATH, self::SAMPLE_VALUE); self::_refreshConfiguration(); } @@ -47,7 +47,7 @@ class DataTest extends \PHPUnit_Framework_TestCase public static function tearDownAfterClass() { \Magento\TestFramework\Helper\Bootstrap::getObjectManager() - ->get('Magento\Core\Model\Config\Storage\Writer\Db') + ->get('Magento\Core\Model\Config\Storage\Db') ->delete(self::SAMPLE_CONFIG_PATH); self::_refreshConfiguration(); } @@ -58,7 +58,7 @@ class DataTest extends \PHPUnit_Framework_TestCase protected static function _refreshConfiguration() { \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Core\Model\App') - ->cleanCache(array(\Magento\Core\Model\Config::CACHE_TAG)); + ->cleanCache(array(\Magento\App\Config::CACHE_TAG)); \Magento\TestFramework\Helper\Bootstrap::getInstance()->reinitialize(); } diff --git a/dev/tests/integration/testsuite/Magento/Core/Model/StoreTest.php b/dev/tests/integration/testsuite/Magento/Core/Model/StoreTest.php index 7db7aef1bbe054c922db4084ea96ba6c65796de9..0f1cb9dd947cad8751ee7bbef0510e4d32a49c8b 100644 --- a/dev/tests/integration/testsuite/Magento/Core/Model/StoreTest.php +++ b/dev/tests/integration/testsuite/Magento/Core/Model/StoreTest.php @@ -65,6 +65,7 @@ class StoreTest extends \PHPUnit_Framework_TestCase 'storeManager' => $objectManager->get('Magento\Core\Model\StoreManager'), 'sidResolver' => $objectManager->get('Magento\Session\SidResolverInterface'), 'cookie' => $objectManager->get('Magento\Stdlib\Cookie'), + 'response' => $objectManager->get('\Magento\App\Response\Http'), ); return $this->getMock( diff --git a/dev/tests/integration/testsuite/Magento/Core/Model/Translate/InlineParserTest.php b/dev/tests/integration/testsuite/Magento/Core/Model/Translate/InlineParserTest.php index cd0a53cd4a28eb3f29dd0bdb5372848c6ada951f..734455a52730c6f1fa9a9ce876921b0aa28fc769 100644 --- a/dev/tests/integration/testsuite/Magento/Core/Model/Translate/InlineParserTest.php +++ b/dev/tests/integration/testsuite/Magento/Core/Model/Translate/InlineParserTest.php @@ -30,7 +30,7 @@ namespace Magento\Core\Model\Translate; class InlineParserTest extends \PHPUnit_Framework_TestCase { /** - * @var \Magento\Core\Model\Translate\InlineParser + * @var \Magento\Core\Model\Translate\Inline\Parser */ protected $_inlineParser; @@ -45,8 +45,11 @@ class InlineParserTest extends \PHPUnit_Framework_TestCase protected function setUp() { + /** @var $inline \Magento\Translate\Inline */ + $inline = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + ->create('Magento\Translate\Inline'); $this->_inlineParser = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() - ->create('Magento\Core\Model\Translate\InlineParser'); + ->create('Magento\Core\Model\Translate\Inline\Parser', array('translateInline' => $inline)); /* Called getConfig as workaround for setConfig bug */ \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Core\Model\StoreManagerInterface') ->getStore($this->_storeId)->getConfig('dev/translate_inline/active'); @@ -63,10 +66,7 @@ class InlineParserTest extends \PHPUnit_Framework_TestCase if ($isPerStore !== null) { $inputArray[0]['perstore'] = $isPerStore; } - /** @var $inline \Magento\Core\Model\Translate\Inline */ - $inline = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() - ->create('Magento\Core\Model\Translate\Inline'); - $this->_inlineParser->processAjaxPost($inputArray, $inline); + $this->_inlineParser->processAjaxPost($inputArray); $model = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() ->create('Magento\Core\Model\Translate\String'); diff --git a/dev/tests/integration/testsuite/Magento/Payment/Model/Config/ReaderTest.php b/dev/tests/integration/testsuite/Magento/Payment/Model/Config/ReaderTest.php index f8d90d401cb5d50ac27323a9caa70db26cfdf075..e39218dbbc008a48e53aca145c8d2ea255cc117d 100644 --- a/dev/tests/integration/testsuite/Magento/Payment/Model/Config/ReaderTest.php +++ b/dev/tests/integration/testsuite/Magento/Payment/Model/Config/ReaderTest.php @@ -63,6 +63,12 @@ class ReaderTest extends \PHPUnit_Framework_TestCase 'groups' => array( 'paypal' => 'PayPal' ), + 'methods' => array( + 'checkmo' => array( + 'allow_multiple_address' => 1, + 'allow_multiple_with_3dsecure' => 1, + ), + ), ); $this->assertEquals($expected, $result); } @@ -88,6 +94,15 @@ class ReaderTest extends \PHPUnit_Framework_TestCase 'paypal' => 'PayPal Payment Methods', 'offline' => 'Offline Payment Methods', ), + 'methods' => array( + 'checkmo' => array( + 'allow_multiple_address' => 1, + 'allow_multiple_with_3dsecure' => 1, + ), + 'deny-method' => array( + 'allow_multiple_address' => 0, + ), + ), ); $this->assertEquals($expected, $result); } diff --git a/dev/tests/integration/testsuite/Magento/Payment/Model/_files/payment.xml b/dev/tests/integration/testsuite/Magento/Payment/Model/_files/payment.xml index e5d099f70d6bf7a1b085655746386ac19c6aeba6..9d9df16d133156a776ea69029360912f5da10b55 100644 --- a/dev/tests/integration/testsuite/Magento/Payment/Model/_files/payment.xml +++ b/dev/tests/integration/testsuite/Magento/Payment/Model/_files/payment.xml @@ -38,4 +38,10 @@ <label>PayPal</label> </group> </groups> + <methods> + <method name="checkmo"> + <allow_multiple_address>1</allow_multiple_address> + <allow_multiple_with_3dsecure>1</allow_multiple_with_3dsecure> + </method> + </methods> </payment> diff --git a/dev/tests/integration/testsuite/Magento/Payment/Model/_files/payment2.xml b/dev/tests/integration/testsuite/Magento/Payment/Model/_files/payment2.xml index c2a242679fc0e6a16c85eb903022e317fda679ef..2b7e7810d8d0278eeab47e3aaef79ddb84e237a2 100644 --- a/dev/tests/integration/testsuite/Magento/Payment/Model/_files/payment2.xml +++ b/dev/tests/integration/testsuite/Magento/Payment/Model/_files/payment2.xml @@ -41,4 +41,9 @@ <label>Offline Payment Methods</label> </group> </groups> + <methods> + <method name="deny-method"> + <allow_multiple_address>0</allow_multiple_address> + </method> + </methods> </payment> diff --git a/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/TemplateFilesTest.php b/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/TemplateFilesTest.php index 903fd49bed864e84318cfcfd825e7fb3c7c10b25..e42ac1621f4f4697b3e379a2413002efad751414 100644 --- a/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/TemplateFilesTest.php +++ b/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/TemplateFilesTest.php @@ -94,7 +94,7 @@ class TemplateFilesTest extends \Magento\TestFramework\TestCase\AbstractIntegrit } \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Core\Model\App')->loadAreaPart( - \Magento\Backend\App\Area\FrontNameResolver::AREA_CODE, + $area, \Magento\Core\Model\App\Area::PART_CONFIG ); \Magento\TestFramework\Helper\Bootstrap::getObjectManager() diff --git a/dev/tests/integration/testsuite/Magento/Core/Model/Translate/InlineTest.php b/dev/tests/integration/testsuite/Magento/Translate/InlineTest.php similarity index 94% rename from dev/tests/integration/testsuite/Magento/Core/Model/Translate/InlineTest.php rename to dev/tests/integration/testsuite/Magento/Translate/InlineTest.php index 74faea74abce905e922b3f4b0560d8392831a4f5..542ceafd41be12193cad22d40277f6475acd7a74 100644 --- a/dev/tests/integration/testsuite/Magento/Core/Model/Translate/InlineTest.php +++ b/dev/tests/integration/testsuite/Magento/Translate/InlineTest.php @@ -18,19 +18,16 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Magento - * @package Magento_Core - * @subpackage integration_tests * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Core\Model\Translate; +namespace Magento\Translate; class InlineTest extends \PHPUnit_Framework_TestCase { /** - * @var \Magento\Core\Model\Translate\Inline + * @var \Magento\Translate\Inline */ protected $_model; @@ -49,7 +46,7 @@ class InlineTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->_model = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() - ->create('Magento\Core\Model\Translate\Inline'); + ->create('Magento\Translate\Inline'); /* Called getConfig as workaround for setConfig bug */ \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Core\Model\StoreManagerInterface') ->getStore($this->_storeId)->getConfig('dev/translate_inline/active'); diff --git a/dev/tests/integration/testsuite/Magento/Core/Model/Translate/_files/_inline_page_expected.html b/dev/tests/integration/testsuite/Magento/Translate/_files/_inline_page_expected.html similarity index 97% rename from dev/tests/integration/testsuite/Magento/Core/Model/Translate/_files/_inline_page_expected.html rename to dev/tests/integration/testsuite/Magento/Translate/_files/_inline_page_expected.html index f5b9c948575c179a0dda7648999b29801fcc0250..979aa22786d5a78861e8948df5c455f1b9f69b6d 100644 --- a/dev/tests/integration/testsuite/Magento/Core/Model/Translate/_files/_inline_page_expected.html +++ b/dev/tests/integration/testsuite/Magento/Translate/_files/_inline_page_expected.html @@ -18,9 +18,6 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Magento - * @package Magento_Core - * @subpackage integration_tests * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */ diff --git a/dev/tests/integration/testsuite/Magento/Core/Model/Translate/_files/_inline_page_original.html b/dev/tests/integration/testsuite/Magento/Translate/_files/_inline_page_original.html similarity index 93% rename from dev/tests/integration/testsuite/Magento/Core/Model/Translate/_files/_inline_page_original.html rename to dev/tests/integration/testsuite/Magento/Translate/_files/_inline_page_original.html index 65b12ff9ae598d036d0ada3fb542018342301a9b..e242158b1386fbde096cd3d19a10f26944e5083f 100644 --- a/dev/tests/integration/testsuite/Magento/Core/Model/Translate/_files/_inline_page_original.html +++ b/dev/tests/integration/testsuite/Magento/Translate/_files/_inline_page_original.html @@ -18,9 +18,6 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Magento - * @package Magento_Core - * @subpackage integration_tests * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */ diff --git a/dev/tests/integration/testsuite/Magento/Core/Model/Translate/_files/_translation_data.php b/dev/tests/integration/testsuite/Magento/Translate/_files/_translation_data.php similarity index 94% rename from dev/tests/integration/testsuite/Magento/Core/Model/Translate/_files/_translation_data.php rename to dev/tests/integration/testsuite/Magento/Translate/_files/_translation_data.php index 5bc3586570127c50b83f496b44886050302ee7df..068cb22e6734e9ddcaf60384912fbc9af4052d75 100644 --- a/dev/tests/integration/testsuite/Magento/Core/Model/Translate/_files/_translation_data.php +++ b/dev/tests/integration/testsuite/Magento/Translate/_files/_translation_data.php @@ -18,9 +18,6 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Magento - * @package Magento_Core - * @subpackage integration_tests * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ diff --git a/dev/tests/integration/testsuite/Magento/Core/Model/TranslateTest.php b/dev/tests/integration/testsuite/Magento/TranslateTest.php similarity index 71% rename from dev/tests/integration/testsuite/Magento/Core/Model/TranslateTest.php rename to dev/tests/integration/testsuite/Magento/TranslateTest.php index 877dd2c8be70b89574f94e01b9619755d889b0c6..ef2c6d1e581e4fa034eb788b602efa29c0bf569c 100644 --- a/dev/tests/integration/testsuite/Magento/Core/Model/TranslateTest.php +++ b/dev/tests/integration/testsuite/Magento/TranslateTest.php @@ -19,13 +19,13 @@ * needs please refer to http://www.magentocommerce.com for more information. * * @category Magento - * @package Magento_Core + * @package Magento * @subpackage integration_tests * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Core\Model; +namespace Magento; /** * @magentoDataFixture Magento/Backend/controllers/_files/cache/all_types_disabled.php @@ -33,7 +33,7 @@ namespace Magento\Core\Model; class TranslateTest extends \PHPUnit_Framework_TestCase { /** - * @var \Magento\Core\Model\Translate + * @var \Magento\Translate */ protected $_model; @@ -49,7 +49,17 @@ class TranslateTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $pathChunks = array(__DIR__, '_files', 'design', 'frontend', 'test_default', 'i18n', 'en_US.csv'); + $pathChunks = array( + __DIR__, + 'Core', + 'Model', + '_files', + 'design', + 'frontend', + 'test_default', + 'i18n', + 'en_US.csv' + ); $this->_viewFileSystem = $this->getMock('Magento\View\FileSystem', array('getFilename', 'getDesignTheme'), array(), '', false); @@ -58,20 +68,11 @@ class TranslateTest extends \PHPUnit_Framework_TestCase ->method('getFilename') ->will($this->returnValue(implode('/', $pathChunks))); - $theme = $this->getMock('Magento\Core\Model\Theme', array('getId', 'getCollection'), array(), '', false); + $theme = $this->getMock('\Magento\View\Design\ThemeInterface', array()); $theme->expects($this->any()) ->method('getId') ->will($this->returnValue(10)); - $collection = $this->getMock('Magento\Core\Model\Theme', array('getThemeByFullPath'), array(), '', false); - $collection->expects($this->any()) - ->method('getThemeByFullPath') - ->will($this->returnValue($theme)); - - $theme->expects($this->any()) - ->method('getCollection') - ->will($this->returnValue($collection)); - $this->_viewFileSystem->expects($this->any()) ->method('getDesignTheme') ->will($this->returnValue($theme)); @@ -81,9 +82,9 @@ class TranslateTest extends \PHPUnit_Framework_TestCase /** @var $moduleReader \Magento\Module\Dir\Reader */ $moduleReader = $objectManager->get('Magento\Module\Dir\Reader'); - $moduleReader->setModuleDir('Magento_Core', 'i18n', __DIR__ . '/_files/Magento/Core/i18n'); + $moduleReader->setModuleDir('Magento_Core', 'i18n', __DIR__ . '/Core/Model/_files/Magento/Core/i18n'); $moduleReader->setModuleDir('Magento_Catalog', 'i18n', - __DIR__ . '/_files/Magento/Catalog/i18n'); + __DIR__ . '/Core/Model/_files/Magento/Catalog/i18n'); /** @var \Magento\Core\Model\View\Design _designModel */ $this->_designModel = $this->getMock('Magento\Core\Model\View\Design', @@ -107,7 +108,7 @@ class TranslateTest extends \PHPUnit_Framework_TestCase $objectManager->addSharedInstance($this->_designModel, 'Magento\Core\Model\View\Design\Proxy'); $this->_model = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() - ->create('Magento\Core\Model\Translate'); + ->create('Magento\Translate'); $this->_model->init(\Magento\Core\Model\App\Area::AREA_FRONTEND); } @@ -140,43 +141,6 @@ class TranslateTest extends \PHPUnit_Framework_TestCase ); } - public function testGetConfig() - { - $this->assertEquals('frontend', $this->_model->getConfig(\Magento\Core\Model\Translate::CONFIG_KEY_AREA)); - $this->assertEquals('en_US', $this->_model->getConfig(\Magento\Core\Model\Translate::CONFIG_KEY_LOCALE)); - $this->assertEquals(1, $this->_model->getConfig(\Magento\Core\Model\Translate::CONFIG_KEY_STORE)); - $design = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() - ->get('Magento\View\DesignInterface'); - $this->assertEquals($design->getDesignTheme()->getId(), - $this->_model->getConfig(\Magento\Core\Model\Translate::CONFIG_KEY_DESIGN_THEME)); - $this->assertNull($this->_model->getConfig('non_existing_key')); - } - - public function testGetData() - { - $this->markTestIncomplete('Bug MAGETWO-6986'); - $expectedData = include(__DIR__ . '/Translate/_files/_translation_data.php'); - $this->assertEquals($expectedData, $this->_model->getData()); - } - - public function testGetSetLocale() - { - $this->assertEquals('en_US', $this->_model->getLocale()); - $this->_model->setLocale('ru_RU'); - $this->assertEquals('ru_RU', $this->_model->getLocale()); - } - - public function testGetResource() - { - $this->assertInstanceOf('Magento\Core\Model\Resource\Translate', $this->_model->getResource()); - } - - public function testGetTranslate() - { - $translate = $this->_model->getTranslate(); - $this->assertInstanceOf('Zend_Translate', $translate); - } - /** * @magentoAppIsolation enabled * @dataProvider translateDataProvider @@ -184,7 +148,7 @@ class TranslateTest extends \PHPUnit_Framework_TestCase public function testTranslate($inputText, $expectedTranslation) { $this->_model = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() - ->create('Magento\Core\Model\Translate'); + ->create('Magento\Translate'); $this->_model->init(\Magento\Core\Model\App\Area::AREA_FRONTEND); $actualTranslation = $this->_model->translate(array($inputText)); diff --git a/dev/tests/js/framework/stub.js b/dev/tests/js/framework/stub.js new file mode 100644 index 0000000000000000000000000000000000000000..48a3b471c6d1df5120a5db00b1b43ad31d566983 --- /dev/null +++ b/dev/tests/js/framework/stub.js @@ -0,0 +1,151 @@ +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ + +"use strict"; + +(function ($, window) { + + function wrapMethod(object, property, method, copyProperties) { + if (!object) { + throw new TypeError("Should wrap property of object"); + } + + if (typeof method != "function") { + throw new TypeError("Method wrapper should be function"); + } + + var wrappedMethod = object[property], + error; + + if ($.type(wrappedMethod) !== 'function') { + error = new TypeError("Attempted to wrap " + (typeof wrappedMethod) + " property " + + property + " as function"); + } + + if (wrappedMethod.restore) { + error = new TypeError("Attempted to wrap " + property + " which is already wrapped"); + } + + if (error) { + if (wrappedMethod._stack) { + error.stack += '\n--------------\n' + wrappedMethod._stack; + } + throw error; + } + + // IE 8 does not support hasOwnProperty. + var owned = object.hasOwnProperty ? + object.hasOwnProperty(property) : + Object.prototype.hasOwnProperty.call(object, property); + + object[property] = method; + method.displayName = property; + // Stack trace which can be used to find what line of code the original method was created on. + method._stack = (new Error('Stack Trace for original')).stack; + + method.restore = function () { + if (!owned) { + delete object[property]; + } + if (object[property] === method) { + object[property] = wrappedMethod; + } + }; + + if (copyProperties) { + for (var prop in wrappedMethod) { + if (!Object.prototype.hasOwnProperty.call(method, prop)) { + method[prop] = wrappedMethod[prop]; + } + }; + } + + return method; + } + + function stub(object, property, func, copyProperties) { + if (!!func && typeof func != "function") { + throw new TypeError("Custom stub should be function"); + } + + var wrapper; + + if (func) { + wrapper = func; + } else { + wrapper = stub.create(); + } + + if (!object && typeof property === "undefined") { + return stub.create(); + } + + if (typeof property === "undefined" && typeof object == "object") { + for (var prop in object) { + if (typeof object[prop] === "function") { + stub(object, prop); + } + } + + return object; + } + + return wrapMethod(object, property, wrapper, copyProperties); + } + + $.extend(stub, (function () { + var proto = { + create: function create() { + var functionStub = function () { + functionStub.callCount = functionStub.callCount ? functionStub.callCount + 1 : 1; + functionStub.lastCallArgs = arguments; + functionStub.callArgsStack.push(arguments); + if (functionStub.returnCallback && $.type(functionStub.returnCallback) === 'function') { + return functionStub.returnCallback.apply(functionStub.returnCallback, arguments); + } else if (functionStub.returnValue) { + return functionStub.returnValue; + } + }; + $.extend(functionStub, stub); + functionStub.reset(); + functionStub.displayName = "stub"; + return functionStub; + }, + + reset: function() { + this.callCount = null; + this.lastCallArgs = []; + this.callArgsStack = []; + this.returnValue = null; + this.returnCallback = null; + } + }; + + return proto; + }())); + + window.jsunit = window.jsunit || {}; + $.extend(window.jsunit, { + stub: stub + }); +})(jQuery, window); \ No newline at end of file diff --git a/dev/tests/js/jsTestDriver.php.dist b/dev/tests/js/jsTestDriver.php.dist index e585c994ccbeb80562faa55dfb04c434119154b6..882f452bcc01ba44dbfecc3a58af15fa9f282dd5 100644 --- a/dev/tests/js/jsTestDriver.php.dist +++ b/dev/tests/js/jsTestDriver.php.dist @@ -35,6 +35,7 @@ return array( '/pub/lib/mage/webapi.js', '/pub/lib/jquery/jquery-ui-timepicker-addon.js', '/pub/lib/jquery/jquery.tmpl.min.js', + '/dev/tests/js/framework/stub.js', '/app/code/Magento/DesignEditor/view/adminhtml/js/base.js', '/app/code/Magento/DesignEditor/view/adminhtml/js/design_editor.js', '/app/code/Magento/DesignEditor/view/frontend/js/change/layout.js', @@ -57,7 +58,10 @@ return array( '/pub/lib/mage/validation/validation.js', '/pub/lib/mage/backend/menu.js', '/pub/lib/mage/backend/suggest.js', - '/pub/lib/mage/backend/tree-suggest.js' + '/pub/lib/mage/backend/tree-suggest.js', + '/pub/lib/mage/gallery.js', + '/pub/lib/mage/gallery-fullscreen.js', + '/pub/lib/mage/zoom.js' ), 'test' => array('/dev/tests/js/testsuite'), 'JsTestDriver' => '{{path_to_jstestdriver_jar}}' diff --git a/dev/tests/js/testsuite/mage/gallery/gallery-fullscreen-test.js b/dev/tests/js/testsuite/mage/gallery/gallery-fullscreen-test.js new file mode 100644 index 0000000000000000000000000000000000000000..3fbd2ab9537e18f49bfdf42c2d7371bd8f950acf --- /dev/null +++ b/dev/tests/js/testsuite/mage/gallery/gallery-fullscreen-test.js @@ -0,0 +1,71 @@ +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +GalleryFullscreenTest = TestCase('GalleryFullscreenTest'); +GalleryFullscreenTest.prototype.setUp = function() { + /*:DOC += + <div data-role="media-gallery-test"></div> + */ + this.galleryFullscreenElement = jQuery('[data-role=media-gallery-test]'); +}; +GalleryFullscreenTest.prototype.widgetName = 'galleryFullScreen'; +GalleryFullscreenTest.prototype.tearDown = function() { + this.galleryFullscreenDestroy(); +}; +GalleryFullscreenTest.prototype.galleryFullscreenDestroy = function() { + var instance = this.galleryFullscreenElement.data(this.widgetName) || + this.galleryFullscreenElement.data(this.widgetName.toLowerCase()); + if(instance) { + this.galleryFullscreenElement[this.widgetName]('destroy'); + } +}; +GalleryFullscreenTest.prototype.galleryFullscreenCreate = function(options, element) { + (element || this.galleryFullscreenElement)[this.widgetName](options || {} ) + return this.galleryFullscreenElement.data(this.widgetName) || + this.galleryFullscreenElement.data(this.widgetName.toLowerCase()); +}; + +GalleryFullscreenTest.prototype.testInit = function() { + this.galleryFullscreenElement[this.widgetName](); + assertTrue(this.galleryFullscreenElement.is(':mage-galleryfullscreen')); +}; + +GalleryFullscreenTest.prototype.testCreate = function() { + var galleryFullscreenInstance = this.galleryFullscreenCreate(), + _bind = jsunit.stub(galleryFullscreenInstance, '_bind'); + galleryFullscreenInstance._create(); + + assertTrue(_bind.callCount === 1); +}; + +GalleryFullscreenTest.prototype.testBind = function() { + var galleryFullscreenInstance = this.galleryFullscreenCreate(), + _fullScreen = jsunit.stub(galleryFullscreenInstance, '_fullScreen'), + zoomImage = jQuery('<p data-role="zoom-image" />'), + zoomTrack = jQuery('<p data-role="zoom-track" />'); + + galleryFullscreenInstance.element.append(zoomImage).append(zoomTrack); + zoomImage.trigger('click'); + assertTrue(_fullScreen.callCount === 1); + zoomTrack.trigger('click'); + assertTrue(_fullScreen.callCount === 2); +}; \ No newline at end of file diff --git a/dev/tests/js/testsuite/mage/gallery/gallery-test.js b/dev/tests/js/testsuite/mage/gallery/gallery-test.js new file mode 100644 index 0000000000000000000000000000000000000000..0ffd7d076991fdfd1ccb66b67b3f343dfd7b56ae --- /dev/null +++ b/dev/tests/js/testsuite/mage/gallery/gallery-test.js @@ -0,0 +1,416 @@ +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +GalleryTest = TestCase('GalleryTest'); +GalleryTest.prototype.setUp = function() { + /*:DOC += + <script data-template="gallery-wrapper" type="text/x-jQuery-tmpl"> + <div data-role="gallery-base-image-container"></div> + <div data-role="gallery-notice-container"></div> + <div data-role="gallery-thumbs-container"><div> + <div data-role="gallery-buttons-container"></div> + </script> + <script data-template="gallery-buttons" type="text/x-jQuery-tmpl"> + <a data-role="gallery-prev" href="#"></a> + <a data-role="gallery-next" href="#"></a> + </script> + <script data-template="gallery-base-image" type="text/x-jQuery-tmpl"> + <img data-role="zoom-image" {{if !fullSizeMode}}data-large="${large}" + src="${medium}"{{else}}src="${large}"{{/if}} alt="${title}"/> + </script> + <script data-template="gallery-thumbs" type="text/x-jQuery-tmpl"> + <div> + {{each(index, img) images}} + <a title="${img.title}" data-index="${index}" data-role="gallery-thumb" href="#"> + <img alt="${img.title}" src="${img.small}" itemprop="image"> + </a> + {{/each}} + <div> + </script> + <script data-template="notice" type="text/x-jQuery-tmpl"> + <p class="notice" data-role="notice">${text}</p> + </script> + <div data-role="media-gallery-test"></div> + */ + this.galleryElement = jQuery('[data-role=media-gallery-test]'); +}; +GalleryTest.prototype.tearDown = function() { + this.galleryDestroy(); +}; +GalleryTest.prototype.galleryDestroy = function() { + if(this.galleryElement.data('gallery')) { + this.galleryElement.gallery('destroy'); + } +}; +GalleryTest.prototype.galleryCreate = function(options, element) { + return (element || this.galleryElement).gallery(options || {} ).data('gallery'); +}; + +GalleryTest.prototype.galleryHTML = + '<div data-role="media-gallery">' + + '<div class="product photo main">' + + '<div data-role="gallery-base-image-container">' + + '<a href="#" data-role="zoom-image" data-large="image1.large.jpg">' + + '<img data-role="zoom-image" src="image1.medium.js" />' + + '</a>' + + '</div>' + + '<div data-role="gallery-notice-container">' + + '<p data-role="notice"></p>' + + '</div>' + + '</div>' + + '<div class="product photo thumbs">' + + '<ul>' + + '<li>' + + '<a href="#" data-role="gallery-thumb"' + + ' data-image-small="image1.small.jpg"' + + ' data-image-medium="image1.medium.jpg"' + + ' data-image-large="image1.large.jpg"' + + ' data-image-selected="true">' + + '<img src="image1.small.jpg" alt=""/>' + + '</a>' + + '</li>' + + '<li>' + + '<a href="#" data-role="gallery-thumb"' + + ' data-image-small="image2.small.jpg"' + + ' data-image-medium="image2.medium.jpg"' + + ' data-image-large="image2.large.jpg">' + + '<img src="image2.small.jpg" alt=""/>' + + '</a>' + + '</li>' + + '</ul>' + + '</div>' + + '</div>'; + +GalleryTest.prototype.galleryOptions = { + controls: { + notice: { + text: 'Test Notice' + } + } +}; + +GalleryTest.prototype.galleryImages = [ + { + small: 'image1.small.jpg', + medium: 'image1.medium.jpg', + large: 'image1.large.jpg', + selected: true + }, + { + small: 'image2.small.jpg', + medium: 'image2.medium.jpg', + large: 'image2.large.jpg' + } +]; + +GalleryTest.prototype.resetImageSelection = function(images) { + return jQuery.grep(images, function(image) { + if (image.selected) { + delete image.selected; + } + return true; + }) +} + +GalleryTest.prototype.testInit = function() { + this.galleryElement.gallery(); + assertTrue(this.galleryElement.is(':mage-gallery')); +}; + +GalleryTest.prototype.testSerializeImages = function() { + this.galleryElement.replaceWith(this.galleryHTML); + var galleryInstance = this.galleryCreate(), + images = galleryInstance._serializeImages(); + + assertEquals(images[0], this.galleryImages[0]); + assertEquals(images[1], this.galleryImages[1]); + + jQuery('[data-role=gallery-thumb]').data('image-small', null); + images = galleryInstance._serializeImages(); + assertTrue(images.length === 0); + + this.galleryDestroy(); + this.galleryElement.replaceWith(this.galleryHTML); + galleryInstance = this.galleryCreate(); + jQuery('[data-role=gallery-thumb]').data('image-medium', null); + images = galleryInstance._serializeImages(); + assertTrue(images.length === 0); + + this.galleryDestroy(); + this.galleryElement.replaceWith(this.galleryHTML); + galleryInstance = this.galleryCreate(); + jQuery('[data-role=gallery-thumb]').data('image-large', null); + images = galleryInstance._serializeImages(); + assertTrue(images.length === 0); +}; + +GalleryTest.prototype.testBind = function() { + var galleryInstance = this.galleryCreate(), + options = galleryInstance.options, + _on = jsunit.stub(galleryInstance, '_on'); + + galleryInstance._bind(); + assertTrue(_on.callCount > 0); + assertTrue(_on.callArgsStack[0][0]['click ' + options.selectors.thumb] === 'select'); + assertTrue(_on.callArgsStack[0][0]['click ' + options.selectors.prev] === 'prev'); + assertTrue(_on.callArgsStack[0][0]['click ' + options.selectors.next] === 'next'); +}; + +GalleryTest.prototype.testToggleControl = function() { + var galleryInstance = this.galleryCreate(), + controlName = 'testControl', + _initControl = jsunit.stub(galleryInstance, '_initControl'); + + galleryInstance[controlName] = null; + galleryInstance._toggleControl(controlName, true); + assertTrue(_initControl.callCount === 1); + + // Append to body needed for that the method ".is(':visible')" worked correctly + galleryInstance[controlName] = jQuery('<p />').hide().appendTo('body'); + assertFalse(galleryInstance[controlName].is(':visible')); + galleryInstance._toggleControl(controlName, true); + assertTrue(galleryInstance[controlName].is(':visible')); + + galleryInstance[controlName] = jQuery('<p />').show().appendTo('body'); + assertTrue(galleryInstance[controlName].is(':visible')); + galleryInstance._toggleControl(controlName, false); + assertFalse(galleryInstance[controlName].is(':visible')); +}; + +GalleryTest.prototype.testSetOption = function() { + var galleryInstance = this.galleryCreate(), + _toggleControl = jsunit.stub(galleryInstance, '_toggleControl'), + _initControl = jsunit.stub(galleryInstance, '_initControl'), + _render = jsunit.stub(galleryInstance, '_render'); + + galleryInstance.options.showThumbs = false; + galleryInstance._setOption('showThumbs', true); + assertEquals(_toggleControl.lastCallArgs[0], 'thumbs'); + assertTrue(_toggleControl.lastCallArgs[1]); + + galleryInstance.options.showButtons = false; + galleryInstance._setOption('showButtons', true); + assertEquals(_toggleControl.lastCallArgs[0], 'slideButtons'); + assertTrue(_toggleControl.lastCallArgs[1]); + + galleryInstance.options.showNotice = false; + galleryInstance._setOption('showNotice', true); + assertEquals(_toggleControl.lastCallArgs[0], 'notice'); + assertTrue(_toggleControl.lastCallArgs[1]); + + galleryInstance.options.fullSizeMode = false; + galleryInstance._setOption('fullSizeMode', true); + assertEquals(_initControl.lastCallArgs[0], 'baseImage'); + + galleryInstance._setOption('images', []); + assertTrue(_render.callCount === 1); +}; + +GalleryTest.prototype.testSelect = function() { + var galleryInstance = this.galleryCreate(), + e = {currentTarget: jQuery('<p />').data('index', 1)}, + updateTriggered = false, + _select = jsunit.stub(galleryInstance, '_select'); + + galleryInstance.baseImage = jQuery('<p />'); + galleryInstance._on(galleryInstance.baseImage, { + imageupdated: function() { + updateTriggered = true; + } + }); + + galleryInstance.selected = 0; + galleryInstance.select(e); + assertTrue(updateTriggered); + assertTrue(_select.callCount === 1); + assertEquals(_select.lastCallArgs[0], e.currentTarget.data('index')); + + updateTriggered = false; + galleryInstance.selected = e.currentTarget.data('index'); + galleryInstance.select(e); + assertFalse(updateTriggered); +}; + +GalleryTest.prototype.test_select = function() { + var galleryInstance = this.galleryCreate({images: this.galleryImages}), + options = galleryInstance.options, + selectIndex = 1, + _setSelected = jsunit.stub(galleryInstance, '_setSelected'), + _initControl = jsunit.stub(galleryInstance, '_initControl'); + + var thumb = galleryInstance.thumbs + .find(options.selectors.thumb) + .eq(selectIndex); + assertFalse(thumb.hasClass(options.activeClass)); + galleryInstance._select(selectIndex); + assertTrue(_setSelected.callCount === 1); + assertTrue(_initControl.callCount === 1); + assertEquals(_setSelected.lastCallArgs[0], selectIndex); + assertEquals(_initControl.lastCallArgs[0], 'baseImage'); + assertTrue(thumb.hasClass(options.activeClass)); +}; + +GalleryTest.prototype.testResolveIndex = function() { + var galleryInstance = this.galleryCreate({images: this.galleryImages}), + imagesLength = this.galleryImages.length, + resolvedIndex; + + resolvedIndex = galleryInstance._resolveIndex(imagesLength); + assertTrue(resolvedIndex === 0); + + resolvedIndex = galleryInstance._resolveIndex(imagesLength + 1); + assertTrue(resolvedIndex === 0); + + resolvedIndex = galleryInstance._resolveIndex(-1); + assertTrue(resolvedIndex === imagesLength - 1); + + resolvedIndex = galleryInstance._resolveIndex(0); + assertTrue(resolvedIndex === 0); +}; + +GalleryTest.prototype.testPrev = function() { + var galleryInstance = this.galleryCreate({images: this.galleryImages}), + _select = jsunit.stub(galleryInstance, '_select'), + _resolveIndex = jsunit.stub(galleryInstance, '_resolveIndex'), + _getSelected = jsunit.stub(galleryInstance, '_getSelected'); + _getSelected.returnValue = 2; + _resolveIndex.returnValue = 1; + galleryInstance.selected = 1; + + galleryInstance.prev(); + assertTrue(_getSelected.callCount === 1); + assertTrue(_resolveIndex.callCount === 1); + assertTrue(_resolveIndex.lastCallArgs[0] === _getSelected.returnValue - galleryInstance.selected); + assertTrue(_select.callCount === 1); + assertTrue(_select.lastCallArgs[0] === _resolveIndex.returnValue); +}; + +GalleryTest.prototype.testNext = function() { + var galleryInstance = this.galleryCreate({images: this.galleryImages}), + _select = jsunit.stub(galleryInstance, '_select'), + _resolveIndex = jsunit.stub(galleryInstance, '_resolveIndex'), + _getSelected = jsunit.stub(galleryInstance, '_getSelected'); + _getSelected.returnValue = 1; + _resolveIndex.returnValue = 2; + galleryInstance.selected = 1; + + galleryInstance.next(); + assertTrue(_getSelected.callCount === 1); + assertTrue(_resolveIndex.callCount === 1); + assertTrue(_resolveIndex.lastCallArgs[0] === _getSelected.returnValue + galleryInstance.selected); + assertTrue(_select.callCount === 1); + assertTrue(_select.lastCallArgs[0] === _resolveIndex.returnValue); +}; + +GalleryTest.prototype.testRender = function() { + var galleryInstance = this.galleryCreate({showNotice: false, showThumbs: false, showButtons: false}), + _initControl = jsunit.stub(galleryInstance, '_initControl'), + _renderWrapper = jsunit.stub(galleryInstance, '_renderWrapper'); + + galleryInstance._render(); + assertTrue(_initControl.callCount === 1); + assertTrue(_initControl.lastCallArgs.length > 0); + assertTrue(_initControl.lastCallArgs[0] === 'baseImage'); + + _initControl.reset(); + galleryInstance.options.showNotice = true; + galleryInstance._render(); + assertTrue(_initControl.callCount === 2); + assertTrue(_initControl.callArgsStack.length === 2); + assertTrue(_initControl.callArgsStack[0][0] === 'notice'); + assertTrue(_initControl.callArgsStack[1][0] === 'baseImage'); + + _initControl.reset(); + galleryInstance.options.showThumbs = true; + galleryInstance._render(); + assertTrue(_initControl.callCount === 3); + assertTrue(_initControl.callArgsStack.length === 3); + assertTrue(_initControl.callArgsStack[0][0] === 'notice'); + assertTrue(_initControl.callArgsStack[1][0] === 'baseImage'); + assertTrue(_initControl.callArgsStack[2][0] === 'thumbs'); + + _initControl.reset(); + galleryInstance.options.showButtons = true; + galleryInstance._render(); + assertTrue(_initControl.callCount === 4); + assertTrue(_initControl.callArgsStack.length === 4); + assertTrue(_initControl.callArgsStack[0][0] === 'notice'); + assertTrue(_initControl.callArgsStack[1][0] === 'baseImage'); + assertTrue(_initControl.callArgsStack[2][0] === 'thumbs'); + assertTrue(_initControl.callArgsStack[3][0] === 'slideButtons'); +}; +GalleryTest.prototype.testSetSelected = function() { + var galleryInstance = this.galleryCreate(), + selected = 1; + + galleryInstance._setSelected(selected); + assertTrue(galleryInstance.selected === selected); +}; +GalleryTest.prototype.testGetSelected = function() { + var galleryInstance = this.galleryCreate(), + _findSelected = jsunit.stub(galleryInstance, '_findSelected'); + + galleryInstance.selected = null; + galleryInstance._getSelected(); + assertTrue(_findSelected.callCount === 1); + + _findSelected.reset(); + galleryInstance.selected = 1; + var selected = galleryInstance._getSelected(); + assertNull(_findSelected.callCount); + assertEquals(selected, galleryInstance.selected); +}; +GalleryTest.prototype.testFindSelected = function() { + var galleryInstance = this.galleryCreate({images: this.galleryImages}); + + galleryInstance.options.images = this.resetImageSelection(galleryInstance.options.images); + galleryInstance.options.images[0].selected = true; + var selected = galleryInstance._findSelected(); + assertTrue(selected === 0); + + galleryInstance.options.images = this.resetImageSelection(galleryInstance.options.images); + galleryInstance.options.images[1].selected = true; + var selected = galleryInstance._findSelected(); + assertTrue(selected === 1); + + galleryInstance.options.images = this.resetImageSelection(galleryInstance.options.images); + galleryInstance.options.images[0].selected = true; + galleryInstance.options.images[1].selected = true; + var selected = galleryInstance._findSelected(); + assertTrue(selected === 0); +}; +GalleryTest.prototype.testInitControl = function() { + var galleryInstance = this.galleryCreate(), + _renderControl = jsunit.stub(galleryInstance, '_renderControl'), + controlContainer = jQuery('<p data-role="test-control-container" />'), + controlName = 'test', + renderedControl = jQuery('<p data-role="test-control" />'); + + galleryInstance.element.append(controlContainer); + galleryInstance.options.controls[controlName] = {container: '[data-role=test-control-container]'}; + _renderControl.returnValue = renderedControl; + galleryInstance._initControl('test'); + assertTrue(_renderControl.callCount === 1); + assertTrue(_renderControl.lastCallArgs[0] === 'test'); + assertTrue(galleryInstance.element.find('[data-role=test-control]').length > 0); + assertTrue(galleryInstance.element.find('[data-role=test-control]').is(renderedControl)); +}; \ No newline at end of file diff --git a/dev/tests/js/testsuite/mage/zoom/zoom-test.js b/dev/tests/js/testsuite/mage/zoom/zoom-test.js new file mode 100644 index 0000000000000000000000000000000000000000..28448c403101294b270c0b8202fbdac0074a6027 --- /dev/null +++ b/dev/tests/js/testsuite/mage/zoom/zoom-test.js @@ -0,0 +1,410 @@ +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ +ZoomTest = TestCase('ZoomTest'); +ZoomTest.prototype.setUp = function() { + /*:DOC += + <script data-template="zoom-display" type="text/x-jQuery-tmpl"> + <div data-role="zoom-container"> + <div data-role="zoom-inner"></div> + </div> + </script> + <script data-template="zoom-enlarged-image" type="text/x-jQuery-tmpl"> + <img data-role="enlarged-image" src="${img}" /> + </script> + <script data-template="zoom-track" type="text/z-jQuery-tmpl"> + <div data-role="zoom-track"></div> + </script> + <script data-template="zoom-lens" type="text/z-jQuery-tmpl"> + <div data-role="zoom-lens"></div> + </script> + <script data-template="notice" type="text/x-jQuery-tmpl"> + <p class="notice" data-role="notice">${text}</p> + </script> + <div data-role="zoom-test"> + <img /> + </div> + */ + this.zoomElement = jQuery('[data-role=zoom-test]'); +}; +ZoomTest.prototype.tearDown = function() { + this.zoomDestroy(); +}; +ZoomTest.prototype.zoomDestroy = function() { + if(this.zoomElement.data('zoom')) { + this.zoomElement.zoom('destroy'); + } +}; +ZoomTest.prototype.zoomCreate = function(options, element) { + return (element || this.zoomElement).zoom(options || {} ).data('zoom'); +}; +ZoomTest.prototype.testInit = function() { + this.zoomElement.zoom(); + assertTrue(this.zoomElement.is(':mage-zoom')); +}; +ZoomTest.prototype.testCreate = function() { + var zoomInstance = this.zoomCreate(), + _setZoomData = jsunit.stub(zoomInstance, '_setZoomData'), + _render = jsunit.stub(zoomInstance, '_render'), + _bind = jsunit.stub(zoomInstance, '_bind'), + _hide = jsunit.stub(zoomInstance, '_hide'), + _largeImageLoaded = jsunit.stub(zoomInstance, '_largeImageLoaded'); + + zoomInstance.largeImage = [{ + complete: false + }]; + + zoomInstance._create(); + assertTrue(_setZoomData.callCount === 1); + assertTrue(_render.callCount === 1); + assertTrue(_bind.callCount === 1); + assertNull(_largeImageLoaded.callCount); + assertTrue(_hide.callCount === 2); + _setZoomData.reset(); + _render.reset(); + _bind.reset(); + _hide.reset(); + + zoomInstance.largeImage[0].complete = true; + zoomInstance._create(); + assertTrue(_setZoomData.callCount === 1); + assertTrue(_render.callCount === 1); + assertTrue(_bind.callCount === 1); + assertTrue(_largeImageLoaded.callCount === 1); + assertTrue(_hide.callCount === 2); +}; +ZoomTest.prototype.testRender = function() { + var zoomInstance = this.zoomCreate(), + _renderControl = jsunit.stub(zoomInstance, '_renderControl'), + _renderLargeImage = jsunit.stub(zoomInstance, '_renderLargeImage'); + _renderControl.returnCallback = function(control) { + return jQuery('<p />', {'data-control': control}); + }; + + zoomInstance._render(); + assertTrue(_renderControl.callCount === 4); + assertTrue(zoomInstance.element.find('[data-control=track]').length > 0); + assertTrue(zoomInstance.element.find('[data-control=lens]').length > 0); + assertTrue(zoomInstance.element.find('[data-control=display]').length > 0); + assertTrue(zoomInstance.element.find('[data-control=notice]').length > 0); + assertTrue(_renderLargeImage.callCount === 1); +}; +ZoomTest.prototype.testToggleNotice = function() { + var zoomInstance = this.zoomCreate(), + getZoomRatio = jsunit.stub(zoomInstance, 'getZoomRatio'); + + zoomInstance.noticeOriginal = 'notice original'; + zoomInstance.options.controls.notice = { + text: 'test text' + }; + + zoomInstance.notice.text(''); + zoomInstance.largeImageSrc = 'image.large.jpg'; + zoomInstance.activated = false; + getZoomRatio.returnValue = 2; + zoomInstance._toggleNotice(); + assertEquals(zoomInstance.notice.text(), zoomInstance.options.controls.notice.text); + assertTrue(getZoomRatio.callCount === 1); + + zoomInstance.notice.text(''); + zoomInstance.largeImageSrc = null; + zoomInstance.activated = false; + getZoomRatio.returnValue = 2; + zoomInstance._toggleNotice(); + assertEquals(zoomInstance.notice.text(), zoomInstance.noticeOriginal); + + zoomInstance.notice.text(''); + zoomInstance.largeImageSrc = 'image.large.jpg'; + zoomInstance.activated = true; + getZoomRatio.returnValue = 2; + zoomInstance._toggleNotice(); + assertEquals(zoomInstance.notice.text(), zoomInstance.noticeOriginal); + + zoomInstance.notice.text(''); + zoomInstance.largeImageSrc = 'image.large.jpg'; + zoomInstance.activated = false; + getZoomRatio.returnValue = 0; + zoomInstance._toggleNotice(); + assertEquals(zoomInstance.notice.text(), zoomInstance.noticeOriginal); +}; +ZoomTest.prototype.testRenderControl = function() { + var zoomInstance = this.zoomCreate(), + tmpl = jsunit.stub(jQuery, 'tmpl', null, true); + + zoomInstance.display.remove(); + zoomInstance.track.remove(); + zoomInstance.lens.remove(); + zoomInstance.notice.remove(); + + tmpl.returnValue = jQuery('<p />'); + zoomInstance.largeImageSrc = 'image.large.jpg'; + var display = zoomInstance._renderControl('display'); + assertTrue(tmpl.callCount === 1); + assertTrue(tmpl.lastCallArgs[0].is(zoomInstance.options.controls.display.template)); + assertEquals(tmpl.lastCallArgs[1], {img: zoomInstance.largeImageSrc}); + assertNotUndefined(zoomInstance.display); + assertNotUndefined(zoomInstance.display.length > 0); + assertTrue(zoomInstance.display.is(display)); + assertTrue(display.width() == zoomInstance.options.controls.display.width); + assertTrue(display.height() == zoomInstance.options.controls.display.height); + + tmpl.reset(); + tmpl.returnValue = jQuery('<p />'); + var notice = zoomInstance._renderControl('notice'); + assertTrue(tmpl.callCount === 1); + assertTrue(tmpl.lastCallArgs[0].is(zoomInstance.options.controls.notice.template)); + assertEquals(tmpl.lastCallArgs[1], {text: zoomInstance.options.controls.notice.text || ''}); + assertNotUndefined(zoomInstance.notice); + assertNotUndefined(zoomInstance.notice.length > 0); + assertTrue(zoomInstance.notice.is(notice)); + + tmpl.reset(); + tmpl.returnValue = jQuery('<p />'); + var track = zoomInstance._renderControl('track'); + assertTrue(tmpl.callCount === 1); + assertTrue(tmpl.lastCallArgs[0].is(zoomInstance.options.controls.track.template)); + assertNotUndefined(zoomInstance.track); + assertNotUndefined(zoomInstance.track.length > 0); + assertTrue(zoomInstance.track.is(track)); + + tmpl.reset(); + tmpl.returnValue = jQuery('<p />'); + var lens = zoomInstance._renderControl('lens'); + assertTrue(tmpl.callCount === 1); + assertTrue(tmpl.lastCallArgs[0].is(zoomInstance.options.controls.lens.template)); + assertNotUndefined(zoomInstance.lens); + assertNotUndefined(zoomInstance.lens.length > 0); + assertTrue(zoomInstance.lens.is(lens)); + + tmpl.restore(); +}; +ZoomTest.prototype.testRefresh = function() { + var zoomInstance = this.zoomCreate(), + _refreshControl = jsunit.stub(zoomInstance, '_refreshControl'); + + zoomInstance._refresh(); + assertTrue(_refreshControl.callCount === 3); + assertTrue(_refreshControl.callArgsStack[0][0] === 'display'); + assertTrue(_refreshControl.callArgsStack[1][0] === 'track'); + assertTrue(_refreshControl.callArgsStack[2][0] === 'lens'); +}; + +ZoomTest.prototype.testBind = function() { + var zoomInstance = this.zoomCreate(), + _on = jsunit.stub(zoomInstance, '_on'), + events = {}; + + zoomInstance.largeImage = jQuery('<p />'); + zoomInstance._bind(); + assertTrue(_on.callCount > 0); + assertTrue( + _on.callArgsStack[0][0][ + zoomInstance.options.startZoomEvent + + ' ' + + zoomInstance.options.selectors.image + ] === 'show' + ); + assertTrue( + jQuery.type(_on.callArgsStack[0][0][ + zoomInstance.options.stopZoomEvent + + ' ' + + zoomInstance.options.selectors.track + ]) === 'function' + ); + assertTrue(_on.callArgsStack[0][0]['mousemove ' + zoomInstance.options.selectors.track] === '_move'); + assertTrue(_on.callArgsStack[0][0].imageupdated === '_onImageUpdated'); + assertTrue(_on.callArgsStack[1][0].is(zoomInstance.largeImage)); + assertTrue(_on.callArgsStack[1][1].load === '_largeImageLoaded'); +}; +ZoomTest.prototype.testEnable = function() { + var zoomInstance = this.zoomCreate(), + _onImageUpdated = jsunit.stub(zoomInstance, '_onImageUpdated'); + + zoomInstance.enable(); + assertTrue(_onImageUpdated.callCount === 1); +}; +ZoomTest.prototype.testDisable = function() { + var zoomInstance = this.zoomCreate(); + + zoomInstance.noticeOriginal = 'original notice'; + zoomInstance.notice.text(''); + zoomInstance.disable(); + assertEquals(zoomInstance.noticeOriginal, zoomInstance.notice.text()); +}; +ZoomTest.prototype.testShow = function() { + var zoomInstance = this.zoomCreate(), + e = { + preventDefault: jsunit.stub(), + stopImmediatePropagation: jsunit.stub() + }, + getZoomRatio = jsunit.stub(zoomInstance, 'getZoomRatio'), + _show = jsunit.stub(zoomInstance, '_show'), + _refresh = jsunit.stub(zoomInstance, '_refresh'), + _toggleNotice = jsunit.stub(zoomInstance, '_toggleNotice'), + _trigger = jsunit.stub(zoomInstance, '_trigger'); + + getZoomRatio.returnValue = 0; + zoomInstance.show(e); + assertTrue(e.preventDefault.callCount === 1); + + e.preventDefault.reset(); + getZoomRatio.reset(); + getZoomRatio.returnValue = 2; + zoomInstance.largeImageSrc = 'image.large.jpg'; + zoomInstance.show(e); + assertTrue(e.preventDefault.callCount === 1); + assertTrue(e.stopImmediatePropagation.callCount === 1); + assertTrue(zoomInstance.activated); + assertTrue(_show.callCount > 0); + assertTrue(_refresh.callCount === 1); + assertTrue(_toggleNotice.callCount === 1); + assertTrue(_trigger.callCount === 1); + assertTrue(_trigger.lastCallArgs[0] === 'show'); +}; +ZoomTest.prototype.testHide = function() { + var zoomInstance = this.zoomCreate(), + _hide = jsunit.stub(zoomInstance, '_hide'), + _toggleNotice = jsunit.stub(zoomInstance, '_toggleNotice'), + _trigger = jsunit.stub(zoomInstance, '_trigger'); + + zoomInstance.hide(); + assertTrue(_hide.callCount > 0); + assertTrue(_toggleNotice.callCount === 1); + assertTrue(_trigger.callCount === 1); + assertTrue(_trigger.lastCallArgs[0] === 'hide'); +}; +ZoomTest.prototype.testOnImageUpdated = function() { + var zoomInstance = this.zoomCreate(), + _setZoomData = jsunit.stub(zoomInstance, '_setZoomData'), + _refreshLargeImage = jsunit.stub(zoomInstance, '_refreshLargeImage'), + _refresh = jsunit.stub(zoomInstance, '_refresh'), + hide = jsunit.stub(zoomInstance, 'hide'), + testImage = jQuery('<p data-role="test-image" />'); + + zoomInstance.options.selectors.image = "[data-role=test-image]"; + zoomInstance.element.append(testImage); + zoomInstance.image = testImage; + zoomInstance._onImageUpdated(); + assertNull(_setZoomData.callCount); + assertNull(_refreshLargeImage.callCount); + assertNull(_refresh.callCount); + assertNull(hide.callCount); + + zoomInstance.image = jQuery('<p />'); + zoomInstance.largeImageSrc = null; + zoomInstance._onImageUpdated(); + assertTrue(_setZoomData.callCount === 1); + assertNull(_refreshLargeImage.callCount); + assertNull(_refresh.callCount); + assertTrue(hide.callCount === 1); + + _setZoomData.reset(); + hide.reset(); + zoomInstance.largeImageSrc = 'image.large.jpg'; + zoomInstance._onImageUpdated(); + assertTrue(_setZoomData.callCount === 1); + assertTrue(_refreshLargeImage.callCount === 1); + assertTrue(_refresh.callCount === 1); + assertNull(hide.callCount); +}; +ZoomTest.prototype.testLargeImageLoaded = function() { + var zoomInstance = this.zoomCreate(), + _toggleNotice = jsunit.stub(zoomInstance, '_toggleNotice'), + _getAspectRatio = jsunit.stub(zoomInstance, '_getAspectRatio'), + _getWhiteBordersOffset = jsunit.stub(zoomInstance, '_getWhiteBordersOffset'), + processStopTriggered = false, + image = jQuery('<p data-role="test-image" />'); + + _getWhiteBordersOffset.returnValue = 1; + zoomInstance.element.append(image); + zoomInstance.options.selectors.image = '[data-role=test-image]'; + zoomInstance.image = image + _getAspectRatio.returnCallback = function(image) { + if (image.is(zoomInstance.image)) { + return 0; + } else { + return 1; + } + } + + jQuery(zoomInstance.options.selectors.image).on('processStop', function() { + processStopTriggered = true; + }); + zoomInstance.ratio = 1; + + zoomInstance._largeImageLoaded(); + assertNull(zoomInstance.ratio); + assertTrue(_toggleNotice.callCount === 1); + assertTrue(processStopTriggered); + assertTrue(_getAspectRatio.callCount > 0); + assertTrue(_getWhiteBordersOffset.callCount === 1); + assertEquals(zoomInstance.whiteBordersOffset, _getWhiteBordersOffset.returnValue); +}; +ZoomTest.prototype.testRefreshLargeImage = function() { + var zoomInstance = this.zoomCreate(), + css = {top: 0, left: 0}; + zoomInstance.largeImage = jQuery('<img />'); + zoomInstance.largeImageSrc = 'large.image.jpg'; + + zoomInstance._refreshLargeImage(); + assertNotUndefined(zoomInstance.largeImage.prop('src')); + assertEquals(zoomInstance.largeImage.css('top'), css.top + 'px'); + assertEquals(zoomInstance.largeImage.css('left'), css.left + 'px'); +}; +ZoomTest.prototype.testRenderLargeImage = function() { + var zoomInstance = this.zoomCreate(), + processStartTriggered = false; + + zoomInstance.element.append(jQuery('<p data-role="test-image" />')); + zoomInstance.options.selectors.image = '[data-role=test-image]'; + jQuery(zoomInstance.options.selectors.image).on('processStart', function() { + processStartTriggered = true; + }); + + var image = zoomInstance._renderLargeImage(); + assertTrue(image.is('img')); + assertTrue(image.is(zoomInstance.largeImage)); + assertTrue(processStartTriggered); +}; +ZoomTest.prototype.testGetZoomRatio = function() { + var zoomInstance = this.zoomCreate(), + imageSize = {width: 100, height: 100}, + largeImageSize = {width: 200, height: 200}; + + zoomInstance.ratio = null; + zoomInstance.image = jQuery('<img />', imageSize); + zoomInstance.largeImageSize = largeImageSize; + var zoomRatio = zoomInstance.getZoomRatio(); + + assertEquals(zoomRatio, (largeImageSize.width / imageSize.width)); + zoomInstance.ratio = 100; + zoomRatio = zoomInstance.getZoomRatio(); + assertEquals(zoomRatio, zoomInstance.ratio); +}; +ZoomTest.prototype.testGetAspectRatio = function() { + var zoomInstance = this.zoomCreate(), + aspectRatio = zoomInstance._getAspectRatio(), + size = {width: 200, height: 100}; + assertNull(aspectRatio); + aspectRatio = zoomInstance._getAspectRatio(jQuery('<div />', size)); + assertEquals((Math.round((size.width / size.height) * 100) / 100), aspectRatio); +}; \ No newline at end of file diff --git a/dev/tests/performance/testsuite/checkout.jmx b/dev/tests/performance/testsuite/checkout.jmx index 163acdbf06ea23b2ed6b34b118f9496558ecb939..8d60c1272c1024a693db3bd3c05d602d0e2f1c5f 100644 --- a/dev/tests/performance/testsuite/checkout.jmx +++ b/dev/tests/performance/testsuite/checkout.jmx @@ -329,7 +329,17 @@ <boolProp name="HTTPSampler.monitor">false</boolProp> <stringProp name="HTTPSampler.embedded_url_re"></stringProp> </HTTPSamplerProxy> - <hashTree/> + <hashTree> + <RegexExtractor guiclass="RegexExtractorGui" testclass="RegexExtractor" testname="Extract form key" enabled="true"> + <stringProp name="RegexExtractor.useHeaders">false</stringProp> + <stringProp name="RegexExtractor.refname">form_key</stringProp> + <stringProp name="RegexExtractor.regex"><input name="form_key" type="hidden" value="([^'"]+)" /></stringProp> + <stringProp name="RegexExtractor.template">$1$</stringProp> + <stringProp name="RegexExtractor.default"></stringProp> + <stringProp name="RegexExtractor.match_number">1</stringProp> + </RegexExtractor> + <hashTree/> + </hashTree> <HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="Checkout guest" enabled="true"> <elementProp name="HTTPsampler.Arguments" elementType="Arguments" guiclass="HTTPArgumentsPanel" testclass="Arguments" enabled="true"> <collectionProp name="Arguments.arguments"> @@ -907,6 +917,14 @@ <stringProp name="Argument.metadata">=</stringProp> <boolProp name="HTTPArgument.use_equals">true</boolProp> </elementProp> + <elementProp name="form_key" elementType="HTTPArgument"> + <boolProp name="HTTPArgument.always_encode">false</boolProp> + <stringProp name="Argument.value">${form_key}</stringProp> + <stringProp name="Argument.metadata">=</stringProp> + <boolProp name="HTTPArgument.use_equals">true</boolProp> + <stringProp name="Argument.name">form_key</stringProp> + <stringProp name="Argument.desc">false</stringProp> + </elementProp> </collectionProp> </elementProp> <stringProp name="HTTPSampler.domain"></stringProp> diff --git a/dev/tests/performance/testsuite/fixtures/shipping_flatrate_enabled.php b/dev/tests/performance/testsuite/fixtures/shipping_flatrate_enabled.php index 6d44bbf086f812ba6019c27c3123ca6be09c20eb..760d1c9e6f8bd4025857617b1b305e8846c7bce7 100644 --- a/dev/tests/performance/testsuite/fixtures/shipping_flatrate_enabled.php +++ b/dev/tests/performance/testsuite/fixtures/shipping_flatrate_enabled.php @@ -29,10 +29,10 @@ */ $configData = $this->getObjectManager()->create('Magento\App\Config\ValueInterface'); $configData->setPath('carriers/flatrate/active') - ->setScope(\Magento\Core\Model\ScopeInterface::SCOPE_DEFAULT) + ->setScope(\Magento\BaseScopeInterface::SCOPE_DEFAULT) ->setScopeId(0) ->setValue(1) ->save(); $this->getObjectManager()->get('Magento\App\CacheInterface') - ->clean(array(\Magento\Core\Model\Config::CACHE_TAG)); + ->clean(array(\Magento\App\Config::CACHE_TAG)); diff --git a/dev/tests/static/framework/Magento/Sniffs/Annotations/Helper.php b/dev/tests/static/framework/Magento/Sniffs/Annotations/Helper.php new file mode 100644 index 0000000000000000000000000000000000000000..90c62312f68a8fdaf337f77cd49edc642fc1d6b3 --- /dev/null +++ b/dev/tests/static/framework/Magento/Sniffs/Annotations/Helper.php @@ -0,0 +1,559 @@ +<?php +namespace Magento\Sniffs\Annotations; + +use \PHP_CodeSniffer_File; +use \PHP_CodeSniffer; +/** + * Base of the annotations sniffs + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood <gsherwood@squiz.net> + * @author Marc McIntyre <mmcintyre@squiz.net> + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @link http://pear.php.net/package/PHP_CodeSniffer + * + * @SuppressWarnings(PHPMD) + */ +class Helper +{ + const ERROR_PARSING = 'ErrorParsing'; + + const AMBIGUOUS_TYPE = 'AmbiguousType'; + + const MISSING = 'Missing'; + + const WRONG_STYLE = 'WrongStyle'; + + const WRONG_END = 'WrongEnd'; + + const FAILED_PARSE = 'FailedParse'; + + const CONTENT_AFTER_OPEN = 'ContentAfterOpen'; + + const MISSING_SHORT = 'MissingShort'; + + const EMPTY_DOC = 'Empty'; + + const SPACING_BETWEEN = 'SpacingBetween'; + + const SPACING_BEFORE_SHORT = 'SpacingBeforeShort'; + + const SPACING_BEFORE_TAGS = 'SpacingBeforeTags'; + + const SHORT_SINGLE_LINE = 'ShortSingleLine'; + + const SHORT_NOT_CAPITAL = 'ShortNotCapital'; + + const SHORT_FULL_STOP = 'ShortFullStop'; + + const SPACING_AFTER = 'SpacingAfter'; + + const SEE_ORDER = 'SeeOrder'; + + const EMPTY_SEE = 'EmptySee'; + + const SEE_INDENT = 'SeeIndent'; + + const DUPLICATE_RETURN = 'DuplicateReturn'; + + const MISSING_PARAM_TAG = 'MissingParamTag'; + + const SPACING_AFTER_LONG_NAME = 'SpacingAfterLongName'; + + const SPACING_AFTER_LONG_TYPE = 'SpacingAfterLongType'; + + const MISSING_PARAM_TYPE = 'MissingParamType'; + + const MISSING_PARAM_NAME = 'MissingParamName'; + + const EXTRA_PARAM_COMMENT = 'ExtraParamComment'; + + const PARAM_NAME_NO_MATCH = 'ParamNameNoMatch'; + + const PARAM_NAME_NO_CASE_MATCH = 'ParamNameNoCaseMatch'; + + const INVALID_TYPE_HINT = 'InvalidTypeHint'; + + const INCORRECT_TYPE_HINT = 'IncorrectTypeHint'; + + const TYPE_HINT_MISSING = 'TypeHintMissing'; + + const INCORRECT_PARAM_VAR_NAME = 'IncorrectParamVarName'; + + const RETURN_ORDER = 'ReturnOrder'; + + const MISSING_RETURN_TYPE = 'MissingReturnType'; + + const INVALID_RETURN = 'InvalidReturn'; + + const INVALID_RETURN_VOID = 'InvalidReturnVoid'; + + const INVALID_NO_RETURN = 'InvalidNoReturn'; + + const INVALID_RETURN_NOT_VOID = 'InvalidReturnNotVoid'; + + const INCORRECT_INHERIT_DOC = 'IncorrectInheritDoc'; + + const RETURN_INDENT = 'ReturnIndent'; + + const MISSING_RETURN = 'MissingReturn'; + + const RETURN_NOT_REQUIRED = 'ReturnNotRequired'; + + const INVALID_THROWS = 'InvalidThrows'; + + const THROWS_NOT_CAPITAL = 'ThrowsNotCapital'; + + const THROWS_ORDER = 'ThrowsOrder'; + + const EMPTY_THROWS = 'EmptyThrows'; + + const THROWS_NO_FULL_STOP = 'ThrowsNoFullStop'; + + const SPACING_AFTER_PARAMS = 'SpacingAfterParams'; + + const SPACING_BEFORE_PARAMS = 'SpacingBeforeParams'; + + const SPACING_BEFORE_PARAM_TYPE = 'SpacingBeforeParamType'; + + const LONG_NOT_CAPITAL = 'LongNotCapital'; + + const TAG_NOT_ALLOWED = 'TagNotAllowed'; + + const DUPLICATE_VAR = 'DuplicateVar'; + + const VAR_ORDER = 'VarOrder'; + + const MISSING_VAR_TYPE = 'MissingVarType'; + + const INCORRECT_VAR_TYPE = 'IncorrectVarType'; + + const VAR_INDENT = 'VarIndent'; + + const MISSING_VAR = 'MissingVar'; + + const MISSING_PARAM_COMMENT = 'MissingParamComment'; + + const PARAM_COMMENT_NOT_CAPITAL = 'ParamCommentNotCapital'; + + const PARAM_COMMENT_FULL_STOP = 'ParamCommentFullStop'; + + // tells phpcs to use the default level + const ERROR = 0; + + // default level of warnings is 5 + const WARNING = 6; + + const INFO = 2; + + // Lowest possible level. + const OFF = 1; + + const LEVEL = 'level'; + + const MESSAGE = 'message'; + + /** + * Map of Error Type to Error Severity + * + * @var array + */ + protected static $reportingLevel = array( + self::ERROR_PARSING => array(self::LEVEL => self::ERROR, self::MESSAGE => '%s'), + self::FAILED_PARSE => array(self::LEVEL => self::ERROR, self::MESSAGE => '%s'), + self::AMBIGUOUS_TYPE => array( + self::LEVEL => self::WARNING, + self::MESSAGE => 'Ambiguous type "%s" for %s is NOT recommended' + ), + self::MISSING => array(self::LEVEL => self::WARNING, self::MESSAGE => 'Missing %s doc comment'), + self::WRONG_STYLE => array( + self::LEVEL => self::WARNING, + self::MESSAGE => 'You must use "/**" style comments for a %s comment' + ), + self::WRONG_END => array( + self::LEVEL => self::WARNING, + self::MESSAGE => 'You must use "*/" to end a function comment; found "%s"' + ), + self::EMPTY_DOC => array(self::LEVEL => self::WARNING, self::MESSAGE => '%s doc comment is empty'), + self::CONTENT_AFTER_OPEN => array( + self::LEVEL => self::WARNING, + self::MESSAGE => 'The open comment tag must be the only content on the line' + ), + self::MISSING_SHORT => array( + self::LEVEL => self::WARNING, + self::MESSAGE => 'Missing short description in %s doc comment' + ), + self::SPACING_BETWEEN => array( + self::LEVEL => self::OFF, + self::MESSAGE => 'There must be exactly one blank line between descriptions in %s comment' + ), + self::SPACING_BEFORE_SHORT => array( + self::LEVEL => self::WARNING, + self::MESSAGE => 'Extra newline(s) found before %s comment short description' + ), + self::SPACING_BEFORE_TAGS => array( + self::LEVEL => self::INFO, + self::MESSAGE => 'There must be exactly one blank line before the tags in %s comment' + ), + self::SHORT_SINGLE_LINE => array( + self::LEVEL => self::OFF, + self::MESSAGE => '%s comment short description must be on a single line' + ), + self::SHORT_NOT_CAPITAL => array( + self::LEVEL => self::WARNING, + self::MESSAGE => '%s comment short description must start with a capital letter' + ), + self::SHORT_FULL_STOP => array( + self::LEVEL => self::OFF, + self::MESSAGE => '%s comment short description must end with a full stop' + ), + self::SPACING_AFTER => array( + self::LEVEL => self::WARNING, + self::MESSAGE => 'Additional blank lines found at end of %s comment' + ), + self::SEE_ORDER => array( + self::LEVEL => self::WARNING, + self::MESSAGE => 'The @see tag is in the wrong order; the tag precedes @return' + ), + self::EMPTY_SEE => array( + self::LEVEL => self::WARNING, + self::MESSAGE => 'Content missing for @see tag in %s comment' + ), + self::SEE_INDENT => array( + self::LEVEL => self::OFF, + self::MESSAGE => '@see tag indented incorrectly; expected 1 spaces but found %s' + ), + self::DUPLICATE_RETURN => array( + self::LEVEL => self::WARNING, + self::MESSAGE => 'Only 1 @return tag is allowed in function comment' + ), + self::MISSING_PARAM_TAG => array( + self::LEVEL => self::WARNING, + self::MESSAGE => 'Doc comment for "%s" missing' + ), + self::SPACING_AFTER_LONG_NAME => array( + self::LEVEL => self::OFF, + self::MESSAGE => 'Expected 1 space after the longest variable name' + ), + self::SPACING_AFTER_LONG_TYPE => array( + self::LEVEL => self::OFF, + self::MESSAGE => 'Expected 1 space after the longest type' + ), + self::MISSING_PARAM_TYPE => array( + self::LEVEL => self::WARNING, + self::MESSAGE => 'Missing type at position %s' + ), + self::MISSING_PARAM_NAME => array( + self::LEVEL => self::WARNING, + self::MESSAGE => 'Missing parameter name at position %s' + ), + self::EXTRA_PARAM_COMMENT => array( + self::LEVEL => self::WARNING, + self::MESSAGE => 'Superfluous doc comment at position %s' + ), + self::PARAM_NAME_NO_MATCH => array( + self::LEVEL => self::WARNING, + self::MESSAGE => 'Doc comment for var %s does not match actual variable name %s at position %s' + ), + self::PARAM_NAME_NO_CASE_MATCH => array( + self::LEVEL => self::WARNING, + self::MESSAGE => 'Doc comment for var %s does not match case of actual variable name %s at position %s' + ), + self::INVALID_TYPE_HINT => array( + self::LEVEL => self::WARNING, + self::MESSAGE => 'Unknown type hint "%s" found for %s at position %s' + ), + self::INCORRECT_TYPE_HINT => array( + self::LEVEL => self::WARNING, + self::MESSAGE => 'Expected type hint "%s"; found "%s" for %s at position %s' + ), + self::TYPE_HINT_MISSING => array( + self::LEVEL => self::INFO, + self::MESSAGE => 'Type hint "%s" missing for %s at position %s' + ), + self::INCORRECT_PARAM_VAR_NAME => array( + self::LEVEL => self::WARNING, + self::MESSAGE => 'Expected "%s"; found "%s" for %s at position %s' + ), + self::RETURN_ORDER => array( + self::LEVEL => self::WARNING, + self::MESSAGE => 'The @return tag is in the wrong order; the tag follows @see (if used)' + ), + self::MISSING_RETURN_TYPE => array( + self::LEVEL => self::WARNING, + self::MESSAGE => 'Return type missing for @return tag in function comment' + ), + self::INVALID_RETURN => array( + self::LEVEL => self::WARNING, + self::MESSAGE => 'Function return type "%s" is invalid' + ), + self::INVALID_RETURN_VOID => array( + self::LEVEL => self::WARNING, + self::MESSAGE => 'Function return type is void, but function contains return statement' + ), + self::INVALID_NO_RETURN => array( + self::LEVEL => self::WARNING, + self::MESSAGE => 'Function return type is not void, but function has no return statement' + ), + self::INVALID_RETURN_NOT_VOID => array( + self::LEVEL => self::WARNING, + self::MESSAGE => 'Function return type is not void, but function is returning void here' + ), + self::INCORRECT_INHERIT_DOC => array( + self::LEVEL => self::WARNING, + self::MESSAGE => 'The incorrect inherit doc tag usage. Should be {@inheritdoc}' + ), + self::RETURN_INDENT => array( + self::LEVEL => self::OFF, + self::MESSAGE => '@return tag indented incorrectly; expected 1 space but found %s' + ), + self::MISSING_RETURN => array( + self::LEVEL => self::WARNING, + self::MESSAGE => 'Missing @return tag in function comment' + ), + self::RETURN_NOT_REQUIRED => array( + self::LEVEL => self::WARNING, + self::MESSAGE => '@return tag is not required for constructor and destructor' + ), + self::INVALID_THROWS => array( + self::LEVEL => self::WARNING, + self::MESSAGE => 'Exception type and comment missing for @throws tag in function comment' + ), + self::THROWS_NOT_CAPITAL => array( + self::LEVEL => self::WARNING, + self::MESSAGE => '@throws tag comment must start with a capital letter' + ), + self::THROWS_ORDER => array( + self::LEVEL => self::WARNING, + self::MESSAGE => 'The @throws tag is in the wrong order; the tag follows @return' + ), + self::EMPTY_THROWS => array( + self::LEVEL => self::OFF, + self::MESSAGE => 'Comment missing for @throws tag in function comment' + ), + self::THROWS_NO_FULL_STOP => array( + self::LEVEL => self::OFF, + self::MESSAGE => '@throws tag comment must end with a full stop' + ), + self::SPACING_AFTER_PARAMS => array( + self::LEVEL => self::OFF, + self::MESSAGE => 'Last parameter comment requires a blank newline after it' + ), + self::SPACING_BEFORE_PARAMS => array( + self::LEVEL => self::WARNING, + self::MESSAGE => 'Parameters must appear immediately after the comment' + ), + self::SPACING_BEFORE_PARAM_TYPE => array( + self::LEVEL => self::OFF, + self::MESSAGE => 'Expected 1 space before variable type' + ), + self::LONG_NOT_CAPITAL => array( + self::LEVEL => self::WARNING, + self::MESSAGE => '%s comment long description must start with a capital letter' + ), + self::TAG_NOT_ALLOWED => array( + self::LEVEL => self::WARNING, + self::MESSAGE => '@%s tag is not allowed in variable comment' + ), + self::DUPLICATE_VAR => array( + self::LEVEL => self::WARNING, + self::MESSAGE => 'Only 1 @var tag is allowed in variable comment' + ), + self::VAR_ORDER => array( + self::LEVEL => self::WARNING, + self::MESSAGE => 'The @var tag must be the first tag in a variable comment' + ), + self::MISSING_VAR_TYPE => array( + self::LEVEL => self::WARNING, + self::MESSAGE => 'Var type missing for @var tag in variable comment' + ), + self::INCORRECT_VAR_TYPE => array( + self::LEVEL => self::WARNING, + self::MESSAGE => 'Expected "%s"; found "%s" for @var tag in variable comment' + ), + self::VAR_INDENT => array( + self::LEVEL => self::OFF, + self::MESSAGE => '@var tag indented incorrectly; expected 1 space but found %s' + ), + self::MISSING_VAR => array( + self::LEVEL => self::WARNING, + self::MESSAGE => 'Missing @var tag in variable comment' + ), + self::MISSING_PARAM_COMMENT => array( + self::LEVEL => self::OFF, + self::MESSAGE => 'Missing comment for param "%s" at position %s' + ), + self::PARAM_COMMENT_NOT_CAPITAL => array( + self::LEVEL => self::OFF, + self::MESSAGE => 'Param comment must start with a capital letter' + ), + self::PARAM_COMMENT_FULL_STOP => array( + self::LEVEL => self::OFF, + self::MESSAGE => 'Param comment must end with a full stop' + ) + ); + + /** + * List of allowed types + * + * @var string[] + */ + protected static $allowedTypes = array( + 'array', + 'boolean', + 'bool', + 'float', + 'integer', + 'int', + 'object', + 'string', + 'resource', + 'callable', + 'true', + 'false' + ); + + /** + * The current PHP_CodeSniffer_File object we are processing. + * + * @var PHP_CodeSniffer_File + */ + protected $currentFile = null; + + /** + * Constructor for class. + * + * @param PHP_CodeSniffer_File $phpcsFile + */ + public function __construct(PHP_CodeSniffer_File $phpcsFile) + { + $this->currentFile = $phpcsFile; + } + + /** + * Returns the current file object + * + * @return PHP_CodeSniffer_File + */ + public function getCurrentFile() + { + return $this->currentFile; + } + + /** + * Returns the eol character used in the file + * + * @return string + */ + public function getEolChar() + { + return $this->currentFile->eolChar; + } + + /** + * Returns the array of allowed types for magento standard + * + * @return string[] + */ + public function getAllowedTypes() + { + return self::$allowedTypes; + } + + /** + * This method will add the message as an error or warning depending on the configuration + * + * @param int $stackPtr The stack position where the error occurred. + * @param string $code A violation code unique to the sniff message. + * @param string[] $data Replacements for the error message. + * @param int $severity The severity level for this error. A value of 0 + * @return void + */ + public function addMessage($stackPtr, $code, $data = array(), $severity = 0) + { + // Does the $code key exist in the report level + if (array_key_exists($code, self::$reportingLevel)) { + $message = self::$reportingLevel[$code][self::MESSAGE]; + $level = self::$reportingLevel[$code][self::LEVEL]; + if ($level === self::WARNING || $level === self::INFO || $level === self::OFF) { + $s = $level; + if ($severity !== 0) { + $s = $severity; + } + $this->currentFile->addWarning($message, $stackPtr, $code, $data, $s); + } else { + $this->currentFile->addError($message, $stackPtr, $code, $data, $severity); + } + } + } + + /** + * Determine if text is a class name + * + * @param string $class + * @return bool + */ + protected function isClassName($class) + { + $return = false; + if (preg_match('/^\\\\?[A-Z]\\w+(?:\\\\\\w+)*?$/', $class)) { + $return = true; + } + return $return; + } + + /** + * Determine if the text has an ambiguous type + * + * @param string $text + * @param array &$matches Type that was detected as ambiguous is in result. + * @return bool + */ + public function isAmbiguous($text, &$matches = array()) + { + return preg_match('/(array|mixed)/', $text, $matches); + } + + /** + * Take the type and suggest the correct one. + * + * @param string $type + * @return string + */ + public function suggestType($type) + { + $suggestedName = null; + // First check to see if this type is a list of types. If so we break it up and check each + if (preg_match('/^.*?(?:\|.*)+$/', $type)) { + // Return list of all types in this string. + $types = explode('|', $type); + if (is_array($types)) { + // Loop over all types and call this method on each. + $suggestions = array(); + foreach ($types as $t) { + $suggestions[] = $this->suggestType($t); + } + // Now that we have suggestions put them back together. + $suggestedName = implode('|', $suggestions); + } else { + $suggestedName = 'Unknown'; + } + } elseif ($this->isClassName($type)) { + // If this looks like a class name. + $suggestedName = $type; + } else { + // Only one type First check if that type is a base one. + $lowerVarType = strtolower($type); + if (in_array($lowerVarType, self::$allowedTypes)) { + $suggestedName = $lowerVarType; + } + // If no name suggested yet then call the phpcs version of this method. + if (empty($suggestedName)) { + $suggestedName = PHP_CodeSniffer::suggestType($type); + } + } + return $suggestedName; + } +} diff --git a/dev/tests/static/framework/Magento/Sniffs/Annotations/RequireAnnotatedAttributesSniff.php b/dev/tests/static/framework/Magento/Sniffs/Annotations/RequireAnnotatedAttributesSniff.php new file mode 100644 index 0000000000000000000000000000000000000000..03cfe8f64dbda87109aaea0c40de08bd1e777088 --- /dev/null +++ b/dev/tests/static/framework/Magento/Sniffs/Annotations/RequireAnnotatedAttributesSniff.php @@ -0,0 +1,395 @@ +<?php +namespace Magento\Sniffs\Annotations; + +use \PHP_CodeSniffer_Standards_AbstractVariableSniff; +use \PHP_CodeSniffer_CommentParser_ClassCommentParser; +use \PHP_CodeSniffer_File; +use \PHP_CodeSniffer_CommentParser_MemberCommentParser; +use \PHP_CodeSniffer_CommentParser_ParserException; +use \PHP_CodeSniffer_CommentParser_CommentElement; + +include_once 'Helper.php'; + +/** + * Parses and verifies the variable doc comment. + * + * Verifies that : + * <ul> + * <li>A variable doc comment exists.</li> + * <li>Short description ends with a full stop.</li> + * <li>There is a blank line after the short description.</li> + * <li>There is a blank line between the description and the tags.</li> + * <li>Check the order, indentation and content of each tag.</li> + * </ul> + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood <gsherwood@squiz.net> + * @author Marc McIntyre <mmcintyre@squiz.net> + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @version Release: @package_version@ + * @link http://pear.php.net/package/PHP_CodeSniffer + * + * @SuppressWarnings(PHPMD) + */ +class RequireAnnotatedAttributesSniff extends PHP_CodeSniffer_Standards_AbstractVariableSniff +{ + /** + * The header comment parser for the current file. + * + * @var PHP_CodeSniffer_CommentParser_ClassCommentParser + */ + protected $commentParser = null; + + /** + * The sniff helper for stuff shared between the annotations sniffs + * + * @var Helper + */ + protected $helper = null; + + /** + * Extract the var comment docblock + * + * @param array $tokens + * @param string $commentToken + * @param int $stackPtr The position of the current token in the stack passed in $tokens. + * @return int|false + */ + protected function extractVarDocBlock($tokens, $commentToken, $stackPtr) + { + $commentEnd = $this->helper->getCurrentFile()->findPrevious($commentToken, $stackPtr - 3); + $break = false; + if ($commentEnd !== false && $tokens[$commentEnd]['code'] === T_COMMENT) { + $this->helper->addMessage( + $stackPtr, + Helper::WRONG_STYLE, + array('variable') + ); + $break = true; + } elseif ($commentEnd === false || $tokens[$commentEnd]['code'] !== T_DOC_COMMENT) { + $this->helper->addMessage( + $stackPtr, + Helper::MISSING, + array('variable') + ); + $break = true; + } else { + // Make sure the comment we have found belongs to us. + $commentFor = $this->helper->getCurrentFile()->findNext( + array(T_VARIABLE, T_CLASS, T_INTERFACE), $commentEnd + 1 + ); + if ($commentFor !== $stackPtr) { + $this->helper->addMessage( + $stackPtr, + Helper::MISSING, + array('variable') + ); + $break = true; + } + } + return $break ? false : $commentEnd; + } + + /** + * Checks for short and long descriptions on variable definitions + * + * @param PHP_CodeSniffer_CommentParser_CommentElement $comment + * @param int $commentStart + * @return void + */ + protected function checkForDescription($comment, $commentStart) + { + $short = $comment->getShortComment(); + $long = ''; + $newlineCount = 0; + if (trim($short) === '') { + $this->helper->addMessage($commentStart, Helper::MISSING_SHORT, array('variable')); + $newlineCount = 1; + } else { + // No extra newline before short description. + $newlineSpan = strspn($short, $this->helper->getEolChar()); + if ($short !== '' && $newlineSpan > 0) { + $this->helper->addMessage( + $commentStart + 1, + Helper::SPACING_BEFORE_SHORT, + array('variable') + ); + } + + $newlineCount = substr_count($short, $this->helper->getEolChar()) + 1; + + // Exactly one blank line between short and long description. + $long = $comment->getLongComment(); + if (empty($long) === false) { + $between = $comment->getWhiteSpaceBetween(); + $newlineBetween = substr_count($between, $this->helper->getEolChar()); + if ($newlineBetween !== 2) { + $this->helper->addMessage( + $commentStart + $newlineCount + 1, + Helper::SPACING_BETWEEN, + array('variable') + ); + } + + $newlineCount += $newlineBetween; + + $testLong = trim($long); + if (preg_match('|\p{Lu}|u', $testLong[0]) === 0) { + $this->helper->addMessage( + $commentStart + $newlineCount, + Helper::LONG_NOT_CAPITAL, + array('Variable') + ); + } + } + + // Short description must be single line and end with a full stop. + $testShort = trim($short); + $lastChar = $testShort[strlen($testShort) - 1]; + if (substr_count($testShort, $this->helper->getEolChar()) !== 0) { + $this->helper->addMessage( + $commentStart + 1, + Helper::SHORT_SINGLE_LINE, + array('Variable') + ); + } + + if (preg_match('|\p{Lu}|u', $testShort[0]) === 0) { + $this->helper->addMessage( + $commentStart + 1, + Helper::SHORT_NOT_CAPITAL, + array('Variable') + ); + } + + if ($lastChar !== '.') { + $this->helper->addMessage( + $commentStart + 1, + Helper::SHORT_FULL_STOP, + array('Variable') + ); + } + } + // Exactly one blank line before tags. + $tags = $this->commentParser->getTagOrders(); + if (count($tags) > 1) { + $newlineSpan = $comment->getNewlineAfter(); + if ($newlineSpan !== 2) { + if ($long !== '') { + $newlineCount += substr_count($long, $this->helper->getEolChar()) - $newlineSpan + 1; + } + + $this->helper->addMessage( + $commentStart + $newlineCount, + Helper::SPACING_BEFORE_TAGS, + array('variable') + ); + $short = rtrim($short, $this->helper->getEolChar() . ' '); + } + } + } + + /** + * Called to process class member vars. + * + * @param PHP_CodeSniffer_File $phpcsFile The file being scanned. + * @param int $stackPtr The position of the current token + * in the stack passed in $tokens. + * + * @return void + */ + public function processMemberVar(PHP_CodeSniffer_File $phpcsFile, $stackPtr) + { + $this->helper = new Helper($phpcsFile); + $tokens = $phpcsFile->getTokens(); + $commentToken = array(T_COMMENT, T_DOC_COMMENT); + + // Extract the var comment docblock. + $commentEnd = $this->extractVarDocBlock($tokens, $commentToken, $stackPtr); + if ($commentEnd === false) { + return; + } + + $commentStart = $phpcsFile->findPrevious(T_DOC_COMMENT, $commentEnd - 1, null, true) + 1; + $commentString = $phpcsFile->getTokensAsString($commentStart, $commentEnd - $commentStart + 1); + + // Parse the header comment docblock. + try { + $this->commentParser = new PHP_CodeSniffer_CommentParser_MemberCommentParser($commentString, $phpcsFile); + $this->commentParser->parse(); + } catch (PHP_CodeSniffer_CommentParser_ParserException $e) { + $line = $e->getLineWithinComment() + $commentStart; + $data = array($e->getMessage()); + $this->helper->addMessage($line, Helper::ERROR_PARSING, $data); + return; + } + + $comment = $this->commentParser->getComment(); + if (is_null($comment) === true) { + $this->helper->addMessage($commentStart, Helper::EMPTY_DOC, array('Variable')); + return; + } + + // The first line of the comment should just be the /** code. + $eolPos = strpos($commentString, $phpcsFile->eolChar); + $firstLine = substr($commentString, 0, $eolPos); + if ($firstLine !== '/**') { + $this->helper->addMessage($commentStart, Helper::CONTENT_AFTER_OPEN); + } + + // Check for a comment description. + $this->checkForDescription($comment, $commentStart); + + // Check for unknown/deprecated tags. + $unknownTags = $this->commentParser->getUnknown(); + foreach ($unknownTags as $errorTag) { + // Unknown tags are not parsed, do not process further. + $data = array($errorTag['tag']); + $this->helper->addMessage( + $commentStart + $errorTag['line'], + Helper::TAG_NOT_ALLOWED, + $data + ); + } + + // Check each tag. + $this->processVar($commentStart, $commentEnd); + $this->processSees($commentStart); + + // The last content should be a newline and the content before + // that should not be blank. If there is more blank space + // then they have additional blank lines at the end of the comment. + $words = $this->commentParser->getWords(); + $lastPos = count($words) - 1; + if (trim( + $words[$lastPos - 1] + ) !== '' || strpos( + $words[$lastPos - 1], + $this->currentFile->eolChar + ) === false || trim( + $words[$lastPos - 2] + ) === '' + ) { + $this->helper->addMessage($commentEnd, Helper::SPACING_AFTER, array('variable')); + } + } + + /** + * Process the var tag. + * + * @param int $commentStart The position in the stack where the comment started. + * @param int $commentEnd The position in the stack where the comment ended. + * + * @return void + */ + protected function processVar($commentStart, $commentEnd) + { + $var = $this->commentParser->getVar(); + + if ($var !== null) { + $errorPos = $commentStart + $var->getLine(); + $index = array_keys($this->commentParser->getTagOrders(), 'var'); + + if (count($index) > 1) { + $this->helper->addMessage($errorPos, Helper::DUPLICATE_VAR); + return; + } + + if ($index[0] !== 1) { + $this->helper->addMessage($errorPos, Helper::VAR_ORDER); + } + + $content = $var->getContent(); + if (empty($content) === true) { + $this->helper->addMessage($errorPos, Helper::MISSING_VAR_TYPE); + return; + } else { + $suggestedType = $this->helper->suggestType($content); + if ($content !== $suggestedType) { + $data = array($suggestedType, $content); + $this->helper->addMessage( + $errorPos, + Helper::INCORRECT_VAR_TYPE, + $data + ); + } elseif ($this->helper->isAmbiguous($content, $matches)) { + // Warn about ambiguous types ie array or mixed + $data = array($matches[1],'@var'); + $this->helper->addMessage( + $errorPos, + Helper::AMBIGUOUS_TYPE, + $data + ); + } + } + + $spacing = substr_count($var->getWhitespaceBeforeContent(), ' '); + if ($spacing !== 1) { + $data = array($spacing); + $this->helper->addMessage($errorPos, Helper::VAR_INDENT, $data); + } + } else { + $this->helper->addMessage($commentEnd, Helper::MISSING_VAR); + } + } + + /** + * Process the see tags. + * + * @param int $commentStart The position in the stack where the comment started. + * + * @return void + */ + protected function processSees($commentStart) + { + $sees = $this->commentParser->getSees(); + if (empty($sees) === false) { + foreach ($sees as $see) { + $errorPos = $commentStart + $see->getLine(); + $content = $see->getContent(); + if (empty($content) === true) { + $this->helper->addMessage($errorPos, Helper::EMPTY_SEE, array('variable')); + continue; + } + + $spacing = substr_count($see->getWhitespaceBeforeContent(), ' '); + if ($spacing !== 1) { + $data = array($spacing); + $this->helper->addMessage($errorPos, Helper::SEE_INDENT, $data); + } + } + } + } + + /** + * Called to process a normal variable. + * + * Not required for this sniff. + * + * @param PHP_CodeSniffer_File $phpcsFile The PHP_CodeSniffer file where this token was found. + * @param int $stackPtr The position where the double quoted + * string was found. + * + * @return void + */ + protected function processVariable(PHP_CodeSniffer_File $phpcsFile, $stackPtr) + { + } + + /** + * Called to process variables found in double quoted strings. + * + * Not required for this sniff. + * + * @param PHP_CodeSniffer_File $phpcsFile The PHP_CodeSniffer file where this token was found. + * @param int $stackPtr The position where the double quoted + * string was found. + * + * @return void + */ + protected function processVariableInString(PHP_CodeSniffer_File $phpcsFile, $stackPtr) + { + } +} diff --git a/dev/tests/static/framework/Magento/Sniffs/Annotations/RequireAnnotatedMethodsSniff.php b/dev/tests/static/framework/Magento/Sniffs/Annotations/RequireAnnotatedMethodsSniff.php new file mode 100644 index 0000000000000000000000000000000000000000..e932c1d48dcff1bb0b0d413dbc9191aae27a66b4 --- /dev/null +++ b/dev/tests/static/framework/Magento/Sniffs/Annotations/RequireAnnotatedMethodsSniff.php @@ -0,0 +1,788 @@ +<?php +namespace Magento\Sniffs\Annotations; + +use \PHP_CodeSniffer_Sniff; +use \PHP_CodeSniffer_File; +use \PHP_CodeSniffer_CommentParser_FunctionCommentParser; +use \PHP_CodeSniffer_CommentParser_ParserException; +use \PHP_CodeSniffer_Tokens; + +include_once 'Helper.php'; +/** + * Parses and verifies the doc comments for functions. + * + * PHP version 5 + * + * @category PHP + * @package PHP_CodeSniffer + * @author Greg Sherwood <gsherwood@squiz.net> + * @author Marc McIntyre <mmcintyre@squiz.net> + * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + * @link http://pear.php.net/package/PHP_CodeSniffer + * + * @SuppressWarnings(PHPMD) + */ +class RequireAnnotatedMethodsSniff implements PHP_CodeSniffer_Sniff +{ + /** + * The name of the method that we are currently processing. + * + * @var string + */ + private $_methodName = ''; + + /** + * The position in the stack where the function token was found. + * + * @var int + */ + private $_functionToken = null; + + /** + * The position in the stack where the class token was found. + * + * @var int + */ + private $_classToken = null; + + /** + * The index of the current tag we are processing. + * + * @var int + */ + private $_tagIndex = 0; + + /** + * The function comment parser for the current method. + * + * @var PHP_CodeSniffer_CommentParser_FunctionCommentParser + */ + protected $commentParser = null; + + /** + * The sniff helper for stuff shared between the annotations sniffs + * + * @var Helper + */ + protected $helper = null; + + /** + * Returns an array of tokens this test wants to listen for. + * + * @return array + */ + public function register() + { + return array(T_FUNCTION); + } + + /** + * Processes this test, when one of its tokens is encountered. + * + * @param PHP_CodeSniffer_File $phpcsFile The file being scanned. + * @param int $stackPtr The position of the current token + * in the stack passed in $tokens. + * + * @return void + */ + public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) + { + $this->helper = new Helper($phpcsFile); + + $tokens = $phpcsFile->getTokens(); + + $find = array(T_COMMENT, T_DOC_COMMENT, T_CLASS, T_FUNCTION, T_OPEN_TAG); + + $commentEnd = $phpcsFile->findPrevious($find, $stackPtr - 1); + + if ($commentEnd === false) { + return; + } + + // If the token that we found was a class or a function, then this + // function has no doc comment. + $code = $tokens[$commentEnd]['code']; + + if ($code === T_COMMENT) { + // The function might actually be missing a comment, and this last comment + // found is just commenting a bit of code on a line. So if it is not the + // only thing on the line, assume we found nothing. + $prevContent = $phpcsFile->findPrevious(PHP_CodeSniffer_Tokens::$emptyTokens, $commentEnd); + if ($tokens[$commentEnd]['line'] === $tokens[$commentEnd]['line']) { + $this->helper->addMessage($stackPtr, Helper::MISSING, array('function')); + } else { + $this->helper->addMessage($stackPtr, Helper::WRONG_STYLE, array('function')); + } + return; + } elseif ($code !== T_DOC_COMMENT) { + $this->helper->addMessage($stackPtr, Helper::MISSING, array('function')); + return; + } elseif (trim($tokens[$commentEnd]['content']) !== '*/') { + $this->helper->addMessage( + $commentEnd, + Helper::WRONG_END, + array(trim($tokens[$commentEnd]['content'])) + ); + return; + } + + // If there is any code between the function keyword and the doc block + // then the doc block is not for us. + $ignore = PHP_CodeSniffer_Tokens::$scopeModifiers; + $ignore[] = T_STATIC; + $ignore[] = T_WHITESPACE; + $ignore[] = T_ABSTRACT; + $ignore[] = T_FINAL; + $prevToken = $phpcsFile->findPrevious($ignore, $stackPtr - 1, null, true); + if ($prevToken !== $commentEnd) { + $this->helper->addMessage( + $stackPtr, + Helper::MISSING, + array('function') + ); + return; + } + + $this->_functionToken = $stackPtr; + + $this->_classToken = null; + foreach ($tokens[$stackPtr]['conditions'] as $condPtr => $condition) { + if ($condition === T_CLASS || $condition === T_INTERFACE) { + $this->_classToken = $condPtr; + break; + } + } + + // Find the first doc comment. + $commentStart = $phpcsFile->findPrevious(T_DOC_COMMENT, $commentEnd - 1, null, true) + 1; + $commentString = $phpcsFile->getTokensAsString($commentStart, $commentEnd - $commentStart + 1); + $this->_methodName = $phpcsFile->getDeclarationName($stackPtr); + + try { + $this->commentParser = new PHP_CodeSniffer_CommentParser_FunctionCommentParser($commentString, $phpcsFile); + $this->commentParser->parse(); + } catch (PHP_CodeSniffer_CommentParser_ParserException $e) { + $line = $e->getLineWithinComment() + $commentStart; + $this->helper->addMessage($line, Helper::FAILED_PARSE, array($e->getMessage())); + return; + } + + $comment = $this->commentParser->getComment(); + if (is_null($comment) === true) { + $this->helper->addMessage($commentStart, Helper::EMPTY_DOC, array('Function')); + return; + } + + // The first line of the comment should just be the /** code. + $eolPos = strpos($commentString, $phpcsFile->eolChar); + $firstLine = substr($commentString, 0, $eolPos); + if ($firstLine !== '/**') { + $this->helper->addMessage($commentStart, Helper::CONTENT_AFTER_OPEN); + } + + // If the comment has an inherit doc note just move on + if (preg_match('/\{\@inheritdoc\}/', $commentString)) { + return; + } elseif (preg_match('/\{?\@?inherit[dD]oc\}?/', $commentString)) { + $this->helper->addMessage($commentStart, Helper::INCORRECT_INHERIT_DOC); + return; + } + + $this->processParams($commentStart, $commentEnd); + $this->processSees($commentStart); + $this->processReturn($commentStart, $commentEnd); + $this->processThrows($commentStart); + + // Check for a comment description. + $short = $comment->getShortComment(); + if (trim($short) === '') { + $this->helper->addMessage($commentStart, Helper::MISSING_SHORT, array('function')); + return; + } + + // No extra newline before short description. + $newlineCount = 0; + $newlineSpan = strspn($short, $phpcsFile->eolChar); + if ($short !== '' && $newlineSpan > 0) { + $this->helper->addMessage( + $commentStart + 1, + Helper::SPACING_BEFORE_SHORT, + array('function') + ); + } + + $newlineCount = substr_count($short, $phpcsFile->eolChar) + 1; + + // Exactly one blank line between short and long description. + $long = $comment->getLongComment(); + if (empty($long) === false) { + $between = $comment->getWhiteSpaceBetween(); + $newlineBetween = substr_count($between, $phpcsFile->eolChar); + if ($newlineBetween !== 2) { + $this->helper->addMessage( + $commentStart + $newlineCount + 1, + Helper::SPACING_BETWEEN, + array('function') + ); + } + $newlineCount += $newlineBetween; + $testLong = trim($long); + if (preg_match('|\p{Lu}|u', $testLong[0]) === 0) { + $this->helper->addMessage( + $commentStart + $newlineCount, + Helper::LONG_NOT_CAPITAL, + array('Function') + ); + } + } + + // Exactly one blank line before tags. + $params = $this->commentParser->getTagOrders(); + if (count($params) > 1) { + $newlineSpan = $comment->getNewlineAfter(); + if ($newlineSpan !== 2) { + if ($long !== '') { + $newlineCount += substr_count($long, $phpcsFile->eolChar) - $newlineSpan + 1; + } + + $this->helper->addMessage( + $commentStart + $newlineCount, + Helper::SPACING_BEFORE_TAGS, + array('function') + ); + $short = rtrim($short, $phpcsFile->eolChar . ' '); + } + } + + // Short description must be single line and end with a full stop. + $testShort = trim($short); + $lastChar = $testShort[strlen($testShort) - 1]; + if (substr_count($testShort, $phpcsFile->eolChar) !== 0) { + $this->helper->addMessage($commentStart + 1, Helper::SHORT_SINGLE_LINE, array('Function')); + } + + if (preg_match('|\p{Lu}|u', $testShort[0]) === 0) { + $this->helper->addMessage($commentStart + 1, Helper::SHORT_NOT_CAPITAL, array('Function')); + } + + if ($lastChar !== '.') { + $this->helper->addMessage($commentStart + 1, Helper::SHORT_FULL_STOP, array('Function')); + } + + // Check for unknown/deprecated tags. + // For example call: $this->processUnknownTags($commentStart, $commentEnd); + + // The last content should be a newline and the content before + // that should not be blank. If there is more blank space + // then they have additional blank lines at the end of the comment. + $words = $this->commentParser->getWords(); + $lastPos = count($words) - 1; + if (trim( + $words[$lastPos - 1] + ) !== '' || strpos( + $words[$lastPos - 1], + $this->helper->getCurrentFile()->eolChar + ) === false || trim( + $words[$lastPos - 2] + ) === '' + ) { + $this->helper->addMessage($commentEnd, Helper::SPACING_AFTER, array('function')); + } + } + + /** + * Process the see tags. + * + * @param int $commentStart The position in the stack where the comment started. + * + * @return void + */ + protected function processSees($commentStart) + { + $sees = $this->commentParser->getSees(); + if (empty($sees) === false) { + $tagOrder = $this->commentParser->getTagOrders(); + $index = array_keys($this->commentParser->getTagOrders(), 'see'); + foreach ($sees as $i => $see) { + $errorPos = $commentStart + $see->getLine(); + $since = array_keys($tagOrder, 'since'); + if (count($since) === 1 && $this->_tagIndex !== 0) { + $this->_tagIndex++; + if ($index[$i] !== $this->_tagIndex) { + $this->helper->addMessage($errorPos, Helper::SEE_ORDER); + } + } + + $content = $see->getContent(); + if (empty($content) === true) { + $this->helper->addMessage($errorPos, Helper::EMPTY_SEE, array('function')); + continue; + } + } + } + } + + /** + * Process the return comment of this function comment. + * + * @param int $commentStart The position in the stack where the comment started. + * @param int $commentEnd The position in the stack where the comment ended. + * + * @return void + */ + protected function processReturn($commentStart, $commentEnd) + { + // Skip constructor and destructor. + $className = ''; + if ($this->_classToken !== null) { + $className = $this->helper->getCurrentFile()->getDeclarationName($this->_classToken); + $className = strtolower(ltrim($className, '_')); + } + + $methodName = strtolower(ltrim($this->_methodName, '_')); + $isSpecialMethod = $this->_methodName === '__construct' || $this->_methodName === '__destruct'; + $return = $this->commentParser->getReturn(); + + if ($isSpecialMethod === false && $methodName !== $className) { + if ($return !== null) { + $tagOrder = $this->commentParser->getTagOrders(); + $index = array_keys($tagOrder, 'return'); + $errorPos = $commentStart + $return->getLine(); + $content = trim($return->getRawContent()); + + if (count($index) > 1) { + $this->helper->addMessage($errorPos, Helper::DUPLICATE_RETURN); + return; + } + + $since = array_keys($tagOrder, 'since'); + if (count($since) === 1 && $this->_tagIndex !== 0) { + $this->_tagIndex++; + if ($index[0] !== $this->_tagIndex) { + $this->helper->addMessage($errorPos, Helper::RETURN_ORDER); + } + } + + if (empty($content) === true) { + $this->helper->addMessage( + $errorPos, + Helper::MISSING_RETURN_TYPE + ); + } else { + // Check return type (can be multiple, separated by '|'). + $typeNames = explode('|', $content); + $suggestedNames = array(); + foreach ($typeNames as $i => $typeName) { + $suggestedName = $this->helper->suggestType($typeName); + if (in_array($suggestedName, $suggestedNames) === false) { + $suggestedNames[] = $suggestedName; + } + } + + $suggestedType = implode('|', $suggestedNames); + if ($content !== $suggestedType) { + $data = array($content); + $this->helper->addMessage( + $errorPos, + Helper::INVALID_RETURN, + $data + ); + } elseif ($this->helper->isAmbiguous($typeName, $matches)) { + // Warn about ambiguous types ie array or mixed + $data = array($matches[1], '@return'); + $this->helper->addMessage( + $errorPos, + Helper::AMBIGUOUS_TYPE, + $data + ); + } + + $tokens = $this->helper->getCurrentFile()->getTokens(); + + // If the return type is void, make sure there is + // no return statement in the function. + if ($content === 'void') { + if (isset($tokens[$this->_functionToken]['scope_closer']) === true) { + $endToken = $tokens[$this->_functionToken]['scope_closer']; + + $tokens = $this->helper->getCurrentFile()->getTokens(); + for ($returnToken = $this->_functionToken; $returnToken < $endToken; $returnToken++) { + if ($tokens[$returnToken]['code'] === T_CLOSURE) { + $returnToken = $tokens[$returnToken]['scope_closer']; + continue; + } + + if ($tokens[$returnToken]['code'] === T_RETURN) { + break; + } + } + + if ($returnToken !== $endToken) { + // If the function is not returning anything, just + // exiting, then there is no problem. + $semicolon = $this->helper->getCurrentFile()->findNext( + T_WHITESPACE, + $returnToken + 1, + null, + true + ); + if ($tokens[$semicolon]['code'] !== T_SEMICOLON) { + $this->helper->addMessage( + $errorPos, + Helper::INVALID_RETURN_VOID + ); + } + } + } + } elseif ($content !== 'mixed') { + // If return type is not void, there needs to be a + // returns statement somewhere in the function that + // returns something. + if (isset($tokens[$this->_functionToken]['scope_closer']) === true) { + $endToken = $tokens[$this->_functionToken]['scope_closer']; + $returnToken = $this->helper->getCurrentFile()->findNext( + T_RETURN, + $this->_functionToken, + $endToken + ); + if ($returnToken === false) { + $this->helper->addMessage( + $errorPos, + Helper::INVALID_NO_RETURN + ); + } else { + $semicolon = $this->helper->getCurrentFile()->findNext( + T_WHITESPACE, + $returnToken + 1, + null, + true + ); + if ($tokens[$semicolon]['code'] === T_SEMICOLON) { + $this->helper->addMessage( + $returnToken, + Helper::INVALID_RETURN_NOT_VOID + ); + } + } + } + } + + $spacing = substr_count($return->getWhitespaceBeforeValue(), ' '); + if ($spacing !== 1) { + $data = array($spacing); + $this->helper->addMessage( + $errorPos, + Helper::RETURN_INDENT, + $data + ); + } + } + } else { + $this->helper->addMessage($commentEnd, Helper::MISSING_RETURN); + } + } elseif ($return !== null) { + // No return tag for constructor and destructor. + $errorPos = $commentStart + $return->getLine(); + $this->helper->addMessage($errorPos, Helper::RETURN_NOT_REQUIRED); + } + } + + /** + * Process any throw tags that this function comment has. + * + * @param int $commentStart The position in the stack where the comment started. + * + * @return void + */ + protected function processThrows($commentStart) + { + if (count($this->commentParser->getThrows()) === 0) { + return; + } + + $tagOrder = $this->commentParser->getTagOrders(); + $index = array_keys($this->commentParser->getTagOrders(), 'throws'); + + foreach ($this->commentParser->getThrows() as $i => $throw) { + $exception = $throw->getValue(); + $content = trim($throw->getComment()); + $errorPos = $commentStart + $throw->getLine(); + if (empty($exception) === true) { + $this->helper->addMessage($errorPos, Helper::INVALID_THROWS); + } elseif (empty($content) === true) { + $this->helper->addMessage($errorPos, Helper::EMPTY_THROWS); + } else { + // Assumes that $content is not empty. + // Starts with a capital letter and ends with a fullstop. + $firstChar = $content[0]; + if (strtoupper($firstChar) !== $firstChar) { + $this->helper->addMessage( + $errorPos, + Helper::THROWS_NOT_CAPITAL + ); + } + + $lastChar = $content[strlen($content) - 1]; + if ($lastChar !== '.') { + $this->helper->addMessage( + $errorPos, + Helper::THROWS_NO_FULL_STOP + ); + } + } + + $since = array_keys($tagOrder, 'since'); + if (count($since) === 1 && $this->_tagIndex !== 0) { + $this->_tagIndex++; + if ($index[$i] !== $this->_tagIndex) { + $this->helper->addMessage($errorPos, Helper::THROWS_ORDER); + } + } + } + } + + /** + * Process the function parameter comments. + * + * @param int $commentStart The position in the stack where + * the comment started. + * @param int $commentEnd The position in the stack where + * the comment ended. + * + * @return void + */ + protected function processParams($commentStart, $commentEnd) + { + $realParams = $this->helper->getCurrentFile()->getMethodParameters($this->_functionToken); + $params = $this->commentParser->getParams(); + $foundParams = array(); + + if (empty($params) === false) { + $subStrCount = substr_count( + $params[count($params) - 1]->getWhitespaceAfter(), + $this->helper->getCurrentFile()->eolChar + ); + if ($subStrCount !== 2) { + $errorPos = $params[count($params) - 1]->getLine() + $commentStart; + $this->helper->addMessage($errorPos, Helper::SPACING_AFTER_PARAMS); + } + + // Parameters must appear immediately after the comment. + if ($params[0]->getOrder() !== 2) { + $errorPos = $params[0]->getLine() + $commentStart; + $this->helper->addMessage($errorPos, Helper::SPACING_BEFORE_PARAMS); + } + + $previousParam = null; + $spaceBeforeVar = 10000; + $spaceBeforeComment = 10000; + $longestType = 0; + $longestVar = 0; + + foreach ($params as $param) { + + $paramComment = trim($param->getComment()); + $errorPos = $param->getLine() + $commentStart; + + // Make sure that there is only one space before the var type. + if ($param->getWhitespaceBeforeType() !== ' ') { + $this->helper->addMessage( + $errorPos, + Helper::SPACING_BEFORE_PARAM_TYPE + ); + } + + $spaceCount = substr_count($param->getWhitespaceBeforeVarName(), ' '); + if ($spaceCount < $spaceBeforeVar) { + $spaceBeforeVar = $spaceCount; + $longestType = $errorPos; + } + + $spaceCount = substr_count($param->getWhitespaceBeforeComment(), ' '); + + if ($spaceCount < $spaceBeforeComment && $paramComment !== '') { + $spaceBeforeComment = $spaceCount; + $longestVar = $errorPos; + } + + // Make sure they are in the correct order, and have the correct name. + $pos = $param->getPosition(); + $paramName = $param->getVarName() !== '' ? $param->getVarName() : '[ UNKNOWN ]'; + + if ($previousParam !== null) { + $previousName = $previousParam->getVarName() !== '' ? $previousParam->getVarName() : 'UNKNOWN'; + } + + // Variable must be one of the supported standard type. + $typeNames = explode('|', $param->getType()); + foreach ($typeNames as $typeName) { + $suggestedName = $this->helper->suggestType($typeName); + if ($typeName !== $suggestedName) { + $data = array($suggestedName, $typeName, $paramName, $pos); + $this->helper->addMessage( + $errorPos, + Helper::INCORRECT_PARAM_VAR_NAME, + $data + ); + } elseif ($this->helper->isAmbiguous($typeName, $matches)) { + // Warn about ambiguous types ie array or mixed + $data = array($matches[1], $paramName, ' at position '.$pos.' is NOT recommended'); + $this->helper->addMessage( + $commentEnd + 2, + Helper::AMBIGUOUS_TYPE, + $data + ); + } elseif (count($typeNames) === 1) { + // Check type hint for array and custom type. + $suggestedTypeHint = ''; + if (strpos($suggestedName, 'array') !== false) { + $suggestedTypeHint = 'array'; + } elseif (strpos($suggestedName, 'callable') !== false) { + $suggestedTypeHint = 'callable'; + } elseif (in_array($typeName, $this->helper->getAllowedTypes()) === false) { + $suggestedTypeHint = $suggestedName; + } else { + $suggestedTypeHint = $this->helper->suggestType($typeName); + } + + if ($suggestedTypeHint !== '' && isset($realParams[$pos - 1]) === true) { + $typeHint = $realParams[$pos - 1]['type_hint']; + if ($typeHint === '') { + $data = array($suggestedTypeHint, $paramName, $pos); + $this->helper->addMessage( + $commentEnd + 2, + Helper::TYPE_HINT_MISSING, + $data + ); + } elseif ($typeHint !== $suggestedTypeHint) { + $data = array($suggestedTypeHint, $typeHint, $paramName, $pos); + $this->helper->addMessage( + $commentEnd + 2, + Helper::INCORRECT_TYPE_HINT, + $data + ); + } + } elseif ($suggestedTypeHint === '' && isset($realParams[$pos - 1]) === true) { + $typeHint = $realParams[$pos - 1]['type_hint']; + if ($typeHint !== '') { + $data = array($typeHint, $paramName, $pos); + $this->helper->addMessage( + $commentEnd + 2, + Helper::INVALID_TYPE_HINT, + $data + ); + } + } + } + } + + // Make sure the names of the parameter comment matches the + // actual parameter. + if (isset($realParams[$pos - 1]) === true) { + $realName = $realParams[$pos - 1]['name']; + $foundParams[] = $realName; + + // Append ampersand to name if passing by reference. + if ($realParams[$pos - 1]['pass_by_reference'] === true) { + $realName = '&' . $realName; + } + + if ($realName !== $paramName) { + $code = Helper::PARAM_NAME_NO_MATCH; + $data = array($paramName, $realName, $pos); + + if (strtolower($paramName) === strtolower($realName)) { + $code = Helper::PARAM_NAME_NO_CASE_MATCH; + } + + $this->helper->addMessage($errorPos, $code, $data); + } + } elseif (substr($paramName, -4) !== ',...') { + // We must have an extra parameter comment. + $this->helper->addMessage( + $errorPos, + Helper::EXTRA_PARAM_COMMENT, + array($pos) + ); + } + + if ($param->getVarName() === '') { + $this->helper->addMessage( + $errorPos, + Helper::MISSING_PARAM_NAME, + array($pos) + ); + } + + if ($param->getType() === '') { + $this->helper->addMessage( + $errorPos, + Helper::MISSING_PARAM_TYPE, + array($pos) + ); + } + + if ($paramComment === '') { + $data = array($paramName, $pos); + $this->helper->addMessage( + $errorPos, + Helper::MISSING_PARAM_COMMENT, + $data + ); + } else { + // Param comments must start with a capital letter and + // end with the full stop. + $firstChar = $paramComment[0]; + if (preg_match('|\p{Lu}|u', $firstChar) === 0) { + $this->helper->addMessage( + $errorPos, + Helper::PARAM_COMMENT_NOT_CAPITAL + ); + } + $lastChar = $paramComment[strlen($paramComment) - 1]; + if ($lastChar !== '.') { + $this->helper->addMessage( + $errorPos, + Helper::PARAM_COMMENT_FULL_STOP + ); + } + } + + $previousParam = $param; + } + + if ($spaceBeforeVar !== 1 && $spaceBeforeVar !== 10000 && $spaceBeforeComment !== 10000) { + $this->helper->addMessage( + $longestType, + Helper::SPACING_AFTER_LONG_TYPE + ); + } + + if ($spaceBeforeComment !== 1 && $spaceBeforeComment !== 10000) { + $this->helper->addMessage( + $longestVar, + Helper::SPACING_AFTER_LONG_NAME + ); + } + } + + $realNames = array(); + foreach ($realParams as $realParam) { + $realNames[] = $realParam['name']; + } + + // Report missing comments. + $diff = array_diff($realNames, $foundParams); + foreach ($diff as $neededParam) { + if (count($params) !== 0) { + $errorPos = $params[count($params) - 1]->getLine() + $commentStart; + } else { + $errorPos = $commentStart; + } + + $data = array($neededParam); + $this->helper->addMessage($errorPos, Helper::MISSING_PARAM_TAG, $data); + } + } +} diff --git a/dev/tests/static/framework/Magento/TestFramework/CodingStandard/Tool/CodeSniffer.php b/dev/tests/static/framework/Magento/TestFramework/CodingStandard/Tool/CodeSniffer.php index 7f7a1b13b40a652072c908fcba5f577842a7c117..872b5cad61f77f63158606a15f7a012c48abee01 100644 --- a/dev/tests/static/framework/Magento/TestFramework/CodingStandard/Tool/CodeSniffer.php +++ b/dev/tests/static/framework/Magento/TestFramework/CodingStandard/Tool/CodeSniffer.php @@ -18,9 +18,6 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Magento - * @package Magento - * @subpackage static_tests * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ @@ -30,43 +27,45 @@ */ namespace Magento\TestFramework\CodingStandard\Tool; -class CodeSniffer - implements \Magento\TestFramework\CodingStandard\ToolInterface +use Magento\TestFramework\CodingStandard\Tool\CodeSniffer\Wrapper; +use Magento\TestFramework\CodingStandard\ToolInterface; + +class CodeSniffer implements ToolInterface { /** * Ruleset directory * * @var string */ - protected $_rulesetDir; + protected $rulesetDir; /** * Report file * * @var string */ - protected $_reportFile; + protected $reportFile; /** * PHPCS cli tool wrapper * - * @var \Magento\TestFramework\CodingStandard\Tool\CodeSniffer\Wrapper + * @var Wrapper */ - protected $_wrapper; + protected $wrapper; /** * Constructor * * @param string $rulesetDir \Directory that locates the inspection rules * @param string $reportFile Destination file to write inspection report to - * @param \Magento\TestFramework\CodingStandard\Tool\CodeSniffer\Wrapper $wrapper + * @param Wrapper $wrapper */ public function __construct($rulesetDir, $reportFile, - \Magento\TestFramework\CodingStandard\Tool\CodeSniffer\Wrapper $wrapper + Wrapper $wrapper ) { - $this->_reportFile = $reportFile; - $this->_rulesetDir = $rulesetDir; - $this->_wrapper = $wrapper; + $this->reportFile = $reportFile; + $this->rulesetDir = $rulesetDir; + $this->wrapper = $wrapper; } /** @@ -86,11 +85,11 @@ class CodeSniffer */ public function version() { - return $this->_wrapper->version(); + return $this->wrapper->version(); } /** - * Run tool for files cpecified + * Run tool for files specified * * @param array $whiteList Files/directories to be inspected * @param array $blackList Files/directories to be excluded from the inspection @@ -109,19 +108,19 @@ class CodeSniffer return preg_quote($item); }, $blackList); - $this->_wrapper->checkRequirements(); - $settings = $this->_wrapper->getDefaults(); + $this->wrapper->checkRequirements(); + $settings = $this->wrapper->getDefaults(); $settings['files'] = $whiteList; - $settings['standard'] = $this->_rulesetDir; + $settings['standard'] = $this->rulesetDir; $settings['ignored'] = $blackList; $settings['extensions'] = $extensions; - $settings['reportFile'] = $this->_reportFile; + $settings['reportFile'] = $this->reportFile; $settings['warningSeverity'] = $warningSeverity; $settings['reports']['checkstyle'] = null; - $this->_wrapper->setValues($settings); + $this->wrapper->setValues($settings); ob_start(); - $result = $this->_wrapper->process(); + $result = $this->wrapper->process(); ob_end_clean(); return $result; } @@ -133,6 +132,6 @@ class CodeSniffer */ public function getReportFile() { - return $this->_reportFile; + return $this->reportFile; } } diff --git a/dev/tests/static/framework/Magento/TestFramework/Dependency/LayoutRule.php b/dev/tests/static/framework/Magento/TestFramework/Dependency/LayoutRule.php index 099f3ac46e861842dcea098bbfb281591c701180..356768a8254a65d4079509edb33e7fe26871ce9e 100644 --- a/dev/tests/static/framework/Magento/TestFramework/Dependency/LayoutRule.php +++ b/dev/tests/static/framework/Magento/TestFramework/Dependency/LayoutRule.php @@ -227,7 +227,7 @@ class LayoutRule implements \Magento\TestFramework\Dependency\RuleInterface */ protected function _caseLayoutHandle($currentModule, $file, &$contents) { - $xml = @simplexml_load_string($contents); + $xml = simplexml_load_string($contents); if (!$xml) { return array(); } @@ -265,7 +265,7 @@ class LayoutRule implements \Magento\TestFramework\Dependency\RuleInterface */ protected function _caseLayoutHandleParent($currentModule, $file, &$contents) { - $xml = @simplexml_load_string($contents); + $xml = simplexml_load_string($contents); if (!$xml) { return array(); } @@ -303,7 +303,7 @@ class LayoutRule implements \Magento\TestFramework\Dependency\RuleInterface */ protected function _caseLayoutHandleUpdate($currentModule, $file, &$contents) { - $xml = @simplexml_load_string($contents); + $xml = simplexml_load_string($contents); if (!$xml) { return array(); } @@ -341,7 +341,7 @@ class LayoutRule implements \Magento\TestFramework\Dependency\RuleInterface */ protected function _caseLayoutReference($currentModule, $file, &$contents) { - $xml = @simplexml_load_string($contents); + $xml = simplexml_load_string($contents); if (!$xml) { return array(); } diff --git a/dev/tests/static/testsuite/Magento/Test/Php/_files/phpcs/Magento/ruleset.xml b/dev/tests/static/framework/Magento/ruleset.xml similarity index 100% rename from dev/tests/static/testsuite/Magento/Test/Php/_files/phpcs/Magento/ruleset.xml rename to dev/tests/static/framework/Magento/ruleset.xml diff --git a/dev/tests/static/framework/tests/unit/testsuite/Magento/TestFramework/Dependency/LayoutRuleTest.php b/dev/tests/static/framework/tests/unit/testsuite/Magento/TestFramework/Dependency/LayoutRuleTest.php index 412bb29ba0e9ec94c495b511bad4bac55281b88f..9edb4465a3a8b57669bfbfb37f9a1f09d994b8e1 100644 --- a/dev/tests/static/framework/tests/unit/testsuite/Magento/TestFramework/Dependency/LayoutRuleTest.php +++ b/dev/tests/static/framework/tests/unit/testsuite/Magento/TestFramework/Dependency/LayoutRuleTest.php @@ -51,39 +51,41 @@ class LayoutRuleTest extends \PHPUnit_Framework_TestCase { return [ [ - '<element module="Magento\AnotherModule">', + '<element module="Magento\AnotherModule"/>', [[ 'module' => 'Magento\AnotherModule', 'type' => \Magento\Test\Integrity\DependencyTest::TYPE_SOFT, - 'source' => '<element module="Magento\AnotherModule">', + 'source' => '<element module="Magento\AnotherModule"/>', ]] ], [ - '<element module="Magento\SomeModule">', + '<element module="Magento\SomeModule"/>', [] ], [ - '<block class="Magento\AnotherModule\Several\Chunks">', + '<block class="Magento\AnotherModule\Several\Chunks"/>', [[ 'module' => 'Magento\AnotherModule', 'type' => \Magento\Test\Integrity\DependencyTest::TYPE_HARD, - 'source' => '<block class="Magento\AnotherModule\Several\Chunks">', + 'source' => '<block class="Magento\AnotherModule\Several\Chunks"/>', ]] ], [ - '<block class="Magento\SomeModule\Several\Chunks">', + '<block class="Magento\SomeModule\Several\Chunks"/>', [] ], [ - '<extra></extra><block template="Magento_AnotherModule::template/path.phtml">', + '<any> + <extra></extra><block template="Magento_AnotherModule::template/path.phtml"/> + </any>', [[ 'module' => 'Magento\AnotherModule', 'type' => \Magento\Test\Integrity\DependencyTest::TYPE_SOFT, - 'source' => '<block template="Magento_AnotherModule::template/path.phtml">', + 'source' => '<block template="Magento_AnotherModule::template/path.phtml"/>', ]] ], [ - '<block template="Magento_SomeModule::template/path.phtml">', + '<block template="Magento_SomeModule::template/path.phtml"/>', [] ], [ @@ -123,15 +125,15 @@ class LayoutRuleTest extends \PHPUnit_Framework_TestCase [] ], [ - '<any helper="Magento\AnotherModule\Several\Chunks::text">', + '<any helper="Magento\AnotherModule\Several\Chunks::text"/>', [[ 'module' => 'Magento\AnotherModule', 'type' => \Magento\Test\Integrity\DependencyTest::TYPE_SOFT, - 'source' => '<any helper="Magento\AnotherModule\Several\Chunks::text">', + 'source' => '<any helper="Magento\AnotherModule\Several\Chunks::text"/>', ]] ], [ - '<any helper="Magento\SomeModule\Several\Chunks::text">', + '<any helper="Magento\SomeModule\Several\Chunks::text"/>', [] ], ]; diff --git a/dev/tests/static/testsuite/Magento/Test/Integrity/ConcreteImplementationTest.php b/dev/tests/static/testsuite/Magento/Test/Integrity/ConcreteImplementationTest.php index 6e9dbec4f5116d1823f9379fb21723154875fe15..fb3d2f0351f223277055b024664d8d0b4151905c 100644 --- a/dev/tests/static/testsuite/Magento/Test/Integrity/ConcreteImplementationTest.php +++ b/dev/tests/static/testsuite/Magento/Test/Integrity/ConcreteImplementationTest.php @@ -50,6 +50,10 @@ class ConcreteImplementationTest extends \PHPUnit_Framework_TestCase function ($file) { $content = file_get_contents($file); + if (strpos($content, "namespace Magento\Core") !== false) { + return; + } + $result = (bool)preg_match( '/function __construct\(([^\)]*)\)/iS', $content, diff --git a/dev/tests/static/testsuite/Magento/Test/Integrity/_files/classes/blacklist.txt b/dev/tests/static/testsuite/Magento/Test/Integrity/_files/classes/blacklist.txt index 1f94e467559bb55fae0e5107ba6af6e23fd4e738..4443eb218ec57b3a94a97413a3823932d0891362 100644 --- a/dev/tests/static/testsuite/Magento/Test/Integrity/_files/classes/blacklist.txt +++ b/dev/tests/static/testsuite/Magento/Test/Integrity/_files/classes/blacklist.txt @@ -3,4 +3,20 @@ \Magento\Core\Model\Url\SecurityInfo \Magento\Core\Model\Url\ScopeResolver \Magento\Url -\Magento\Core\Model\Config +\Magento\App\Config +\Magento\App\ReinitableConfig +\Magento\Core\Model\Config\Scope\ReaderPool +\Magento\Core\Model\Config\Scope\Store\Converter +\Magento\Core\Model\Config\Scope\Reader\DefaultReader +\Magento\Core\Model\Config\Scope\Reader\Store +\Magento\Core\Model\Config\Scope\Reader\Website +\Magento\Core\Model\Config\Scope\Processor\Placeholder +\Magento\Core\Model\Config\Storage\Db +\Magento\Core\Model\Config\Value +\Magento\Core\Model\Config\FileResolver +\Magento\Core\Model\Config\Cache +\Magento\Core\Model\Config\Base +\Magento\Core\Model\Translate\String +\Magento\Core\Model\Translate\Inline\Config +\Magento\Core\Model\Translate\Inline\Parser +\Magento\Translate \ No newline at end of file diff --git a/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_constants.php b/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_constants.php index 982d56711acfd1b844c36451b6411779ac8f3e32..a92aa0502174e6984213968869cd22a7de3ce006 100644 --- a/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_constants.php +++ b/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_constants.php @@ -37,7 +37,7 @@ return array( 'Magento\Core\Model\Resource\Db\Collection\AbstractCollection', 'Magento_Core_Model_Cache_Type_Collection::CACHE_TAG' ), - array('CACHE_TAG', 'Magento\Core\Model\Translate', 'Magento_Core_Model_Cache_Type_Translate::CACHE_TAG'), + array('CACHE_TAG', 'Magento\Translate', 'Magento_Core_Model_Cache_Type_Translate::CACHE_TAG'), array('CACHE_TAG', 'Magento\Rss\Block\Catalog\NotifyStock'), array('CACHE_TAG', 'Magento\Rss\Block\Catalog\Review'), array('CACHE_TAG', 'Magento\Rss\Block\Order\NewOrder'), diff --git a/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_methods.php b/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_methods.php index b4ac933e9ce510d7e88b17399d1068c9d5301872..47489e0f5125a8416523783e5faab271bd8b316c 100644 --- a/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_methods.php +++ b/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_methods.php @@ -400,7 +400,7 @@ return array( ), array('getInstance', 'Magento\TestFramework\Bootstrap', 'Magento_TestFramework_Helper_Bootstrap::getInstance'), array('getIsActiveAanalytics', '', 'getOnsubmitJs'), - array('getIsAjaxRequest', 'Magento\Core\Model\Translate\Inline'), + array('getIsAjaxRequest', 'Magento\Translate\Inline'), array('getIsEngineAvailable'), array('getIsGlobal', 'Magento\Eav\Model\Entity\Attribute\AbstractAttribute'), array('getIsInStock', 'Magento\Checkout\Block\Cart\Item\Renderer'), @@ -665,6 +665,7 @@ return array( array('preprocess', 'Magento\Newsletter\Model\Template'), array('processBeacon'), array('processBeforeVoid', 'Magento\Payment\Model\Method\AbstractMethod'), + array('canUseForMultishipping', 'Magento\Payment\Model\Method\AbstractMethod'), array('processRequest', 'Magento\App\Cache'), array('processSubst', 'Magento\Core\Model\Store'), array('productEventAggregate'), @@ -706,7 +707,7 @@ return array( array('setCustomerId', 'Magento\Customer\Model\Resource\Address'), array('setDirectOutput', 'Magento\Core\Model\Layout'), array('setInstance', 'Magento\TestFramework\Bootstrap', 'Magento_TestFramework_Helper_Bootstrap::setInstance'), - array('setIsAjaxRequest', 'Magento\Core\Model\Translate\Inline'), + array('setIsAjaxRequest', 'Magento\Translate\Inline'), array('setNeedUsePriceExcludeTax', '', 'Magento_Tax_Model_Config::setPriceIncludesTax()'), array('setOption', 'Magento\Captcha\Helper\Data'), array('setOptions', 'Magento\Core\Model\Config'), diff --git a/dev/tests/static/testsuite/Magento/Test/Php/LiveCodeTest.php b/dev/tests/static/testsuite/Magento/Test/Php/LiveCodeTest.php index 7d2bb7b346e73ab8162a379d3df81a2987921349..459155c3c31f5046cf1ebd58986011e46c02d10a 100644 --- a/dev/tests/static/testsuite/Magento/Test/Php/LiveCodeTest.php +++ b/dev/tests/static/testsuite/Magento/Test/Php/LiveCodeTest.php @@ -25,34 +25,40 @@ */ namespace Magento\Test\Php; +use Magento\TestFramework\CodingStandard\Tool\CodeMessDetector; +use Magento\TestFramework\CodingStandard\Tool\CodeSniffer\Wrapper; +use Magento\TestFramework\CodingStandard\Tool\CodeSniffer; +use Magento\TestFramework\CodingStandard\Tool\CopyPasteDetector; use Magento\TestFramework\Utility; +use PHP_PMD_TextUI_Command; +use PHPUnit_Framework_TestCase; /** * Set of tests for static code analysis, e.g. code style, code complexity, copy paste detecting, etc. */ -class LiveCodeTest extends \PHPUnit_Framework_TestCase +class LiveCodeTest extends PHPUnit_Framework_TestCase { /** * @var string */ - protected static $_reportDir = ''; + protected static $reportDir = ''; /** * @var array */ - protected static $_whiteList = array(); + protected static $whiteList = array(); /** * @var array */ - protected static $_blackList = array(); + protected static $blackList = array(); public static function setUpBeforeClass() { - self::$_reportDir = Utility\Files::init()->getPathToSource() + self::$reportDir = Utility\Files::init()->getPathToSource() . '/dev/tests/static/report'; - if (!is_dir(self::$_reportDir)) { - mkdir(self::$_reportDir, 0777); + if (!is_dir(self::$reportDir)) { + mkdir(self::$reportDir, 0777); } self::setupFileLists(); } @@ -62,8 +68,8 @@ class LiveCodeTest extends \PHPUnit_Framework_TestCase if ($type != '' && !preg_match('/\/$/', $type)) { $type = $type . '/'; } - self::$_whiteList = Utility\Files::readLists(__DIR__ . '/_files/' . $type . 'whitelist/*.txt'); - self::$_blackList = Utility\Files::readLists(__DIR__ . '/_files/' . $type . 'blacklist/*.txt'); + self::$whiteList = Utility\Files::readLists(__DIR__ . '/_files/' . $type . 'whitelist/*.txt'); + self::$blackList = Utility\Files::readLists(__DIR__ . '/_files/' . $type . 'blacklist/*.txt'); } /** @@ -71,9 +77,9 @@ class LiveCodeTest extends \PHPUnit_Framework_TestCase */ public function testCodeStylePsr2() { - $reportFile = self::$_reportDir . '/phpcs_psr2_report.xml'; - $wrapper = new \Magento\TestFramework\CodingStandard\Tool\CodeSniffer\Wrapper(); - $codeSniffer = new \Magento\TestFramework\CodingStandard\Tool\CodeSniffer( + $reportFile = self::$reportDir . '/phpcs_psr2_report.xml'; + $wrapper = new Wrapper(); + $codeSniffer = new CodeSniffer( 'PSR2', $reportFile, $wrapper @@ -85,7 +91,7 @@ class LiveCodeTest extends \PHPUnit_Framework_TestCase $this->markTestSkipped('PHP Code Sniffer Build Too Old.'); } self::setupFileLists('phpcs'); - $result = $codeSniffer->run(self::$_whiteList, self::$_blackList, array('php')); + $result = $codeSniffer->run(self::$whiteList, self::$blackList, array('php')); $this->assertFileExists( $reportFile, 'Expected ' . $reportFile . ' to be created by phpcs run with PSR2 standard' @@ -100,9 +106,9 @@ class LiveCodeTest extends \PHPUnit_Framework_TestCase public function testCodeStyle() { - $reportFile = self::$_reportDir . '/phpcs_report.xml'; - $wrapper = new \Magento\TestFramework\CodingStandard\Tool\CodeSniffer\Wrapper(); - $codeSniffer = new \Magento\TestFramework\CodingStandard\Tool\CodeSniffer( + $reportFile = self::$reportDir . '/phpcs_report.xml'; + $wrapper = new Wrapper(); + $codeSniffer = new CodeSniffer( realpath(__DIR__ . '/_files/phpcs'), $reportFile, $wrapper @@ -111,7 +117,7 @@ class LiveCodeTest extends \PHPUnit_Framework_TestCase $this->markTestSkipped('PHP Code Sniffer is not installed.'); } self::setupFileLists(); - $result = $codeSniffer->run(self::$_whiteList, self::$_blackList, array('php', 'phtml')); + $result = $codeSniffer->run(self::$whiteList, self::$blackList, array('php', 'phtml')); $this->assertEquals( 0, $result, @@ -121,19 +127,19 @@ class LiveCodeTest extends \PHPUnit_Framework_TestCase public function testAnnotationStandard() { - $reportFile = self::$_reportDir . '/phpcs_annotations_report.xml'; + $reportFile = self::$reportDir . '/phpcs_annotations_report.xml'; $warningSeverity = 5; - $wrapper = new \Magento\TestFramework\CodingStandard\Tool\CodeSniffer\Wrapper(); - $codeSniffer = new \Magento\TestFramework\CodingStandard\Tool\CodeSniffer( - realpath(__DIR__ . '/_files/phpcs/Magento'), + $wrapper = new Wrapper(); + $codeSniffer = new CodeSniffer( + realpath(__DIR__ . '/../../../../framework/Magento/ruleset.xml'), $reportFile, $wrapper ); if (!$codeSniffer->canRun()) { $this->markTestSkipped('PHP Code Sniffer is not installed.'); } - self::setupFileLists(); - $result = $codeSniffer->run(self::$_whiteList, self::$_blackList, array('php', 'phtml'), $warningSeverity); + self::setupFileLists('phpcs'); + $result = $codeSniffer->run(self::$whiteList, self::$blackList, array('php', 'phtml'), $warningSeverity); $this->markTestIncomplete("PHP Code Sniffer has found $result error(s): See detailed report in $reportFile"); $this->assertEquals( 0, @@ -144,8 +150,8 @@ class LiveCodeTest extends \PHPUnit_Framework_TestCase public function testCodeMess() { - $reportFile = self::$_reportDir . '/phpmd_report.xml'; - $codeMessDetector = new \Magento\TestFramework\CodingStandard\Tool\CodeMessDetector( + $reportFile = self::$reportDir . '/phpmd_report.xml'; + $codeMessDetector = new CodeMessDetector( realpath(__DIR__ . '/_files/phpmd/ruleset.xml'), $reportFile ); @@ -156,16 +162,16 @@ class LiveCodeTest extends \PHPUnit_Framework_TestCase self::setupFileLists(); $this->assertEquals( - \PHP_PMD_TextUI_Command::EXIT_SUCCESS, - $codeMessDetector->run(self::$_whiteList, self::$_blackList), + PHP_PMD_TextUI_Command::EXIT_SUCCESS, + $codeMessDetector->run(self::$whiteList, self::$blackList), "PHP Code Mess has found error(s): See detailed report in $reportFile" ); } public function testCopyPaste() { - $reportFile = self::$_reportDir . '/phpcpd_report.xml'; - $copyPasteDetector = new \Magento\TestFramework\CodingStandard\Tool\CopyPasteDetector($reportFile); + $reportFile = self::$reportDir . '/phpcpd_report.xml'; + $copyPasteDetector = new CopyPasteDetector($reportFile); if (!$copyPasteDetector->canRun()) { $this->markTestSkipped('PHP Copy/Paste Detector is not available.'); diff --git a/dev/tests/static/testsuite/Magento/Test/Php/_files/phpcs/Magento/Sniffs/Annotations/RequireAnnotatedMethodsSniff.php b/dev/tests/static/testsuite/Magento/Test/Php/_files/phpcs/Magento/Sniffs/Annotations/RequireAnnotatedMethodsSniff.php deleted file mode 100644 index 6bee378ab18a3e4b5e06d422a6eadd2825159930..0000000000000000000000000000000000000000 --- a/dev/tests/static/testsuite/Magento/Test/Php/_files/phpcs/Magento/Sniffs/Annotations/RequireAnnotatedMethodsSniff.php +++ /dev/null @@ -1,1022 +0,0 @@ -<?php -/** - * Parses and verifies the doc comments for functions. - * - * PHP version 5 - * - * @category PHP - * @package PHP_CodeSniffer - * @author Greg Sherwood <gsherwood@squiz.net> - * @author Marc McIntyre <mmcintyre@squiz.net> - * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600) - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence - * @link http://pear.php.net/package/PHP_CodeSniffer - * - * @SuppressWarnings(PHPMD) - */ -class Magento_Sniffs_Annotations_RequireAnnotatedMethodsSniff implements PHP_CodeSniffer_Sniff -{ - const AMBIGUOUS_TYPE = 'AmbiguousType'; - - const MISSING = 'Missing'; - - const WRONG_STYLE = 'WrongStyle'; - - const WRONG_END = 'WrongEnd'; - - const FAILED_PARSE = 'FailedParse'; - - const CONTENT_AFTER_OPEN = 'ContentAfterOpen'; - - const MISSING_SHORT = 'MissingShort'; - - const NO_DOC = 'Empty'; - - const SPACING_BEFORE_SHORT = 'SpacingBeforeShort'; - - const SPACING_BEFORE_TAGS = 'SpacingBeforeTags'; - - const SHORT_SINGLE_LINE = 'ShortSingleLine'; - - const SHORT_NOT_CAPITAL = 'ShortNotCapital'; - - const SPACING_AFTER = 'SpacingAfter'; - - const SEE_ORDER = 'SeeOrder'; - - const EMPTY_SEE = 'EmptySee'; - - const DUPLICATE_RETURN = 'DuplicateReturn'; - - const MISSING_PARAM_TAG = 'MissingParamTag'; - - const SPACING_AFTER_LONG_NAME = 'SpacingAfterLongName'; - - const SPACING_AFTER_LONG_TYPE = 'SpacingAfterLongType'; - - const MISSING_PARAM_TYPE = 'MissingParamType'; - - const MISSING_PARAM_NAME = 'MissingParamName'; - - const EXTRA_PARAM_COMMENT = 'ExtraParamComment'; - - const PARAM_NAME_NO_MATCH = 'ParamNameNoMatch'; - - const PARAM_NAME_NO_CASE_MATCH = 'ParamNameNoCaseMatch'; - - const INVALID_TYPE_HINT = 'InvalidTypeHint'; - - const INCORRECT_TYPE_HINT = 'IncorrectTypeHint'; - - const TYPE_HINT_MISSING = 'TypeHintMissing'; - - const INCORRECT_PARAM_VAR_NAME = 'IncorrectParamVarName'; - - const RETURN_ORDER = 'ReturnOrder'; - - const MISSING_RETURN_TYPE = 'MissingReturnType'; - - const INVALID_RETURN = 'InvalidReturn'; - - const INVALID_RETURN_VOID = 'InvalidReturnVoid'; - - const INVALID_NO_RETURN = 'InvalidNoReturn'; - - const INVALID_RETURN_NOT_VOID = 'InvalidReturnNotVoid'; - - const INCORRECT_INHERIT_DOC = 'IncorrectInheritDoc'; - - const RETURN_INDENT = 'ReturnIndent'; - - const MISSING_RETURN = 'MissingReturn'; - - const RETURN_NOT_REQUIRED = 'ReturnNotRequired'; - - const INVALID_THROWS = 'InvalidThrows'; - - const THROWS_NOT_CAPITAL = 'ThrowsNotCapital'; - - const THROWS_ORDER = 'ThrowsOrder'; - - const SPACING_AFTER_PARAMS = 'SpacingAfterParams'; - - const SPACING_BEFORE_PARAMS = 'SpacingBeforeParams'; - - const SPACING_BEFORE_PARAM_TYPE = 'SpacingBeforeParamType'; - - const ERROR = 0; - - // tells phpcs to use the default level - const WARNING = 6; - - // default level of warnings is 5 - const INFO = 1; - - protected static $reportingLevel = array( - self::AMBIGUOUS_TYPE => self::WARNING, - self::MISSING => self::WARNING, - self::WRONG_STYLE => self::WARNING, - self::WRONG_END => self::WARNING, - self::FAILED_PARSE => self::WARNING, - self::NO_DOC => self::WARNING, - self::CONTENT_AFTER_OPEN => self::WARNING, - self::MISSING_SHORT => self::WARNING, - self::NO_DOC => self::WARNING, - self::SPACING_BEFORE_SHORT => self::WARNING, - self::SPACING_BEFORE_TAGS => self::WARNING, - self::SHORT_SINGLE_LINE => self::WARNING, - self::SHORT_NOT_CAPITAL => self::WARNING, - self::SPACING_AFTER => self::WARNING, - self::SEE_ORDER => self::WARNING, - self::EMPTY_SEE => self::WARNING, - self::DUPLICATE_RETURN => self::WARNING, - self::MISSING_PARAM_TAG => self::WARNING, - self::SPACING_AFTER_LONG_NAME => self::WARNING, - self::SPACING_AFTER_LONG_TYPE => self::WARNING, - self::MISSING_PARAM_TYPE => self::WARNING, - self::MISSING_PARAM_NAME => self::WARNING, - self::EXTRA_PARAM_COMMENT => self::WARNING, - self::PARAM_NAME_NO_MATCH => self::WARNING, - self::PARAM_NAME_NO_CASE_MATCH => self::WARNING, - self::INVALID_TYPE_HINT => self::WARNING, - self::INCORRECT_TYPE_HINT => self::WARNING, - self::TYPE_HINT_MISSING => self::WARNING, - self::INCORRECT_PARAM_VAR_NAME => self::WARNING, - self::RETURN_ORDER => self::WARNING, - self::MISSING_RETURN_TYPE => self::WARNING, - self::INVALID_RETURN => self::WARNING, - self::INVALID_RETURN_VOID => self::WARNING, - self::INVALID_NO_RETURN => self::WARNING, - self::INVALID_RETURN_NOT_VOID => self::WARNING, - self::INCORRECT_INHERIT_DOC => self::WARNING, - self::RETURN_INDENT => self::WARNING, - self::MISSING_RETURN => self::WARNING, - self::RETURN_NOT_REQUIRED => self::WARNING, - self::INVALID_THROWS => self::WARNING, - self::THROWS_NOT_CAPITAL => self::WARNING, - self::THROWS_ORDER => self::WARNING, - self::SPACING_AFTER_PARAMS => self::WARNING, - self::SPACING_BEFORE_PARAMS => self::WARNING, - self::SPACING_BEFORE_PARAM_TYPE => self::WARNING - ); - - /** - * List of allowed types - * - * @var string[] - */ - protected static $allowedTypes = array( - 'array', - 'boolean', - 'bool', - 'float', - 'integer', - 'int', - 'object', - 'string', - 'resource', - 'callable' - ); - - /** - * The name of the method that we are currently processing. - * - * @var string - */ - private $_methodName = ''; - - /** - * The position in the stack where the function token was found. - * - * @var int - */ - private $_functionToken = null; - - /** - * The position in the stack where the class token was found. - * - * @var int - */ - private $_classToken = null; - - /** - * The index of the current tag we are processing. - * - * @var int - */ - private $_tagIndex = 0; - - /** - * The function comment parser for the current method. - * - * @var PHP_CodeSniffer_Comment_Parser_FunctionCommentParser - */ - protected $commentParser = null; - - /** - * The current PHP_CodeSniffer_File object we are processing. - * - * @var PHP_CodeSniffer_File - */ - protected $currentFile = null; - - /** - * Returns an array of tokens this test wants to listen for. - * - * @return array - */ - public function register() - { - return array(T_FUNCTION); - } - - //end register() - - - /** - * Processes this test, when one of its tokens is encountered. - * - * @param PHP_CodeSniffer_File $phpcsFile The file being scanned. - * @param int $stackPtr The position of the current token - * in the stack passed in $tokens. - * - * @return void - */ - public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) - { - $this->currentFile = $phpcsFile; - - $tokens = $phpcsFile->getTokens(); - - $find = array(T_COMMENT, T_DOC_COMMENT, T_CLASS, T_FUNCTION, T_OPEN_TAG); - - $commentEnd = $phpcsFile->findPrevious($find, $stackPtr - 1); - - if ($commentEnd === false) { - return; - } - - // If the token that we found was a class or a function, then this - // function has no doc comment. - $code = $tokens[$commentEnd]['code']; - - if ($code === T_COMMENT) { - // The function might actually be missing a comment, and this last comment - // found is just commenting a bit of code on a line. So if it is not the - // only thing on the line, assume we found nothing. - $prevContent = $phpcsFile->findPrevious(PHP_CodeSniffer_Tokens::$emptyTokens, $commentEnd); - if ($tokens[$commentEnd]['line'] === $tokens[$commentEnd]['line']) { - $error = 'Missing function doc comment'; - $this->addMessage($error, $stackPtr, self::MISSING); - } else { - $error = 'You must use "/**" style comments for a function comment'; - $this->addMessage($error, $stackPtr, self::WRONG_STYLE); - } - return; - } else { - if ($code !== T_DOC_COMMENT) { - $error = 'Missing function doc comment'; - $this->addMessage($error, $stackPtr, self::MISSING); - return; - } else { - if (trim($tokens[$commentEnd]['content']) !== '*/') { - $error = 'You must use "*/" to end a function comment; found "%s"'; - $this->addMessage( - $error, - $commentEnd, - self::WRONG_END, - array(trim($tokens[$commentEnd]['content'])) - ); - return; - } - } - } - - // If there is any code between the function keyword and the doc block - // then the doc block is not for us. - $ignore = PHP_CodeSniffer_Tokens::$scopeModifiers; - $ignore[] = T_STATIC; - $ignore[] = T_WHITESPACE; - $ignore[] = T_ABSTRACT; - $ignore[] = T_FINAL; - $prevToken = $phpcsFile->findPrevious($ignore, $stackPtr - 1, null, true); - if ($prevToken !== $commentEnd) { - $this->addMessage('Missing function doc comment', $stackPtr, self::MISSING); - return; - } - - $this->_functionToken = $stackPtr; - - $this->_classToken = null; - foreach ($tokens[$stackPtr]['conditions'] as $condPtr => $condition) { - if ($condition === T_CLASS || $condition === T_INTERFACE) { - $this->_classToken = $condPtr; - break; - } - } - - // Find the first doc comment. - $commentStart = $phpcsFile->findPrevious(T_DOC_COMMENT, $commentEnd - 1, null, true) + 1; - $commentString = $phpcsFile->getTokensAsString($commentStart, $commentEnd - $commentStart + 1); - $this->_methodName = $phpcsFile->getDeclarationName($stackPtr); - - try { - $this->commentParser = new PHP_CodeSniffer_CommentParser_FunctionCommentParser($commentString, $phpcsFile); - $this->commentParser->parse(); - } catch (PHP_CodeSniffer_CommentParser_ParserException $e) { - $line = $e->getLineWithinComment() + $commentStart; - $this->addMessage($e->getMessage(), $line, self::FAILED_PARSE); - return; - } - - $comment = $this->commentParser->getComment(); - if (is_null($comment) === true) { - $error = 'Function doc comment is empty'; - $this->addMessage($error, $commentStart, self::NO_DOC); - return; - } - - // The first line of the comment should just be the /** code. - $eolPos = strpos($commentString, $phpcsFile->eolChar); - $firstLine = substr($commentString, 0, $eolPos); - if ($firstLine !== '/**') { - $error = 'The open comment tag must be the only content on the line'; - $this->addMessage($error, $commentStart, self::CONTENT_AFTER_OPEN); - } - - // If the comment has an inherit doc note just move on - if (preg_match('/\{\@inheritdoc\}/', $commentString)) { - return; - } else { - if (preg_match('/\{?\@?inherit[dD]oc\}?/', $commentString)) { - $error = 'The incorrect inherit doc tag usage. Should be {@inheritdoc}'; - $this->addMessage($error, $commentStart, self::INCORRECT_INHERIT_DOC); - return; - } - } - - $this->processParams($commentStart, $commentEnd); - $this->processSees($commentStart); - $this->processReturn($commentStart, $commentEnd); - $this->processThrows($commentStart); - - // Check for a comment description. - $short = $comment->getShortComment(); - if (trim($short) === '') { - $error = 'Missing short description in function doc comment'; - $this->addMessage($error, $commentStart, self::MISSING_SHORT); - return; - } - - // No extra newline before short description. - $newlineCount = 0; - $newlineSpan = strspn($short, $phpcsFile->eolChar); - if ($short !== '' && $newlineSpan > 0) { - $error = 'Extra newline(s) found before function comment short description'; - $this->addMessage($error, $commentStart + 1, self::SPACING_BEFORE_SHORT); - } - - $newlineCount = substr_count($short, $phpcsFile->eolChar) + 1; - - // Exactly one blank line between short and long description. - $long = $comment->getLongComment(); - /* Magento Standard Allows for no long description - if (empty($long) === false) { - $between = $comment->getWhiteSpaceBetween(); - $newlineBetween = substr_count($between, $phpcsFile->eolChar); - if ($newlineBetween !== 2) { - $error = 'There must be exactly one blank line between descriptions in function comment'; - $phpcsFile->addError($error, ($commentStart + $newlineCount + 1), 'SpacingBetween'); - } - $newlineCount += $newlineBetween; - $testLong = trim($long); - if (preg_match('|\p{Lu}|u', $testLong[0]) === 0) { - $error = 'Function comment long description must start with a capital letter'; - $phpcsFile->addError($error, ($commentStart + $newlineCount), 'LongNotCapital'); - } - }//end if - */ - - // Exactly one blank line before tags. - $params = $this->commentParser->getTagOrders(); - if (count($params) > 1) { - $newlineSpan = $comment->getNewlineAfter(); - if ($newlineSpan !== 2) { - $error = 'There must be exactly one blank line before the tags in function comment'; - if ($long !== '') { - $newlineCount += substr_count($long, $phpcsFile->eolChar) - $newlineSpan + 1; - } - - $this->addMessage($error, $commentStart + $newlineCount, self::SPACING_BEFORE_TAGS); - $short = rtrim($short, $phpcsFile->eolChar . ' '); - } - } - - // Short description must be single line and end with a full stop. - $testShort = trim($short); - $lastChar = $testShort[strlen($testShort) - 1]; - if (substr_count($testShort, $phpcsFile->eolChar) !== 0) { - $error = 'Function comment short description must be on a single line'; - $this->addMessage($error, $commentStart + 1, self::SHORT_SINGLE_LINE); - } - - if (preg_match('|\p{Lu}|u', $testShort[0]) === 0) { - $error = 'Function comment short description must start with a capital letter'; - $this->addMessage($error, $commentStart + 1, self::SHORT_NOT_CAPITAL); - } - - /* Magento standard does not require this. - if ($lastChar !== '.') { - $error = 'Function comment short description must end with a full stop'; - $phpcsFile->addError($error, ($commentStart + 1), 'ShortFullStop'); - } - */ - - // Check for unknown/deprecated tags. - /* Magento is not using this at the moment - $this->processUnknownTags($commentStart, $commentEnd); - */ - - // The last content should be a newline and the content before - // that should not be blank. If there is more blank space - // then they have additional blank lines at the end of the comment. - $words = $this->commentParser->getWords(); - $lastPos = count($words) - 1; - if (trim( - $words[$lastPos - 1] - ) !== '' || strpos( - $words[$lastPos - 1], - $this->currentFile->eolChar - ) === false || trim( - $words[$lastPos - 2] - ) === '' - ) { - $error = 'Additional blank lines found at end of function comment'; - $this->addMessage($error, $commentEnd, self::SPACING_AFTER); - } - } - - //end process() - - - /** - * Process the see tags. - * - * @param int $commentStart The position in the stack where the comment started. - * - * @return void - */ - protected function processSees($commentStart) - { - $sees = $this->commentParser->getSees(); - if (empty($sees) === false) { - $tagOrder = $this->commentParser->getTagOrders(); - $index = array_keys($this->commentParser->getTagOrders(), 'see'); - foreach ($sees as $i => $see) { - $errorPos = $commentStart + $see->getLine(); - $since = array_keys($tagOrder, 'since'); - if (count($since) === 1 && $this->_tagIndex !== 0) { - $this->_tagIndex++; - if ($index[$i] !== $this->_tagIndex) { - $error = 'The @see tag is in the wrong order; the tag precedes @return'; - $this->addMessage($error, $errorPos, self::SEE_ORDER); - } - } - - $content = $see->getContent(); - if (empty($content) === true) { - $error = 'Content missing for @see tag in function comment'; - $this->addMessage($error, $errorPos, self::EMPTY_SEE); - continue; - } - } - } - } - - //end processSees() - - - /** - * Process the return comment of this function comment. - * - * @param int $commentStart The position in the stack where the comment started. - * @param int $commentEnd The position in the stack where the comment ended. - * - * @return void - */ - protected function processReturn($commentStart, $commentEnd) - { - // Skip constructor and destructor. - $className = ''; - if ($this->_classToken !== null) { - $className = $this->currentFile->getDeclarationName($this->_classToken); - $className = strtolower(ltrim($className, '_')); - } - - $methodName = strtolower(ltrim($this->_methodName, '_')); - $isSpecialMethod = $this->_methodName === '__construct' || $this->_methodName === '__destruct'; - $return = $this->commentParser->getReturn(); - - if ($isSpecialMethod === false && $methodName !== $className) { - if ($return !== null) { - $tagOrder = $this->commentParser->getTagOrders(); - $index = array_keys($tagOrder, 'return'); - $errorPos = $commentStart + $return->getLine(); - $content = trim($return->getRawContent()); - - if (count($index) > 1) { - $error = 'Only 1 @return tag is allowed in function comment'; - $this->addMessage($error, $errorPos, self::DUPLICATE_RETURN); - return; - } - - $since = array_keys($tagOrder, 'since'); - if (count($since) === 1 && $this->_tagIndex !== 0) { - $this->_tagIndex++; - if ($index[0] !== $this->_tagIndex) { - $error = 'The @return tag is in the wrong order; the tag follows @see (if used)'; - $this->addMessage($error, $errorPos, self::RETURN_ORDER); - } - } - - if (empty($content) === true) { - $error = 'Return type missing for @return tag in function comment'; - $this->addMessage($error, $errorPos, self::MISSING_RETURN_TYPE); - } else { - // Check return type (can be multiple, separated by '|'). - $typeNames = explode('|', $content); - $suggestedNames = array(); - foreach ($typeNames as $i => $typeName) { - $suggestedName = $this->suggestType($typeName); - if (in_array($suggestedName, $suggestedNames) === false) { - $suggestedNames[] = $suggestedName; - } - } - - $suggestedType = implode('|', $suggestedNames); - if ($content !== $suggestedType) { - $error = 'Function return type "%s" is invalid'; - $data = array($content); - $this->addMessage($error, $errorPos, self::INVALID_RETURN, $data); - } elseif ($content === 'array' || $content === 'mixed') { - // Warn about ambiguous types ie array or mixed - $error = 'Ambiguous type "%s" for @return is NOT recommended'; - $data = array($typeName); - $this->addMessage($error, $errorPos, self::AMBIGUOUS_TYPE, $data); - } - - $tokens = $this->currentFile->getTokens(); - - // If the return type is void, make sure there is - // no return statement in the function. - if ($content === 'void') { - if (isset($tokens[$this->_functionToken]['scope_closer']) === true) { - $endToken = $tokens[$this->_functionToken]['scope_closer']; - - $tokens = $this->currentFile->getTokens(); - for ($returnToken = $this->_functionToken; $returnToken < $endToken; $returnToken++) { - if ($tokens[$returnToken]['code'] === T_CLOSURE) { - $returnToken = $tokens[$returnToken]['scope_closer']; - continue; - } - - if ($tokens[$returnToken]['code'] === T_RETURN) { - break; - } - } - - if ($returnToken !== $endToken) { - // If the function is not returning anything, just - // exiting, then there is no problem. - $semicolon = $this->currentFile->findNext(T_WHITESPACE, $returnToken + 1, null, true); - if ($tokens[$semicolon]['code'] !== T_SEMICOLON) { - $error = 'Function return type is void, but function contains return statement'; - $this->addMessage($error, $errorPos, self::INVALID_RETURN_VOID); - } - } - } - } else { - if ($content !== 'mixed') { - // If return type is not void, there needs to be a - // returns statement somewhere in the function that - // returns something. - if (isset($tokens[$this->_functionToken]['scope_closer']) === true) { - $endToken = $tokens[$this->_functionToken]['scope_closer']; - $returnToken = $this->currentFile->findNext( - T_RETURN, - $this->_functionToken, - $endToken - ); - if ($returnToken === false) { - $error = 'Function return type is not void, but function has no return statement'; - $this->addMessage($error, $errorPos, self::INVALID_NO_RETURN); - } else { - $semicolon = $this->currentFile->findNext( - T_WHITESPACE, - $returnToken + 1, - null, - true - ); - if ($tokens[$semicolon]['code'] === T_SEMICOLON) { - $error = 'Function return type is not void, ' . - 'but function is returning void here'; - $this->addMessage($error, $returnToken, self::INVALID_RETURN_NOT_VOID); - } - } - } - } - } - //end if - - $spacing = substr_count($return->getWhitespaceBeforeValue(), ' '); - if ($spacing !== 1) { - $error = '@return tag indented incorrectly; expected 1 space but found %s'; - $data = array($spacing); - $this->addMessage($error, $errorPos, self::RETURN_INDENT, $data); - } - } - } else { - $error = 'Missing @return tag in function comment'; - $this->addMessage($error, $commentEnd, self::MISSING_RETURN); - } - } else { - // No return tag for constructor and destructor. - if ($return !== null) { - $errorPos = $commentStart + $return->getLine(); - $error = '@return tag is not required for constructor and destructor'; - $this->addMessage($error, $errorPos, self::RETURN_NOT_REQUIRED); - } - } - } - - //end processReturn() - - - /** - * Process any throw tags that this function comment has. - * - * @param int $commentStart The position in the stack where the comment started. - * - * @return void - */ - protected function processThrows($commentStart) - { - if (count($this->commentParser->getThrows()) === 0) { - return; - } - - $tagOrder = $this->commentParser->getTagOrders(); - $index = array_keys($this->commentParser->getTagOrders(), 'throws'); - - foreach ($this->commentParser->getThrows() as $i => $throw) { - $exception = $throw->getValue(); - $content = trim($throw->getComment()); - $errorPos = $commentStart + $throw->getLine(); - if (empty($exception) === true) { - $error = 'Exception type and comment missing for @throws tag in function comment'; - $this->addMessage($error, $errorPos, self::INVALID_THROWS); - } else { - if (empty($content) === true) { - } else { - // Assumes that $content is not empty. - // Starts with a capital letter and ends with a fullstop. - $firstChar = $content[0]; - if (strtoupper($firstChar) !== $firstChar) { - $error = '@throws tag comment must start with a capital letter'; - $this->addMessage($error, $errorPos, self::THROWS_NOT_CAPITAL); - } - } - } - - $since = array_keys($tagOrder, 'since'); - if (count($since) === 1 && $this->_tagIndex !== 0) { - $this->_tagIndex++; - if ($index[$i] !== $this->_tagIndex) { - $error = 'The @throws tag is in the wrong order; the tag follows @return'; - $this->addMessage($error, $errorPos, self::THROWS_ORDER); - } - } - } - } - - //end processThrows() - - - /** - * Process the function parameter comments. - * - * @param int $commentStart The position in the stack where - * the comment started. - * @param int $commentEnd The position in the stack where - * the comment ended. - * - * @return void - */ - protected function processParams($commentStart, $commentEnd) - { - $realParams = $this->currentFile->getMethodParameters($this->_functionToken); - $params = $this->commentParser->getParams(); - $foundParams = array(); - - if (empty($params) === false) { - - if (substr_count($params[count($params) - 1]->getWhitespaceAfter(), $this->currentFile->eolChar) !== 2) { - $error = 'Last parameter comment requires a blank newline after it'; - $errorPos = $params[count($params) - 1]->getLine() + $commentStart; - $this->addMessage($error, $errorPos, self::SPACING_AFTER_PARAMS); - } - - // Parameters must appear immediately after the comment. - if ($params[0]->getOrder() !== 2) { - $error = 'Parameters must appear immediately after the comment'; - $errorPos = $params[0]->getLine() + $commentStart; - $this->addMessage($error, $errorPos, self::SPACING_BEFORE_PARAMS); - } - - $previousParam = null; - $spaceBeforeVar = 10000; - $spaceBeforeComment = 10000; - $longestType = 0; - $longestVar = 0; - - foreach ($params as $param) { - - $paramComment = trim($param->getComment()); - $errorPos = $param->getLine() + $commentStart; - - // Make sure that there is only one space before the var type. - if ($param->getWhitespaceBeforeType() !== ' ') { - $error = 'Expected 1 space before variable type'; - $this->addMessage($error, $errorPos, self::SPACING_BEFORE_PARAM_TYPE); - } - - $spaceCount = substr_count($param->getWhitespaceBeforeVarName(), ' '); - if ($spaceCount < $spaceBeforeVar) { - $spaceBeforeVar = $spaceCount; - $longestType = $errorPos; - } - - $spaceCount = substr_count($param->getWhitespaceBeforeComment(), ' '); - - if ($spaceCount < $spaceBeforeComment && $paramComment !== '') { - $spaceBeforeComment = $spaceCount; - $longestVar = $errorPos; - } - - // Make sure they are in the correct order, and have the correct name. - $pos = $param->getPosition(); - $paramName = $param->getVarName() !== '' ? $param->getVarName() : '[ UNKNOWN ]'; - - if ($previousParam !== null) { - $previousName = $previousParam->getVarName() !== '' ? $previousParam->getVarName() : 'UNKNOWN'; - } - - // Variable must be one of the supported standard type. - $typeNames = explode('|', $param->getType()); - foreach ($typeNames as $typeName) { - $suggestedName = $this->suggestType($typeName); - if ($typeName !== $suggestedName) { - $error = 'Expected "%s"; found "%s" for %s at position %s'; - $data = array($suggestedName, $typeName, $paramName, $pos); - $this->addMessage($error, $errorPos, self::INCORRECT_PARAM_VAR_NAME, $data); - } elseif ($typeName === 'array' || $typeName === 'mixed') { - // Warn about ambiguous types ie array or mixed - $error = 'Ambiguous type "%s" for %s at position %s is NOT recommended'; - $data = array($typeName, $paramName, $pos); - $this->addMessage($error, $commentEnd + 2, self::AMBIGUOUS_TYPE, $data); - } elseif (count($typeNames) === 1) { - // Check type hint for array and custom type. - $suggestedTypeHint = ''; - if (strpos($suggestedName, 'array') !== false) { - $suggestedTypeHint = 'array'; - } else { - if (strpos($suggestedName, 'callable') !== false) { - $suggestedTypeHint = 'callable'; - } else { - if (in_array($typeName, self::$allowedTypes) === false) { - $suggestedTypeHint = $suggestedName; - } else { - $suggestedTypeHint = $this->suggestType($typeName); - } - } - } - - if ($suggestedTypeHint !== '' && isset($realParams[$pos - 1]) === true) { - $typeHint = $realParams[$pos - 1]['type_hint']; - if ($typeHint === '') { - $error = 'Type hint "%s" missing for %s at position %s'; - $data = array($suggestedTypeHint, $paramName, $pos); - $this->addMessage($error, $commentEnd + 2, self::TYPE_HINT_MISSING, $data); - } else { - if ($typeHint !== $suggestedTypeHint) { - $error = 'Expected type hint "%s"; found "%s" for %s at position %s'; - $data = array($suggestedTypeHint, $typeHint, $paramName, $pos); - $this->addMessage($error, $commentEnd + 2, self::INCORRECT_TYPE_HINT, $data); - } - } - } else { - if ($suggestedTypeHint === '' && isset($realParams[$pos - 1]) === true) { - $typeHint = $realParams[$pos - 1]['type_hint']; - if ($typeHint !== '') { - $error = 'Unknown type hint "%s" found for %s at position %s'; - $data = array($typeHint, $paramName, $pos); - $this->addMessage($error, $commentEnd + 2, self::INVALID_TYPE_HINT, $data); - } - } - } - } - } - //end foreach - - // Make sure the names of the parameter comment matches the - // actual parameter. - if (isset($realParams[$pos - 1]) === true) { - $realName = $realParams[$pos - 1]['name']; - $foundParams[] = $realName; - - // Append ampersand to name if passing by reference. - if ($realParams[$pos - 1]['pass_by_reference'] === true) { - $realName = '&' . $realName; - } - - if ($realName !== $paramName) { - $code = self::PARAM_NAME_NO_MATCH; - $data = array($paramName, $realName, $pos); - - $error = 'Doc comment for var %s does not match '; - if (strtolower($paramName) === strtolower($realName)) { - $error .= 'case of '; - $code = self::PARAM_NAME_NO_CASE_MATCH; - } - - $error .= 'actual variable name %s at position %s'; - - $this->addMessage($error, $errorPos, $code, $data); - } - } else { - if (substr($paramName, -4) !== ',...') { - // We must have an extra parameter comment. - $error = 'Superfluous doc comment at position ' . $pos; - $this->addMessage($error, $errorPos, self::EXTRA_PARAM_COMMENT); - } - } - - if ($param->getVarName() === '') { - $error = 'Missing parameter name at position ' . $pos; - $this->addMessage($error, $errorPos, self::MISSING_PARAM_NAME); - } - - if ($param->getType() === '') { - $error = 'Missing type at position ' . $pos; - $this->addMessage($error, $errorPos, self::MISSING_PARAM_TYPE); - } - - /* no param comments required. - if ($paramComment === '') { - $error = 'Missing comment for param "%s" at position %s'; - $data = array( - $paramName, - $pos, - ); - $this->currentFile->addError($error, $errorPos, 'MissingParamComment', $data); - } else { - // Param comments must start with a capital letter and - // end with the full stop. - $firstChar = $paramComment{0}; - if (preg_match('|\p{Lu}|u', $firstChar) === 0) { - $error = 'Param comment must start with a capital letter'; - $this->currentFile->addError($error, $errorPos, 'ParamCommentNotCapital'); - } - $lastChar = $paramComment[(strlen($paramComment) - 1)]; - if ($lastChar !== '.') { - $error = 'Param comment must end with a full stop'; - $this->currentFile->addError($error, $errorPos, 'ParamCommentFullStop'); - } - } - */ - - $previousParam = $param; - } - //end foreach - - if ($spaceBeforeVar !== 1 && $spaceBeforeVar !== 10000 && $spaceBeforeComment !== 10000) { - $error = 'Expected 1 space after the longest type'; - $this->addMessage($error, $longestType, self::SPACING_AFTER_LONG_TYPE); - } - - if ($spaceBeforeComment !== 1 && $spaceBeforeComment !== 10000) { - $error = 'Expected 1 space after the longest variable name'; - $this->addMessage($error, $longestVar, self::SPACING_AFTER_LONG_NAME); - } - } - //end if - - $realNames = array(); - foreach ($realParams as $realParam) { - $realNames[] = $realParam['name']; - } - - // Report missing comments. - $diff = array_diff($realNames, $foundParams); - foreach ($diff as $neededParam) { - if (count($params) !== 0) { - $errorPos = $params[count($params) - 1]->getLine() + $commentStart; - } else { - $errorPos = $commentStart; - } - - $error = 'Doc comment for "%s" missing'; - $data = array($neededParam); - $this->addMessage($error, $errorPos, self::MISSING_PARAM_TAG, $data); - } - } - - //end processParams() - /** - * This method will add the message as an error or warning depending on the configuration - * - * @param string $error The error message. - * @param int $stackPtr The stack position where the error occurred. - * @param string $code A violation code unique to the sniff message. - * @param array $data Replacements for the error message. - * @param int $severity The severity level for this error. A value of 0 - */ - protected function addMessage($message, $stackPtr, $code, $data = array(), $severity = 0) - { - // - // Does the $code key exist in the report level - if (array_key_exists($code, self::$reportingLevel)) { - $level = self::$reportingLevel[$code]; - if ($level === self::WARNING || $level === self::INFO) { - $s = $level; - if ($severity !== 0) { - $s = $severity; - } - $this->currentFile->addWarning($message, $stackPtr, $code, $data, $s); - } else { - $this->currentFile->addError($message, $stackPtr, $code, $data, $severity); - } - } - } - - /** - * Determine if text is a class name - * - * @param string $class - * @return bool - */ - protected function isClassName($class) - { - $return = false; - if (preg_match('/^\\\\?[A-Z]\\w+(?:\\\\\\w+)*?$/', $class)) { - $return = true; - } - } - - /** - * Take the type and suggest the correct one. - * - * @param string $type - * @return string - */ - protected function suggestType($type) - { - $suggestedName = null; - // First check to see if this type is a list of types. If so we break it up and check each - if (preg_match('/^.*?(?:\|.*)+$/', $type)) { - // Return list of all types in this string. - $types = explode('|', $type); - if (is_array($types)) { - // Loop over all types and call this method on each. - $suggestions = array(); - foreach ($types as $t) { - $suggestions[] = $this->suggestType($t); - } - // Now that we have suggestions put them back together. - $suggestedName = implode('|', $suggestions); - } else { - $suggestedName = 'Unknown'; - } - } elseif ($this->isClassName($type)) { - // If this looks like a class name. - $suggestedName = $type; - } else { - // Only one type First check if that type is a base one. - $lowerVarType = strtolower($type); - switch ($lowerVarType) { - case 'boolean': - $suggestedName = 'bool'; - break; - case 'integer': - $suggestedName = 'int'; - break; - } - //end switch - // If no name suggested yet then call the phpcs version of this method. - if (empty($suggestedName)) { - $suggestedName = PHP_CodeSniffer::suggestType($type); - } - } - return $suggestedName; - } -} diff --git a/dev/tests/static/testsuite/Magento/Test/Php/_files/phpcs/ruleset.xml b/dev/tests/static/testsuite/Magento/Test/Php/_files/phpcs/ruleset.xml index 6cdb47406ce68c9509c99b5da1ecfc0d91f2d42b..45bb3b5e02b5e760e75496c4b0420495d1e6beee 100644 --- a/dev/tests/static/testsuite/Magento/Test/Php/_files/phpcs/ruleset.xml +++ b/dev/tests/static/testsuite/Magento/Test/Php/_files/phpcs/ruleset.xml @@ -56,4 +56,5 @@ <rule ref="Squiz.WhiteSpace.LogicalOperatorSpacing"/> <rule ref="Squiz.Commenting.DocCommentAlignment"/> <rule ref="Generic.PHP.DeprecatedFunctions"/> + <rule ref="../../../../../../framework/Magento"/> </ruleset> diff --git a/dev/tests/unit/framework/Magento/Test/Block/Adminhtml.php b/dev/tests/unit/framework/Magento/Test/Block/Adminhtml.php index 49e9c21de1e4bc33ba1ee5819706a5899f0d4187..34ef9902be3589d95ad0c135b8cd0408357a0722 100644 --- a/dev/tests/unit/framework/Magento/Test/Block/Adminhtml.php +++ b/dev/tests/unit/framework/Magento/Test/Block/Adminhtml.php @@ -99,7 +99,7 @@ class Adminhtml extends \PHPUnit_Framework_TestCase $this->_designMock = $this->_makeMock('Magento\View\DesignInterface'); $this->_sessionMock = $this->_makeMock('Magento\Core\Model\Session'); $this->_sidResolver = $this->_makeMock('Magento\Core\Model\Session\SidResolver'); - $this->_translatorMock = $this->_makeMock('Magento\Core\Model\Translate'); + $this->_translatorMock = $this->_makeMock('Magento\TranslateInterface'); $this->_layoutMock = $this->_makeMock('Magento\Core\Model\Layout'); $this->_requestMock = $this->_makeMock('Magento\App\RequestInterface'); $this->_messagesMock = $this->_makeMock('Magento\View\Element\Messages'); diff --git a/dev/tests/unit/framework/Magento/TestFramework/Helper/ObjectManager.php b/dev/tests/unit/framework/Magento/TestFramework/Helper/ObjectManager.php index d91524f51c46246ccdf0cbcd02d06b0306d3e5c5..599e8b7fadef6bd4ba2b94f3efd288829c935a80 100644 --- a/dev/tests/unit/framework/Magento/TestFramework/Helper/ObjectManager.php +++ b/dev/tests/unit/framework/Magento/TestFramework/Helper/ObjectManager.php @@ -38,7 +38,7 @@ class ObjectManager */ protected $_specialCases = array( 'Magento\Core\Model\Resource\AbstractResource' => '_getResourceModelMock', - 'Magento\Core\Model\Translate' => '_getTranslatorMock', + 'Magento\TranslateInterface' => '_getTranslatorMock', ); /** @@ -120,13 +120,12 @@ class ObjectManager * Retrieve mock of core translator model * * @param string $className - * @return \Magento\Core\Model\Translate|\PHPUnit_Framework_MockObject_MockObject + * @return \Magento\TranslateInterface|\PHPUnit_Framework_MockObject_MockObject */ protected function _getTranslatorMock($className) { $translator = $this->_testObject->getMockBuilder($className) ->disableOriginalConstructor() - ->setMethods(array('translate')) ->getMock(); $translateCallback = function ($arguments) { return is_array($arguments) ? vsprintf(array_shift($arguments), $arguments) : ''; diff --git a/dev/tests/unit/testsuite/Magento/AdminNotification/Model/System/Message/BaseurlTest.php b/dev/tests/unit/testsuite/Magento/AdminNotification/Model/System/Message/BaseurlTest.php index 1f170a3e86d4c73657044b378d75d11a2ede6d88..df35151e0f2b541bc48d8be1113f987d718a51ae 100644 --- a/dev/tests/unit/testsuite/Magento/AdminNotification/Model/System/Message/BaseurlTest.php +++ b/dev/tests/unit/testsuite/Magento/AdminNotification/Model/System/Message/BaseurlTest.php @@ -63,7 +63,7 @@ class BaseurlTest extends \PHPUnit_Framework_TestCase protected function setUp() { $helper = new \Magento\TestFramework\Helper\ObjectManager($this); - $this->_configMock = $this->getMock('Magento\Core\Model\Config', array(), array(), '', false); + $this->_configMock = $this->getMock('Magento\App\Config', array(), array(), '', false); $this->_urlBuilderMock = $this->getMock('Magento\UrlInterface'); $this->_storeManagerMock = $this->getMock('Magento\Core\Model\StoreManagerInterface'); diff --git a/dev/tests/unit/testsuite/Magento/App/CacheTest.php b/dev/tests/unit/testsuite/Magento/App/CacheTest.php index cd581c11e0373835010919e9eda5731a7ae647b9..374c7e493902d8ce0b57e4bab99a92a8b066b16c 100644 --- a/dev/tests/unit/testsuite/Magento/App/CacheTest.php +++ b/dev/tests/unit/testsuite/Magento/App/CacheTest.php @@ -144,7 +144,7 @@ class CacheTest extends \PHPUnit_Framework_TestCase public function saveDataProvider() { - $configTag = \Magento\Core\Model\Config::CACHE_TAG; + $configTag = \Magento\App\Config::CACHE_TAG; return array( 'default tags' => array( 'test_data', 'test_id', array(), 'test_data', 'test_id', array() diff --git a/dev/tests/unit/testsuite/Magento/Core/Model/Config/Data/BackendModelPoolTest.php b/dev/tests/unit/testsuite/Magento/App/Config/Data/BackendModelPoolTest.php similarity index 53% rename from dev/tests/unit/testsuite/Magento/Core/Model/Config/Data/BackendModelPoolTest.php rename to dev/tests/unit/testsuite/Magento/App/Config/Data/BackendModelPoolTest.php index 941a8be6940bc52f3aa7e2ee0e74c5b135e1aaf2..20437ca3e01fc7806d7c382335ac4c4a1082047f 100644 --- a/dev/tests/unit/testsuite/Magento/Core/Model/Config/Data/BackendModelPoolTest.php +++ b/dev/tests/unit/testsuite/Magento/App/Config/Data/BackendModelPoolTest.php @@ -21,15 +21,20 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Core\Model\Config\Data; +namespace Magento\App\Config\Data; class BackendModelPoolTest extends \PHPUnit_Framework_TestCase { /** - * @var \Magento\Core\Model\Config\Data\BackendModelPoolTest + * @var \Magento\App\Config\Data\ProcessorFactory */ protected $_model; + /** + * @var \Magento\App\Config\Data\ProcessorInterface + */ + protected $_processorMock; + /** * @var \Magento\ObjectManager */ @@ -38,48 +43,54 @@ class BackendModelPoolTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->_objectManager = $this->getMock('Magento\ObjectManager'); - $this->_model = new \Magento\Core\Model\Config\Data\BackendModelPool($this->_objectManager); + $this->_model = new \Magento\App\Config\Data\ProcessorFactory($this->_objectManager); + $this->_processorMock = $this->getMockForAbstractClass('Magento\App\Config\Data\ProcessorInterface'); + $this->_processorMock->expects($this->any()) + ->method('processValue') + ->will($this->returnArgument(0)); } /** - * @covers \Magento\Core\Model\Config\Data\BackendModelPool::get + * @covers \Magento\App\Config\Data\ProcessorFactory::get */ public function testGetModelWithCorrectInterface() { $this->_objectManager->expects($this->once()) ->method('create') - ->with('Magento\Core\Model\Config\Data\TestBackendModel') - ->will($this->returnValue(new \Magento\Core\Model\Config\Data\TestBackendModel())); + ->with('Magento\App\Config\Data\TestBackendModel') + ->will($this->returnValue($this->_processorMock)); - $this->assertInstanceOf('Magento\Core\Model\Config\Data\TestBackendModel', - $this->_model->get('Magento\Core\Model\Config\Data\TestBackendModel')); + $this->assertInstanceOf('Magento\App\Config\Data\ProcessorInterface', + $this->_model->get('Magento\App\Config\Data\TestBackendModel')); } /** - * @covers \Magento\Core\Model\Config\Data\BackendModelPool::get + * @covers \Magento\App\Config\Data\ProcessorFactory::get * @expectedException \InvalidArgumentException */ public function testGetModelWithWrongInterface() { $this->_objectManager->expects($this->once()) ->method('create') - ->with('Magento\Core\Model\Config\Data\WrongBackendModel') - ->will($this->returnValue(new \Magento\Core\Model\Config\Data\WrongBackendModel())); + ->with('Magento\App\Config\Data\WrongBackendModel') + ->will($this->returnValue($this->getMock( + 'Magento\App\Config\Data\WrongBackendModel', array(), array(), '', false + ))); - $this->_model->get('Magento\Core\Model\Config\Data\WrongBackendModel'); + $this->_model->get('Magento\App\Config\Data\WrongBackendModel'); } /** - * @covers \Magento\Core\Model\Config\Data\BackendModelPool::get + * @covers \Magento\App\Config\Data\ProcessorFactory::get */ public function testGetMemoryCache() { $this->_objectManager->expects($this->once()) ->method('create') - ->with('Magento\Core\Model\Config\Data\TestBackendModel') - ->will($this->returnValue(new \Magento\Core\Model\Config\Data\TestBackendModel())); + ->with('Magento\App\Config\Data\TestBackendModel') + ->will($this->returnValue($this->_processorMock)); - $this->_model->get('Magento\Core\Model\Config\Data\TestBackendModel'); - $this->_model->get('Magento\Core\Model\Config\Data\TestBackendModel'); + $this->_model->get('Magento\App\Config\Data\TestBackendModel'); + $this->_model->get('Magento\App\Config\Data\TestBackendModel'); } } diff --git a/dev/tests/unit/testsuite/Magento/Core/Model/Config/DataTest.php b/dev/tests/unit/testsuite/Magento/App/Config/DataTest.php similarity index 86% rename from dev/tests/unit/testsuite/Magento/Core/Model/Config/DataTest.php rename to dev/tests/unit/testsuite/Magento/App/Config/DataTest.php index 18958e7185cb1e6887c219a5d871d2c4aaf0f5ca..5f29f49bedebfbcfaf6f80027b56b3835384faf6 100644 --- a/dev/tests/unit/testsuite/Magento/Core/Model/Config/DataTest.php +++ b/dev/tests/unit/testsuite/Magento/App/Config/DataTest.php @@ -21,24 +21,24 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Core\Model\Config; +namespace Magento\App\Config; class DataTest extends \PHPUnit_Framework_TestCase { /** - * @var \Magento\Core\Model\Config\Data + * @var \Magento\App\Config\Data */ protected $_model; /** - * @var \PHPUnit_Framework_MockObject_MockObject + * @var \Magento\App\Config\MetadataProcessor|\PHPUnit_Framework_MockObject_MockObject */ protected $_metaDataProcessor; protected function setUp() { $this->_metaDataProcessor = $this->getMock( - 'Magento\Core\Model\Config\MetadataProcessor', + 'Magento\App\Config\MetadataProcessor', array(), array(), '', @@ -47,7 +47,7 @@ class DataTest extends \PHPUnit_Framework_TestCase $this->_metaDataProcessor->expects($this->any()) ->method('process') ->will($this->returnArgument(0)); - $this->_model = new \Magento\Core\Model\Config\Data($this->_metaDataProcessor, array()); + $this->_model = new \Magento\App\Config\Data($this->_metaDataProcessor, array()); } /** @@ -77,7 +77,7 @@ class DataTest extends \PHPUnit_Framework_TestCase public function testGetData() { - $model = new \Magento\Core\Model\Config\Data( + $model = new \Magento\App\Config\Data( $this->_metaDataProcessor, array( 'test' => array( diff --git a/dev/tests/unit/testsuite/Magento/Core/Model/Config/Initial/ConverterTest.php b/dev/tests/unit/testsuite/Magento/App/Config/Initial/ConverterTest.php similarity index 80% rename from dev/tests/unit/testsuite/Magento/Core/Model/Config/Initial/ConverterTest.php rename to dev/tests/unit/testsuite/Magento/App/Config/Initial/ConverterTest.php index c4eb52e9e43a0a09dc0ad5793f6640be27376b59..4fad237861f39e0daf7fb9b1549b1c6d7e0566c1 100644 --- a/dev/tests/unit/testsuite/Magento/Core/Model/Config/Initial/ConverterTest.php +++ b/dev/tests/unit/testsuite/Magento/App/Config/Initial/ConverterTest.php @@ -21,18 +21,23 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Core\Model\Config\Initial; +namespace Magento\App\Config\Initial; class ConverterTest extends \PHPUnit_Framework_TestCase { /** - * @var \Magento\Core\Model\Config\Initial\Converter + * @var \Magento\App\Config\Initial\Converter */ protected $_model; protected function setUp() { - $this->_model = new \Magento\Core\Model\Config\Initial\Converter(); + $nodeMap = array( + 'default' => '/config/default', + 'stores' => '/config/stores', + 'websites' => '/config/websites', + ); + $this->_model = new \Magento\App\Config\Initial\Converter($nodeMap); } public function testConvert() diff --git a/dev/tests/unit/testsuite/Magento/Core/Model/Config/Initial/ReaderTest.php b/dev/tests/unit/testsuite/Magento/App/Config/Initial/ReaderTest.php similarity index 87% rename from dev/tests/unit/testsuite/Magento/Core/Model/Config/Initial/ReaderTest.php rename to dev/tests/unit/testsuite/Magento/App/Config/Initial/ReaderTest.php index 462e317dfe8a35795a3967fffdb50ada370ad5e1..7f3a9b94577ff2dc04eda695785742cc9a846748 100644 --- a/dev/tests/unit/testsuite/Magento/Core/Model/Config/Initial/ReaderTest.php +++ b/dev/tests/unit/testsuite/Magento/App/Config/Initial/ReaderTest.php @@ -21,14 +21,14 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Core\Model\Config\Initial; +namespace Magento\App\Config\Initial; use Magento\App\Filesystem; class ReaderTest extends \PHPUnit_Framework_TestCase { /** - * @var \Magento\Core\Model\Config\Initial\Reader + * @var \Magento\App\Config\Initial\Reader */ protected $_model; @@ -38,7 +38,7 @@ class ReaderTest extends \PHPUnit_Framework_TestCase protected $_fileResolverMock; /** - * @var \Magento\Core\Model\Config\Initial\Converter|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\App\Config\Initial\Converter|\PHPUnit_Framework_MockObject_MockObject */ protected $_converterMock; @@ -56,9 +56,9 @@ class ReaderTest extends \PHPUnit_Framework_TestCase { $this->_filePath = __DIR__ . '/_files/'; $this->_fileResolverMock = $this->getMock('Magento\Config\FileResolverInterface'); - $this->_converterMock = $this->getMock('Magento\Core\Model\Config\Initial\Converter'); + $this->_converterMock = $this->getMock('Magento\App\Config\Initial\Converter'); $schemaLocatorMock = - $this->getMock('Magento\Core\Model\Config\Initial\SchemaLocator', array(), array(), '', false); + $this->getMock('Magento\App\Config\Initial\SchemaLocator', array(), array(), '', false); $validationStateMock = $this->getMock('Magento\Config\ValidationStateInterface'); $validationStateMock->expects($this->once())->method('isValidated')->will($this->returnValue(true)); $schemaFile = $this->_filePath . 'config.xsd'; @@ -68,7 +68,7 @@ class ReaderTest extends \PHPUnit_Framework_TestCase array('readFile', 'getRelativePath'), array(), '', false ); - $this->_model = new \Magento\Core\Model\Config\Initial\Reader( + $this->_model = new \Magento\App\Config\Initial\Reader( $this->_fileResolverMock, $this->_converterMock, $schemaLocatorMock, @@ -77,7 +77,7 @@ class ReaderTest extends \PHPUnit_Framework_TestCase } /** - * @covers \Magento\Core\Model\Config\Initial\Reader::read + * @covers \Magento\App\Config\Initial\Reader::read */ public function testReadNoFiles() { @@ -95,7 +95,7 @@ class ReaderTest extends \PHPUnit_Framework_TestCase } /** - * @covers \Magento\Core\Model\Config\Initial\Reader::read + * @covers \Magento\App\Config\Initial\Reader::read */ public function testReadValidConfig() { diff --git a/dev/tests/unit/testsuite/Magento/Core/Model/Config/Initial/XsdTest.php b/dev/tests/unit/testsuite/Magento/App/Config/Initial/XsdTest.php similarity index 98% rename from dev/tests/unit/testsuite/Magento/Core/Model/Config/Initial/XsdTest.php rename to dev/tests/unit/testsuite/Magento/App/Config/Initial/XsdTest.php index bdca8cd9a49de107370b0e5fbd7b82ab5ef4cc64..6b4856636ffe00e1a937955da79ea2e89c67b78f 100644 --- a/dev/tests/unit/testsuite/Magento/Core/Model/Config/Initial/XsdTest.php +++ b/dev/tests/unit/testsuite/Magento/App/Config/Initial/XsdTest.php @@ -22,7 +22,7 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Core\Model\Config\Initial; +namespace Magento\App\Config\Initial; class XsdTest extends \PHPUnit_Framework_TestCase { diff --git a/dev/tests/unit/testsuite/Magento/Core/Model/Config/Initial/_files/config.xml b/dev/tests/unit/testsuite/Magento/App/Config/Initial/_files/config.xml similarity index 100% rename from dev/tests/unit/testsuite/Magento/Core/Model/Config/Initial/_files/config.xml rename to dev/tests/unit/testsuite/Magento/App/Config/Initial/_files/config.xml diff --git a/dev/tests/unit/testsuite/Magento/Core/Model/Config/Initial/_files/config.xsd b/dev/tests/unit/testsuite/Magento/App/Config/Initial/_files/config.xsd similarity index 100% rename from dev/tests/unit/testsuite/Magento/Core/Model/Config/Initial/_files/config.xsd rename to dev/tests/unit/testsuite/Magento/App/Config/Initial/_files/config.xsd diff --git a/dev/tests/unit/testsuite/Magento/Core/Model/Config/Initial/_files/converted_config.php b/dev/tests/unit/testsuite/Magento/App/Config/Initial/_files/converted_config.php similarity index 100% rename from dev/tests/unit/testsuite/Magento/Core/Model/Config/Initial/_files/converted_config.php rename to dev/tests/unit/testsuite/Magento/App/Config/Initial/_files/converted_config.php diff --git a/dev/tests/unit/testsuite/Magento/Core/Model/Config/Initial/_files/initial_config1.xml b/dev/tests/unit/testsuite/Magento/App/Config/Initial/_files/initial_config1.xml similarity index 100% rename from dev/tests/unit/testsuite/Magento/Core/Model/Config/Initial/_files/initial_config1.xml rename to dev/tests/unit/testsuite/Magento/App/Config/Initial/_files/initial_config1.xml diff --git a/dev/tests/unit/testsuite/Magento/Core/Model/Config/Initial/_files/initial_config2.xml b/dev/tests/unit/testsuite/Magento/App/Config/Initial/_files/initial_config2.xml similarity index 100% rename from dev/tests/unit/testsuite/Magento/Core/Model/Config/Initial/_files/initial_config2.xml rename to dev/tests/unit/testsuite/Magento/App/Config/Initial/_files/initial_config2.xml diff --git a/dev/tests/unit/testsuite/Magento/Core/Model/Config/Initial/_files/initial_config_merged.php b/dev/tests/unit/testsuite/Magento/App/Config/Initial/_files/initial_config_merged.php similarity index 100% rename from dev/tests/unit/testsuite/Magento/Core/Model/Config/Initial/_files/initial_config_merged.php rename to dev/tests/unit/testsuite/Magento/App/Config/Initial/_files/initial_config_merged.php diff --git a/dev/tests/unit/testsuite/Magento/Core/Model/Config/Initial/_files/invalidConfigXmlArray.php b/dev/tests/unit/testsuite/Magento/App/Config/Initial/_files/invalidConfigXmlArray.php similarity index 100% rename from dev/tests/unit/testsuite/Magento/Core/Model/Config/Initial/_files/invalidConfigXmlArray.php rename to dev/tests/unit/testsuite/Magento/App/Config/Initial/_files/invalidConfigXmlArray.php diff --git a/dev/tests/unit/testsuite/Magento/Core/Model/Config/Initial/_files/valid_config.xml b/dev/tests/unit/testsuite/Magento/App/Config/Initial/_files/valid_config.xml similarity index 100% rename from dev/tests/unit/testsuite/Magento/Core/Model/Config/Initial/_files/valid_config.xml rename to dev/tests/unit/testsuite/Magento/App/Config/Initial/_files/valid_config.xml diff --git a/dev/tests/unit/testsuite/Magento/Core/Model/Config/InitialTest.php b/dev/tests/unit/testsuite/Magento/App/Config/InitialTest.php similarity index 75% rename from dev/tests/unit/testsuite/Magento/Core/Model/Config/InitialTest.php rename to dev/tests/unit/testsuite/Magento/App/Config/InitialTest.php index 088ce73cda1794652a8b149fafe96055214e3b27..d85839c7ec1e2f2707f5005ded7e45038dc31b16 100644 --- a/dev/tests/unit/testsuite/Magento/Core/Model/Config/InitialTest.php +++ b/dev/tests/unit/testsuite/Magento/App/Config/InitialTest.php @@ -21,12 +21,12 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Core\Model\Config; +namespace Magento\App\Config; class InitialTest extends \PHPUnit_Framework_TestCase { /** - * @var \Magento\Core\Model\Config\Initial + * @var \Magento\App\Config\Initial */ protected $_model; @@ -43,7 +43,7 @@ class InitialTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->_initialReaderMock = $this->getMock( - 'Magento\Core\Model\Config\Initial\Reader', array(), array(), '', false + 'Magento\App\Config\Initial\Reader', array(), array(), '', false ); $this->_configCacheMock = $this->getMock('Magento\App\Cache\Type\Config', array(), array(), '', false); $serializedData = serialize(array( @@ -65,25 +65,27 @@ class InitialTest extends \PHPUnit_Framework_TestCase ->with('initial_config') ->will($this->returnValue($serializedData)); - $this->_model = new \Magento\Core\Model\Config\Initial($this->_initialReaderMock, $this->_configCacheMock); + $this->_model = new \Magento\App\Config\Initial($this->_initialReaderMock, $this->_configCacheMock); } - public function testGetDefault() - { - $expectedResult = array('key' => 'default_value'); - $this->assertEquals($expectedResult, $this->_model->getDefault()); - } - - public function testGetStore() + /** + * @dataProvider getDataDataProvider + * + * @param string $scope + * @param array $expectedResult + */ + public function testGetData($scope, $expectedResult) { - $expectedResult = array('key' => 'store_value'); - $this->assertEquals($expectedResult, $this->_model->getStore('default')); + $this->assertEquals($expectedResult, $this->_model->getData($scope)); } - public function testGetWebsite() + public function getDataDataProvider() { - $expectedResult = array('key' => 'website_value'); - $this->assertEquals($expectedResult, $this->_model->getWebsite('default')); + return array( + array('default', array('key' => 'default_value')), + array('stores|default', array('key' => 'store_value')), + array('websites|default', array('key' => 'website_value')), + ); } public function testGetMetadata() diff --git a/dev/tests/unit/testsuite/Magento/Core/Model/Config/MetadataProcessorTest.php b/dev/tests/unit/testsuite/Magento/App/Config/MetadataProcessorTest.php similarity index 83% rename from dev/tests/unit/testsuite/Magento/Core/Model/Config/MetadataProcessorTest.php rename to dev/tests/unit/testsuite/Magento/App/Config/MetadataProcessorTest.php index 6f501339f015a87c03d776fe5b818b304028dab5..42d1ec561d796de6f6df89f4aaf2f6416813855d 100644 --- a/dev/tests/unit/testsuite/Magento/Core/Model/Config/MetadataProcessorTest.php +++ b/dev/tests/unit/testsuite/Magento/App/Config/MetadataProcessorTest.php @@ -21,12 +21,12 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Core\Model\Config; +namespace Magento\App\Config; class MetadataProcessorTest extends \PHPUnit_Framework_TestCase { /** - * @var \Magento\Core\Model\Config\MetadataProcessor + * @var \Magento\App\Config\MetadataProcessor */ protected $_model; @@ -48,15 +48,15 @@ class MetadataProcessorTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->_modelPoolMock = $this->getMock( - 'Magento\Core\Model\Config\Data\BackendModelPool', array(), array(), '', false); - $this->_initialConfigMock = $this->getMock('Magento\Core\Model\Config\Initial', array(), array(), '', false); - $this->_backendModelMock = $this->getMock('Magento\Core\Model\Config\Data\BackendModelInterface'); + 'Magento\App\Config\Data\ProcessorFactory', array(), array(), '', false); + $this->_initialConfigMock = $this->getMock('Magento\App\Config\Initial', array(), array(), '', false); + $this->_backendModelMock = $this->getMock('Magento\App\Config\Data\ProcessorInterface'); $this->_initialConfigMock->expects($this->any()) ->method('getMetadata') ->will($this->returnValue(array( 'some/config/path' => array('backendModel' => 'Custom_Backend_Model'), ))); - $this->_model = new \Magento\Core\Model\Config\MetadataProcessor( + $this->_model = new \Magento\App\Config\MetadataProcessor( $this->_modelPoolMock, $this->_initialConfigMock ); diff --git a/dev/tests/unit/testsuite/Magento/Core/Model/Config/Section/ConverterTest.php b/dev/tests/unit/testsuite/Magento/App/Config/Scope/ConverterTest.php similarity index 89% rename from dev/tests/unit/testsuite/Magento/Core/Model/Config/Section/ConverterTest.php rename to dev/tests/unit/testsuite/Magento/App/Config/Scope/ConverterTest.php index a65822c9da34eca1cf2aea02eaeb94ce2ec1fe78..41540678921a71280aa608b019c15456b585a20b 100644 --- a/dev/tests/unit/testsuite/Magento/Core/Model/Config/Section/ConverterTest.php +++ b/dev/tests/unit/testsuite/Magento/App/Config/Scope/ConverterTest.php @@ -21,18 +21,18 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Core\Model\Config\Section; +namespace Magento\App\Config\Scope; class ConverterTest extends \PHPUnit_Framework_TestCase { /** - * @var \Magento\Core\Model\Config\Section\Converter + * @var \Magento\App\Config\Scope\Converter */ protected $_model; protected function setUp() { - $this->_model = new \Magento\Core\Model\Config\Section\Converter(); + $this->_model = new \Magento\App\Config\Scope\Converter(); } public function testConvert() diff --git a/dev/tests/unit/testsuite/Magento/App/Config/ScopePoolTest.php b/dev/tests/unit/testsuite/Magento/App/Config/ScopePoolTest.php new file mode 100644 index 0000000000000000000000000000000000000000..097dff8db6eed9f0bc5a9956ddd008bd93ec4342 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/App/Config/ScopePoolTest.php @@ -0,0 +1,127 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\App\Config; + +class ScopePoolTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\App\Config\Scope\Reader|PHPUnit_Framework_MockObject_MockObject + */ + protected $_reader; + + /** + * @var \Magento\App\Config\Scope\ReaderPoolInterface|PHPUnit_Framework_MockObject_MockObject + */ + protected $_readerPool; + + /** + * @var \Magento\App\Config\DataFactory|PHPUnit_Framework_MockObject_MockObject + */ + protected $_dataFactory; + /** + * @var \Magento\Cache\FrontendInterface|PHPUnit_Framework_MockObject_MockObject + */ + protected $_cache; + + /** + * @var \Magento\App\Config\ScopePool + */ + protected $_object; + + public function setUp() + { + $helper = new \Magento\TestFramework\Helper\ObjectManager($this); + $this->_readerPool = $this->getMockForAbstractClass('\Magento\App\Config\Scope\ReaderPoolInterface'); + $this->_reader = $this->getMockForAbstractClass('\Magento\App\Config\Scope\ReaderInterface'); + $this->_dataFactory = $this->getMockBuilder('\Magento\App\Config\DataFactory') + ->disableOriginalConstructor() + ->getMock(); + $this->_cache = $this->getMock('\Magento\Cache\FrontendInterface'); + $this->_object = $helper->getObject('\Magento\App\Config\ScopePool', array( + 'readerPool' => $this->_readerPool, + 'dataFactory' => $this->_dataFactory, + 'cache' => $this->_cache, + 'cacheId' => 'test_cache_id' + )); + } + + /** + * @dataProvider getScopeDataProvider + * + * @param string $scopeType + * @param string $scope + * @param array $data + * @param string|null $cachedData + */ + public function testGetScope($scopeType, $scope, array $data, $cachedData) + { + $cacheKey = "test_cache_id|$scopeType|$scope"; + + $this->_readerPool->expects($this->any()) + ->method('getReader') + ->with($scopeType) + ->will($this->returnValue($this->_reader)); + $this->_cache->expects($this->once()) + ->method('load') + ->with($cacheKey) + ->will($this->returnValue($cachedData)); + + if (!$cachedData) { + $this->_reader->expects($this->once()) + ->method('read') + ->with('testScope') + ->will($this->returnValue($data)); + $this->_cache->expects($this->once()) + ->method('save') + ->with(serialize($data), $cacheKey, array(\Magento\App\Config\ScopePool::CACHE_TAG)); + } + + $configData = $this->getMockBuilder('\Magento\App\Config\Data')->disableOriginalConstructor()->getMock(); + $this->_dataFactory->expects($this->once()) + ->method('create') + ->with(array('data' => $data)) + ->will($this->returnValue($configData)); + $this->assertInstanceOf('\Magento\App\Config\DataInterface', $this->_object->getScope($scopeType, $scope)); + + // second call to check caching + $this->assertInstanceOf('\Magento\App\Config\DataInterface', $this->_object->getScope($scopeType, $scope)); + } + + public function getScopeDataProvider() + { + return array( + array('scopeType1', 'testScope', array('key' => 'value'), null), + array('scopeType2', 'testScope', array('key' => 'value'), serialize(array('key' => 'value'))), + ); + } + + public function testClean() + { + $this->_cache->expects($this->once()) + ->method('clean') + ->with(\Zend_Cache::CLEANING_MODE_MATCHING_TAG, array(\Magento\App\Config\ScopePool::CACHE_TAG)); + $this->_object->clean('testScope'); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Core/Model/Config/XsdTest.php b/dev/tests/unit/testsuite/Magento/App/Config/XsdTest.php similarity index 98% rename from dev/tests/unit/testsuite/Magento/Core/Model/Config/XsdTest.php rename to dev/tests/unit/testsuite/Magento/App/Config/XsdTest.php index e40eefa118d973224a50ac7169768ad538ac6dec..22618709ed374f3fedaa282e1b31a469793e9a2b 100644 --- a/dev/tests/unit/testsuite/Magento/Core/Model/Config/XsdTest.php +++ b/dev/tests/unit/testsuite/Magento/App/Config/XsdTest.php @@ -21,7 +21,7 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Core\Model\Config; +namespace Magento\App\Config; class XsdTest extends \PHPUnit_Framework_TestCase { diff --git a/dev/tests/unit/testsuite/Magento/Core/Model/Config/_files/invalidRoutesXmlArray.php b/dev/tests/unit/testsuite/Magento/App/Config/_files/invalidRoutesXmlArray.php similarity index 100% rename from dev/tests/unit/testsuite/Magento/Core/Model/Config/_files/invalidRoutesXmlArray.php rename to dev/tests/unit/testsuite/Magento/App/Config/_files/invalidRoutesXmlArray.php diff --git a/dev/tests/unit/testsuite/Magento/Core/Model/Config/_files/valid_routes.xml b/dev/tests/unit/testsuite/Magento/App/Config/_files/valid_routes.xml similarity index 100% rename from dev/tests/unit/testsuite/Magento/Core/Model/Config/_files/valid_routes.xml rename to dev/tests/unit/testsuite/Magento/App/Config/_files/valid_routes.xml diff --git a/dev/tests/unit/testsuite/Magento/Core/Model/ReinitableConfigTest.php b/dev/tests/unit/testsuite/Magento/App/ReinitableConfigTest.php similarity index 82% rename from dev/tests/unit/testsuite/Magento/Core/Model/ReinitableConfigTest.php rename to dev/tests/unit/testsuite/Magento/App/ReinitableConfigTest.php index d63f8857368e97c02033cdd5c7df976059a4003f..afe4a1bc34e4b1d30b98a8174956a1b46d29bb4e 100644 --- a/dev/tests/unit/testsuite/Magento/Core/Model/ReinitableConfigTest.php +++ b/dev/tests/unit/testsuite/Magento/App/ReinitableConfigTest.php @@ -25,18 +25,18 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Core\Model; +namespace Magento\App; class ReinitableConfigTest extends \PHPUnit_Framework_TestCase { public function testReinit() { $helper = new \Magento\TestFramework\Helper\ObjectManager($this); - $sectionPool = $this->getMock('\Magento\Core\Model\Config\SectionPool', ['clean'], array(), '', false); - $sectionPool->expects($this->once()) + $scopePool = $this->getMock('\Magento\App\Config\ScopePool', ['clean'], array(), '', false); + $scopePool->expects($this->once()) ->method('clean'); /** @var \Magento\Core\Model\ReinitableConfig $config */ - $config = $helper->getObject('Magento\Core\Model\ReinitableConfig', ['sectionPool' => $sectionPool]); + $config = $helper->getObject('Magento\App\ReinitableConfig', ['scopePool' => $scopePool]); $this->assertInstanceOf('\Magento\App\ReinitableConfigInterface', $config->reinit()); } } diff --git a/dev/tests/unit/testsuite/Magento/App/Response/HttpTest.php b/dev/tests/unit/testsuite/Magento/App/Response/HttpTest.php index 16381d3fe36e0a5b35ef140a7d0914d576ebee0b..8072cce6d871b91cc4d45da3477594a1fe7c299c 100644 --- a/dev/tests/unit/testsuite/Magento/App/Response/HttpTest.php +++ b/dev/tests/unit/testsuite/Magento/App/Response/HttpTest.php @@ -53,4 +53,14 @@ class HttpTest extends \PHPUnit_Framework_TestCase { $this->assertFalse($this->_model->getHeader('Test')); } + + public function testGetVaryString() + { + $vary = array('some-vary-key' => 'some-vary-value'); + ksort($vary); + $expected = sha1(serialize($vary)); + $this->_model->setVary('some-vary-key', 'some-vary-value'); + + $this->assertEquals($expected, $this->_model->getVaryString()); + } } diff --git a/dev/tests/unit/testsuite/Magento/Backend/App/ConfigTest.php b/dev/tests/unit/testsuite/Magento/Backend/App/ConfigTest.php index 97aa355f4fc73351f0419e0fbd4e220e8a504bf8..78390fc7f5c8a5195a5d56397cb4546a8dbaaa0a 100644 --- a/dev/tests/unit/testsuite/Magento/Backend/App/ConfigTest.php +++ b/dev/tests/unit/testsuite/Magento/Backend/App/ConfigTest.php @@ -26,7 +26,7 @@ namespace Magento\Backend\App; class ConfigTest extends \PHPUnit_Framework_TestCase { /** - * @var \Magento\Core\Model\Config\SectionPool|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\App\Config\ScopePool|\PHPUnit_Framework_MockObject_MockObject */ protected $sectionPool; @@ -38,8 +38,8 @@ class ConfigTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->sectionPool = $this->getMock( - 'Magento\Core\Model\Config\SectionPool', - array('getSection', 'clean'), + 'Magento\App\Config\ScopePool', + array('getScope', 'clean'), array(), '', false @@ -59,7 +59,7 @@ class ConfigTest extends \PHPUnit_Framework_TestCase ->will($this->returnValue($expectedValue)); $this->sectionPool ->expects($this->once()) - ->method('getSection') + ->method('getScope') ->with($this->equalTo('default'), $this->isNull()) ->will($this->returnValue($configData)); $this->assertEquals($expectedValue, $this->model->getValue($path)); @@ -76,7 +76,7 @@ class ConfigTest extends \PHPUnit_Framework_TestCase ->with($this->equalTo($path), $this->equalTo($value)); $this->sectionPool ->expects($this->once()) - ->method('getSection') + ->method('getScope') ->with($this->equalTo('default'), $this->isNull()) ->will($this->returnValue($configData)); $this->model->setValue($path, $value); @@ -104,7 +104,7 @@ class ConfigTest extends \PHPUnit_Framework_TestCase ->will($this->returnValue($configValue)); $this->sectionPool ->expects($this->once()) - ->method('getSection') + ->method('getScope') ->with($this->equalTo('default'), $this->isNull()) ->will($this->returnValue($configData)); $this->assertEquals($expectedResult, $this->model->isSetFlag($path)); @@ -126,10 +126,10 @@ class ConfigTest extends \PHPUnit_Framework_TestCase * Get ConfigData mock * * @param $mockedMethod - * @return \PHPUnit_Framework_MockObject_MockObject|\Magento\Core\Model\Config\Data + * @return \PHPUnit_Framework_MockObject_MockObject|\Magento\App\Config\Data */ protected function getConfigDataMock($mockedMethod) { - return $this->getMock('Magento\Core\Model\Config\Data', array($mockedMethod), array(), '', false); + return $this->getMock('Magento\App\Config\Data', array($mockedMethod), array(), '', false); } } diff --git a/dev/tests/unit/testsuite/Magento/Backend/Controller/Adminhtml/System/AccountTest.php b/dev/tests/unit/testsuite/Magento/Backend/Controller/Adminhtml/System/AccountTest.php index 82e93a1ed4014066bfaea0103e4dbc4dd21fb62f..d6ddb8dcbccfafcb6649a2c7bc0219017f93dcf7 100644 --- a/dev/tests/unit/testsuite/Magento/Backend/Controller/Adminhtml/System/AccountTest.php +++ b/dev/tests/unit/testsuite/Magento/Backend/Controller/Adminhtml/System/AccountTest.php @@ -59,7 +59,7 @@ class AccountTest extends \PHPUnit_Framework_TestCase /** @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Backend\Model\Locale\Manager */ protected $_managerMock; - /** @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Core\Model\Translate */ + /** @var \PHPUnit_Framework_MockObject_MockObject|\Magento\TranslateInterface */ protected $_translatorMock; protected function setUp() @@ -109,9 +109,8 @@ class AccountTest extends \PHPUnit_Framework_TestCase ->setMethods(array('switchBackendInterfaceLocale')) ->getMock(); - $this->_translatorMock = $this->getMockBuilder('Magento\Core\Model\Translate') + $this->_translatorMock = $this->getMockBuilder('Magento\TranslateInterface') ->disableOriginalConstructor() - ->setMethods(array('_canUseCache')) ->getMock(); $contextMock = $this->getMock('Magento\Backend\App\Action\Context', array(), array(), '', false); diff --git a/dev/tests/unit/testsuite/Magento/Backend/Model/Locale/ManagerTest.php b/dev/tests/unit/testsuite/Magento/Backend/Model/Locale/ManagerTest.php index 3ed49f6f96e6375d9506e7f67f5f7060a38f6aae..2a406040c93fafc25c10dc65b17663fa3ba29f4c 100644 --- a/dev/tests/unit/testsuite/Magento/Backend/Model/Locale/ManagerTest.php +++ b/dev/tests/unit/testsuite/Magento/Backend/Model/Locale/ManagerTest.php @@ -35,7 +35,7 @@ class ManagerTest extends \PHPUnit_Framework_TestCase protected $_model; /** - * @var \Magento\Core\Model\Translate + * @var \Magento\TranslateInterface */ protected $_translator; @@ -62,7 +62,7 @@ class ManagerTest extends \PHPUnit_Framework_TestCase ->method('getUser') ->will($this->returnValue($userMock)); - $this->_translator = $this->getMock('Magento\Core\Model\Translate', + $this->_translator = $this->getMock('Magento\TranslateInterface', array(), array(), '', false); $this->_translator->expects($this->any()) diff --git a/dev/tests/unit/testsuite/Magento/Backend/Model/Translate/Inline/ConfigFactoryTest.php b/dev/tests/unit/testsuite/Magento/Backend/Model/Translate/Inline/ConfigFactoryTest.php index 5b80ce02ac31830f6bb0eb7ffd320b07b89a9f5c..b1a3ff19616ba8e46e1c8708999b5231fd89e712 100644 --- a/dev/tests/unit/testsuite/Magento/Backend/Model/Translate/Inline/ConfigFactoryTest.php +++ b/dev/tests/unit/testsuite/Magento/Backend/Model/Translate/Inline/ConfigFactoryTest.php @@ -25,16 +25,16 @@ namespace Magento\Backend\Model\Translate\Inline; class ConfigFactoryTest extends \PHPUnit_Framework_TestCase { - public function testCreate() + public function testGet() { $result = 'result'; $objectManager = $this->getMockForAbstractClass('Magento\ObjectManager'); $objectManager ->expects($this->once()) - ->method('create') + ->method('get') ->with($this->equalTo('Magento\Backend\Model\Translate\Inline\Config')) ->will($this->returnValue($result)); $factory = new ConfigFactory($objectManager); - $this->assertEquals($result, $factory->create()); + $this->assertEquals($result, $factory->get()); } } diff --git a/dev/tests/unit/testsuite/Magento/Backend/Model/Translate/Inline/ConfigTest.php b/dev/tests/unit/testsuite/Magento/Backend/Model/Translate/Inline/ConfigTest.php index 35561948fea71e886958d01492ca06a95ee57253..e06a6b63d49c37cb370b214ac2cd1dfec6a0aa9f 100644 --- a/dev/tests/unit/testsuite/Magento/Backend/Model/Translate/Inline/ConfigTest.php +++ b/dev/tests/unit/testsuite/Magento/Backend/Model/Translate/Inline/ConfigTest.php @@ -34,7 +34,13 @@ class ConfigTest extends \PHPUnit_Framework_TestCase ->method('isSetFlag') ->with($this->equalTo('dev/translate_inline/active_admin')) ->will($this->returnValue($result)); - $config = new Config($backendConfig); + $objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); + $config = $objectManager->getObject( + '\Magento\Backend\Model\Translate\Inline\Config', + array( + 'config' => $backendConfig + ) + ); $this->assertEquals($result, $config->isActive('any')); } } diff --git a/dev/tests/unit/testsuite/Magento/Backend/Model/TranslateTest.php b/dev/tests/unit/testsuite/Magento/Backend/Model/TranslateTest.php new file mode 100644 index 0000000000000000000000000000000000000000..914257b133c77cf04b120c5460dd1f4bb670a873 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Backend/Model/TranslateTest.php @@ -0,0 +1,93 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Backend\Model; + +class TranslateTest extends \PHPUnit_Framework_TestCase +{ + /** + * @dataProvider initDataProvider + * + * @param string $area + * @param string $expectedScope + */ + public function testInit($area, $expectedScope) + { + $localeMock = $this->getMock('\Magento\Core\Model\LocaleInterface'); + $appMock = $this->getMock('\Magento\AppInterface', array(), array(), '', false); + $appMock->expects($this->once()) + ->method('getLocale') + ->will($this->returnValue($localeMock)); + $appStateMock = $this->getMock('\Magento\App\State', array(), array(), '', false); + $appStateMock->expects($this->any()) + ->method('getAreaCode') + ->will($this->returnValue($area)); + $scopeMock = $this->getMock('\Magento\BaseScopeInterface'); + $scopeResolverMock = $this->getMock('\Magento\BaseScopeResolverInterface'); + $scopeResolverMock->expects($this->once()) + ->method('getScope') + ->will($this->returnValue($scopeMock)); + $themeMock = $this->getMock('\Magento\View\Design\ThemeInterface', array()); + $themeMock->expects($this->once()) + ->method('getId') + ->will($this->returnValue(1)); + $designMock = $this->getMock('\Magento\View\DesignInterface'); + $designMock->expects($this->once()) + ->method('getDesignTheme') + ->will($this->returnValue($themeMock)); + + $inlineMock = $this->getMock('\Magento\Translate\InlineInterface'); + $inlineMock->expects($this->at(0)) + ->method('isAllowed') + ->with() + ->will($this->returnValue(false)); + $inlineMock->expects($this->at(1)) + ->method('isAllowed') + ->with($this->equalTo($expectedScope)) + ->will($this->returnValue(true)); + $translateFactoryMock = $this->getMock('\Magento\Translate\Factory', array(), array(), '', false); + $translateFactoryMock->expects($this->any()) + ->method('create') + ->will($this->returnValue($inlineMock)); + + $helper = new \Magento\TestFramework\Helper\ObjectManager($this); + /** @var \Magento\Backend\Model\Translate $translate */ + $translate = $helper->getObject('Magento\Backend\Model\Translate', array( + 'app' => $appMock, + 'appState' => $appStateMock, + 'scopeResolver' => $scopeResolverMock, + 'viewDesign' => $designMock, + 'translateFactory' => $translateFactoryMock + )); + $translate->init(); + } + + public function initDataProvider() + { + return array( + array('adminhtml', 'admin'), + array('frontend', null), + ); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Checkout/Helper/DataTest.php b/dev/tests/unit/testsuite/Magento/Checkout/Helper/DataTest.php index c58b47a3d62cae47a6d5b67d83c6c0aea6e99c7b..69ce34740fa8e8a63bd874a0dec9da81ee516faf 100644 --- a/dev/tests/unit/testsuite/Magento/Checkout/Helper/DataTest.php +++ b/dev/tests/unit/testsuite/Magento/Checkout/Helper/DataTest.php @@ -42,9 +42,8 @@ class DataTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_translator = $this->getMock('Magento\Core\Model\Translate', array(), array(), '', false); + $this->_translator = $this->getMock('Magento\TranslateInterface', array(), array(), '', false); $context = $this->getMock('\Magento\App\Helper\Context', array(), array(), '', false); - $context->expects($this->any())->method('getTranslator')->will($this->returnValue($this->_translator)); $storeConfig = $this->getMock('\Magento\Core\Model\Store\Config', array(), array(), '', false); $storeConfig->expects($this->any())->method('getConfig')->will($this->returnValueMap(array( @@ -76,7 +75,7 @@ class DataTest extends \PHPUnit_Framework_TestCase $this->_helper = new Data( $context, $storeConfig, $storeManager, $checkoutSession, - $locale, $collectionFactory, $emailTplFactory + $locale, $collectionFactory, $emailTplFactory, $this->_translator ); } diff --git a/dev/tests/unit/testsuite/Magento/Core/Model/Config/Data/TestBackendModel.php b/dev/tests/unit/testsuite/Magento/Core/Model/Config/Data/TestBackendModel.php deleted file mode 100644 index fb6b04444a53ddfd7c2e501e9fe0b4c4714b4666..0000000000000000000000000000000000000000 --- a/dev/tests/unit/testsuite/Magento/Core/Model/Config/Data/TestBackendModel.php +++ /dev/null @@ -1,32 +0,0 @@ -<?php -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - */ -namespace Magento\Core\Model\Config\Data; - -class TestBackendModel implements \Magento\Core\Model\Config\Data\BackendModelInterface -{ - public function processValue($value) - { - return $value; - } -} diff --git a/dev/tests/unit/testsuite/Magento/Core/Model/Config/Data/WrongBackendModel.php b/dev/tests/unit/testsuite/Magento/Core/Model/Config/Data/WrongBackendModel.php deleted file mode 100644 index f4f8806b90c0360e04f86e6818ace0222f68b193..0000000000000000000000000000000000000000 --- a/dev/tests/unit/testsuite/Magento/Core/Model/Config/Data/WrongBackendModel.php +++ /dev/null @@ -1,28 +0,0 @@ -<?php -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - */ -namespace Magento\Core\Model\Config\Data; - -class WrongBackendModel -{ -} diff --git a/dev/tests/unit/testsuite/Magento/Core/Model/Config/Section/Processor/PlaceholderTest.php b/dev/tests/unit/testsuite/Magento/Core/Model/Config/Scope/Processor/PlaceholderTest.php similarity index 91% rename from dev/tests/unit/testsuite/Magento/Core/Model/Config/Section/Processor/PlaceholderTest.php rename to dev/tests/unit/testsuite/Magento/Core/Model/Config/Scope/Processor/PlaceholderTest.php index 342aafb8ebc572a4fc0724a159486e0c9c0f8866..201a6448328d4d866235aad70dfc6047c4c081dd 100644 --- a/dev/tests/unit/testsuite/Magento/Core/Model/Config/Section/Processor/PlaceholderTest.php +++ b/dev/tests/unit/testsuite/Magento/Core/Model/Config/Scope/Processor/PlaceholderTest.php @@ -21,12 +21,12 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Core\Model\Config\Section\Processor; +namespace Magento\Core\Model\Config\Scope\Processor; class PlaceholderTest extends \PHPUnit_Framework_TestCase { /** - * @var \Magento\Core\Model\Config\Section\Processor\Placeholder + * @var \Magento\Core\Model\Config\Scope\Processor\Placeholder */ protected $_model; @@ -41,7 +41,7 @@ class PlaceholderTest extends \PHPUnit_Framework_TestCase $this->_requestMock->expects($this->any()) ->method('getDistroBaseUrl') ->will($this->returnValue('http://localhost/')); - $this->_model = new \Magento\Core\Model\Config\Section\Processor\Placeholder($this->_requestMock); + $this->_model = new \Magento\Core\Model\Config\Scope\Processor\Placeholder($this->_requestMock); } public function testProcess() diff --git a/dev/tests/unit/testsuite/Magento/Core/Model/Config/Section/Reader/DefaultReaderTest.php b/dev/tests/unit/testsuite/Magento/Core/Model/Config/Scope/Reader/DefaultReaderTest.php similarity index 86% rename from dev/tests/unit/testsuite/Magento/Core/Model/Config/Section/Reader/DefaultReaderTest.php rename to dev/tests/unit/testsuite/Magento/Core/Model/Config/Scope/Reader/DefaultReaderTest.php index 1767e57d40d7729999af2e8bf574e7e3e3ac7d1b..58a00d9cfb8a34dfb5ef97de267b753cb63531b8 100644 --- a/dev/tests/unit/testsuite/Magento/Core/Model/Config/Section/Reader/DefaultReaderTest.php +++ b/dev/tests/unit/testsuite/Magento/Core/Model/Config/Scope/Reader/DefaultReaderTest.php @@ -21,12 +21,12 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Core\Model\Config\Section\Reader; +namespace Magento\Core\Model\Config\Scope\Reader; class DefaultReaderTest extends \PHPUnit_Framework_TestCase { /** - * @var \Magento\Core\Model\Config\Section\Reader\DefaultReader + * @var \Magento\Core\Model\Config\Scope\Reader\DefaultReader */ protected $_model; @@ -47,7 +47,7 @@ class DefaultReaderTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_initialConfigMock = $this->getMock('Magento\Core\Model\Config\Initial', array(), array(), '', false); + $this->_initialConfigMock = $this->getMock('Magento\App\Config\Initial', array(), array(), '', false); $this->_collectionFactory = $this->getMock( 'Magento\Core\Model\Resource\Config\Value\Collection\ScopedFactory', array('create'), @@ -59,9 +59,9 @@ class DefaultReaderTest extends \PHPUnit_Framework_TestCase $this->_appStateMock->expects($this->any()) ->method('isInstalled') ->will($this->returnValue(true)); - $this->_model = new \Magento\Core\Model\Config\Section\Reader\DefaultReader( + $this->_model = new \Magento\Core\Model\Config\Scope\Reader\DefaultReader( $this->_initialConfigMock, - new \Magento\Core\Model\Config\Section\Converter(), + new \Magento\App\Config\Scope\Converter(), $this->_collectionFactory, $this->_appStateMock ); @@ -70,7 +70,8 @@ class DefaultReaderTest extends \PHPUnit_Framework_TestCase public function testRead() { $this->_initialConfigMock->expects($this->any()) - ->method('getDefault') + ->method('getData') + ->with(\Magento\BaseScopeInterface::SCOPE_DEFAULT) ->will($this->returnValue(array( 'config' => array('key1' => 'default_value1', 'key2' => 'default_value2'), ))); diff --git a/dev/tests/unit/testsuite/Magento/Core/Model/Config/Section/Reader/StoreTest.php b/dev/tests/unit/testsuite/Magento/Core/Model/Config/Scope/Reader/StoreTest.php similarity index 78% rename from dev/tests/unit/testsuite/Magento/Core/Model/Config/Section/Reader/StoreTest.php rename to dev/tests/unit/testsuite/Magento/Core/Model/Config/Scope/Reader/StoreTest.php index 5eb0ab1e0d1da3dcfba23ff7e75550dc8c7d0051..711ff2c22b0354f774fdcfe72af482b40c681dfd 100644 --- a/dev/tests/unit/testsuite/Magento/Core/Model/Config/Section/Reader/StoreTest.php +++ b/dev/tests/unit/testsuite/Magento/Core/Model/Config/Scope/Reader/StoreTest.php @@ -21,19 +21,19 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Core\Model\Config\Section\Reader; +namespace Magento\Core\Model\Config\Scope\Reader; class StoreTest extends \PHPUnit_Framework_TestCase { /** - * @var \Magento\Core\Model\Config\Section\Reader\Store + * @var \Magento\Core\Model\Config\Scope\Reader\Store */ protected $_model; /** - * @var \PHPUnit_Framework_MockObject_MockObject + * @var \Magento\App\Config\ScopePool|\PHPUnit_Framework_MockObject_MockObject */ - protected $_sectionPullMock; + protected $_scopePullMock; /** * @var \PHPUnit_Framework_MockObject_MockObject @@ -57,8 +57,8 @@ class StoreTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_sectionPullMock = $this->getMock('Magento\Core\Model\Config\SectionPool', array(), array(), '', false); - $this->_initialConfigMock = $this->getMock('Magento\Core\Model\Config\Initial', array(), array(), '', false); + $this->_scopePullMock = $this->getMock('Magento\App\Config\ScopePool', array(), array(), '', false); + $this->_initialConfigMock = $this->getMock('Magento\App\Config\Initial', array(), array(), '', false); $this->_collectionFactory = $this->getMock( 'Magento\Core\Model\Resource\Config\Value\Collection\ScopedFactory', array('create'), @@ -78,7 +78,7 @@ class StoreTest extends \PHPUnit_Framework_TestCase ->will($this->returnValue(true)); $placeholderProcessor = $this->getMock( - 'Magento\Core\Model\Config\Section\Processor\Placeholder', + 'Magento\Core\Model\Config\Scope\Processor\Placeholder', array(), array(), '', @@ -87,10 +87,10 @@ class StoreTest extends \PHPUnit_Framework_TestCase $placeholderProcessor->expects($this->any()) ->method('process') ->will($this->returnArgument(0)); - $this->_model = new \Magento\Core\Model\Config\Section\Reader\Store( + $this->_model = new \Magento\Core\Model\Config\Scope\Reader\Store( $this->_initialConfigMock, - $this->_sectionPullMock, - new \Magento\Core\Model\Config\Section\Store\Converter($placeholderProcessor), + $this->_scopePullMock, + new \Magento\Core\Model\Config\Scope\Store\Converter($placeholderProcessor), $this->_collectionFactory, $storeFactoryMock, $this->_appStateMock @@ -112,21 +112,22 @@ class StoreTest extends \PHPUnit_Framework_TestCase ->method('getId') ->will($this->returnValue($storeId)); - $sectionMock = $this->getMock('Magento\Core\Model\Config\Data', array(), array(), '', false); - $sectionMock->expects($this->any())->method('getValue')->will($this->returnValue(array( + $dataMock = $this->getMock('Magento\App\Config\Data', array(), array(), '', false); + $dataMock->expects($this->any())->method('getValue')->will($this->returnValue(array( 'config' => array('key0' => 'website_value0', 'key1' => 'website_value1'), ))); - $sectionMock->expects($this->once())->method('getSource')->will($this->returnValue(array( + + $dataMock->expects($this->once())->method('getSource')->will($this->returnValue(array( 'config' => array('key0' => 'website_value0', 'key1' => 'website_value1'), ))); - $this->_sectionPullMock->expects($this->once()) - ->method('getSection') + $this->_scopePullMock->expects($this->once()) + ->method('getScope') ->with('website', $websiteCode) - ->will($this->returnValue($sectionMock)); + ->will($this->returnValue($dataMock)); - $this->_initialConfigMock->expects($this->any()) - ->method('getStore') - ->with($storeCode) + $this->_initialConfigMock->expects($this->once()) + ->method('getData') + ->with("sotres|{$storeCode}") ->will($this->returnValue(array( 'config' => array('key1' => 'store_value1', 'key2' => 'store_value2'), ))); diff --git a/dev/tests/unit/testsuite/Magento/Core/Model/Config/Section/Reader/WebsiteTest.php b/dev/tests/unit/testsuite/Magento/Core/Model/Config/Scope/Reader/WebsiteTest.php similarity index 80% rename from dev/tests/unit/testsuite/Magento/Core/Model/Config/Section/Reader/WebsiteTest.php rename to dev/tests/unit/testsuite/Magento/Core/Model/Config/Scope/Reader/WebsiteTest.php index 282d8927b5ff36df40ec48c08747822c20e2f4ca..ecf2cc8b415967dbe3faa79e90565a53912ff632 100644 --- a/dev/tests/unit/testsuite/Magento/Core/Model/Config/Section/Reader/WebsiteTest.php +++ b/dev/tests/unit/testsuite/Magento/Core/Model/Config/Scope/Reader/WebsiteTest.php @@ -21,12 +21,12 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Core\Model\Config\Section\Reader; +namespace Magento\Core\Model\Config\Scope\Reader; class WebsiteTest extends \PHPUnit_Framework_TestCase { /** - * @var \Magento\Core\Model\Config\Section\Reader\Website + * @var \Magento\Core\Model\Config\Scope\Reader\Website */ protected $_model; @@ -36,9 +36,9 @@ class WebsiteTest extends \PHPUnit_Framework_TestCase protected $_initialConfigMock; /** - * @var \PHPUnit_Framework_MockObject_MockObject + * @var \Magento\App\Config\ScopePool|\PHPUnit_Framework_MockObject_MockObject */ - protected $_sectionPullMock; + protected $_scopePullMock; /** * @var \PHPUnit_Framework_MockObject_MockObject @@ -57,8 +57,8 @@ class WebsiteTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_initialConfigMock = $this->getMock('Magento\Core\Model\Config\Initial', array(), array(), '', false); - $this->_sectionPullMock = $this->getMock('Magento\Core\Model\Config\SectionPool', array(), array(), '', false); + $this->_initialConfigMock = $this->getMock('Magento\App\Config\Initial', array(), array(), '', false); + $this->_scopePullMock = $this->getMock('Magento\App\Config\ScopePool', array(), array(), '', false); $this->_collectionFactory = $this->getMock( 'Magento\Core\Model\Resource\Config\Value\Collection\ScopedFactory', array('create'), @@ -77,10 +77,10 @@ class WebsiteTest extends \PHPUnit_Framework_TestCase ->method('isInstalled') ->will($this->returnValue(true)); - $this->_model = new \Magento\Core\Model\Config\Section\Reader\Website( + $this->_model = new \Magento\Core\Model\Config\Scope\Reader\Website( $this->_initialConfigMock, - $this->_sectionPullMock, - new \Magento\Core\Model\Config\Section\Converter(), + $this->_scopePullMock, + new \Magento\App\Config\Scope\Converter(), $this->_collectionFactory, $websiteFactoryMock, $this->_appStateMock @@ -92,25 +92,25 @@ class WebsiteTest extends \PHPUnit_Framework_TestCase $websiteCode = 'default'; $websiteId = 1; - $sectionMock = $this->getMock('Magento\Core\Model\Config\Data', array(), array(), '', false); - $sectionMock->expects($this->any()) + $dataMock = $this->getMock('Magento\App\Config\Data', array(), array(), '', false); + $dataMock->expects($this->any()) ->method('getValue') ->will($this->returnValue(array( 'config' => array('key0' => 'default_value0', 'key1' => 'default_value1'), ))); - $sectionMock->expects($this->once()) + $dataMock->expects($this->once()) ->method('getSource') ->will($this->returnValue(array( 'config' => array('key0' => 'default_value0', 'key1' => 'default_value1'), ))); - $this->_sectionPullMock->expects($this->once()) - ->method('getSection') + $this->_scopePullMock->expects($this->once()) + ->method('getScope') ->with('default', null) - ->will($this->returnValue($sectionMock)); + ->will($this->returnValue($dataMock)); $this->_initialConfigMock->expects($this->any()) - ->method('getWebsite') - ->with($websiteCode) + ->method('getData') + ->with("websites|{$websiteCode}") ->will($this->returnValue(array( 'config' => array('key1' => 'website_value1', 'key2' => 'website_value2'), ))); diff --git a/dev/tests/unit/testsuite/Magento/Core/Model/Config/Section/ReaderPoolTest.php b/dev/tests/unit/testsuite/Magento/Core/Model/Config/Scope/ReaderPoolTest.php similarity index 76% rename from dev/tests/unit/testsuite/Magento/Core/Model/Config/Section/ReaderPoolTest.php rename to dev/tests/unit/testsuite/Magento/Core/Model/Config/Scope/ReaderPoolTest.php index 299d7fa3547c9d79338c6e5b9363a087e3de07ee..8df82026c0a452bb5cb195e8664bf45f00ea4bd9 100644 --- a/dev/tests/unit/testsuite/Magento/Core/Model/Config/Section/ReaderPoolTest.php +++ b/dev/tests/unit/testsuite/Magento/Core/Model/Config/Scope/ReaderPoolTest.php @@ -21,43 +21,43 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Core\Model\Config\Section; +namespace Magento\Core\Model\Config\Scope; class ReaderPoolTest extends \PHPUnit_Framework_TestCase { /** - * @var \Magento\Core\Model\Config\Section\ReaderPool + * @var \Magento\Core\Model\Config\Scope\ReaderPool */ protected $_model; /** - * @var \Magento\Core\Model\Config\Section\Reader\DefaultReader + * @var \Magento\Core\Model\Config\Scope\Reader\DefaultReader */ protected $_defaultReaderMock; /** - * @var \Magento\Core\Model\Config\Section\Reader\Website + * @var \Magento\Core\Model\Config\Scope\Reader\Website */ protected $_websiteReaderMock; /** - * @var \Magento\Core\Model\Config\Section\Reader\Store + * @var \Magento\Core\Model\Config\Scope\Reader\Store */ protected $_storeReaderMock; protected function setUp() { $this->_defaultReaderMock = $this->getMock( - 'Magento\Core\Model\Config\Section\Reader\DefaultReader', array(), array(), '', false + 'Magento\Core\Model\Config\Scope\Reader\DefaultReader', array(), array(), '', false ); $this->_websiteReaderMock = $this->getMock( - 'Magento\Core\Model\Config\Section\Reader\Website', array(), array(), '', false + 'Magento\Core\Model\Config\Scope\Reader\Website', array(), array(), '', false ); $this->_storeReaderMock = $this->getMock( - 'Magento\Core\Model\Config\Section\Reader\Store', array(), array(), '', false + 'Magento\Core\Model\Config\Scope\Reader\Store', array(), array(), '', false ); - $this->_model = new \Magento\Core\Model\Config\Section\ReaderPool( + $this->_model = new \Magento\Core\Model\Config\Scope\ReaderPool( $this->_defaultReaderMock, $this->_websiteReaderMock, $this->_storeReaderMock @@ -65,7 +65,7 @@ class ReaderPoolTest extends \PHPUnit_Framework_TestCase } /** - * @covers \Magento\Core\Model\Config\Section\ReaderPool::getReader + * @covers \Magento\Core\Model\Config\Scope\ReaderPool::getReader * @dataProvider getReaderDataProvider * @param string $scope * @param string $instanceType @@ -83,23 +83,23 @@ class ReaderPoolTest extends \PHPUnit_Framework_TestCase return array( array( 'scope' => 'default', - 'expectedResult' => 'Magento\Core\Model\Config\Section\Reader\DefaultReader' + 'expectedResult' => 'Magento\Core\Model\Config\Scope\Reader\DefaultReader' ), array( 'scope' => 'website', - 'expectedResult' => 'Magento\Core\Model\Config\Section\Reader\Website' + 'expectedResult' => 'Magento\Core\Model\Config\Scope\Reader\Website' ), array( 'scope' => 'websites', - 'expectedResult' => 'Magento\Core\Model\Config\Section\Reader\Website' + 'expectedResult' => 'Magento\Core\Model\Config\Scope\Reader\Website' ), array( 'scope' => 'store', - 'expectedResult' => 'Magento\Core\Model\Config\Section\Reader\Store' + 'expectedResult' => 'Magento\Core\Model\Config\Scope\Reader\Store' ), array( 'scope' => 'stores', - 'expectedResult' => 'Magento\Core\Model\Config\Section\Reader\Store' + 'expectedResult' => 'Magento\Core\Model\Config\Scope\Reader\Store' ) ); } diff --git a/dev/tests/unit/testsuite/Magento/Core/Model/Config/Section/Store/ConverterTest.php b/dev/tests/unit/testsuite/Magento/Core/Model/Config/Scope/Store/ConverterTest.php similarity index 88% rename from dev/tests/unit/testsuite/Magento/Core/Model/Config/Section/Store/ConverterTest.php rename to dev/tests/unit/testsuite/Magento/Core/Model/Config/Scope/Store/ConverterTest.php index 5b112143880a8987ec530b02241e881998e2dc4f..123c4d6f1b4a9493d73efa2934e75e7f6956514d 100644 --- a/dev/tests/unit/testsuite/Magento/Core/Model/Config/Section/Store/ConverterTest.php +++ b/dev/tests/unit/testsuite/Magento/Core/Model/Config/Scope/Store/ConverterTest.php @@ -21,11 +21,11 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Core\Model\Config\Section\Store; +namespace Magento\Core\Model\Config\Scope\Store; class ConverterTest extends \PHPUnit_Framework_TestCase { - /** @var \Magento\Core\Model\Config\Section\Store\Converter */ + /** @var \Magento\Core\Model\Config\Scope\Store\Converter */ protected $_model; /** @var \PHPUnit_Framework_MockObject_MockObject */ @@ -33,9 +33,9 @@ class ConverterTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_processorMock = $this->getMock('Magento\Core\Model\Config\Section\Processor\Placeholder', + $this->_processorMock = $this->getMock('Magento\Core\Model\Config\Scope\Processor\Placeholder', array(), array(), '', false); - $this->_model = new \Magento\Core\Model\Config\Section\Store\Converter($this->_processorMock); + $this->_model = new \Magento\Core\Model\Config\Scope\Store\Converter($this->_processorMock); } public function testConvert() diff --git a/dev/tests/unit/testsuite/Magento/Core/Model/Config/SectionPoolTest.php b/dev/tests/unit/testsuite/Magento/Core/Model/Config/SectionPoolTest.php deleted file mode 100644 index 1f7b5b00d4e4346652d18ee6e95d274e2ae1f625..0000000000000000000000000000000000000000 --- a/dev/tests/unit/testsuite/Magento/Core/Model/Config/SectionPoolTest.php +++ /dev/null @@ -1,221 +0,0 @@ -<?php -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - */ -namespace Magento\Core\Model\Config; - -class SectionPoolTest extends \PHPUnit_Framework_TestCase -{ - /** - * @var \Magento\Core\Model\Config\SectionPool - */ - protected $_model; - - /** - * @var \Magento\Core\Model\Config\Section\ReaderPool - */ - protected $_readerPoolMock; - - /** - * @var \Magento\Core\Model\Config\DataFactory - */ - protected $_dataFactoryMock; - - /** - * @var \Magento\Cache\FrontendInterface - */ - protected $_cacheMock; - - /** - * @var string - */ - protected $_cacheKey; - - /** - * @var string - */ - protected $_scopeType; - - /** - * @var string - */ - protected $_scopeCode; - - /** - * @var string - */ - protected $_configData; - - protected function setUp() - { - $this->_readerPoolMock = $this->getMock( - 'Magento\Core\Model\Config\Section\ReaderPool', array(), array(), '', false - ); - $this->_dataFactoryMock = $this->getMock( - 'Magento\Core\Model\Config\DataFactory', array('create'), array(), '', false - ); - $this->_cacheMock = $this->getMock('Magento\Cache\FrontendInterface'); - $this->_cacheKey = 'customCacheId'; - - $this->_scopeType = 'scopeType'; - $this->_scopeCode = 'scopeCode'; - $this->_configData = array('key' => 'value'); - - $this->_model = new \Magento\Core\Model\Config\SectionPool( - $this->_readerPoolMock, - $this->_dataFactoryMock, - $this->_cacheMock, - $this->_cacheKey - ); - } - - /** - * @covers \Magento\Core\Model\Config\SectionPool::getSection - */ - public function testGetSectionCached() - { - $this->_cacheMock->expects($this->once()) - ->method('load') - ->with($this->_cacheKey . '|' . $this->_scopeType . '|' . $this->_scopeCode) - ->will($this->returnValue(serialize($this->_configData))); - - $this->_dataFactoryMock->expects($this->once()) - ->method('create') - ->with(array('data' => $this->_configData)) - ->will($this->returnValue(new \Magento\Core\Model\Config\TestConfigClass())); - - $this->assertInstanceOf('Magento\Core\Model\Config\TestConfigClass', - $this->_model->getSection($this->_scopeType, $this->_scopeCode) - ); - } - - /** - * @covers \Magento\Core\Model\Config\SectionPool::getSection - */ - public function testGetSectionNotCachedCertainScope() - { - $this->_cacheMock->expects($this->once()) - ->method('load') - ->with($this->_cacheKey . '|' . $this->_scopeType . '|' . $this->_scopeCode) - ->will($this->returnValue(false)); - - $readerMock = $this->getMock('Magento\Core\Model\Config\TestReaderClass'); - - $readerMock->expects($this->once()) - ->method('read') - ->with($this->_scopeCode) - ->will($this->returnValue($this->_configData)); - - $this->_readerPoolMock->expects($this->once()) - ->method('getReader') - ->with($this->_scopeType) - ->will($this->returnValue($readerMock)); - - $this->_cacheMock->expects($this->once()) - ->method('save') - ->with( - serialize($this->_configData), - $this->_cacheKey . '|' . $this->_scopeType . '|' . $this->_scopeCode, - array(\Magento\Core\Model\Config\SectionPool::CACHE_TAG)); - - $this->_dataFactoryMock->expects($this->once()) - ->method('create') - ->with(array('data' => $this->_configData)) - ->will($this->returnValue(new \Magento\Core\Model\Config\TestConfigClass())); - - $this->assertInstanceOf( - 'Magento\Core\Model\Config\TestConfigClass', - $this->_model->getSection($this->_scopeType, $this->_scopeCode) - ); - } - - /** - * @covers \Magento\Core\Model\Config\SectionPool::getSection - */ - public function testGetSectionNotCachedDefaultScope() - { - $this->_cacheMock->expects($this->once()) - ->method('load') - ->with($this->_cacheKey . '|' . 'default' . '|' . $this->_scopeCode) - ->will($this->returnValue(false)); - - $readerMock = $this->getMock('Magento\Core\Model\Config\TestReaderClass'); - - $readerMock->expects($this->once()) - ->method('read') - ->with('primary') - ->will($this->returnValue($this->_configData)); - - $this->_readerPoolMock->expects($this->once()) - ->method('getReader') - ->with('default') - ->will($this->returnValue($readerMock)); - - $this->_cacheMock->expects($this->once()) - ->method('save') - ->with( - serialize($this->_configData), - $this->_cacheKey . '|' . 'default' . '|' . $this->_scopeCode, - array(\Magento\Core\Model\Config\SectionPool::CACHE_TAG)); - - $this->_dataFactoryMock->expects($this->once()) - ->method('create') - ->with(array('data' => $this->_configData)) - ->will($this->returnValue(new \Magento\Core\Model\Config\TestConfigClass())); - - $this->assertInstanceOf( - 'Magento\Core\Model\Config\TestConfigClass', - $this->_model->getSection('default', $this->_scopeCode) - ); - } - - /** - * @covers \Magento\Core\Model\Config\SectionPool::getSection - */ - public function testGetSectionMemoryCache() - { - $this->_cacheMock->expects($this->once()) - ->method('load') - ->with($this->_cacheKey . '|' . $this->_scopeType . '|' . $this->_scopeCode) - ->will($this->returnValue(serialize($this->_configData))); - - $this->_dataFactoryMock->expects($this->once()) - ->method('create') - ->with(array('data' => $this->_configData)) - ->will($this->returnValue(new \Magento\Core\Model\Config\TestConfigClass())); - - $this->_model->getSection($this->_scopeType, $this->_scopeCode); - $this->_model->getSection($this->_scopeType, $this->_scopeCode); - } - - /** - * @covers \Magento\Core\Model\Config\SectionPool::clean - */ - public function testClean() - { - $this->_cacheMock->expects($this->once()) - ->method('clean') - ->with(\Zend_Cache::CLEANING_MODE_MATCHING_TAG, array(\Magento\Core\Model\Config\SectionPool::CACHE_TAG)); - - $this->_model->clean(); - } -} diff --git a/dev/tests/unit/testsuite/Magento/Core/Model/Config/Storage/Writer/DbTest.php b/dev/tests/unit/testsuite/Magento/Core/Model/Config/Storage/DbTest.php similarity index 90% rename from dev/tests/unit/testsuite/Magento/Core/Model/Config/Storage/Writer/DbTest.php rename to dev/tests/unit/testsuite/Magento/Core/Model/Config/Storage/DbTest.php index 39afd1038a0b7e5ebe188c6c364b918a861975ef..8b848f554c0641f1e4b908da56fd4ea2773f5b2f 100644 --- a/dev/tests/unit/testsuite/Magento/Core/Model/Config/Storage/Writer/DbTest.php +++ b/dev/tests/unit/testsuite/Magento/Core/Model/Config/Storage/DbTest.php @@ -24,14 +24,14 @@ */ /** - * Test class for \Magento\Core\Model\Config\Storage\Writer\Db + * Test class for \Magento\Core\Model\Config\Storage\Db */ -namespace Magento\Core\Model\Config\Storage\Writer; +namespace Magento\Core\Model\Config\Storage; class DbTest extends \PHPUnit_Framework_TestCase { /** - * @var \Magento\Core\Model\Config\Storage\Writer\Db + * @var \Magento\Core\Model\Config\Storage\Db */ protected $_model; @@ -44,7 +44,7 @@ class DbTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->_resourceMock = $this->getMock('Magento\Core\Model\Resource\Config', array(), array(), '', false, false); - $this->_model = new \Magento\Core\Model\Config\Storage\Writer\Db($this->_resourceMock); + $this->_model = new \Magento\Core\Model\Config\Storage\Db($this->_resourceMock); } protected function tearDown() diff --git a/dev/tests/unit/testsuite/Magento/Core/Model/Config/TestConfigClass.php b/dev/tests/unit/testsuite/Magento/Core/Model/Config/TestConfigClass.php deleted file mode 100644 index 119df38a26cb8b748bd46f000aed0ba909f2d58e..0000000000000000000000000000000000000000 --- a/dev/tests/unit/testsuite/Magento/Core/Model/Config/TestConfigClass.php +++ /dev/null @@ -1,28 +0,0 @@ -<?php -/** - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - */ -namespace Magento\Core\Model\Config; - -class TestConfigClass -{ -} diff --git a/dev/tests/unit/testsuite/Magento/Core/Model/File/Storage/MediaTest.php b/dev/tests/unit/testsuite/Magento/Core/Model/File/Storage/MediaTest.php index b59188a32459e20ae6112969d0cf84964ca43d91..e654f5713e483d352bfe1486acb302f9c5660359 100644 --- a/dev/tests/unit/testsuite/Magento/Core/Model/File/Storage/MediaTest.php +++ b/dev/tests/unit/testsuite/Magento/Core/Model/File/Storage/MediaTest.php @@ -38,7 +38,7 @@ class MediaTest extends \PHPUnit_Framework_TestCase protected $_loggerMock; /** - * @var \Magento\App\Helper\Context + * @var \Magento\Core\Helper\File\Storage\Database */ protected $_storageHelperMock; diff --git a/dev/tests/unit/testsuite/Magento/Core/Model/Translate/Inline/ConfigTest.php b/dev/tests/unit/testsuite/Magento/Core/Model/Translate/Inline/ConfigTest.php index b6504c89bc146ccba99b84a4e1fe550e4fe1a1d5..68276315ebea160e2dd7e6fbc583789b824a3e82 100644 --- a/dev/tests/unit/testsuite/Magento/Core/Model/Translate/Inline/ConfigTest.php +++ b/dev/tests/unit/testsuite/Magento/Core/Model/Translate/Inline/ConfigTest.php @@ -38,7 +38,13 @@ class ConfigTest extends \PHPUnit_Framework_TestCase ->method('getConfigFlag') ->with($this->equalTo('dev/translate_inline/active'), $this->equalTo($store)) ->will($this->returnValue($result)); - $config = new Config($coreStoreConfig); + $objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); + $config = $objectManager->getObject( + '\Magento\Core\Model\Translate\Inline\Config', + array( + 'coreStoreConfig' => $coreStoreConfig + ) + ); $this->assertEquals($result, $config->isActive($store)); } } diff --git a/dev/tests/unit/testsuite/Magento/Core/Model/Validator/FactoryTest.php b/dev/tests/unit/testsuite/Magento/Core/Model/Validator/FactoryTest.php index d7139616882bd00f827bb5f31fd1889c9400f99d..82c091640d6b3ccf00ecc97a667e89ae4349f340 100644 --- a/dev/tests/unit/testsuite/Magento/Core/Model/Validator/FactoryTest.php +++ b/dev/tests/unit/testsuite/Magento/Core/Model/Validator/FactoryTest.php @@ -38,7 +38,7 @@ class FactoryTest extends \PHPUnit_Framework_TestCase protected $_config; /** - * @var \Magento\Core\Model\Translate + * @var \Magento\TranslateInterface */ protected $_translateAdapter; @@ -85,13 +85,9 @@ class FactoryTest extends \PHPUnit_Framework_TestCase ->will($this->returnValue(array('/tmp/moduleOne/etc/validation.xml'))); // Translate adapter mock - $this->_translateAdapter = $this->getMockBuilder('Magento\Core\Model\Translate') - ->setMethods(array('_getTranslatedString', 'translate')) + $this->_translateAdapter = $this->getMockBuilder('Magento\TranslateInterface') ->disableOriginalConstructor() ->getMock(); - $this->_translateAdapter->expects($this->any()) - ->method('_getTranslatedString') - ->will($this->returnArgument(0)); } /** diff --git a/dev/tests/unit/testsuite/Magento/Cron/Model/Config/Reader/DbTest.php b/dev/tests/unit/testsuite/Magento/Cron/Model/Config/Reader/DbTest.php index 28384f3fcf3b71d1768c3ba1d2e08eefafb33f7a..c5103337bab8a48a4dca8e9e8e6994153bc89bb6 100644 --- a/dev/tests/unit/testsuite/Magento/Cron/Model/Config/Reader/DbTest.php +++ b/dev/tests/unit/testsuite/Magento/Cron/Model/Config/Reader/DbTest.php @@ -28,7 +28,7 @@ namespace Magento\Cron\Model\Config\Reader; class DbTest extends \PHPUnit_Framework_TestCase { /** - * @var \Magento\Core\Model\Config\Section\Reader\DefaultReader|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Core\Model\Config\Scope\Reader\DefaultReader|\PHPUnit_Framework_MockObject_MockObject */ protected $_defaultReader; @@ -47,7 +47,7 @@ class DbTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { - $this->_defaultReader = $this->getMockBuilder('Magento\Core\Model\Config\Section\Reader\DefaultReader') + $this->_defaultReader = $this->getMockBuilder('Magento\Core\Model\Config\Scope\Reader\DefaultReader') ->disableOriginalConstructor() ->getMock(); $this->_converter = new \Magento\Cron\Model\Config\Converter\Db(); diff --git a/dev/tests/unit/testsuite/Magento/Customer/Controller/Adminhtml/IndexTest.php b/dev/tests/unit/testsuite/Magento/Customer/Controller/Adminhtml/IndexTest.php index 8e4769018e72d8b462508e917ac4d478a00ade8a..179ee0b0d80fe2ac650bf3610a93d173a431b2be 100644 --- a/dev/tests/unit/testsuite/Magento/Customer/Controller/Adminhtml/IndexTest.php +++ b/dev/tests/unit/testsuite/Magento/Customer/Controller/Adminhtml/IndexTest.php @@ -121,11 +121,6 @@ class IndexTest extends \PHPUnit_Framework_TestCase ->setMethods(array('getUrl')) ->getMock(); - $translator = $this->getMockBuilder('Magento\Core\Model\Translate') - ->disableOriginalConstructor() - ->setMethods(array('getTranslateInline', '__wakeup')) - ->getMock(); - $this->messageManager = $this->getMockBuilder('Magento\Message\Manager') ->disableOriginalConstructor() ->setMethods(array('addSuccess')) @@ -154,7 +149,6 @@ class IndexTest extends \PHPUnit_Framework_TestCase $contextMock->expects($this->any())->method('getHelper')->will($this->returnValue($this->_helper)); $contextMock->expects($this->any())->method('getSession')->will($this->returnValue($this->_session)); - $contextMock->expects($this->any())->method('getTranslator')->will($this->returnValue($translator)); $contextMock->expects($this->any()) ->method('getMessageManager') ->will($this->returnValue($this->messageManager)); diff --git a/dev/tests/unit/testsuite/Magento/DesignEditor/Controller/Adminhtml/System/Design/EditorTest.php b/dev/tests/unit/testsuite/Magento/DesignEditor/Controller/Adminhtml/System/Design/EditorTest.php index d995b7fc0298856d9319ff5951bcbf960b698ddc..75942f0a3eb958e3f3ed1135416e622e1ba5f1ce 100644 --- a/dev/tests/unit/testsuite/Magento/DesignEditor/Controller/Adminhtml/System/Design/EditorTest.php +++ b/dev/tests/unit/testsuite/Magento/DesignEditor/Controller/Adminhtml/System/Design/EditorTest.php @@ -184,7 +184,7 @@ class EditorTest extends \PHPUnit_Framework_TestCase */ protected function _getObjectManagerMap($countCustomization) { - $translate = $this->getMock('Magento\Core\Model\Translate', array(), array(), '', false); + $translate = $this->getMock('Magento\TranslateInterface', array(), array(), '', false); $translate->expects($this->any())->method('translate') ->will($this->returnSelf()); @@ -203,7 +203,7 @@ class EditorTest extends \PHPUnit_Framework_TestCase $this->returnValue($this->getMock('Magento\Message\Collection', array(), array(), '', false)) ); - $inlineMock = $this->getMock('Magento\Core\Model\Translate\Inline', array(), array(), '', false); + $inlineMock = $this->getMock('Magento\Translate\Inline', array(), array(), '', false); $aclFilterMock = $this->getMock('Magento\Core\Model\Layout\Filter\Acl', array(), array(), '', false); return array( @@ -211,13 +211,13 @@ class EditorTest extends \PHPUnit_Framework_TestCase 'Magento\Core\Model\Resource\Theme\CollectionFactory', $this->_getThemeCollectionFactory($countCustomization) ), - array('Magento\Core\Model\Translate', $translate), + array('Magento\TranslateInterface', $translate), array('Magento\App\ConfigInterface', $configMock), array('Magento\Event\ManagerInterface', $eventManager), array('Magento\Core\Model\StoreManager', $storeManager), array('Magento\AuthorizationInterface', $authMock), array('Magento\Backend\Model\Session', $backendSession), - array('Magento\Core\Model\Translate\Inline', $inlineMock), + array('Magento\Translate\Inline', $inlineMock), array('Magento\Core\Model\Layout\Filter\Acl', $aclFilterMock), ); } diff --git a/dev/tests/unit/testsuite/Magento/DesignEditor/Helper/DataTest.php b/dev/tests/unit/testsuite/Magento/DesignEditor/Helper/DataTest.php index b7dc42785cf18d88fcaf301d393bdcbae7d90702..e9b91a1bd7b57696d1fe0e5acb3a933431e0be75 100644 --- a/dev/tests/unit/testsuite/Magento/DesignEditor/Helper/DataTest.php +++ b/dev/tests/unit/testsuite/Magento/DesignEditor/Helper/DataTest.php @@ -44,11 +44,6 @@ class DataTest extends \PHPUnit_Framework_TestCase */ protected $_model; - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $_translatorMock; - /** * @var \PHPUnit_Framework_MockObject_MockObject */ @@ -56,10 +51,7 @@ class DataTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_translatorMock = $this->getMock('Magento\Core\Model\Translate', array(), array(), '', false); $this->_context = $this->getMock('Magento\App\Helper\Context', array(), array(), '', false); - $this->_context - ->expects($this->any())->method('getTranslator')->will($this->returnValue($this->_translatorMock)); } protected function tearDown() diff --git a/dev/tests/unit/testsuite/Magento/ImportExport/Model/Import/Entity/CustomerCompositeTest.php b/dev/tests/unit/testsuite/Magento/ImportExport/Model/Import/Entity/CustomerCompositeTest.php index a911906de11ed6b229b3b0a702bad671103e4c3a..d18d9e2e2a918515fed17a33f049ffb7c54da233 100644 --- a/dev/tests/unit/testsuite/Magento/ImportExport/Model/Import/Entity/CustomerCompositeTest.php +++ b/dev/tests/unit/testsuite/Magento/ImportExport/Model/Import/Entity/CustomerCompositeTest.php @@ -110,14 +110,18 @@ class CustomerCompositeTest extends \PHPUnit_Framework_TestCase protected function setUp() { $objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); - $translator = $this->getMock('Magento\Core\Model\Translate', array('isAllowed'), array(), '', false); - $translator->expects($this->any()) + $translateInline = $this->getMock('\Magento\Translate\InlineInterface', array(), array(), '', false); + $translateInline->expects($this->any()) ->method('isAllowed') ->will($this->returnValue(false)); - $context = $this->getMock('Magento\App\Helper\Context', array('getTranslator'), array(), '', false); - $context->expects($this->any())->method('getTranslator')->will($this->returnValue($translator)); + $inlineFactory = $this->getMock('\Magento\Translate\InlineFactory', array(), array(), '', false); + $inlineFactory->expects($this->any()) + ->method('get') + ->will($this->returnValue($translateInline)); + $context = $this->getMock('Magento\App\Helper\Context', array('getInlineFactory'), array(), '', false); + $context->expects($this->any())->method('getInlineFactory')->will($this->returnValue($inlineFactory)); $data = array( - 'translator' => $translator, + 'inlineFactory' => $inlineFactory, 'context' => $context, 'locale' => $this->getMock('Magento\Core\Model\Locale', array(), array(), '', false), 'dateModel' => $this->getMock('Magento\Core\Model\Date', array(), array(), '', false) diff --git a/dev/tests/unit/testsuite/Magento/Integration/Controller/Adminhtml/IntegrationTest.php b/dev/tests/unit/testsuite/Magento/Integration/Controller/Adminhtml/IntegrationTest.php index 5df13c474f98049a0e50d6266cf2013216a31fe6..5c8767389003f8ab4f53bbcb59f2e36e2df89154 100644 --- a/dev/tests/unit/testsuite/Magento/Integration/Controller/Adminhtml/IntegrationTest.php +++ b/dev/tests/unit/testsuite/Magento/Integration/Controller/Adminhtml/IntegrationTest.php @@ -57,7 +57,7 @@ class IntegrationTest extends \PHPUnit_Framework_TestCase /** @var \Magento\Event\ManagerInterface|\PHPUnit_Framework_MockObject_MockObject */ protected $_eventManagerMock; - /** @var \Magento\Core\Model\Translate|\PHPUnit_Framework_MockObject_MockObject */ + /** @var \Magento\Translate|\PHPUnit_Framework_MockObject_MockObject */ protected $_translateModelMock; /** @var \Magento\Backend\Model\Session|\PHPUnit_Framework_MockObject_MockObject */ @@ -134,7 +134,7 @@ class IntegrationTest extends \PHPUnit_Framework_TestCase $this->_backendSessionMock = $this->getMockBuilder('Magento\Backend\Model\Session') ->disableOriginalConstructor() ->getMock(); - $this->_translateModelMock = $this->getMockBuilder('Magento\Core\Model\Translate') + $this->_translateModelMock = $this->getMockBuilder('Magento\TranslateInterface') ->disableOriginalConstructor() ->getMock(); $this->_integrationSvcMock = $this->getMockBuilder('Magento\Integration\Service\IntegrationV1') @@ -650,7 +650,7 @@ HANDLE; array('Magento\App\ConfigInterface', $this->_configMock), array('Magento\Core\Model\Layout\Filter\Acl', $this->_layoutFilterMock), array('Magento\Backend\Model\Session', $this->_backendSessionMock), - array('Magento\Core\Model\Translate', $this->_translateModelMock), + array('Magento\TranslateInterface', $this->_translateModelMock), array('Magento\Config\ScopeInterface', $this->_configScopeMock) ); $this->_objectManagerMock->expects($this->any()) diff --git a/dev/tests/unit/testsuite/Magento/Core/Model/Locale/Hierarchy/ConfigTest.php b/dev/tests/unit/testsuite/Magento/Locale/Hierarchy/ConfigTest.php similarity index 88% rename from dev/tests/unit/testsuite/Magento/Core/Model/Locale/Hierarchy/ConfigTest.php rename to dev/tests/unit/testsuite/Magento/Locale/Hierarchy/ConfigTest.php index 504eed30d32779194865ef2e23d8b63c60901ca4..7c868ff495cee37dfe12c0d35b6c67dc1fe79f0a 100644 --- a/dev/tests/unit/testsuite/Magento/Core/Model/Locale/Hierarchy/ConfigTest.php +++ b/dev/tests/unit/testsuite/Magento/Locale/Hierarchy/ConfigTest.php @@ -21,12 +21,12 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Core\Model\Locale\Hierarchy; +namespace Magento\Locale\Hierarchy; class ConfigTest extends \PHPUnit_Framework_TestCase { /** - * @var \Magento\Core\Model\Locale\Hierarchy\Config + * @var \Magento\Locale\Hierarchy\Config */ protected $_model; @@ -53,7 +53,7 @@ class ConfigTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->_configReaderMock = $this->getMock( - 'Magento\Core\Model\Locale\Hierarchy\Config\Reader', array(), array(), '', false + '\Magento\Config\ReaderInterface', array(), array(), '', false ); $this->_cacheMock = $this->getMock('Magento\Config\CacheInterface'); $this->_cacheId = 'customCacheId'; @@ -65,7 +65,7 @@ class ConfigTest extends \PHPUnit_Framework_TestCase ->with($this->_cacheId) ->will($this->returnValue(serialize($this->_testData))); - $this->_model = new \Magento\Core\Model\Locale\Hierarchy\Config( + $this->_model = new \Magento\Locale\Hierarchy\Config( $this->_configReaderMock, $this->_cacheMock, $this->_cacheId diff --git a/dev/tests/unit/testsuite/Magento/Mail/Template/TransportBuilderTest.php b/dev/tests/unit/testsuite/Magento/Mail/Template/TransportBuilderTest.php new file mode 100644 index 0000000000000000000000000000000000000000..96d1d3c7a6bc32324f43f4f4d828b164cb32a801 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Mail/Template/TransportBuilderTest.php @@ -0,0 +1,168 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Mail\Template; + +class TransportBuilderTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Mail\Template\TransportBuilder + */ + protected $builder; + + /** + * @var \Magento\Mail\Template\FactoryInterface | \PHPUnit_Framework_MockObject_MockObject + */ + protected $templateFactoryMock; + + /** + * @var \Magento\Mail\Message | \PHPUnit_Framework_MockObject_MockObject + */ + protected $messageMock; + + /** + * @var \Magento\ObjectManager | \PHPUnit_Framework_MockObject_MockObject + */ + protected $objectManagerMock; + + public function setUp() + { + $helper = new \Magento\TestFramework\Helper\ObjectManager($this); + $this->templateFactoryMock = $this->getMock('\Magento\Mail\Template\FactoryInterface'); + $this->messageMock = $this->getMock('\Magento\Mail\Message'); + $this->objectManagerMock = $this->getMock('\Magento\ObjectManager'); + + $this->builder = $helper->getObject('\Magento\Mail\Template\TransportBuilder', array( + 'templateFactory' => $this->templateFactoryMock, + 'message' => $this->messageMock, + 'objectManager' => $this->objectManagerMock + )); + } + + /** + * @dataProvider getTransportDataProvider + * @param int $templateType + * @param string $bodyText + */ + public function testGetTransport($templateType, $messageType, $bodyText) + { + $vars = array( + 'reason' => 'Reason', + 'customer' => 'Customer' + ); + $options = array( + 'area' => 'frontend', + 'store' => 1 + ); + $template = $this->getMock('\Magento\Mail\Template\TemplateInterface'); + $template->expects($this->once()) + ->method('setVars') + ->with($this->equalTo($vars)) + ->will($this->returnSelf()); + $template->expects($this->once()) + ->method('setOptions') + ->with($this->equalTo($options)) + ->will($this->returnSelf()); + $template->expects($this->once()) + ->method('getSubject') + ->will($this->returnValue('Email Subject')); + $template->expects($this->once()) + ->method('getType') + ->will($this->returnValue($templateType)); + $template->expects($this->once()) + ->method('processTemplate') + ->will($this->returnValue($bodyText)); + + $this->templateFactoryMock->expects($this->once()) + ->method('get') + ->with($this->equalTo('identifier')) + ->will($this->returnValue($template)); + + $this->messageMock->expects($this->once()) + ->method('setSubject') + ->with($this->equalTo('Email Subject')) + ->will($this->returnSelf()); + $this->messageMock->expects($this->once()) + ->method('setMessageType') + ->with($this->equalTo($messageType)) + ->will($this->returnSelf()); + $this->messageMock->expects($this->once()) + ->method('setBody') + ->with($this->equalTo($bodyText)) + ->will($this->returnSelf()); + + $transport = $this->getMock('\Magento\Mail\TransportInterface'); + + $this->objectManagerMock->expects($this->once()) + ->method('create') + ->with( + $this->equalTo('\Magento\Mail\TransportInterface'), + $this->equalTo(array('message' => $this->messageMock)) + ) + ->will($this->returnValue($transport)); + + $this->builder->setTemplateIdentifier('identifier') + ->setTemplateVars($vars) + ->setTemplateOptions($options); + + $result = $this->builder->getTransport(); + + $this->assertInstanceOf('\Magento\Mail\TransportInterface', $result); + } + + public function getTransportDataProvider() + { + return array( + array( + \Magento\Mail\Template\TemplateInterface::TYPE_TEXT, + \Magento\Mail\Message::TYPE_TEXT, + 'Plain text' + ), + array( + \Magento\Mail\Template\TemplateInterface::TYPE_HTML, + \Magento\Mail\Message::TYPE_HTML, + '<h1>Html message</h1>' + ) + ); + } + + public function testSetFrom() + { + $this->messageMock->expects($this->once()) + ->method('setFrom') + ->with('from@example.com') + ->will($this->returnSelf()); + + $this->builder->setFrom('from@example.com'); + } + + public function testSetCc() + { + $this->messageMock->expects($this->once()) + ->method('addCc') + ->with('cc@example.com') + ->will($this->returnSelf()); + + $this->builder->addCc('cc@example.com'); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Multishipping/Model/Payment/Method/Specification/EnabledTest.php b/dev/tests/unit/testsuite/Magento/Multishipping/Model/Payment/Method/Specification/EnabledTest.php new file mode 100644 index 0000000000000000000000000000000000000000..254e502c050b9ee2ab04a5fbec86855dc264db7d --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Multishipping/Model/Payment/Method/Specification/EnabledTest.php @@ -0,0 +1,100 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Multishipping\Model\Payment\Method\Specification; + +/** + * Enabled method Test + */ +class EnabledTest extends \PHPUnit_Framework_TestCase +{ + /** + * Object Manager helper + * + * @var \Magento\TestFramework\Helper\ObjectManager + */ + protected $objectManager; + + /** + * Payment config mock + * + * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Payment\Model\Config + */ + protected $paymentConfigMock; + + public function setUp() + { + $this->paymentConfigMock = $this->getMock('\Magento\Payment\Model\Config', array(), array(), '', false); + $this->objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); + } + + /** + * Test isSatisfiedBy method + * + * @param array $methodsInfo + * @param bool $result + * @dataProvider methodsDataProvider + */ + public function testIsSatisfiedBy($methodsInfo, $result) + { + $method = 'method-name'; + $methodsInfo = array($method => $methodsInfo); + + $this->paymentConfigMock->expects($this->once())->method('getMethodsInfo') + ->will($this->returnValue($methodsInfo)); + + $configSpecification = $this->objectManager->getObject( + 'Magento\Multishipping\Model\Payment\Method\Specification\Enabled', + array( + 'paymentConfig' => $this->paymentConfigMock, + ) + ); + + $this->assertEquals( + $result, + $configSpecification->isSatisfiedBy($method), + sprintf('Failed payment method test: "%s"', $method) + ); + } + + /** + * Data provider + * + * @return array + */ + public function methodsDataProvider() + { + return array( + array( + array('allow_multiple_address' => 1), true, + ), + array( + array('allow_multiple_address' => 0), false, + ), + array( + array('no_flag' => 0), false, + ), + ); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Multishipping/Model/Payment/Method/Specification/Is3DSecureTest.php b/dev/tests/unit/testsuite/Magento/Multishipping/Model/Payment/Method/Specification/Is3DSecureTest.php new file mode 100644 index 0000000000000000000000000000000000000000..c8a100d6c3d237e5d3b5f9636c9e630733fc0fcb --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Multishipping/Model/Payment/Method/Specification/Is3DSecureTest.php @@ -0,0 +1,118 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Multishipping\Model\Payment\Method\Specification; + +/** + * Multishipping specification Test + */ +class Is3DSecureTest extends \PHPUnit_Framework_TestCase +{ + /** + * Object Manager helper + * + * @var \Magento\TestFramework\Helper\ObjectManager + */ + protected $objectManager; + + /** + * Payment config mock + * + * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Payment\Model\Config + */ + protected $paymentConfigMock; + + /** + * Store config mock + * + * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Core\Model\Store\Config + */ + protected $storeConfigMock; + + public function setUp() + { + $this->paymentConfigMock = $this->getMock('\Magento\Payment\Model\Config', array(), array(), '', false); + $this->storeConfigMock = $this->getMock('\Magento\Core\Model\Store\Config', array(), array(), '', false); + $this->objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); + } + + /** + * Test isSatisfiedBy method + * + * @param array $methodsInfo + * @param bool $is3DSecureEnabled + * @param bool $result + * @dataProvider methodsDataProvider + */ + public function testIsSatisfiedBy($methodsInfo, $is3DSecureEnabled, $result) + { + $method = 'method-name'; + $methodsInfo = array($method => $methodsInfo); + + $this->paymentConfigMock->expects($this->once())->method('getMethodsInfo') + ->will($this->returnValue($methodsInfo)); + $this->storeConfigMock->expects($this->any())->method('getConfigFlag') + ->will($this->returnValue($is3DSecureEnabled)); + + $configSpecification = $this->objectManager->getObject( + 'Magento\Multishipping\Model\Payment\Method\Specification\Is3DSecure', + array( + 'paymentConfig' => $this->paymentConfigMock, + 'storeConfig' => $this->storeConfigMock, + ) + ); + + $this->assertEquals( + $result, + $configSpecification->isSatisfiedBy($method), + sprintf('Failed payment method test: "%s"', $method) + ); + } + + /** + * Data provider + * + * @return array + */ + public function methodsDataProvider() + { + return array( + array( + array('allow_multiple_with_3dsecure' => 1), true, true, + ), + array( + array('allow_multiple_with_3dsecure' => 1), false, true, + ), + array( + array('allow_multiple_with_3dsecure' => 0), true, false, + ), + array( + array('allow_multiple_with_3dsecure' => 0), false, true, + ), + array( + array('no-flag' => 0), true, false, + ), + ); + } +} diff --git a/dev/tests/unit/testsuite/Magento/PageCache/Controller/BlockTest.php b/dev/tests/unit/testsuite/Magento/PageCache/Controller/BlockTest.php index 6f59c3ccdabde351d035e888d0a62eb9ae7fb39e..cd272383b19f7032221ec9dca660b619c51b1c42 100644 --- a/dev/tests/unit/testsuite/Magento/PageCache/Controller/BlockTest.php +++ b/dev/tests/unit/testsuite/Magento/PageCache/Controller/BlockTest.php @@ -124,8 +124,6 @@ class BlockTest extends \PHPUnit_Framework_TestCase $blocks = array('block1', 'block2'); $handles = array('handle1', 'handle2'); $expectedData = array('block1' => 'data1', 'block2' => 'data2'); - // one year - $maxAge = 365 * 24 * 60 * 60; $blockInstance1 = $this->getMockForAbstractClass( 'Magento\View\Element\AbstractBlock', array(), '', false, true, true, array('toHtml') @@ -161,17 +159,7 @@ class BlockTest extends \PHPUnit_Framework_TestCase ->with($this->equalTo($blocks[1])) ->will($this->returnValue($blockInstance2)); - $this->responseMock->expects($this->at(0)) - ->method('setHeader') - ->with( - $this->equalTo('cache-control'), - $this->equalTo('private, max-age=' . $maxAge), - $this->equalTo(true) - ); - $this->responseMock->expects($this->at(1)) - ->method('setHeader') - ->with($this->equalTo('expires')); - $this->responseMock->expects($this->at(2)) + $this->responseMock->expects($this->once()) ->method('appendBody') ->with($this->equalTo(json_encode($expectedData))); diff --git a/dev/tests/unit/testsuite/Magento/PageCache/Model/App/FrontController/HeaderPluginTest.php b/dev/tests/unit/testsuite/Magento/PageCache/Model/App/FrontController/HeaderPluginTest.php index 2dea378966809c34a8fcf81dce4c1d94b858b72a..88efd47fe8a153a7e1a318225133fe60f763a210 100644 --- a/dev/tests/unit/testsuite/Magento/PageCache/Model/App/FrontController/HeaderPluginTest.php +++ b/dev/tests/unit/testsuite/Magento/PageCache/Model/App/FrontController/HeaderPluginTest.php @@ -27,6 +27,8 @@ namespace Magento\PageCache\Model\App\FrontController; +use Magento\PageCache\Helper\Data; + class HeaderPluginTest extends \PHPUnit_Framework_TestCase { /** @@ -82,6 +84,10 @@ class HeaderPluginTest extends \PHPUnit_Framework_TestCase $pragma = 'no-cache'; $cacheControl = 'no-store, no-cache, must-revalidate, max-age=0'; + $this->layoutMock->expects($this->once()) + ->method('isPrivate') + ->will($this->returnValue(false)); + $this->layoutMock->expects($this->once()) ->method('isCacheable') ->will($this->returnValue(false)); @@ -107,20 +113,25 @@ class HeaderPluginTest extends \PHPUnit_Framework_TestCase public function testAfterDispatchPrivateCache() { $pragma = 'cache'; + $maxAge = Data::PRIVATE_MAX_AGE_CACHE; + $cacheControl = 'private, max-age=' . $maxAge; $this->layoutMock->expects($this->once()) - ->method('isCacheable') + ->method('isPrivate') ->will($this->returnValue(true)); $this->responseMock->expects($this->at(0)) ->method('setHeader') ->with($this->equalTo('pragma'), $this->equalTo($pragma), $this->equalTo(true)); $this->responseMock->expects($this->at(1)) - ->method('getHeader') - ->with($this->equalTo('cache-control')) - ->will($this->returnValue(true)); + ->method('setHeader') + ->with($this->equalTo('cache-control'), $this->equalTo($cacheControl), $this->equalTo(true)); + $this->responseMock->expects($this->at(2)) + ->method('setHeader') + ->with($this->equalTo('expires')); - $this->versionMock->expects($this->once())->method('process'); + $this->layoutMock->expects($this->never())->method('isCacheable'); + $this->versionMock->expects($this->never())->method('process'); $this->plugin->afterDispatch($this->responseMock); } @@ -134,6 +145,10 @@ class HeaderPluginTest extends \PHPUnit_Framework_TestCase $pragma = 'cache'; $cacheControl = 'public, max-age=' . $maxAge; + $this->layoutMock->expects($this->once()) + ->method('isPrivate') + ->will($this->returnValue(false)); + $this->layoutMock->expects($this->once()) ->method('isCacheable') ->will($this->returnValue(true)); @@ -144,13 +159,9 @@ class HeaderPluginTest extends \PHPUnit_Framework_TestCase ->method('setHeader') ->with($this->equalTo('pragma'), $this->equalTo($pragma), $this->equalTo(true)); $this->responseMock->expects($this->at(1)) - ->method('getHeader') - ->with($this->equalTo('cache-control')) - ->will($this->returnValue(false)); - $this->responseMock->expects($this->at(2)) ->method('setHeader') ->with($this->equalTo('cache-control'), $this->equalTo($cacheControl), $this->equalTo(true)); - $this->responseMock->expects($this->at(3)) + $this->responseMock->expects($this->at(2)) ->method('setHeader') ->with($this->equalTo('expires')); diff --git a/dev/tests/unit/testsuite/Magento/Payment/Model/Cart/SalesModel/FactoryTest.php b/dev/tests/unit/testsuite/Magento/Payment/Model/Cart/SalesModel/FactoryTest.php new file mode 100644 index 0000000000000000000000000000000000000000..f37b7317d7791bd418f2d3f3e9aa38dfbd31a47d --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Payment/Model/Cart/SalesModel/FactoryTest.php @@ -0,0 +1,71 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Payment\Model\Cart\SalesModel; + +class FactoryTest extends \PHPUnit_Framework_TestCase +{ + /** @var \Magento\Payment\Model\Cart\SalesModel\Factory */ + protected $_model; + + /** @var \Magento\ObjectManager|\PHPUnit_Framework_MockObject_MockObject */ + protected $_objectManagerMock; + + protected function setUp() + { + $this->_objectManagerMock = $this->getMockForAbstractClass('Magento\ObjectManager'); + $this->_model = new \Magento\Payment\Model\Cart\SalesModel\Factory($this->_objectManagerMock); + } + + /** + * @param string $salesModelClass + * @param string $expectedType + * @dataProvider createDataProvider + */ + public function testCreate($salesModelClass, $expectedType) + { + $salesModel = $this->getMock($salesModelClass, ['__wakeup'], [], '', false); + $this->_objectManagerMock->expects($this->once()) + ->method('create') + ->with($expectedType, ['salesModel' => $salesModel]) + ->will($this->returnValue('some value')); + $this->assertEquals('some value', $this->_model->create($salesModel)); + } + + public function createDataProvider() + { + return [ + ['Magento\Sales\Model\Quote', 'Magento\Payment\Model\Cart\SalesModel\Quote'], + ['Magento\Sales\Model\Order', 'Magento\Payment\Model\Cart\SalesModel\Order'], + ]; + } + + /** + * @expectedException \InvalidArgumentException + */ + public function testCreateInvalid() + { + $this->_model->create('any invalid'); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Payment/Model/Cart/SalesModel/OrderTest.php b/dev/tests/unit/testsuite/Magento/Payment/Model/Cart/SalesModel/OrderTest.php new file mode 100644 index 0000000000000000000000000000000000000000..281caf4c0ec4f029015eaef79d2ed5da8ed2e90c --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Payment/Model/Cart/SalesModel/OrderTest.php @@ -0,0 +1,131 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Payment\Model\Cart\SalesModel; + +class OrderTest extends \PHPUnit_Framework_TestCase +{ + /** @var \Magento\Payment\Model\Cart\SalesModel\Order */ + protected $_model; + + /** @var \Magento\Sales\Model\Order|\PHPUnit_Framework_MockObject_MockObject */ + protected $_orderMock; + + protected function setUp() + { + $this->_orderMock = $this->getMock('Magento\Sales\Model\Order', [], [], '', false); + $this->_model = new \Magento\Payment\Model\Cart\SalesModel\Order($this->_orderMock); + } + + /** + * @param string $getterMethod + * @dataProvider gettersDataProvider + */ + public function testGetters($getterMethod) + { + $this->_orderMock + ->expects($this->once()) + ->method('__call') + ->with($getterMethod) + ->will($this->returnValue('some value')); + $this->assertEquals('some value', $this->_model->$getterMethod()); + } + + public function gettersDataProvider() + { + return [ + ['getBaseSubtotal'], + ['getBaseTaxAmount'], + ['getBaseShippingAmount'], + ['getBaseDiscountAmount'], + ]; + } + + public function testGetDataUsingMethod() + { + $this->_orderMock + ->expects($this->once()) + ->method('getDataUsingMethod') + ->with('any key', 'any args') + ->will($this->returnValue('some value')); + $this->assertEquals('some value', $this->_model->getDataUsingMethod('any key', 'any args')); + } + + public function testGetTaxContainer() + { + $this->assertEquals($this->_orderMock, $this->_model->getTaxContainer()); + } + + public function testGetAllItems() + { + $items = [ + new \Magento\Object([ + 'parent_item' => 'parent item 1', + 'name' => 'name 1', + 'qty_ordered' => 1, + 'base_price' => 0.1, + ]), + new \Magento\Object([ + 'parent_item' => 'parent item 2', + 'name' => 'name 2', + 'qty_ordered' => 2, + 'base_price' => 1.2, + ]), + new \Magento\Object([ + 'parent_item' => 'parent item 3', + 'name' => 'name 3', + 'qty_ordered' => 3, + 'base_price' => 2.3, + ]), + ]; + $expected = [ + new \Magento\Object([ + 'parent_item' => 'parent item 1', + 'name' => 'name 1', + 'qty' => 1, + 'price' => 0.1, + 'original_item' => $items[0], + ]), + new \Magento\Object([ + 'parent_item' => 'parent item 2', + 'name' => 'name 2', + 'qty' => 2, + 'price' => 1.2, + 'original_item' => $items[1], + ]), + new \Magento\Object([ + 'parent_item' => 'parent item 3', + 'name' => 'name 3', + 'qty' => 3, + 'price' => 2.3, + 'original_item' => $items[2], + ]), + ]; + $this->_orderMock + ->expects($this->once()) + ->method('getAllItems') + ->will($this->returnValue($items)); + $this->assertEquals($expected, $this->_model->getAllItems()); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Payment/Model/Cart/SalesModel/QuoteTest.php b/dev/tests/unit/testsuite/Magento/Payment/Model/Cart/SalesModel/QuoteTest.php new file mode 100644 index 0000000000000000000000000000000000000000..47316db90a0d645c486fe6bd9fe5ac8a75648c21 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Payment/Model/Cart/SalesModel/QuoteTest.php @@ -0,0 +1,183 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @category Magento + * @package Magento_Payment + * @subpackage unit_tests + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Payment\Model\Cart\SalesModel; + +class QuoteTest extends \PHPUnit_Framework_TestCase +{ + /** @var \Magento\Payment\Model\Cart\SalesModel\Quote */ + protected $_model; + + /** @var \Magento\Sales\Model\Quote|\PHPUnit_Framework_MockObject_MockObject */ + protected $_quoteMock; + + protected function setUp() + { + $this->_quoteMock = $this->getMock('Magento\Sales\Model\Quote', [], [], '', false); + $this->_model = new \Magento\Payment\Model\Cart\SalesModel\Quote($this->_quoteMock); + } + + public function testGetDataUsingMethod() + { + $this->_quoteMock + ->expects($this->once()) + ->method('getDataUsingMethod') + ->with('any key', 'any args') + ->will($this->returnValue('some value')); + $this->assertEquals('some value', $this->_model->getDataUsingMethod('any key', 'any args')); + } + + public function testGetTaxContainer() + { + $this->_quoteMock + ->expects($this->any()) + ->method('getBillingAddress') + ->will($this->returnValue('billing address')); + $this->_quoteMock + ->expects($this->any()) + ->method('getShippingAddress') + ->will($this->returnValue('shipping address')); + $this->assertEquals('shipping address', $this->_model->getTaxContainer()); + $this->_quoteMock + ->expects($this->any()) + ->method('getIsVirtual') + ->will($this->returnValue(1)); + $this->assertEquals('billing address', $this->_model->getTaxContainer()); + } + + /** + * @param int $isNominal + * @param string $pItem + * @param string $name + * @param int $qty + * @param float $price + * @dataProvider getAllItemsDataProvider + */ + public function testGetAllItems($isNominal, $pItem, $name, $qty, $price) + { + $itemMock = $this->getMock('Magento\Sales\Model\Quote\Item\AbstractItem', [], [], '', false) ; + $itemMock + ->expects($this->any()) + ->method('isNominal') + ->will($this->returnValue($isNominal)); + $itemMock + ->expects($this->any()) + ->method('getParentItem') + ->will($this->returnValue($pItem)); + $itemMock + ->expects($this->once()) + ->method('__call') + ->with('getName') + ->will($this->returnValue($name)); + $itemMock + ->expects($this->any()) + ->method('getTotalQty') + ->will($this->returnValue($qty)); + $itemMock + ->expects($this->any()) + ->method('getBaseCalculationPrice') + ->will($this->returnValue($price)); + $expected = [ + new \Magento\Object([ + 'parent_item' => $pItem, + 'name' => $name, + 'qty' => $qty, + 'price' => $isNominal ? 0 : $price, + 'original_item' => $itemMock, + ]) + ]; + $this->_quoteMock + ->expects($this->once()) + ->method('getAllItems') + ->will($this->returnValue([$itemMock])); + $this->assertEquals($expected, $this->_model->getAllItems()); + } + + public function getAllItemsDataProvider() + { + return [ + [0, 'parent item 1', 'name 1', 1, 0.1], + [1, 'parent item 1', 'name 1', 1, 0.1], + [0, 'parent item 2', 'name 2', 2, 1.2], + [1, 'parent item 2', 'name 2', 2, 1.2], + [0, 'parent item 3', 'name 3', 3, 2.3], + [1, 'parent item 3', 'name 3', 3, 2.3], + ]; + } + + public function testGetBaseSubtotal() + { + $this->_quoteMock + ->expects($this->once()) + ->method('__call') + ->with('getBaseSubtotal') + ->will($this->returnValue(100)); + $this->assertEquals(100, $this->_model->getBaseSubtotal()); + } + + /** + * @param int $isVirtual + * @param string $getterMethod + * @dataProvider getterDataProvider + */ + public function testGetter($isVirtual, $getterMethod) + { + $address = $this->getMock('Magento\Sales\Model\Quote\Address', [], [], '', false); + $address + ->expects($this->any()) + ->method('__call') + ->with($getterMethod) + ->will($this->returnValue($getterMethod)); + $quoteMock = $this->getMock('Magento\Sales\Model\Quote', [], [], '', false); + $quoteMock + ->expects($this->any()) + ->method('getIsVirtual') + ->will($this->returnValue($isVirtual)); + $method = 'getShippingAddress'; + if ($isVirtual) { + $method = 'getBillingAddress'; + } + $quoteMock + ->expects($this->any()) + ->method($method) + ->will($this->returnValue($address)); + $model = new \Magento\Payment\Model\Cart\SalesModel\Quote($quoteMock); + $this->assertEquals($getterMethod, $model->$getterMethod()); + } + + public function getterDataProvider() + { + return [ + [0, 'getBaseTaxAmount'], + [1, 'getBaseTaxAmount'], + [0, 'getBaseShippingAmount'], + [1, 'getBaseShippingAmount'], + [0, 'getBaseDiscountAmount'], + [1, 'getBaseDiscountAmount'], + ]; + } +} diff --git a/dev/tests/unit/testsuite/Magento/Payment/Model/CartTest.php b/dev/tests/unit/testsuite/Magento/Payment/Model/CartTest.php new file mode 100644 index 0000000000000000000000000000000000000000..34b247226363965af94abe918213b81a5a752e75 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Payment/Model/CartTest.php @@ -0,0 +1,345 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Payment\Model; + +use Magento\Payment\Model\Cart; + +class CartTest extends \PHPUnit_Framework_TestCase +{ + /** @var \Magento\Payment\Model\Cart */ + protected $_model; + + /** @var \PHPUnit_Framework_MockObject_MockObject */ + protected $_eventManagerMock; + + /** @var \PHPUnit_Framework_MockObject_MockObject */ + protected $_salesModelMock; + + protected function setUp() + { + $this->_eventManagerMock = $this->getMock('Magento\Event\ManagerInterface'); + $this->_salesModelMock = $this->getMock('Magento\Payment\Model\Cart\SalesModel\SalesModelInterface'); + $factoryMock = $this->getMock('Magento\Payment\Model\Cart\SalesModel\Factory', [], [], '', false); + $factoryMock + ->expects($this->once()) + ->method('create') + ->will($this->returnValue($this->_salesModelMock)); + + $this->_model = new \Magento\Payment\Model\Cart($factoryMock, $this->_eventManagerMock, null); + } + + /** + * Test sales model getter + */ + public function testGetSalesModel() + { + $this->assertTrue($this->_salesModelMock === $this->_model->getSalesModel()); + } + + /** + * Test addCustomItem() + */ + public function testAddCustomItem() + { + $this->_salesModelMock + ->expects($this->once()) + ->method('getAllItems') + ->will($this->returnValue($this->_getSalesModelItems())); + $this->_model->getAllItems(); + $this->_model->addCustomItem('test', 10, 10.5, 'some_id'); + $items = $this->_model->getAllItems(); + $customItem = array_pop($items); + $this->assertTrue( + $customItem->getName() == 'test' + && $customItem->getQty() == 10 + && $customItem->getAmount() == 10.5 + && $customItem->getId() == 'some_id' + ); + } + + /** + * @param array $transferFlags + * @param array $salesModelItems + * @param array $salesModelAmounts + * @param array $expected + * @dataProvider cartDataProvider + */ + public function testGetAmounts($transferFlags, $salesModelItems, $salesModelAmounts, $expected) + { + $amounts = $this->_collectItemsAndAmounts($transferFlags, $salesModelItems, $salesModelAmounts); + $this->assertEquals($expected, $amounts); + + // check that method just return calculated result for further calls + $this->_eventManagerMock + ->expects($this->never()) + ->method('dispatch'); + $amounts = $this->_model->getAmounts(); + $this->assertEquals($expected, $amounts); + } + + /** + * @param array $transferFlags + * @param array $salesModelItems + * @param array $salesModelAmounts + * @dataProvider cartDataProvider + */ + public function testGetAllItems($transferFlags, $salesModelItems, $salesModelAmounts) + { + $this->_collectItemsAndAmounts($transferFlags, $salesModelItems, $salesModelAmounts); + + $customItems = array(); + if ($transferFlags['transfer_shipping']) { + $customItems[] = new \Magento\Object(array( + 'name' => 'Shipping', + 'qty' => 1, + 'amount' => $salesModelAmounts['BaseShippingAmount'] + )); + } + if ($transferFlags['transfer_discount']) { + $customItems[] = new \Magento\Object(array( + 'name' => 'Discount', + 'qty' => 1, + 'amount' => -1.00 * $salesModelAmounts['BaseDiscountAmount'] + )); + } + + $cartItems = $this->_convertToCartItems($salesModelItems); + $expected = array_merge($cartItems, $customItems); + $areEqual = $this->_compareSalesItems($expected, $this->_model->getAllItems()); + $this->assertTrue($areEqual); + } + + /** + * Test all amount specific methods i.e. add...(), set...(), get...() + */ + public function testAmountSettersAndGetters() + { + foreach (['Discount', 'Shipping', 'Tax'] as $amountType) { + $setMethod = 'set' . $amountType; + $getMethod = 'get' . $amountType; + $addMethod = 'add' . $amountType; + + $this->_model->$setMethod(10); + $this->assertEquals(10, $this->_model->$getMethod()); + + $this->_model->$addMethod(5); + $this->assertEquals(15, $this->_model->$getMethod()); + + $this->_model->$addMethod(-20); + $this->assertEquals(-5, $this->_model->$getMethod()); + + $this->_model->$setMethod(10); + $this->assertEquals(10, $this->_model->$getMethod()); + } + + // there is no method setSubtotal(), so test the following separately + $this->_model->addSubtotal(10); + $this->assertEquals(10, $this->_model->getSubtotal()); + + $this->_model->addSubtotal(2); + $this->assertEquals(12, $this->_model->getSubtotal()); + + $this->_model->addSubtotal(-20); + $this->assertEquals(-8, $this->_model->getSubtotal()); + } + + /** + * Data provider + * + * @return array + */ + public function cartDataProvider() + { + return [ + // 1. All transfer flags set to true + [ + ['transfer_shipping' => true, 'transfer_discount' => true], + $this->_getSalesModelItems(), + [ + 'BaseDiscountAmount' => 15.0, + 'BaseShippingAmount' => 20.0, + 'BaseSubtotal' => 100.0, + 'BaseTaxAmount' => 8.0, + ], + [ + Cart::AMOUNT_DISCOUNT => 0.0, + Cart::AMOUNT_SHIPPING => 0.0, + Cart::AMOUNT_SUBTOTAL => 105.0, // = 100.5 + shipping - discount + Cart::AMOUNT_TAX => 8.0 + ] + ], + // 2. All transfer flags set to false + [ + ['transfer_shipping' => false, 'transfer_discount' => false], + $this->_getSalesModelItems(), + [ + 'BaseDiscountAmount' => 15.0, + 'BaseShippingAmount' => 20.0, + 'BaseSubtotal' => 100.0, + 'BaseTaxAmount' => 8.0, + ], + [ + Cart::AMOUNT_DISCOUNT => 15.0, + Cart::AMOUNT_SHIPPING => 20.0, + Cart::AMOUNT_SUBTOTAL => 100.0, + Cart::AMOUNT_TAX => 8.0 + ] + ], + // 3. Shipping transfer flag set to true, discount to false, sales items are empty (don't affect result) + [ + ['transfer_shipping' => true, 'transfer_discount' => false], + [], + [ + 'BaseDiscountAmount' => 15.0, + 'BaseShippingAmount' => 20.0, + 'BaseSubtotal' => 100.0, + 'BaseTaxAmount' => 8.0, + ], + [ + Cart::AMOUNT_DISCOUNT => 15.0, + Cart::AMOUNT_SHIPPING => 0.0, + Cart::AMOUNT_SUBTOTAL => 120.0, + Cart::AMOUNT_TAX => 8.0 + ] + ] + ]; + + } + + /** + * Return true if arrays of cart sales items are equal, false otherwise. Elements order not considered + * + * @param array $salesItemsA + * @param array $salesItemsB + * @return bool + */ + protected function _compareSalesItems(array $salesItemsA, array $salesItemsB) + { + if (count($salesItemsA) != count($salesItemsB)) { + return false; + } + + $toStringCallback = function (&$item) { + $item = $item->toString(); + }; + + array_walk($salesItemsA, $toStringCallback); + array_walk($salesItemsB, $toStringCallback); + + sort($salesItemsA); + sort($salesItemsB); + + return implode('', $salesItemsA) == implode('', $salesItemsB); + } + + /** + * Collect sales model items and calculate amounts of sales model + * + * @param array $transferFlags + * @param array $salesModelItems + * @param array $salesModelAmounts + * @return array Cart amounts + */ + protected function _collectItemsAndAmounts($transferFlags, $salesModelItems, $salesModelAmounts) + { + if ($transferFlags['transfer_shipping']) { + $this->_model->setTransferShippingAsItem(); + } + if ($transferFlags['transfer_discount']) { + $this->_model->setTransferDiscountAsItem(); + } + + $this->_eventManagerMock + ->expects($this->once()) + ->method('dispatch') + ->with( + $this->equalTo('payment_cart_collect_items_and_amounts'), + $this->equalTo(array('cart' => $this->_model)) + ); + + $this->_salesModelMock + ->expects($this->once()) + ->method('getAllItems') + ->will($this->returnValue($salesModelItems)); + + foreach ($salesModelAmounts as $key => $value) { + $this->_salesModelMock + ->expects($this->once()) + ->method('get' . $key) + ->will($this->returnValue($value)); + } + + return $this->_model->getAmounts(); + } + + /** + * Return sales model items + * + * @return array + */ + protected function _getSalesModelItems() + { + return array( + new \Magento\Object([ + 'name' => 'name 1', + 'qty' => 1, + 'price' => 0.1, + ]), + new \Magento\Object([ + 'name' => 'name 2', + 'qty' => 2, + 'price' => 1.2, + ]), + new \Magento\Object([ + 'parent_item' => 'parent item 3', + 'name' => 'name 3', + 'qty' => 3, + 'price' => 2.3, + ]), + ); + } + + /** + * Convert sales model items to cart items + * + * @param array $salesModelItems + * @return array + */ + protected function _convertToCartItems(array $salesModelItems) + { + $result = []; + foreach ($salesModelItems as $item) { + if ($item->getParentItem()) { + continue; + } + $result[] = new \Magento\Object([ + 'name' => $item->getName(), + 'qty' => $item->getQty(), + 'amount' => $item->getPrice() + ]); + } + return $result; + } +} diff --git a/dev/tests/unit/testsuite/Magento/Payment/Model/Config/ConverterTest.php b/dev/tests/unit/testsuite/Magento/Payment/Model/Config/ConverterTest.php index fa5ece68dd751bd3463ccd5cdcec9b2fbc086260..0af6f70d5114aed19114a1566723e953dc631b5b 100644 --- a/dev/tests/unit/testsuite/Magento/Payment/Model/Config/ConverterTest.php +++ b/dev/tests/unit/testsuite/Magento/Payment/Model/Config/ConverterTest.php @@ -54,6 +54,12 @@ class ConverterTest extends \PHPUnit_Framework_TestCase 'groups' => array( 'paypal' => 'PayPal', ), + 'methods' => array( + 'checkmo' => array( + 'allow_multiple_address' => 1, + 'allow_multiple_with_3dsecure' => 1, + ), + ), ); $this->assertEquals($expectedResult, $this->_model->convert($dom), '', 0, 20); } diff --git a/dev/tests/unit/testsuite/Magento/Payment/Model/Config/_files/payment.xml b/dev/tests/unit/testsuite/Magento/Payment/Model/Config/_files/payment.xml index a2297a8519a55834530a0d914de3942e0632e173..440b90f0f1b1cc41455acf27a81f36a4475a8748 100644 --- a/dev/tests/unit/testsuite/Magento/Payment/Model/Config/_files/payment.xml +++ b/dev/tests/unit/testsuite/Magento/Payment/Model/Config/_files/payment.xml @@ -38,4 +38,10 @@ <label>PayPal</label> </group> </groups> + <methods> + <method name="checkmo"> + <allow_multiple_address>1</allow_multiple_address> + <allow_multiple_with_3dsecure>1</allow_multiple_with_3dsecure> + </method> + </methods> </payment> diff --git a/dev/tests/unit/testsuite/Magento/Payment/Model/Method/Specification/CompositeTest.php b/dev/tests/unit/testsuite/Magento/Payment/Model/Method/Specification/CompositeTest.php new file mode 100644 index 0000000000000000000000000000000000000000..888e0cebf2e4d7ff962c6fc8b82c5a2a3dc840ff --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Payment/Model/Method/Specification/CompositeTest.php @@ -0,0 +1,101 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Payment\Model\Method\Specification; + +/** + * Composite Test + */ +class CompositeTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Payment\Model\Method\Specification\Factory|\PHPUnit_Framework_MockObject_MockObject + */ + protected $factoryMock; + + protected function setUp() + { + $this->factoryMock = $this->getMock('Magento\Payment\Model\Method\Specification\Factory', array(), array(), '', + false); + } + + /** + * @param array $specifications + * @return \Magento\Payment\Model\Method\Specification\Composite + */ + protected function createComposite($specifications = array()) + { + $objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); + + return $objectManager->getObject('Magento\Payment\Model\Method\Specification\Composite', array( + 'factory' => $this->factoryMock, + 'specifications' => $specifications, + )); + } + + /** + * @param bool $firstSpecificationResult + * @param bool $secondSpecificationResult + * @param bool $compositeResult + * @dataProvider compositeDataProvider + */ + public function testComposite($firstSpecificationResult, $secondSpecificationResult, $compositeResult) + { + $method = 'method-name'; + + $specificationFirst = $this->getMock('Magento\Payment\Model\Method\SpecificationInterface'); + $specificationFirst->expects($this->once())->method('isSatisfiedBy')->with($method) + ->will($this->returnValue($firstSpecificationResult)); + + $specificationSecond = $this->getMock('Magento\Payment\Model\Method\SpecificationInterface'); + $specificationSecond->expects($this->any())->method('isSatisfiedBy')->with($method) + ->will($this->returnValue($secondSpecificationResult)); + + $this->factoryMock->expects($this->at(0))->method('create')->with('SpecificationFirst') + ->will($this->returnValue($specificationFirst)); + $this->factoryMock->expects($this->at(1))->method('create')->with('SpecificationSecond') + ->will($this->returnValue($specificationSecond)); + + $composite = $this->createComposite(array('SpecificationFirst', 'SpecificationSecond')); + + $this->assertEquals( + $compositeResult, + $composite->isSatisfiedBy($method), + 'Composite specification is not satisfied by payment method' + ); + } + + /** + * @return array + */ + public function compositeDataProvider() + { + return array( + array(true, true, true), + array(true, false, false), + array(false, true, false), + array(false, false, false), + ); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Payment/Model/Method/Specification/FactoryTest.php b/dev/tests/unit/testsuite/Magento/Payment/Model/Method/Specification/FactoryTest.php new file mode 100644 index 0000000000000000000000000000000000000000..e11a48913647df7419e0ae50c3e733db56455740 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Payment/Model/Method/Specification/FactoryTest.php @@ -0,0 +1,75 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Payment\Model\Method\Specification; + +/** + * Factory Test + */ +class FactoryTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\ObjectManager|\PHPUnit_Framework_MockObject_MockObject + */ + protected $objectManagerMock; + + /** + * @var \Magento\Payment\Model\Method\Specification\Factory + */ + protected $factory; + + protected function setUp() + { + $this->objectManagerMock = $this->getMock('Magento\ObjectManager', array(), array(), '', false); + + $objectManagerHelper = new \Magento\TestFramework\Helper\ObjectManager($this); + $this->factory = $objectManagerHelper->getObject('Magento\Payment\Model\Method\Specification\Factory', array( + 'objectManager' => $this->objectManagerMock, + )); + } + + public function testCreateMethod() + { + $className = 'Magento\Payment\Model\Method\SpecificationInterface'; + $methodMock = $this->getMock($className); + $this->objectManagerMock->expects($this->once())->method('get')->with($className) + ->will($this->returnValue($methodMock)); + + $this->assertEquals($methodMock, $this->factory->create($className)); + } + + /** + * @expectedException \InvalidArgumentException + * @expectedExceptionMessage Specification must implement SpecificationInterface + */ + public function testWrongTypeException() + { + $className = 'WrongClass'; + $methodMock = $this->getMock($className); + $this->objectManagerMock->expects($this->once())->method('get')->with($className) + ->will($this->returnValue($methodMock)); + + $this->factory->create($className); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Paypal/Model/CartTest.php b/dev/tests/unit/testsuite/Magento/Paypal/Model/CartTest.php new file mode 100644 index 0000000000000000000000000000000000000000..4376e3576f3bfa1cba339b238386cb12d3f05023 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Paypal/Model/CartTest.php @@ -0,0 +1,309 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Paypal\Model; + +class CartTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var Cart + */ + protected $_model; + + /** + * @var \Magento\Object + */ + protected $_validItem; + + /** + * @var \Magento\Payment\Model\Cart\SalesModel\SalesModelInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $_salesModel; + + /** + * @param null|string $name + * @param array $data + * @param string $dataName + */ + public function __construct($name = null, array $data = [], $dataName = '') + { + parent::__construct($name, $data, $dataName); + $this->_validItem = new \Magento\Object([ + 'parent_item' => null, + 'price' => 2.0, + 'qty' => 3, + 'name' => 'valid item', + 'original_item' => new \Magento\Object(['base_row_total' => 6.0]) + ]); + } + + protected function setUp() + { + $this->_salesModel = $this + ->getMockForAbstractClass('Magento\Payment\Model\Cart\SalesModel\SalesModelInterface'); + $factoryMock = $this->getMock('Magento\Payment\Model\Cart\SalesModel\Factory', [], [], '', false); + $factoryMock->expects($this->once()) + ->method('create') + ->with('sales model') + ->will($this->returnValue($this->_salesModel)); + $eventManagerMock = $this->getMockForAbstractClass('Magento\Event\ManagerInterface'); + + $this->_model = new \Magento\Paypal\Model\Cart($factoryMock, $eventManagerMock, 'sales model'); + } + + /** + * @param array $items + * @dataProvider invalidGetAllItemsDataProvider + */ + public function testInvalidGetAllItems($items) + { + $taxContainer = new \Magento\Object([ + 'base_hidden_tax_amount' => 0.2, + 'base_shipping_hidden_tax_amnt' => 0.1, + ]); + $this->_salesModel->expects($this->once())->method('getTaxContainer')->will($this->returnValue($taxContainer)); + $this->_salesModel->expects($this->once())->method('getAllItems')->will($this->returnValue($items)); + $this->_salesModel->expects($this->once())->method('getBaseSubtotal')->will($this->returnValue(2.1)); + $this->_salesModel->expects($this->once())->method('getBaseTaxAmount')->will($this->returnValue(0.1)); + $this->_salesModel->expects($this->once())->method('getBaseShippingAmount')->will($this->returnValue(1.1)); + $this->_salesModel->expects($this->once())->method('getBaseDiscountAmount')->will($this->returnValue(0.3)); + $this->assertEmpty($this->_model->getAllItems()); + $this->assertEquals(2.1, $this->_model->getSubtotal()); + $this->assertEquals(0.1 + 0.2 + 0.1, $this->_model->getTax()); + $this->assertEquals(1.1, $this->_model->getShipping()); + $this->assertEquals(0.3, $this->_model->getDiscount()); + } + + public function invalidGetAllItemsDataProvider() + { + return [ + [[]], + [[new \Magento\Object([ + 'parent_item' => new \Magento\Object(), + 'price' => 2.0, + 'qty' => 3, + 'name' => 'item 1', + ])]], + [[ + $this->_validItem, + new \Magento\Object([ + 'price' => 2.0, + 'qty' => 3, + 'name' => 'item 2', + 'original_item' => new \Magento\Object(['base_row_total' => 6.01]) + ]) + ]], + [[ + $this->_validItem, + new \Magento\Object([ + 'price' => sqrt(2), + 'qty' => sqrt(2), + 'name' => 'item 3', + 'original_item' => new \Magento\Object(['base_row_total' => 2]) + ]) + ]], + ]; + } + + /** + * @param array $values + * @param bool $transferDiscount + * @dataProvider invalidTotalsGetAllItemsDataProvider + */ + public function testInvalidTotalsGetAllItems($values, $transferDiscount) + { + $expectedSubtotal = $this->_prepareInvalidModelData($values, $transferDiscount); + $this->assertEmpty($this->_model->getAllItems()); + $this->assertEquals($expectedSubtotal, $this->_model->getSubtotal()); + $this->assertEquals( + $values['base_tax_amount'] + $values['base_hidden_tax_amount'] + $values['base_shipping_hidden_tax_amnt'], + $this->_model->getTax() + ); + $this->assertEquals($values['base_shipping_amount'], $this->_model->getShipping()); + $this->assertEquals($transferDiscount ? 0.0 : $values['base_discount_amount'], $this->_model->getDiscount()); + } + + public function invalidTotalsGetAllItemsDataProvider() + { + return [ + [[ + 'base_hidden_tax_amount' => 0, + 'base_shipping_hidden_tax_amnt' => 0, + 'base_subtotal' => 0, + 'base_tax_amount' => 0, + 'base_shipping_amount' => 0, + 'base_discount_amount' => 6.1, + 'base_grand_total' => 0, + ], false], + [[ + 'base_hidden_tax_amount' => 1, + 'base_shipping_hidden_tax_amnt' => 2, + 'base_subtotal' => 3, + 'base_tax_amount' => 4, + 'base_shipping_amount' => 5, + 'base_discount_amount' => 100, + 'base_grand_total' => 5.5, + ], true], + ]; + } + + public function testGetAllItems() + { + $totals = $this->_prepareValidModelData(); + $this->assertEquals( + [new \Magento\Object([ + 'name' => $this->_validItem->getName(), + 'qty' => $this->_validItem->getQty(), + 'amount' => $this->_validItem->getPrice(), + ])], + $this->_model->getAllItems() + ); + $this->assertEquals($totals['subtotal'], $this->_model->getSubtotal()); + $this->assertEquals($totals['tax'], $this->_model->getTax()); + $this->assertEquals($totals['shipping'], $this->_model->getShipping()); + $this->assertEquals($totals['discount'], $this->_model->getDiscount()); + } + + /** + * @param array $values + * @param bool $transferDiscount + * @param bool $transferShipping + * @dataProvider invalidGetAmountsDataProvider + */ + public function testInvalidGetAmounts($values, $transferDiscount, $transferShipping) + { + $expectedSubtotal = $this->_prepareInvalidModelData($values, $transferDiscount); + if ($transferShipping) { + $this->_model->setTransferShippingAsItem(); + } + $result = $this->_model->getAmounts(); + $expectedSubtotal += $this->_model->getTax(); + $expectedSubtotal += $values['base_shipping_amount']; + if (!$transferDiscount) { + $expectedSubtotal -= $this->_model->getDiscount(); + } + $this->assertEquals([Cart::AMOUNT_SUBTOTAL => $expectedSubtotal], $result); + } + + public function invalidGetAmountsDataProvider() + { + $data = []; + $invalidTotalsData = $this->invalidTotalsGetAllItemsDataProvider(); + foreach ($invalidTotalsData as $dataItem) { + $data[] = [$dataItem[0], $dataItem[1], true]; + $data[] = [$dataItem[0], $dataItem[1], false]; + } + return $data; + } + + /** + * Prepare invalid data for cart + * + * @param array $values + * @param bool $transferDiscount + * @return float + */ + protected function _prepareInvalidModelData($values, $transferDiscount) + { + $taxContainer = new \Magento\Object([ + 'base_hidden_tax_amount' => $values['base_hidden_tax_amount'], + 'base_shipping_hidden_tax_amnt' => $values['base_shipping_hidden_tax_amnt'], + ]); + $expectedSubtotal = $values['base_subtotal']; + if ($transferDiscount) { + $this->_model->setTransferDiscountAsItem(); + $expectedSubtotal -= $values['base_discount_amount']; + } + $this->_salesModel->expects($this->once())->method('getTaxContainer')->will($this->returnValue($taxContainer)); + $this->_salesModel->expects($this->once()) + ->method('getAllItems') + ->will($this->returnValue([$this->_validItem])); + $this->_salesModel->expects($this->once()) + ->method('getBaseSubtotal') + ->will($this->returnValue($values['base_subtotal'])); + $this->_salesModel->expects($this->once()) + ->method('getBaseTaxAmount') + ->will($this->returnValue($values['base_tax_amount'])); + $this->_salesModel->expects($this->once()) + ->method('getBaseShippingAmount') + ->will($this->returnValue($values['base_shipping_amount'])); + $this->_salesModel->expects($this->once()) + ->method('getBaseDiscountAmount') + ->will($this->returnValue($values['base_discount_amount'])); + $this->_salesModel->expects($this->once()) + ->method('getDataUsingMethod') + ->with('base_grand_total') + ->will($this->returnValue($values['base_grand_total'])); + return $expectedSubtotal; + } + + public function testGetAmounts() + { + $totals = $this->_prepareValidModelData(); + $this->assertEquals( + $totals, + $this->_model->getAmounts() + ); + } + + /** + * Prepare valid cart data + * + * @return array + */ + protected function _prepareValidModelData() + { + $totals = [ + 'discount' => 0.1, + 'shipping' => 0.2, + 'subtotal' => 0.3, + 'tax' => 0.4, + ]; + $taxContainer = new \Magento\Object([ + 'base_hidden_tax_amount' => 0, + 'base_shipping_hidden_tax_amnt' => 0, + ]); + $this->_salesModel->expects($this->once())->method('getTaxContainer')->will($this->returnValue($taxContainer)); + $this->_salesModel->expects($this->once()) + ->method('getAllItems') + ->will($this->returnValue([$this->_validItem])); + $this->_salesModel->expects($this->once()) + ->method('getBaseSubtotal') + ->will($this->returnValue($totals['subtotal'])); + $this->_salesModel->expects($this->once()) + ->method('getBaseTaxAmount') + ->will($this->returnValue($totals['tax'])); + $this->_salesModel->expects($this->once()) + ->method('getBaseShippingAmount') + ->will($this->returnValue($totals['shipping'])); + $this->_salesModel->expects($this->once()) + ->method('getBaseDiscountAmount') + ->will($this->returnValue($totals['discount'])); + $this->_salesModel->expects($this->once()) + ->method('getDataUsingMethod') + ->with('base_grand_total') + ->will($this->returnValue(6.0 + $totals['tax'] + $totals['shipping'] - $totals['discount'])); + return $totals; + } +} diff --git a/dev/tests/unit/testsuite/Magento/Phrase/Renderer/TranslateTest.php b/dev/tests/unit/testsuite/Magento/Phrase/Renderer/TranslateTest.php index e3ee67dd4c5ec2da7b24d5c381b31afde054ca0a..35e82a4272c462ed1ffc579f3d7b3e751a686036 100644 --- a/dev/tests/unit/testsuite/Magento/Phrase/Renderer/TranslateTest.php +++ b/dev/tests/unit/testsuite/Magento/Phrase/Renderer/TranslateTest.php @@ -26,7 +26,7 @@ namespace Magento\Phrase\Renderer; class TranslateTest extends \PHPUnit_Framework_TestCase { /** - * @var \Magento\Core\Model\Translate|PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Translate|PHPUnit_Framework_MockObject_MockObject */ protected $_translator; @@ -37,7 +37,7 @@ class TranslateTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_translator = $this->getMock('Magento\Core\Model\Translate', array(), array(), '', false); + $this->_translator = $this->getMock('Magento\TranslateInterface', array(), array(), '', false); $objectManagerHelper = new \Magento\TestFramework\Helper\ObjectManager($this); $this->_renderer = $objectManagerHelper->getObject('Magento\Phrase\Renderer\Translate', array( diff --git a/dev/tests/unit/testsuite/Magento/Review/Helper/Action/PagerTest.php b/dev/tests/unit/testsuite/Magento/Review/Helper/Action/PagerTest.php index f09bb3540c3193a01103fca5ffe8fe1982f47fb7..ae0a99056989a6a9d08b0ff3e1109a959d66a3d7 100644 --- a/dev/tests/unit/testsuite/Magento/Review/Helper/Action/PagerTest.php +++ b/dev/tests/unit/testsuite/Magento/Review/Helper/Action/PagerTest.php @@ -50,7 +50,7 @@ class PagerTest extends \PHPUnit_Framework_TestCase ->will($this->returnValue(array(3,2,6,5))); $contextMock = $this->getMock( - 'Magento\App\Helper\Context', array('getTranslator', 'getModuleManager', 'getRequest'), array(), '', false + 'Magento\App\Helper\Context', array('getModuleManager', 'getRequest'), array(), '', false ); $this->_helper = new \Magento\Review\Helper\Action\Pager($contextMock, $sessionMock); $this->_helper->setStorageId('reviews'); diff --git a/dev/tests/unit/testsuite/Magento/Sales/Model/Order/Pdf/AbstractTest.php b/dev/tests/unit/testsuite/Magento/Sales/Model/Order/Pdf/AbstractTest.php index de1b6ef5a598b4fc04323e8b2ef7385ee0be8d05..0c09320940f7449e3972deae7c30faff5f6c0ee9 100644 --- a/dev/tests/unit/testsuite/Magento/Sales/Model/Order/Pdf/AbstractTest.php +++ b/dev/tests/unit/testsuite/Magento/Sales/Model/Order/Pdf/AbstractTest.php @@ -45,7 +45,7 @@ class AbstractTest extends \PHPUnit_Framework_TestCase $paymentData = $this->getMock('Magento\Payment\Helper\Data', array(), array(), '', false); $string = $this->getMock('Magento\Stdlib\String', array(), array(), '', false); $coreStoreConfig = $this->getMock('Magento\Core\Model\Store\Config', array(), array(), '', false); - $translate = $this->getMock('Magento\Core\Model\Translate', array(), array(), '', false); + $translate = $this->getMock('Magento\TranslateInterface', array(), array(), '', false); $filesystem = $this->getMock('Magento\App\Filesystem', array(), array(), '', false); $pdfItemsFactory = $this->getMock('Magento\Sales\Model\Order\Pdf\ItemsFactory', array(), array(), '', false); $localeMock = $this->getMock('Magento\Core\Model\LocaleInterface', array(), array(), '', false, false); diff --git a/dev/tests/unit/testsuite/Magento/Sales/Model/Order/Pdf/InvoiceTest.php b/dev/tests/unit/testsuite/Magento/Sales/Model/Order/Pdf/InvoiceTest.php index 82c845ee6575c2086b44e28a280db1ec5295341b..29f9ce95017e8c4e859ba4731a29713162239be6 100644 --- a/dev/tests/unit/testsuite/Magento/Sales/Model/Order/Pdf/InvoiceTest.php +++ b/dev/tests/unit/testsuite/Magento/Sales/Model/Order/Pdf/InvoiceTest.php @@ -41,7 +41,7 @@ class InvoiceTest extends \PHPUnit_Framework_TestCase $paymentDataMock = $this->getMock('Magento\Payment\Helper\Data', array(), array(), '', false); $stringMock = $this->getMock('Magento\Stdlib\String', array(), array(), '', false, false); $storeConfigMock = $this->getMock('Magento\Core\Model\Store\Config', array(), array(), '', false, false); - $translateMock = $this->getMock('Magento\Core\Model\Translate', array(), array(), '', false, false); + $translateMock = $this->getMock('Magento\TranslateInterface', array(), array(), '', false, false); $directoryMock = $this->getMock('Magento\Filesystem\Directory\Write', array(), array(), '', false, false); $directoryMock->expects($this->any()) ->method('getAbsolutePath') diff --git a/dev/tests/unit/testsuite/Magento/Sales/Model/QuoteTest.php b/dev/tests/unit/testsuite/Magento/Sales/Model/QuoteTest.php new file mode 100644 index 0000000000000000000000000000000000000000..c400fb403cd690a0aa4578858133bf90625d06ff --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Model/QuoteTest.php @@ -0,0 +1,120 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Sales\Model; + +use Magento\TestFramework\Helper\ObjectManager; +use Magento\Sales\Model\Quote\Address; + +/** + * Test class for \Magento\Sales\Model\Order + */ +class QuoteTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Sales\Model\Quote\AddressFactory|\PHPUnit_Framework_MockObject_MockObject + */ + protected $quoteAddressFactoryMock; + + /** + * @var \Magento\Sales\Model\Quote\Address|\PHPUnit_Framework_MockObject_MockObject + */ + protected $quoteAddressMock; + + /** + * @var \Magento\Sales\Model\Resource\Quote\Address\Collection|\PHPUnit_Framework_MockObject_MockObject + */ + protected $quoteAddressCollectionMock; + + /** + * @var \Magento\Sales\Model\Quote + */ + protected $quote; + + protected function setUp() + { + $this->quoteAddressFactoryMock = $this->getMock('Magento\Sales\Model\Quote\AddressFactory', array('create'), + array(), '', false); + $this->quoteAddressMock = $this->getMock('Magento\Sales\Model\Quote\Address', array(), array(), '', false); + $this->quoteAddressCollectionMock = $this->getMock('Magento\Sales\Model\Resource\Quote\Address\Collection', + array(), array(), '', false); + + $this->quoteAddressFactoryMock->expects($this->any())->method('create') + ->will($this->returnValue($this->quoteAddressMock)); + $this->quoteAddressMock->expects($this->any())->method('getCollection') + ->will($this->returnValue($this->quoteAddressCollectionMock)); + + $this->quote = (new ObjectManager($this))->getObject('Magento\Sales\Model\Quote', array( + 'quoteAddressFactory' => $this->quoteAddressFactoryMock, + )); + } + + /** + * @param array $addresses + * @param bool $expected + * @dataProvider dataProviderForTestIsMultipleShippingAddresses + */ + public function testIsMultipleShippingAddresses($addresses, $expected) + { + $this->quoteAddressCollectionMock->expects($this->any())->method('setQuoteFilter') + ->will($this->returnValue($this->quoteAddressCollectionMock)); + $this->quoteAddressCollectionMock->expects($this->once())->method('getIterator') + ->will($this->returnValue(new \ArrayIterator($addresses))); + + $this->assertEquals($expected, $this->quote->isMultipleShippingAddresses()); + } + + /** + * @return array + */ + public function dataProviderForTestIsMultipleShippingAddresses() + { + return array( + array( + array($this->getAddressMock(Address::TYPE_SHIPPING), $this->getAddressMock(Address::TYPE_SHIPPING)), + true, + ), + array( + array($this->getAddressMock(Address::TYPE_SHIPPING), $this->getAddressMock(Address::TYPE_BILLING)), + false, + ), + ); + } + + /** + * @param string $type One of \Magento\Customer\Model\Address\AbstractAddress::TYPE_ const + * @return \PHPUnit_Framework_MockObject_MockObject + */ + protected function getAddressMock($type) + { + $shippingAddressMock = $this->getMock('Magento\Sales\Model\Quote\Address', array('getAddressType', '__wakeup'), + array(), '', false); + + $shippingAddressMock->expects($this->any())->method('getAddressType') + ->will($this->returnValue($type)); + $shippingAddressMock->expects($this->any())->method('isDeleted') + ->will($this->returnValue(false)); + return $shippingAddressMock; + } +} diff --git a/dev/tests/unit/testsuite/Magento/Theme/Model/ConfigTest.php b/dev/tests/unit/testsuite/Magento/Theme/Model/ConfigTest.php index 18b003150253b1cedfc987b32f87d894a09c356b..8b4d2d46beb606cacf903df1d399233b5962f9f7 100644 --- a/dev/tests/unit/testsuite/Magento/Theme/Model/ConfigTest.php +++ b/dev/tests/unit/testsuite/Magento/Theme/Model/ConfigTest.php @@ -58,7 +58,7 @@ class ConfigTest extends \PHPUnit_Framework_TestCase protected $_layoutCacheMock; /** - * @var \Magento\Core\Model\Config\Storage\WriterInterface + * @var \Magento\App\Config\Storage\WriterInterface */ protected $_storeConfigWriter; @@ -86,7 +86,7 @@ class ConfigTest extends \PHPUnit_Framework_TestCase $this->_layoutCacheMock = $this->getMockForAbstractClass('Magento\Cache\FrontendInterface'); $this->_storeConfigWriter = $this->getMock( - 'Magento\Core\Model\Config\Storage\WriterInterface', array('save', 'delete') + 'Magento\App\Config\Storage\WriterInterface', array('save', 'delete') ); $this->_model = new \Magento\Theme\Model\Config( diff --git a/dev/tests/unit/testsuite/Magento/Core/Model/Translate/Inline/ConfigFactoryTest.php b/dev/tests/unit/testsuite/Magento/Translate/Inline/ConfigFactoryTest.php similarity index 75% rename from dev/tests/unit/testsuite/Magento/Core/Model/Translate/Inline/ConfigFactoryTest.php rename to dev/tests/unit/testsuite/Magento/Translate/Inline/ConfigFactoryTest.php index dc00a3881f2a73c5c0b3047a9d2a7737157bc7ba..a0fef710d9e1a71a47372eebd92143035102fc3a 100644 --- a/dev/tests/unit/testsuite/Magento/Core/Model/Translate/Inline/ConfigFactoryTest.php +++ b/dev/tests/unit/testsuite/Magento/Translate/Inline/ConfigFactoryTest.php @@ -18,26 +18,23 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Magento - * @package Magento_Core - * @subpackage unit_tests * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Core\Model\Translate\Inline; +namespace Magento\Translate\Inline; class ConfigFactoryTest extends \PHPUnit_Framework_TestCase { - public function testCreate() + public function testGet() { $result = 'result'; $objectManager = $this->getMockForAbstractClass('Magento\ObjectManager'); $objectManager ->expects($this->once()) - ->method('create') - ->with($this->equalTo('Magento\Core\Model\Translate\Inline\Config')) + ->method('get') + ->with($this->equalTo('Magento\Translate\Inline\ConfigInterface')) ->will($this->returnValue($result)); - $factory = new ConfigFactory($objectManager); - $this->assertEquals($result, $factory->create()); + $factory = new \Magento\Translate\Inline\ConfigFactory($objectManager); + $this->assertEquals($result, $factory->get()); } } diff --git a/lib/Magento/App/Config.php b/lib/Magento/App/Config.php index b6ba5c582157ff697d728424929510c4d854d834..481272a676dd4b38ea3d885d62dc9cf8cb8644e8 100644 --- a/lib/Magento/App/Config.php +++ b/lib/Magento/App/Config.php @@ -29,55 +29,60 @@ namespace Magento\App; class Config implements \Magento\App\ConfigInterface { /** - * @var \Magento\App\Config\Loader + * Config cache tag */ - protected $_loader; + const CACHE_TAG = 'CONFIG'; /** - * @var \Magento\App\Config\Data + * @var \Magento\App\Config\ScopePool */ - protected $_data; + protected $_scopePool; /** - * @param Arguments\Loader $loader + * @param \Magento\App\Config\ScopePool $scopePool */ - public function __construct(Arguments\Loader $loader) + public function __construct(\Magento\App\Config\ScopePool $scopePool) { - $this->_loader = $loader; - $this->_data = $loader->load(); + $this->_scopePool = $scopePool; } /** - * Retrieve config value by path + * Retrieve config value by path and scope * * @param string $path + * @param string $scope + * @param string $scopeCode * @return mixed */ - public function getValue($path = null) + public function getValue($path = null, $scope = \Magento\BaseScopeInterface::SCOPE_DEFAULT, $scopeCode = null) { - return $this->_data->getValue($path); + return $this->_scopePool->getScope($scope, $scopeCode)->getValue($path); } /** - * Set config value + * Set config value in the corresponding config scope * * @param string $path * @param mixed $value + * @param string $scope + * @param null|string $scopeCode * @return void */ - public function setValue($path, $value) + public function setValue($path, $value, $scope = \Magento\BaseScopeInterface::SCOPE_DEFAULT, $scopeCode = null) { - $this->_data->setValue($path, $value); + $this->_scopePool->getScope($scope, $scopeCode)->setValue($path, $value); } /** * Retrieve config flag * * @param string $path + * @param string $scope + * @param null|string $scopeCode * @return bool */ - public function isSetFlag($path) + public function isSetFlag($path, $scope = \Magento\BaseScopeInterface::SCOPE_DEFAULT, $scopeCode = null) { - return (bool)$this->_data->getValue($path); + return (bool)$this->getValue($path, $scope, $scopeCode); } } diff --git a/lib/Magento/App/Config/Data.php b/lib/Magento/App/Config/Data.php index ec1b0e2571ac05cf0cbdcba65e263cd326bf876c..f8e052b3f3f07c00fe3e0b102e5162b9a6704791 100644 --- a/lib/Magento/App/Config/Data.php +++ b/lib/Magento/App/Config/Data.php @@ -34,6 +34,13 @@ class Data implements \Magento\App\Config\DataInterface */ protected $_data = array(); + /** + * Config source data + * + * @var array + */ + protected $_source = array(); + /** * @param \Magento\App\Config\MetadataProcessor $processor * @param array $data @@ -41,6 +48,15 @@ class Data implements \Magento\App\Config\DataInterface public function __construct(\Magento\App\Config\MetadataProcessor $processor, array $data) { $this->_data = $processor->process($data); + $this->_source = $data; + } + + /** + * @return array + */ + public function getSource() + { + return $this->_source; } /** diff --git a/lib/Magento/App/Config/DataFactory.php b/lib/Magento/App/Config/DataFactory.php index 84580fd03dc4041d15d3f0f4264b7f66538aaef8..af72cde21880376ddbb9f08abd75972fc21993e1 100644 --- a/lib/Magento/App/Config/DataFactory.php +++ b/lib/Magento/App/Config/DataFactory.php @@ -43,6 +43,7 @@ class DataFactory /** * @param \Magento\ObjectManager $objectManager + * @param string $instanceName */ public function __construct(\Magento\ObjectManager $objectManager, $instanceName = 'Magento\App\Config\Data') { @@ -54,7 +55,7 @@ class DataFactory * Create class instance with specified parameters * * @param array $data - * @return \Magento\Core\Model\Config\Data + * @return \Magento\App\Config\DataInterface */ public function create(array $data = array()) { diff --git a/lib/Magento/App/Config/Initial.php b/lib/Magento/App/Config/Initial.php index 772ad37f9070f82e4e3b2d6a921fd20b3a41b409..00044cd4cf4d07d3ba271e01e4ff5dc39713b6bf 100644 --- a/lib/Magento/App/Config/Initial.php +++ b/lib/Magento/App/Config/Initial.php @@ -68,13 +68,14 @@ class Initial /** * Get initial data by given scope * - * @return mixed + * @param string $scope + * @return array */ public function getData($scope) { list($scopeType, $scopeCode) = array_pad(explode('|', $scope), 2, null); - if ('default' == $scopeType) { + if (\Magento\BaseScopeInterface::SCOPE_DEFAULT == $scopeType) { return isset($this->_data[$scopeType]) ? $this->_data[$scopeType] : array(); } elseif ($scopeCode) { return isset($this->_data[$scopeType][$scopeCode]) ? $this->_data[$scopeType][$scopeCode] : array(); diff --git a/app/code/Magento/Core/Model/Config/Initial/Converter.php b/lib/Magento/App/Config/Initial/Converter.php similarity index 91% rename from app/code/Magento/Core/Model/Config/Initial/Converter.php rename to lib/Magento/App/Config/Initial/Converter.php index e037f2434dfb9757f9fb32d00fd6f020d153f3b5..73c0c5466240bb4c1be967a04958728442ddcddd 100644 --- a/app/code/Magento/Core/Model/Config/Initial/Converter.php +++ b/lib/Magento/App/Config/Initial/Converter.php @@ -23,20 +23,16 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Core\Model\Config\Initial; +namespace Magento\App\Config\Initial; class Converter implements \Magento\Config\ConverterInterface { /** - * Node path to process + * Node pathes to process * * @var array */ - protected $_nodeMap = array( - 'default' => '/config/default', - 'stores' => '/config/stores', - 'websites' => '/config/websites', - ); + protected $_nodeMap = array(); /** * @var array @@ -48,7 +44,7 @@ class Converter implements \Magento\Config\ConverterInterface */ public function __construct(array $nodeMap = array()) { - $this->_nodeMap = array_merge($this->_nodeMap, $nodeMap); + $this->_nodeMap = $nodeMap; } /** diff --git a/lib/Magento/App/Config/Initial/Reader.php b/lib/Magento/App/Config/Initial/Reader.php index acea58d6b3952c2d8539042a18e610cd1a34b5b4..04bf7834ba015d1c9118016829cf3e59ae5ce149 100644 --- a/lib/Magento/App/Config/Initial/Reader.php +++ b/lib/Magento/App/Config/Initial/Reader.php @@ -103,7 +103,10 @@ class Reader { $fileList = array(); foreach ($this->_scopePriorityScheme as $scope) { - $fileList = array_merge($fileList, $this->_fileResolver->get($this->_fileName, $scope)); + $directories = $this->_fileResolver->get($this->_fileName, $scope); + foreach ($directories as $key => $directory) { + $fileList[$key] = $directory; + } } if (!count($fileList)) { @@ -117,12 +120,12 @@ class Reader if (is_null($domDocument)) { $class = $this->_domDocumentClass; $domDocument = new $class( - file_get_contents($file), + $file, array(), $this->_schemaFile ); } else { - $domDocument->merge(file_get_contents($file)); + $domDocument->merge($file); } } catch (\Magento\Config\Dom\ValidationException $e) { throw new \Magento\Exception("Invalid XML in file " . $file . ":\n" . $e->getMessage()); @@ -135,4 +138,4 @@ class Reader } return $output; } -} +} \ No newline at end of file diff --git a/app/code/Magento/Core/Model/Config/Section/Converter.php b/lib/Magento/App/Config/Scope/Converter.php similarity index 93% rename from app/code/Magento/Core/Model/Config/Section/Converter.php rename to lib/Magento/App/Config/Scope/Converter.php index 7616a6de143da29b0d17fcc0d58a51150dc860d8..3568065709d17210854d1faa2526bb5da1b0fd56 100644 --- a/app/code/Magento/Core/Model/Config/Section/Converter.php +++ b/lib/Magento/App/Config/Scope/Converter.php @@ -1,6 +1,6 @@ <?php /** - * DB configuration data converter. Converts associative array to tree array + * Configuration data converter. Converts associative array to tree array * * Magento * @@ -23,7 +23,7 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Core\Model\Config\Section; +namespace Magento\App\Config\Scope; class Converter implements \Magento\Config\ConverterInterface { diff --git a/lib/Magento/App/Config/Scope/Reader.php b/lib/Magento/App/Config/Scope/Reader.php deleted file mode 100644 index dc37688cf676303b8ab402381a7e98011be96964..0000000000000000000000000000000000000000 --- a/lib/Magento/App/Config/Scope/Reader.php +++ /dev/null @@ -1,125 +0,0 @@ -<?php -/** - * Scope Reader - * - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magentocommerce.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade Magento to newer - * versions in the future. If you wish to customize Magento for your - * needs please refer to http://www.magentocommerce.com for more information. - * - * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - */ -namespace Magento\App\Config\Scope; - -class Reader -{ - /** - * @var \Magento\App\Config\Initial - */ - protected $_initialConfig; - - /** - * @var \Magento\App\Config\ScopePool - */ - protected $_sectionPool; - - /** - * @var \Magento\Config\ConverterInterface - */ - protected $_converter; - - /** - * @var \Magento\App\Config\Data\ProcessorInterface - */ - protected $_processor; - - /** - * @var \Magento\App\Config\Scope\FactoryInterface - */ - protected $_scopeFactory; - - /** - * @var \Magento\App\Config\Scope\HierarchyInterface - */ - protected $_scopeHierarchy; - - /** - * - * @param \Magento\App\Config\Initial $initialConfig - * @param \Magento\Config\ConverterInterface $converter - * @param \Magento\App\Config\Data\ProcessorInterface $processor - * @param \Magento\App\Config\Scope\FactoryInterface $scopeFactory - * @param \Magento\App\Config\Scope\HierarchyInterface $scopeHierarchy - */ - public function __construct( - \Magento\App\Config\Initial $initialConfig, - \Magento\Config\ConverterInterface $converter, - \Magento\App\Config\Data\ProcessorInterface $processor, - \Magento\App\Config\Scope\FactoryInterface $scopeFactory, - \Magento\App\Config\Scope\HierarchyInterface $scopeHierarchy - ) { - $this->_initialConfig = $initialConfig; - $this->_converter = $converter; - $this->_processor = $processor; - $this->_scopeFactory = $scopeFactory; - $this->_scopeHierarchy = $scopeHierarchy; - } - - public function read($scope) - { - $config = array(); - $scopes = $this->_scopeHierarchy->getHierarchy($scope); - foreach ($scopes as $scope) { - $config = array_replace_recursive($config, $this->_getInitialConfigData($scope)); - $config = array_replace_recursive($config, $this->_getExtendedConfigData($scope)); - } - return $this->_processor->processValue($config); - } - - /** - * Retrieve initial scope config from xml files - * - * @param string $scope - * @return array - */ - protected function _getInitialConfigData($scope) - { - return $this->_initialConfig->getData($scope); - } - - /** - * Retrieve scope config from database - * - * @param string $scope - * @return array - */ - protected function _getExtendedConfigData($scope) - { - list($scopeType, $scopeCode) = array_pad(explode('|', $scope), 2, null); - if (null === $scopeCode) { - $collection = $this->_scopeFactory->create(array('scope' => $scopeType)); - } else { - $collection = $this->_scopeFactory->create(array('scope' => $scopeType, 'scopeId' => $scopeCode)); - } - - $config = array(); - foreach ($collection as $item) { - $config[$item->getPath()] = $item->getValue(); - } - return $this->_converter->convert($config); - } -} diff --git a/app/code/Magento/Core/Model/Config/DataInterface.php b/lib/Magento/App/Config/Scope/ReaderInterface.php similarity index 86% rename from app/code/Magento/Core/Model/Config/DataInterface.php rename to lib/Magento/App/Config/Scope/ReaderInterface.php index 3efc6a627781c3a5d4fd2cdedd04ac9841246ac3..861ab921d1f65c77fea2afd1b23fb483a8391ab1 100644 --- a/app/code/Magento/Core/Model/Config/DataInterface.php +++ b/lib/Magento/App/Config/Scope/ReaderInterface.php @@ -1,5 +1,7 @@ <?php /** + * Scope Reader + * * Magento * * NOTICE OF LICENSE @@ -21,13 +23,12 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Core\Model\Config; +namespace Magento\App\Config\Scope; -interface DataInterface +interface ReaderInterface { /** - * @param $path - * @return mixed + * Read configuration scope */ - public function getValue($path); + public function read(); } diff --git a/lib/Magento/App/Config/Scope/Resolver.php b/lib/Magento/App/Config/Scope/ReaderPoolInterface.php similarity index 70% rename from lib/Magento/App/Config/Scope/Resolver.php rename to lib/Magento/App/Config/Scope/ReaderPoolInterface.php index e4ddd586d0a7ea64f9829071be75fcde04f90a23..acc0127fd70f1dc5b3c6e44405d54da0a57d96da 100644 --- a/lib/Magento/App/Config/Scope/Resolver.php +++ b/lib/Magento/App/Config/Scope/ReaderPoolInterface.php @@ -1,7 +1,5 @@ <?php /** - * Scope Resolver - * * Magento * * NOTICE OF LICENSE @@ -20,19 +18,18 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ namespace Magento\App\Config\Scope; -class Resolver implements ResolverInterface +interface ReaderPoolInterface { /** - * @inheritdoc + * Retrieve reader by scope + * + * @param string $scopeType + * @return mixed */ - public function processValue($value) - { - return $value; - } - + public function getReader($scopeType); } diff --git a/lib/Magento/App/Config/ScopePool.php b/lib/Magento/App/Config/ScopePool.php index 7c1f1e3238c86464b090f79a13f7c385b0a36740..eda4efbec283b0c30b80c2269942608d6e5e31ff 100644 --- a/lib/Magento/App/Config/ScopePool.php +++ b/lib/Magento/App/Config/ScopePool.php @@ -28,9 +28,9 @@ class ScopePool const CACHE_TAG = 'config_scopes'; /** - * @var \Magento\App\Config\Scope\Reader + * @var \Magento\App\Config\Scope\ReaderPoolInterface */ - protected $_reader; + protected $_readerPool; /** * @var \Magento\App\Config\DataFactory @@ -53,18 +53,18 @@ class ScopePool protected $_scopes = array(); /** - * @param \Magento\App\Config\Scope\Reader $reader + * @param \Magento\App\Config\Scope\ReaderPoolInterface $readerPool * @param \Magento\App\Config\DataFactory $dataFactory * @param \Magento\Cache\FrontendInterface $cache * @param string $cacheId */ public function __construct( - \Magento\App\Config\Scope\Reader $reader, + \Magento\App\Config\Scope\ReaderPoolInterface $readerPool, \Magento\App\Config\DataFactory $dataFactory, \Magento\Cache\FrontendInterface $cache, $cacheId = 'default_config_cache' ) { - $this->_reader = $reader; + $this->_readerPool = $readerPool; $this->_dataFactory = $dataFactory; $this->_cache = $cache; $this->_cacheId = $cacheId; @@ -73,27 +73,34 @@ class ScopePool /** * Retrieve config section * - * @param string $scope + * @param string $scopeType + * @param string $scopeCode * @return \Magento\App\Config\Data */ - public function getScope($scope) + public function getScope($scopeType, $scopeCode = null) { - if (!isset($this->_scopes[$scope])) { - $cacheKey = $this->_cacheId . '|' . $scope; + $code = $scopeType . '|' . $scopeCode; + if (!isset($this->_scopes[$code])) { + $cacheKey = $this->_cacheId . '|' . $code; $data = $this->_cache->load($cacheKey); if ($data) { $data = unserialize($data); } else { - $data = $this->_reader->read($scope); + $reader = $this->_readerPool->getReader($scopeType); + if ($scopeType === \Magento\BaseScopeInterface::SCOPE_DEFAULT) { + $data = $reader->read(); + } else { + $data = $reader->read($scopeCode); + } $this->_cache->save(serialize($data), $cacheKey, array(self::CACHE_TAG)); } - $this->_scopes[$scope] = $this->_dataFactory->create(array('data' => $data)); + $this->_scopes[$code] = $this->_dataFactory->create(array('data' => $data)); } - return $this->_scopes[$scope]; + return $this->_scopes[$code]; } /** - * Clear all stired sections + * Clear cache of all scopes */ public function clean() { diff --git a/app/code/Magento/Core/Model/Config/Storage/WriterInterface.php b/lib/Magento/App/Config/Storage/WriterInterface.php similarity index 84% rename from app/code/Magento/Core/Model/Config/Storage/WriterInterface.php rename to lib/Magento/App/Config/Storage/WriterInterface.php index 55722c0101527e243b5e79e57b650b1dc21e5aad..6f159b77e7039be668b79fed529d97f047956aa1 100644 --- a/app/code/Magento/Core/Model/Config/Storage/WriterInterface.php +++ b/lib/Magento/App/Config/Storage/WriterInterface.php @@ -23,7 +23,7 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Core\Model\Config\Storage; +namespace Magento\App\Config\Storage; interface WriterInterface { @@ -34,7 +34,7 @@ interface WriterInterface * @param string $scope * @param int $scopeId */ - public function delete($path, $scope = \Magento\Core\Model\Store::DEFAULT_CODE, $scopeId = 0); + public function delete($path, $scope = \Magento\BaseScopeInterface::SCOPE_DEFAULT, $scopeId = 0); /** * Save config value to storage @@ -44,5 +44,5 @@ interface WriterInterface * @param string $scope * @param int $scopeId */ - public function save($path, $value, $scope = \Magento\Core\Model\Store::DEFAULT_CODE, $scopeId = 0); + public function save($path, $value, $scope = \Magento\BaseScopeInterface::SCOPE_DEFAULT, $scopeId = 0); } diff --git a/lib/Magento/App/Helper/AbstractHelper.php b/lib/Magento/App/Helper/AbstractHelper.php index 9690260a17f6893b6fb60a85006fe114d250bf2e..cafbc26e698a929efac19b4c01bbc507a5fd12fa 100644 --- a/lib/Magento/App/Helper/AbstractHelper.php +++ b/lib/Magento/App/Helper/AbstractHelper.php @@ -52,7 +52,7 @@ abstract class AbstractHelper * * @var \Magento\TranslateInterface */ - protected $_translator; + protected $_inlineFactory; /** * @var \Magento\Module\Manager @@ -96,7 +96,7 @@ abstract class AbstractHelper */ public function __construct(\Magento\App\Helper\Context $context) { - $this->_translator = $context->getTranslator(); + $this->_inlineFactory = $context->getInlineFactory(); $this->_moduleManager = $context->getModuleManager(); $this->_logger = $context->getLogger(); $this->_request = $context->getRequest(); diff --git a/lib/Magento/App/Helper/Context.php b/lib/Magento/App/Helper/Context.php index 7f32262d44463210e17f5e19dac5e4cfd030eeac..3021f8edfd5dde6d23e2d73fd3b58b3a45b2a149 100644 --- a/lib/Magento/App/Helper/Context.php +++ b/lib/Magento/App/Helper/Context.php @@ -30,14 +30,14 @@ class Context implements \Magento\ObjectManager\ContextInterface /** * @var \Magento\TranslateInterface */ - protected $_translator; + protected $_inlineFactory; /** * @var \Magento\Module\Manager */ protected $_moduleManager; - /** + /** * @var \Magento\Event\ManagerInterface */ protected $_eventManager; @@ -79,7 +79,7 @@ class Context implements \Magento\ObjectManager\ContextInterface /** * @param \Magento\Logger $logger - * @param \Magento\TranslateInterface $translator + * @param \Magento\Translate\InlineFactory $inlineFactory * @param \Magento\Module\Manager $moduleManager * @param \Magento\App\RequestInterface $httpRequest * @param \Magento\Cache\ConfigInterface $cacheConfig @@ -93,7 +93,7 @@ class Context implements \Magento\ObjectManager\ContextInterface */ public function __construct( \Magento\Logger $logger, - \Magento\TranslateInterface $translator, + \Magento\Translate\InlineFactory $inlineFactory, \Magento\Module\Manager $moduleManager, \Magento\App\RequestInterface $httpRequest, \Magento\Cache\ConfigInterface $cacheConfig, @@ -103,7 +103,7 @@ class Context implements \Magento\ObjectManager\ContextInterface \Magento\HTTP\Header $httpHeader, \Magento\HTTP\PhpEnvironment\RemoteAddress $remoteAddress ) { - $this->_translator = $translator; + $this->_inlineFactory = $inlineFactory; $this->_moduleManager = $moduleManager; $this->_httpRequest = $httpRequest; $this->_cacheConfig = $cacheConfig; @@ -116,11 +116,11 @@ class Context implements \Magento\ObjectManager\ContextInterface } /** - * @return \Magento\TranslateInterface + * @return \Magento\Translate\InlineFactory */ - public function getTranslator() + public function getInlineFactory() { - return $this->_translator; + return $this->_inlineFactory; } /** diff --git a/app/code/Magento/Core/Model/ReinitableConfig.php b/lib/Magento/App/ReinitableConfig.php similarity index 86% rename from app/code/Magento/Core/Model/ReinitableConfig.php rename to lib/Magento/App/ReinitableConfig.php index 03e3090276ffaf0dbe55d02bf27e7a600c4153bf..addd7dceebf48f843d62f429e455c2932c29f276 100644 --- a/app/code/Magento/Core/Model/ReinitableConfig.php +++ b/lib/Magento/App/ReinitableConfig.php @@ -24,16 +24,16 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Core\Model; +namespace Magento\App; -class ReinitableConfig extends \Magento\Core\Model\Config implements \Magento\App\ReinitableConfigInterface +class ReinitableConfig extends \Magento\App\Config implements \Magento\App\ReinitableConfigInterface { /** * (@inheritdoc) */ public function reinit() { - $this->_sectionPool->clean(); + $this->_scopePool->clean(); return $this; } } diff --git a/lib/Magento/App/Response/Http.php b/lib/Magento/App/Response/Http.php index bfd59a4c620c75cf749792972fca795e4f7a648e..6cd61837bdab2c7780fed17a70a4dd8c70ef851a 100644 --- a/lib/Magento/App/Response/Http.php +++ b/lib/Magento/App/Response/Http.php @@ -27,6 +27,18 @@ namespace Magento\App\Response; class Http extends \Zend_Controller_Response_Http implements \Magento\App\ResponseInterface { + /** + * Cookie to store page vary string + */ + const COOKIE_VARY_STRING = 'X-VARY-STRING'; + + /** + * Response vary identifiers + * + * @var array + */ + protected $vary; + /** * Get header value by name. * Returns first found header by passed name. @@ -44,4 +56,46 @@ class Http extends \Zend_Controller_Response_Http implements \Magento\App\Respon } return false; } + + /** + * Set vary identifier + * + * @param string $name + * @param string|array $value + * @return $this + */ + public function setVary($name, $value) + { + if (is_array($value)) { + $value = serialize($value); + } + $this->vary[$name] = $value; + return $this; + } + + /** + * Send the response, including all headers, rendering exceptions if so + * requested. + * + * @return void + */ + public function sendResponse() + { + setcookie(self::COOKIE_VARY_STRING, $this->getVaryString(), null, '/'); + parent::sendResponse(); + } + + /** + * Returns hash of varies + * + * @return string + */ + public function getVaryString() + { + if (!empty($this->vary)) { + ksort($this->vary); + } + + return sha1(serialize($this->vary)); + } } diff --git a/lib/Magento/App/View.php b/lib/Magento/App/View.php index 461b274acaa5e145d60401076f72cd416435a239..74d4ce8a7da0b53ca39f07c8e0114557a6747c29 100644 --- a/lib/Magento/App/View.php +++ b/lib/Magento/App/View.php @@ -42,9 +42,9 @@ class View implements ViewInterface protected $_eventManager; /** - * @var \Magento\TranslateInterface + * @var \Magento\Translate\InlineInterface */ - protected $_translator; + protected $_translateInline; /** * @var \Magento\App\ActionFlag @@ -72,7 +72,7 @@ class View implements ViewInterface * @param \Magento\App\ResponseInterface $response * @param \Magento\Config\ScopeInterface $configScope * @param \Magento\Event\ManagerInterface $eventManager - * @param \Magento\TranslateInterface $translator + * @param \Magento\Translate\InlineInterface $translateInline * @param \Magento\App\ActionFlag $actionFlag */ public function __construct( @@ -81,7 +81,7 @@ class View implements ViewInterface \Magento\App\ResponseInterface $response, \Magento\Config\ScopeInterface $configScope, \Magento\Event\ManagerInterface $eventManager, - \Magento\TranslateInterface $translator, + \Magento\Translate\InlineInterface $translateInline, \Magento\App\ActionFlag $actionFlag ) { $this->_layout = $layout; @@ -89,7 +89,7 @@ class View implements ViewInterface $this->_response = $response; $this->_configScope = $configScope; $this->_eventManager = $eventManager; - $this->_translator = $translator; + $this->_translateInline = $translateInline; $this->_actionFlag = $actionFlag; } @@ -283,7 +283,7 @@ class View implements ViewInterface ); $output = $this->getLayout()->getOutput(); - $this->_translator->processResponseBody($output); + $this->_translateInline->processResponseBody($output); $this->_response->appendBody($output); \Magento\Profiler::stop('layout_render'); diff --git a/lib/Magento/App/Config/Scope/ResolverInterface.php b/lib/Magento/BaseScopeInterface.php similarity index 81% rename from lib/Magento/App/Config/Scope/ResolverInterface.php rename to lib/Magento/BaseScopeInterface.php index eb0fa73c24502d2e55b83962e38c52b82957609e..22772a6c375f22e2c60e5a13cad320422dc18305 100644 --- a/lib/Magento/App/Config/Scope/ResolverInterface.php +++ b/lib/Magento/BaseScopeInterface.php @@ -1,7 +1,5 @@ <?php /** - * Resolver interface - * * Magento * * NOTICE OF LICENSE @@ -23,15 +21,19 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\App\Config\Scope; +namespace Magento; -interface ResolverInterface +interface BaseScopeInterface { /** - * Process config value + * Default scope type + */ + const SCOPE_DEFAULT = 'default'; + + /** + * Retrieve scope code * - * @param string $value - * @return mixed + * @return string */ - public function processValue($value); + public function getCode(); } diff --git a/lib/Magento/App/Config/Scope/HierarchyInterface.php b/lib/Magento/BaseScopeResolverInterface.php similarity index 81% rename from lib/Magento/App/Config/Scope/HierarchyInterface.php rename to lib/Magento/BaseScopeResolverInterface.php index 7cabce69944c24b9b0ca1d7280aa440e67d99b8f..89973299ddb26f7f7180b4e47af0f7581553da66 100644 --- a/lib/Magento/App/Config/Scope/HierarchyInterface.php +++ b/lib/Magento/BaseScopeResolverInterface.php @@ -1,7 +1,5 @@ <?php /** - * Hierarchy interface - * * Magento * * NOTICE OF LICENSE @@ -23,15 +21,17 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\App\Config\Scope; -interface HierarchyInterface +namespace Magento; + +interface BaseScopeResolverInterface { + /** - * Get Hierarchy by Scope + * Retrieve application scope object * - * @param string $scope - * @return array + * @param null|int $scopeId + * @return \Magento\BaseScopeInterface */ - public function getHierarchy($scope); + public function getScope($scopeId = null); } diff --git a/lib/Magento/Json/Encoder.php b/lib/Magento/Json/Encoder.php index 6f0a9109212bea10a48c415c06bd5bc43f9af1fe..baa791bea74eb8a7b4e6869759d5ad34cfaac1c5 100644 --- a/lib/Magento/Json/Encoder.php +++ b/lib/Magento/Json/Encoder.php @@ -21,29 +21,23 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ - namespace Magento\Json; -use Magento\TranslateInterface; - -/** - * @package Magento\Json - */ class Encoder implements EncoderInterface { /** * Translator * - * @var TranslateInterface + * @var \Magento\Translate\InlineInterface */ - protected $translator; + protected $translateInline; /** - * @param TranslateInterface $translator + * @param \Magento\Translate\InlineInterface $translateInline */ - public function __construct(TranslateInterface $translator) + public function __construct(\Magento\Translate\InlineInterface $translateInline) { - $this->translator = $translator; + $this->translateInline = $translateInline; } /** @@ -55,8 +49,8 @@ class Encoder implements EncoderInterface public function encode($data) { $json = \Zend_Json::encode($data); - if ($this->translator->isAllowed()) { - $this->translator->processResponseBody($json, true); + if ($this->translateInline->isAllowed()) { + $this->translateInline->processResponseBody($json, true); } return $json; diff --git a/app/code/Magento/Core/Model/Locale/Hierarchy/Config.php b/lib/Magento/Locale/Hierarchy/Config.php similarity index 79% rename from app/code/Magento/Core/Model/Locale/Hierarchy/Config.php rename to lib/Magento/Locale/Hierarchy/Config.php index 61d79529a10a6387f49fda4b8c1315906f7594b0..63d0c986128efe515af623dadfc9e5e08f9881ee 100644 --- a/app/code/Magento/Core/Model/Locale/Hierarchy/Config.php +++ b/lib/Magento/Locale/Hierarchy/Config.php @@ -23,31 +23,10 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Core\Model\Locale\Hierarchy; +namespace Magento\Locale\Hierarchy; class Config extends \Magento\Config\Data { - /** - * Configuration data reader - * - * @var \Magento\Core\Model\Locale\Hierarchy\Config\Reader - */ - protected $_reader; - - /** - * Configuration cache model - * - * @var \Magento\Config\CacheInterface - */ - protected $_cache; - - /** - * Cache identifier - * - * @var string - */ - protected $_cacheId; - /** * @param \Magento\Config\ReaderInterface $reader * @param \Magento\Config\CacheInterface $cache diff --git a/lib/Magento/Mail/Message.php b/lib/Magento/Mail/Message.php new file mode 100644 index 0000000000000000000000000000000000000000..bfb53e4cbf654227fd0f1152ea46f6836a63aa60 --- /dev/null +++ b/lib/Magento/Mail/Message.php @@ -0,0 +1,112 @@ +<?php +/** + * Mail Message + * + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Mail; + +class Message extends \Zend_Mail implements MessageInterface +{ + /** + * Body + * + * @var string + */ + protected $messageType = self::TYPE_TEXT; + + /** + * Set message body + * + * @param string $body + * @return $this + */ + public function setBody($body) + { + return $this->messageType == self::TYPE_TEXT ? $this->setBodyText($body) : $this->setBodyHtml($body); + } + + /** + * Set message body + * + * @return string + */ + public function getBody() + { + return $this->messageType == self::TYPE_TEXT ? $this->getBodyText() : $this->getBodyHtml(); + } + + /** + * Set to address + * + * @param string|array $toAddress + * @return $this + */ + public function setTo($toAddress) + { + return $this->addTo($toAddress); + } + + /** + * Set cc address + * @param string|array $ccAddress + * @return $this + */ + public function setCc($ccAddress) + { + return $this->addCc($ccAddress); + } + + /** + * Set bcc address + * + * @param string|array $bccAddress + * @return $this + */ + public function setBcc($bccAddress) + { + return $this->addBcc($bccAddress); + } + + /** + * Set reply-to address + * + * @param string|array $replyToAddress + * @return $this + */ + public function addReplyTo($replyToAddress) + { + return $this->addBcc($replyToAddress); + } + + /** + * Set message type + * + * @param string $type + * @return $this + */ + public function setMessageType($type) + { + $this->messageType = $type; + return $this; + } +} diff --git a/lib/Magento/Mail/MessageInterface.php b/lib/Magento/Mail/MessageInterface.php new file mode 100644 index 0000000000000000000000000000000000000000..d7d60ec5e1f150c1f4021a4cde5800809d883ae5 --- /dev/null +++ b/lib/Magento/Mail/MessageInterface.php @@ -0,0 +1,144 @@ +<?php +/** + * Mail Message interface + * + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Mail; + +interface MessageInterface +{ + /** + * Types of message + */ + const TYPE_TEXT = 'text/plain'; + const TYPE_HTML = 'text/html'; + + /** + * Set message subject + * + * @param string $subject + * @return $this + */ + public function setSubject($subject); + + /** + * Get message subject + * + * @return string + */ + public function getSubject(); + + /** + * Set message body + * + * @param mixed $body + * @return $this + */ + public function setBody($body); + + /** + * Get message body + * + * @return mixed + */ + public function getBody(); + + /** + * Set from address + * + * @param string|array $fromAddress + * @return $this + */ + public function setFrom($fromAddress); + + /** + * Set to address + * + * @param string|array $toAddress + * @return $this + */ + public function setTo($toAddress); + + /** + * Add to address + * + * @param string|array $toAddress + * @return $this + */ + public function addTo($toAddress); + + /** + * Set cc address + * @param string|array $ccAddress + * @return $this + */ + public function setCc($ccAddress); + + /** + * Add cc address + * + * @param string|array $ccAddress + * @return $this + */ + public function addCc($ccAddress); + + /** + * Set bcc address + * + * @param string|array $bccAddress + * @return $this + */ + public function setBcc($bccAddress); + + /** + * Add bcc address + * + * @param string|array $bccAddress + * @return $this + */ + public function addBcc($bccAddress); + + /** + * Set reply-to address + * + * @param string|array $replyToAddress + * @return $this + */ + public function setReplyTo($replyToAddress); + + /** + * Add reply-to address + * + * @param string|array $replyToAddress + * @return $this + */ + public function addReplyTo($replyToAddress); + + /** + * Set message type + * + * @param string $type + * @return $this + */ + public function setMessageType($type); +} diff --git a/lib/Magento/Mail/Template/ConfigInterface.php b/lib/Magento/Mail/Template/ConfigInterface.php new file mode 100644 index 0000000000000000000000000000000000000000..0b92ba1358d2dea7d90198eb2674e6c40e514c0e --- /dev/null +++ b/lib/Magento/Mail/Template/ConfigInterface.php @@ -0,0 +1,68 @@ +<?php +/** + * High-level interface for mail templates data that hides format from the client code + * + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Mail\Template; + +interface ConfigInterface +{ + /** + * Retrieve unique identifiers of all available email templates + * + * @return string[] + */ + public function getAvailableTemplates(); + + /** + * Retrieve translated label of an email template + * + * @param string $templateId + * @return string + */ + public function getTemplateLabel($templateId); + + /** + * Retrieve type of an email template + * + * @param string $templateId + * @return string + */ + public function getTemplateType($templateId); + + /** + * Retrieve fully-qualified name of a module an email template belongs to + * + * @param string $templateId + * @return string + */ + public function getTemplateModule($templateId); + + /** + * Retrieve full path to an email template file + * + * @param string $templateId + * @return string + */ + public function getTemplateFilename($templateId); +} diff --git a/lib/Magento/App/Config/Scope/FactoryInterface.php b/lib/Magento/Mail/Template/FactoryInterface.php similarity index 67% rename from lib/Magento/App/Config/Scope/FactoryInterface.php rename to lib/Magento/Mail/Template/FactoryInterface.php index 2d9e7e9140b6e8205ce60ee8d29961d4721f20a4..462f63669d03762f6dfd18fd02fe91ff83489380 100644 --- a/lib/Magento/App/Config/Scope/FactoryInterface.php +++ b/lib/Magento/Mail/Template/FactoryInterface.php @@ -1,6 +1,6 @@ <?php /** - * Scoped Factory + * Mail Template Factory interface * * Magento * @@ -20,18 +20,16 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\App\Config\Scope; +namespace Magento\Mail\Template; interface FactoryInterface { /** - * Create Scope class instance - * - * @param array $data - * @return \IteratorAggregate + * @param string $identifier + * @return \Magento\Mail\Template\TemplateInterface */ - public function create(array $data = array()); -} + public function get($identifier); +} \ No newline at end of file diff --git a/lib/Magento/Mail/Template/TemplateInterface.php b/lib/Magento/Mail/Template/TemplateInterface.php new file mode 100644 index 0000000000000000000000000000000000000000..0961a2932af724dbcbf8234774bc45cd8f0e8a62 --- /dev/null +++ b/lib/Magento/Mail/Template/TemplateInterface.php @@ -0,0 +1,72 @@ +<?php +/** + * Mail Template interface + * + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Mail\Template; + +interface TemplateInterface +{ + /** + * Types of template + */ + const TYPE_TEXT = 1; + const TYPE_HTML = 2; + + /** + * Get processed template + * + * @return string + */ + public function processTemplate(); + + /** + * Get processed subject + * + * @return string + */ + public function getSubject(); + + /** + * Get Type + * + * @return int + */ + public function getType(); + + /** + * Set template variables + * + * @param array $vars + * @return $this + */ + public function setVars($vars); + + /** + * Set template options + * + * @param array $options + * @return $this + */ + public function setOptions($options); +} diff --git a/lib/Magento/Mail/Template/TransportBuilder.php b/lib/Magento/Mail/Template/TransportBuilder.php new file mode 100644 index 0000000000000000000000000000000000000000..149e54fefc758bdc72331aed738561decd86e916 --- /dev/null +++ b/lib/Magento/Mail/Template/TransportBuilder.php @@ -0,0 +1,176 @@ +<?php +/** + * Mail Template Transport Builder + * + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Mail\Template; + +class TransportBuilder +{ + /** + * Template Identifier + * + * @var string + */ + protected $templateIdentifier; + + /** + * Template Variables + * + * @var array + */ + protected $templateVars; + + /** + * Template Options + * + * @var array + */ + protected $templateOptions; + + /** + * Mail Transport + * + * @var \Magento\Mail\TransportInterface + */ + protected $transport; + + /** + * Template Factory + * + * @var FactoryInterface + */ + protected $templateFactory; + + /** + * Object Manager + * + * @var \Magento\ObjectManager + */ + protected $objectManager; + + /** + * Message + * + * @var \Magento\Mail\Message + */ + protected $message; + + /** + * @param FactoryInterface $templateFactory + * @param \Magento\Mail\Message $message + * @param \Magento\ObjectManager $objectManager + */ + public function __construct( + \Magento\Mail\Template\FactoryInterface $templateFactory, + \Magento\Mail\Message $message, + \Magento\ObjectManager $objectManager + ) { + $this->templateFactory = $templateFactory; + $this->message = $message; + $this->objectManager = $objectManager; + } + + /** + * Add cc address + * + * @param array|string $address + * @return $this + */ + public function addCc($address) + { + $this->message->addCc($address); + return $this; + } + + /** + * Set mail from address + * + * @param string $from + * @return $this + */ + public function setFrom($from) + { + $this->message->setFrom($from); + return $this; + } + + /** + * Set template identifier + * + * @param string $templateIdentifier + * @return $this + */ + public function setTemplateIdentifier($templateIdentifier) + { + $this->templateIdentifier = $templateIdentifier; + return $this; + } + + /** + * Set template vars + * + * @param array $templateVars + * @return $this + */ + public function setTemplateVars($templateVars) + { + $this->templateVars = $templateVars; + return $this; + } + + /** + * Set template options + * + * @param array $templateOptions + * @return $this + */ + public function setTemplateOptions($templateOptions) + { + $this->templateOptions = $templateOptions; + return $this; + } + + /** + * Get mail transport + * + * @return \Magento\Mail\TransportInterface + */ + public function getTransport() + { + $template = $this->templateFactory->get($this->templateIdentifier) + ->setVars($this->templateVars) + ->setOptions($this->templateOptions); + $types = array( + \Magento\Mail\Template\TemplateInterface::TYPE_TEXT => \Magento\Mail\MessageInterface::TYPE_TEXT, + \Magento\Mail\Template\TemplateInterface::TYPE_HTML => \Magento\Mail\MessageInterface::TYPE_HTML, + ); + + $this->message->setMessageType($types[$template->getType()]) + ->setBody($template->processTemplate()) + ->setSubject($template->getSubject()); + + return $this->objectManager->create('\Magento\Mail\TransportInterface', array('message' => $this->message)); + + } +} \ No newline at end of file diff --git a/lib/Magento/Mail/Transport.php b/lib/Magento/Mail/Transport.php new file mode 100644 index 0000000000000000000000000000000000000000..ea3efb37b9b03265663b555fd4dcbc4220c8c4a0 --- /dev/null +++ b/lib/Magento/Mail/Transport.php @@ -0,0 +1,42 @@ +<?php +/** + * Mail Transport + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Mail; + +class Transport extends \Zend_Mail_Transport_Sendmail implements \Magento\Mail\TransportInterface +{ + /** + * Send a mail using this transport + * + * @param \Magento\Mail\MessageInterface $message + * @throws \InvalidArgumentException + */ + public function sendMessage(\Magento\Mail\MessageInterface $message) + { + if (!$message instanceof \Zend_Mail) { + throw new \InvalidArgumentException('The message should be an instance of \Zend_Mail'); + } + parent::send($message); + } +} diff --git a/lib/Magento/Mail/TransportInterface.php b/lib/Magento/Mail/TransportInterface.php new file mode 100644 index 0000000000000000000000000000000000000000..11ec3d6e7ca881126e9eb8d0d03eb2583c0fd606 --- /dev/null +++ b/lib/Magento/Mail/TransportInterface.php @@ -0,0 +1,36 @@ +<?php +/** + * Mail Transport interface + * + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Mail; + +interface TransportInterface +{ + /** + * Send a mail using this transport + * + * @param \Magento\Mail\MessageInterface $message + */ + public function sendMessage(\Magento\Mail\MessageInterface $message); +} diff --git a/app/code/Magento/Core/Model/Translate.php b/lib/Magento/Translate.php similarity index 77% rename from app/code/Magento/Core/Model/Translate.php rename to lib/Magento/Translate.php index 32d57d70d192c97b88eacda4d15de584da88a64b..e1503ca941de89b29f42dffd2c3c7d7b8b4f022e 100644 --- a/app/code/Magento/Core/Model/Translate.php +++ b/lib/Magento/Translate.php @@ -18,25 +18,18 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Magento - * @package Magento_Core * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ - -namespace Magento\Core\Model; - -use Magento\TranslateInterface; - +namespace Magento; /** - * Translate model + * Translate library * - * @todo Remove this suppression when jira entry MAGETWO-8296 is completed. * @SuppressWarnings(PHPMD.CouplingBetweenObjects) * @SuppressWarnings(PHPMD.TooManyFields) */ -class Translate implements TranslateInterface +class Translate implements \Magento\TranslateInterface { /** * CSV separator @@ -59,20 +52,15 @@ class Translate implements TranslateInterface const CONFIG_KEY_LOCALE = 'locale'; /** - * Configuration store key + * Configuration scope key */ - const CONFIG_KEY_STORE = 'store'; + const CONFIG_KEY_SCOPE = 'scope'; /** * Configuration theme key */ const CONFIG_KEY_DESIGN_THEME = 'theme'; - /** - * Default translation string - */ - const DEFAULT_STRING = 'Translate String'; - /** * Locale code * @@ -80,13 +68,6 @@ class Translate implements TranslateInterface */ protected $_localeCode; - /** - * Translation object - * - * @var \Zend_Translate_Adapter - */ - protected $_translate; - /** * Translator configuration array * @@ -123,7 +104,7 @@ class Translate implements TranslateInterface protected $_translateInline; /** - * @var \Magento\Core\Model\Translate\InlineInterface + * @var \Magento\Translate\InlineInterface */ protected $_inlineInterface; @@ -147,14 +128,14 @@ class Translate implements TranslateInterface protected $_viewDesign; /** - * @var \Magento\Core\Model\Translate\Factory + * @var \Magento\Translate\Factory */ protected $_translateFactory; /** * @var \Magento\Cache\FrontendInterface $cache */ - private $_cache; + protected $_cache; /** * @var \Magento\View\FileSystem @@ -177,17 +158,17 @@ class Translate implements TranslateInterface protected $_modulesReader; /** - * @var \Magento\Core\Model\StoreManagerInterface + * @var \Magento\BaseScopeResolverInterface */ - protected $_storeManager; + protected $_scopeResolver; /** - * @var \Magento\Core\Model\Resource\Translate + * @var \Magento\Translate\ResourceInterface */ protected $_translateResource; /** - * @var \Magento\Core\Model\App + * @var \Magento\AppInterface */ protected $_app; @@ -208,17 +189,16 @@ class Translate implements TranslateInterface /** * @param \Magento\View\DesignInterface $viewDesign - * @param \Magento\Core\Model\Locale\Hierarchy\Config $config - * @param \Magento\Core\Model\Translate\Factory $translateFactory + * @param \Magento\Locale\Hierarchy\Config $config + * @param \Magento\Translate\Factory $translateFactory * @param \Magento\Cache\FrontendInterface $cache * @param \Magento\View\FileSystem $viewFileSystem * @param \Magento\Phrase\Renderer\Placeholder $placeholderRender * @param \Magento\Module\ModuleList $moduleList * @param \Magento\Module\Dir\Reader $modulesReader - * @param \Magento\App\ConfigInterface $coreConfig - * @param \Magento\Core\Model\StoreManagerInterface $storeManager - * @param \Magento\Core\Model\Resource\Translate $translate - * @param \Magento\Core\Model\App $app + * @param \Magento\BaseScopeResolverInterface $scopeResolver + * @param \Magento\Translate\ResourceInterface $translate + * @param \Magento\AppInterface $app * @param \Magento\App\State $appState * @param \Magento\App\Filesystem $filesystem * @@ -226,17 +206,16 @@ class Translate implements TranslateInterface */ public function __construct( \Magento\View\DesignInterface $viewDesign, - \Magento\Core\Model\Locale\Hierarchy\Config $config, - \Magento\Core\Model\Translate\Factory $translateFactory, + \Magento\Locale\Hierarchy\Config $config, + \Magento\Translate\Factory $translateFactory, \Magento\Cache\FrontendInterface $cache, \Magento\View\FileSystem $viewFileSystem, \Magento\Phrase\Renderer\Placeholder $placeholderRender, \Magento\Module\ModuleList $moduleList, \Magento\Module\Dir\Reader $modulesReader, - \Magento\App\ConfigInterface $coreConfig, - \Magento\Core\Model\StoreManagerInterface $storeManager, - \Magento\Core\Model\Resource\Translate $translate, - \Magento\Core\Model\App $app, + \Magento\BaseScopeResolverInterface $scopeResolver, + \Magento\Translate\ResourceInterface $translate, + \Magento\AppInterface $app, \Magento\App\State $appState, \Magento\App\Filesystem $filesystem ) { @@ -248,8 +227,7 @@ class Translate implements TranslateInterface $this->_placeholderRender = $placeholderRender; $this->_moduleList = $moduleList; $this->_modulesReader = $modulesReader; - $this->_coreConfig = $coreConfig; - $this->_storeManager = $storeManager; + $this->_scopeResolver = $scopeResolver; $this->_translateResource = $translate; $this->_app = $app; $this->_appState = $appState; @@ -263,15 +241,14 @@ class Translate implements TranslateInterface * @param string $area * @param \Magento\Object $initParams * @param bool $forceReload - * @return \Magento\Core\Model\Translate + * @return \Magento\TranslateInterface */ public function init($area = null, $initParams = null, $forceReload = false) { $area = isset($area) ? $area : $this->_appState->getAreaCode(); $this->setConfig(array(self::CONFIG_KEY_AREA => $area)); - $this->_translateInline = $this->getInlineObject($initParams)->isAllowed( - $area == \Magento\Backend\App\Area\FrontNameResolver::AREA_CODE ? 'admin' : null); + $this->_translateInline = $this->getInlineObject($initParams)->isAllowed(); if (!$forceReload) { $this->_data = $this->_loadCache(); @@ -300,16 +277,16 @@ class Translate implements TranslateInterface * Initialize configuration * * @param array $config - * @return \Magento\Core\Model\Translate + * @return \Magento\TranslateInterface */ - public function setConfig($config) + protected function setConfig($config) { $this->_config = $config; if (!isset($this->_config[self::CONFIG_KEY_LOCALE])) { $this->_config[self::CONFIG_KEY_LOCALE] = $this->getLocale(); } - if (!isset($this->_config[self::CONFIG_KEY_STORE])) { - $this->_config[self::CONFIG_KEY_STORE] = $this->_storeManager->getStore()->getId(); + if (!isset($this->_config[self::CONFIG_KEY_SCOPE])) { + $this->_config[self::CONFIG_KEY_SCOPE] = $this->_scopeResolver->getScope()->getCode(); } if (!isset($this->_config[self::CONFIG_KEY_DESIGN_THEME])) { $this->_config[self::CONFIG_KEY_DESIGN_THEME] = $this->_viewDesign->getDesignTheme()->getId(); @@ -323,7 +300,7 @@ class Translate implements TranslateInterface * @param string $key * @return mixed */ - public function getConfig($key) + protected function getConfig($key) { if (isset($this->_config[$key])) { return $this->_config[$key]; @@ -334,47 +311,19 @@ class Translate implements TranslateInterface /** * Determine if translation is enabled and allowed. * - * @param mixed $store + * @param mixed $scope * @return bool */ - public function isAllowed($store = null) + public function isAllowed($scope = null) { - /** @todo see jira entry MAGETWO-8296 */ - return $this->getInlineObject()->isAllowed($store); - } - - /** - * Parse and save edited translate - * - * @param array $translate - * @return \Magento\Core\Model\Translate\InlineInterface - */ - public function processAjaxPost($translate) - { - /** @var \Magento\App\Cache\TypeListInterface $cacheTypeList */ - $cacheTypeList = $this->_translateFactory->create(array(), 'Magento\App\Cache\TypeListInterface'); - $cacheTypeList->invalidate(\Magento\App\Cache\Type\Translate::TYPE_IDENTIFIER); - /** @var $parser \Magento\Core\Model\Translate\InlineParser */ - $parser = $this->_translateFactory->create(array(), 'Magento\Core\Model\Translate\InlineParser'); - $parser->processAjaxPost($translate, $this->getInlineObject()); - } - - /** - * Replace translation templates with HTML fragments - * - * @param array|string $body - * @param bool $isJson - * @return \Magento\Core\Model\Translate\InlineInterface - */ - public function processResponseBody(&$body, $isJson = false) { - return $this->getInlineObject()->processResponseBody($body, $isJson); + return $this->getInlineObject()->isAllowed($scope); } /** * Load data from module translation files * * @param string $moduleName - * @return \Magento\Core\Model\Translate + * @return \Magento\TranslateInterface */ protected function _loadModuleTranslation($moduleName) { @@ -407,7 +356,7 @@ class Translate implements TranslateInterface * @param array $data * @param string|bool $scope * @param boolean $forceReload - * @return \Magento\Core\Model\Translate + * @return \Magento\TranslateInterface */ protected function _addData($data, $scope = false, $forceReload = false) { @@ -452,8 +401,9 @@ class Translate implements TranslateInterface /** * Load current theme translation * - * @param boolean $forceReload - * @return \Magento\Core\Model\Translate + * @param bool $forceReload + * @param string $area + * @return $this */ protected function _loadThemeTranslation($forceReload = false, $area = null) { @@ -461,7 +411,6 @@ class Translate implements TranslateInterface return $this; } - $area = isset($area) ? $area : $this->_appState->getAreaCode(); $requiredLocaleList = $this->_composeRequiredLocaleList($this->getLocale()); foreach ($requiredLocaleList as $locale) { $file = $this->_getThemeTranslationFile($locale, $area); @@ -475,17 +424,17 @@ class Translate implements TranslateInterface } /** - * Loading current store translation from DB + * Loading current translation from DB * * @param boolean $forceReload - * @return \Magento\Core\Model\Translate + * @return \Magento\TranslateInterface */ protected function _loadDbTranslation($forceReload = false) { $requiredLocaleList = $this->_composeRequiredLocaleList($this->getLocale()); foreach ($requiredLocaleList as $locale) { - $arr = $this->getResource()->getTranslationArray(null, $locale); - $this->_addData($arr, $this->getConfig(self::CONFIG_KEY_STORE), $forceReload); + $arr = $this->_translateResource->getTranslationArray(null, $locale); + $this->_addData($arr, $this->getConfig(self::CONFIG_KEY_SCOPE), $forceReload); } return $this; } @@ -508,6 +457,7 @@ class Translate implements TranslateInterface * Retrieve translation file for theme * * @param string $locale + * @param string $area * @return string */ protected function _getThemeTranslationFile($locale, $area = null) @@ -539,7 +489,7 @@ class Translate implements TranslateInterface * * @return array */ - public function getData() + protected function getData() { if (is_null($this->_data)) { return array(); @@ -552,7 +502,7 @@ class Translate implements TranslateInterface * * @return string */ - public function getLocale() + protected function getLocale() { if (null === $this->_localeCode) { $this->_localeCode = $this->_app->getLocale()->getLocaleCode(); @@ -564,7 +514,7 @@ class Translate implements TranslateInterface * Set locale * * @param string $locale - * @return \Magento\Core\Model\Translate + * @return \Magento\TranslateInterface */ public function setLocale($locale) { @@ -572,29 +522,6 @@ class Translate implements TranslateInterface return $this; } - /** - * Retrieve DB resource model - * - * @return \Magento\Core\Model\Resource\Translate - */ - public function getResource() - { - return $this->_translateResource; - } - - /** - * Retrieve translation object - * - * @return \Zend_Translate_Adapter - */ - public function getTranslate() - { - if (null === $this->_translate) { - $this->_translate = new \Zend_Translate('array', $this->getData(), $this->getLocale()); - } - return $this->_translate; - } - /** * Translate * @@ -649,7 +576,7 @@ class Translate implements TranslateInterface * Set Translate inline mode * * @param bool $flag - * @return \Magento\Core\Model\Translate + * @return \Magento\TranslateInterface */ public function setTranslateInline($flag = false) { @@ -673,7 +600,7 @@ class Translate implements TranslateInterface * * @return string */ - public function getCacheId() + protected function getCacheId() { if (is_null($this->_cacheId)) { $this->_cacheId = \Magento\App\Cache\Type\Translate::TYPE_IDENTIFIER; @@ -683,8 +610,8 @@ class Translate implements TranslateInterface if (isset($this->_config[self::CONFIG_KEY_AREA])) { $this->_cacheId .= '_' . $this->_config[self::CONFIG_KEY_AREA]; } - if (isset($this->_config[self::CONFIG_KEY_STORE])) { - $this->_cacheId .= '_' . $this->_config[self::CONFIG_KEY_STORE]; + if (isset($this->_config[self::CONFIG_KEY_SCOPE])) { + $this->_cacheId .= '_' . $this->_config[self::CONFIG_KEY_SCOPE]; } if (isset($this->_config[self::CONFIG_KEY_DESIGN_THEME])) { $this->_cacheId .= '_' . $this->_config[self::CONFIG_KEY_DESIGN_THEME]; @@ -710,7 +637,7 @@ class Translate implements TranslateInterface /** * Saving data cache * - * @return \Magento\Core\Model\Translate + * @return \Magento\TranslateInterface */ protected function _saveCache() { @@ -741,9 +668,9 @@ class Translate implements TranslateInterface * Returns the translate interface object. * * @param \Magento\Object $initParams - * @return \Magento\Core\Model\Translate\InlineInterface + * @return \Magento\Translate\InlineInterface */ - private function getInlineObject($initParams = null) + protected function getInlineObject($initParams = null) { if (null === $this->_inlineInterface) { if ($initParams === null) { diff --git a/app/code/Magento/Core/Model/Translate/Factory.php b/lib/Magento/Translate/Factory.php similarity index 78% rename from app/code/Magento/Core/Model/Translate/Factory.php rename to lib/Magento/Translate/Factory.php index ebf3f8c34d9291afaeec66981f10486c4254783f..d776e49a9b24f8eb5ae7b0ea235db0e7cbb700d1 100644 --- a/app/code/Magento/Core/Model/Translate/Factory.php +++ b/lib/Magento/Translate/Factory.php @@ -18,8 +18,6 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Magento - * @package Magento_Core * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ @@ -27,14 +25,14 @@ /** * Translate factory */ -namespace Magento\Core\Model\Translate; +namespace Magento\Translate; class Factory { /** * Default translate inline class name */ - const DEFAULT_CLASS_NAME = 'Magento\Core\Model\Translate\InlineInterface'; + const DEFAULT_CLASS_NAME = 'Magento\Translate\InlineInterface'; /** * Object Manager @@ -57,13 +55,18 @@ class Factory * * @param array $data * @param string $className - * @return \Magento\Core\Model\Translate\InlineInterface + * @throws \InvalidArgumentException + * @return \Magento\Translate\InlineInterface */ public function create(array $data = null, $className = null) { if ($className === null) { $className = self::DEFAULT_CLASS_NAME; } - return $this->_objectManager->get($className, $data); + $model = $this->_objectManager->get($className, $data); + if (!$model instanceof \Magento\Translate\InlineInterface) { + throw new \InvalidArgumentException('Invalid inline translate model: ' . $className); + } + return $model; } } diff --git a/app/code/Magento/Core/Model/Translate/Inline.php b/lib/Magento/Translate/Inline.php similarity index 63% rename from app/code/Magento/Core/Model/Translate/Inline.php rename to lib/Magento/Translate/Inline.php index cefcc7d6f4080f2ffd490074d09706df8fb992c9..52069da6a853f1e7e7054142e086212c78daf368 100644 --- a/app/code/Magento/Core/Model/Translate/Inline.php +++ b/lib/Magento/Translate/Inline.php @@ -1,5 +1,7 @@ <?php /** + * Inline Translations Library + * * Magento * * NOTICE OF LICENSE @@ -18,19 +20,12 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Magento - * @package Magento_Core * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Translate; - -/** - * Inline Translations PHP part - */ -namespace Magento\Core\Model\Translate; - -class Inline implements \Magento\Core\Model\Translate\InlineInterface +class Inline implements \Magento\Translate\InlineInterface { /** * Regular Expression for detected and replace translate @@ -40,7 +35,7 @@ class Inline implements \Magento\Core\Model\Translate\InlineInterface protected $_tokenRegex = '\{\{\{(.*?)\}\}\{\{(.*?)\}\}\{\{(.*?)\}\}\{\{(.*?)\}\}\}'; /** - * @var \Magento\Core\Model\Translate + * @var \Magento\TranslateInterface */ protected $_translator; /** @@ -51,9 +46,9 @@ class Inline implements \Magento\Core\Model\Translate\InlineInterface protected $_isAllowed; /** - * @var \Magento\Core\Model\Translate\InlineParser + * @var \Magento\Translate\Inline\ParserFactory */ - protected $_parser; + protected $_parserFactory; /** * Flag about inserted styles and scripts for inline translates @@ -78,54 +73,75 @@ class Inline implements \Magento\Core\Model\Translate\InlineInterface protected $_appState; /** - * @var \Magento\Core\Model\Translate\Inline\ConfigFactory + * @var \Magento\Translate\Inline\ConfigFactory */ protected $_configFactory; + /** + * @var \Magento\BaseScopeResolverInterface + */ + protected $_scopeResolver; + + /** + * @var string + */ + protected $_templateFileName = ''; + + /** + * @var string + */ + protected $_translatorRoute = ''; + /** * Initialize inline translation model * - * @param InlineParser $parser - * @param \Magento\Core\Model\Translate $translate + * @param \Magento\BaseScopeResolverInterface $scopeResolver + * @param \Magento\Translate\Inline\ParserFactory $parserFactory + * @param \Magento\TranslateInterface $translate * @param \Magento\UrlInterface $url * @param \Magento\View\LayoutInterface $layout - * @param \Magento\Core\Model\Translate\Inline\ConfigFactory $configFactory + * @param \Magento\Translate\Inline\ConfigFactory $configFactory * @param \Magento\App\State $appState + * @param string $templateFileName + * @param string $translatorRoute */ public function __construct( - \Magento\Core\Model\Translate\InlineParser $parser, - \Magento\Core\Model\Translate $translate, + \Magento\BaseScopeResolverInterface $scopeResolver, + \Magento\Translate\Inline\ParserFactory $parserFactory, + \Magento\TranslateInterface $translate, \Magento\UrlInterface $url, \Magento\View\LayoutInterface $layout, - \Magento\Core\Model\Translate\Inline\ConfigFactory $configFactory, - \Magento\App\State $appState + \Magento\Translate\Inline\ConfigFactory $configFactory, + \Magento\App\State $appState, + $templateFileName = '', + $translatorRoute = '' ) { + $this->_scopeResolver = $scopeResolver; $this->_configFactory = $configFactory; - $this->_parser = $parser; + $this->_parserFactory = $parserFactory; $this->_translator = $translate; $this->_url = $url; $this->_layout = $layout; $this->_appState = $appState; + $this->_templateFileName = $templateFileName; + $this->_translatorRoute = $translatorRoute; } /** * Is enabled and allowed Inline Translates * - * @param mixed $store + * @param mixed $scope * @return bool */ - public function isAllowed($store = null) + public function isAllowed($scope = null) { if (is_null($this->_isAllowed)) { - if (is_null($store)) { - $store = $this->_parser->getStoreManager()->getStore(); - } - if (!$store instanceof \Magento\Core\Model\Store) { - $store = $this->_parser->getStoreManager()->getStore($store); + if (!$scope instanceof \Magento\BaseScopeInterface) { + $scope = $this->_scopeResolver->getScope($scope); } - $active = $this->_configFactory->create()->isActive($store); - $this->_isAllowed = $active && $this->_parser->getHelper()->isDevAllowed($store); + $config = $this->_configFactory->get(); + $this->_isAllowed = $config->isActive($scope) && $config->isDevAllowed($scope); } return $this->_translator->getTranslateInline() && $this->_isAllowed; } @@ -143,15 +159,13 @@ class Inline implements \Magento\Core\Model\Translate\InlineInterface * * @param array|string $body * @param bool $isJson - * @return \Magento\Core\Model\Translate\Inline + * @return $this */ - public function processResponseBody(&$body, $isJson) + public function processResponseBody(&$body, $isJson = false) { - $this->_parser->setIsJson($isJson); + $parser = $this->_parserFactory->get(); + $parser->setIsJson($isJson); if (!$this->isAllowed()) { - if ($this->_appState->getAreaCode() == \Magento\Backend\App\Area\FrontNameResolver::AREA_CODE) { - $this->_stripInlineTranslations($body); - } return $this; } @@ -160,11 +174,11 @@ class Inline implements \Magento\Core\Model\Translate\InlineInterface $this->processResponseBody($part, $isJson); } } elseif (is_string($body)) { - $content = $this->_parser->processResponseBodyString($body, $this); + $content = $parser->processResponseBodyString($body, $this); $this->_insertInlineScriptsHtml($content); - $body = $this->_parser->getContent(); + $body = $parser->getContent(); } - $this->_parser->setIsJson(\Magento\Core\Model\Translate\InlineParser::JSON_FLAG_DEFAULT_STATE); + $parser->setIsJson(\Magento\Translate\Inline\ParserInterface::JSON_FLAG_DEFAULT_STATE); return $this; } @@ -182,7 +196,7 @@ class Inline implements \Magento\Core\Model\Translate\InlineInterface /** * Create block to render script and html with added inline translation content. */ - private function _insertInlineScriptsHtml($content) + protected function _insertInlineScriptsHtml($content) { if ($this->_isScriptInserted || stripos($content, '</body>') === false) { return; @@ -193,11 +207,11 @@ class Inline implements \Magento\Core\Model\Translate\InlineInterface $block->setAjaxUrl($this->_getAjaxUrl()); - $block->setTemplate('Magento_Core::translate_inline.phtml'); + $block->setTemplate($this->_templateFileName); $html = $block->toHtml(); - $this->_parser->setContent(str_ireplace('</body>', $html . '</body>', $content)); + $this->_parserFactory->get()->setContent(str_ireplace('</body>', $html . '</body>', $content)); $this->_isScriptInserted = true; } @@ -209,17 +223,17 @@ class Inline implements \Magento\Core\Model\Translate\InlineInterface */ protected function _getAjaxUrl() { - $store = $this->_parser->getStoreManager()->getStore(); - return $this->_url->getUrl('core/ajax/translate', array('_secure' => $store->isCurrentlySecure())); + $scope = $this->_scopeResolver->getScope(); + return $this->_url->getUrl($this->_translatorRoute, array('_secure' => $scope->isCurrentlySecure())); } /** * Strip inline translations from text * * @param array|string $body - * @return \Magento\Core\Model\Translate\Inline + * @return $this */ - private function _stripInlineTranslations(&$body) + protected function _stripInlineTranslations(&$body) { if (is_array($body)) { foreach ($body as &$part) { diff --git a/app/code/Magento/Core/Model/Translate/Inline/ConfigFactory.php b/lib/Magento/Translate/Inline/ConfigFactory.php similarity index 78% rename from app/code/Magento/Core/Model/Translate/Inline/ConfigFactory.php rename to lib/Magento/Translate/Inline/ConfigFactory.php index fa85b422eedec75b59492609a9582467c74fe5ba..503f602662a207360d91b6b2cdde1b517f199347 100644 --- a/app/code/Magento/Core/Model/Translate/Inline/ConfigFactory.php +++ b/lib/Magento/Translate/Inline/ConfigFactory.php @@ -1,5 +1,7 @@ <?php /** + * Inline Translation config factory + * * Magento * * NOTICE OF LICENSE @@ -18,17 +20,10 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Magento - * @package Magento_Core * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ - - -/** - * Inline Translation config factory - */ -namespace Magento\Core\Model\Translate\Inline; +namespace Magento\Translate\Inline; class ConfigFactory { @@ -46,12 +41,12 @@ class ConfigFactory } /** - * Create instance of inline translate config + * Get instance of inline translate config * - * @return \Magento\Core\Model\Translate\Inline\ConfigInterface + * @return \Magento\Translate\Inline\ConfigInterface */ - public function create() + public function get() { - return $this->_objectManager->create('Magento\Core\Model\Translate\Inline\Config'); + return $this->_objectManager->get('Magento\Translate\Inline\ConfigInterface'); } } diff --git a/app/code/Magento/Core/Model/Translate/Inline/ConfigInterface.php b/lib/Magento/Translate/Inline/ConfigInterface.php similarity index 78% rename from app/code/Magento/Core/Model/Translate/Inline/ConfigInterface.php rename to lib/Magento/Translate/Inline/ConfigInterface.php index 6739f75066709d4499f9c6d289cd935ac63fff01..8a582b09b5d33be06fb3640c6187e1f4164884c1 100644 --- a/app/code/Magento/Core/Model/Translate/Inline/ConfigInterface.php +++ b/lib/Magento/Translate/Inline/ConfigInterface.php @@ -1,5 +1,7 @@ <?php /** + * Inline Translation config interface + * * Magento * * NOTICE OF LICENSE @@ -18,25 +20,27 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Magento - * @package Magento_Core * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ - - -/** - * Inline Translation config interface - */ -namespace Magento\Core\Model\Translate\Inline; +namespace Magento\Translate\Inline; interface ConfigInterface { /** * Check whether inline translation is enabled * - * @param int|null $store + * @param int|null $scope + * @return bool + */ + public function isActive($scope = null); + + + /** + * Check whether allowed client ip for inline translation + * + * @param mixed $scope * @return bool */ - public function isActive($store = null); + public function isDevAllowed($scope = null); } diff --git a/app/code/Magento/Core/Model/Config/Initial/SchemaLocator.php b/lib/Magento/Translate/Inline/ParserFactory.php similarity index 56% rename from app/code/Magento/Core/Model/Config/Initial/SchemaLocator.php rename to lib/Magento/Translate/Inline/ParserFactory.php index 62344488b133e8048c72ef906437c1cbb0a62cab..22f3cb38db8c6bfcde4cb209c52a319848b16d20 100644 --- a/app/code/Magento/Core/Model/Config/Initial/SchemaLocator.php +++ b/lib/Magento/Translate/Inline/ParserFactory.php @@ -1,6 +1,6 @@ <?php /** - * Logging schema locator + * Parser factory * * Magento * @@ -23,42 +23,42 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Core\Model\Config\Initial; +namespace Magento\Translate\Inline; -class SchemaLocator implements \Magento\Config\SchemaLocatorInterface +class ParserFactory { /** - * Path to corresponding XSD file with validation rules for config + * Object Manager * - * @var string + * @var \Magento\ObjectManager */ - protected $_schema = null; + protected $_objectManager; /** - * @param \Magento\Module\Dir\Reader $moduleReader + * Object constructor + * @param \Magento\ObjectManager $objectManager */ - public function __construct(\Magento\Module\Dir\Reader $moduleReader) + public function __construct(\Magento\ObjectManager $objectManager) { - $this->_schema = $moduleReader->getModuleDir('etc', 'Magento_Core') . '/config.xsd'; + $this->_objectManager = $objectManager; } /** - * Get path to merged config schema + * Return instance of inline translate parser object * - * @return string|null + * @return \Magento\Translate\Inline\ParserInterface */ - public function getSchema() + public function get() { - return $this->_schema; + return $this->_objectManager->get('Magento\Translate\Inline\ParserInterface'); } /** - * Get path to pre file validation schema - * - * @return string|null + * @param array $data + * @return \Magento\Translate\Inline\ParserInterface */ - public function getPerFileSchema() + public function create(array $data = null) { - return $this->_schema; + return $this->_objectManager->create('Magento\Translate\Inline\ParserInterface', $data); } } diff --git a/lib/Magento/Translate/Inline/ParserInterface.php b/lib/Magento/Translate/Inline/ParserInterface.php new file mode 100644 index 0000000000000000000000000000000000000000..564f71f3569c2dbb5c0d3d2f889a42d2edb69296 --- /dev/null +++ b/lib/Magento/Translate/Inline/ParserInterface.php @@ -0,0 +1,70 @@ +<?php +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Translate\Inline; + +interface ParserInterface +{ + /** + * Default state for jason flag + */ + const JSON_FLAG_DEFAULT_STATE = false; + + /** + * Parse and save edited translation + * + * @param array $translateParams + * @return $this + */ + public function processAjaxPost(array $translateParams); + + /** + * Replace html body with translation wrapping. + * + * @param string $body + * @return string + */ + public function processResponseBodyString($body); + + /** + * Returns the body content that is being parsed. + * + * @return string + */ + public function getContent(); + + /** + * Sets the body content that is being parsed passed upon the passed in string. + * + * @param $content string + */ + public function setContent($content); + + /** + * Set flag about parsed content is Json + * + * @param bool $flag + * @return $this + */ + public function setIsJson($flag); +} diff --git a/app/code/Magento/Core/Model/Config/Data/BackendModelPool.php b/lib/Magento/Translate/InlineFactory.php similarity index 59% rename from app/code/Magento/Core/Model/Config/Data/BackendModelPool.php rename to lib/Magento/Translate/InlineFactory.php index fda147d7c0c8482e24260499ffb14c0a8b44b655..37a9e911c0d1cdc5547142cd090077477dde3ba7 100644 --- a/app/code/Magento/Core/Model/Config/Data/BackendModelPool.php +++ b/lib/Magento/Translate/InlineFactory.php @@ -1,6 +1,6 @@ <?php /** - * Configuration value backend model factory + * Inline translation factory * * Magento * @@ -23,21 +23,19 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Core\Model\Config\Data; +namespace Magento\Translate; -class BackendModelPool +class InlineFactory { /** + * Object Manager + * * @var \Magento\ObjectManager */ protected $_objectManager; /** - * @var \Magento\Core\Model\Config\Data\BackendModelInterface[] - */ - protected $_pool; - - /** + * Object constructor * @param \Magento\ObjectManager $objectManager */ public function __construct(\Magento\ObjectManager $objectManager) @@ -46,23 +44,15 @@ class BackendModelPool } /** - * Get backend model instance + * Return instance of inline translate parser object * - * @param string $model - * @return \Magento\Core\Model\Config\Data\BackendModelInterface + * @param array $data * @throws \InvalidArgumentException + * @return \Magento\Translate\InlineInterface */ - public function get($model) + public function get(array $data = null) { - if (!isset($this->_pool[$model])) { - $instance = $this->_objectManager->create($model); - if (!($instance instanceof \Magento\Core\Model\Config\Data\BackendModelInterface)) { - throw new \InvalidArgumentException( - $model . ' does not instance of \Magento\Core\Model\Config\Data\BackendModelInterface' - ); - } - $this->_pool[$model] = $instance; - } - return $this->_pool[$model]; + $model = $this->_objectManager->get('Magento\Translate\InlineInterface', $data); + return $model; } } diff --git a/app/code/Magento/Core/Model/Translate/InlineInterface.php b/lib/Magento/Translate/InlineInterface.php similarity index 81% rename from app/code/Magento/Core/Model/Translate/InlineInterface.php rename to lib/Magento/Translate/InlineInterface.php index cd7caf357232e268540470cc0139aec2c97bde8b..95a82a8a6f7db1fd76f6e5b88e7f80f62cea8171 100644 --- a/app/code/Magento/Core/Model/Translate/InlineInterface.php +++ b/lib/Magento/Translate/InlineInterface.php @@ -1,5 +1,7 @@ <?php /** + * Inline translation interface + * * Magento * * NOTICE OF LICENSE @@ -18,24 +20,18 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Magento - * @package Magento_Core * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ - -/** - * Inline translation interface - */ -namespace Magento\Core\Model\Translate; +namespace Magento\Translate; interface InlineInterface { /** * Returns additional html attribute if needed by client. * - * @param mixed|string $tagName - * @return mixed|string + * @param mixed $tagName + * @return mixed */ public function getAdditionalHtmlAttribute($tagName = null); @@ -50,8 +46,8 @@ interface InlineInterface * Replace translation templates with HTML fragments * * @param array|string $body - * @param mixed|bool $isJson - * @return \Magento\Core\Model\Translate\InlineInterface + * @param bool $isJson + * @return \Magento\Translate\InlineInterface */ - public function processResponseBody(&$body, $isJson); + public function processResponseBody(&$body, $isJson = false); } diff --git a/app/code/Magento/Core/Model/Config/Data/BackendModelInterface.php b/lib/Magento/Translate/ResourceInterface.php similarity index 78% rename from app/code/Magento/Core/Model/Config/Data/BackendModelInterface.php rename to lib/Magento/Translate/ResourceInterface.php index b399de1946d141a8d8b69ab1bf53f7ff7687707e..58e5d645e02f8c42f598a1cb80d5f4487eb73050 100644 --- a/app/code/Magento/Core/Model/Config/Data/BackendModelInterface.php +++ b/lib/Magento/Translate/ResourceInterface.php @@ -1,7 +1,5 @@ <?php /** - * Configuration value backend model interface - * * Magento * * NOTICE OF LICENSE @@ -23,15 +21,17 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Core\Model\Config\Data; -interface BackendModelInterface +namespace Magento\Translate; + +interface ResourceInterface { /** - * Process config value + * Retrieve translation array for store / locale code * - * @param string $value - * @return mixed + * @param int $scope + * @param string $locale + * @return array */ - public function processValue($value); + public function getTranslationArray($scope = null, $locale = null); } diff --git a/lib/Magento/TranslateInterface.php b/lib/Magento/TranslateInterface.php index a548ea4f229cd392aa76003a24203cb8ce4b3250..4c48fbd3c986c355cbb9f789d085d49011747225 100644 --- a/lib/Magento/TranslateInterface.php +++ b/lib/Magento/TranslateInterface.php @@ -31,27 +31,34 @@ namespace Magento; interface TranslateInterface { /** - * Translate + * Default translation string + */ + const DEFAULT_STRING = 'Translate String'; + + /** + * Determine if translation is enabled and allowed. * - * @param array $args - * @return string + * @param mixed $scope + * @return bool */ - public function translate($args); + public function isAllowed($scope = null); /** - * Parse and save edited translate + * Initialization translation data * - * @param array $translate + * @param string $area + * @param \Magento\Object $initParams + * @param bool $forceReload + * @return \Magento\TranslateInterface */ - public function processAjaxPost($translate); + public function init($area = null, $initParams = null, $forceReload = false); /** - * Replace translation templates with HTML fragments + * Retrieve active translate mode * - * @param array|string $body - * @param bool $isJson + * @return bool */ - public function processResponseBody(&$body, $isJson = false); + public function getTranslateInline(); /** * Set Translate inline mode @@ -60,4 +67,20 @@ interface TranslateInterface * @return \Magento\TranslateInterface */ public function setTranslateInline($flag); + + /** + * Set locale + * + * @param $locale + * @return \Magento\TranslateInterface + */ + public function setLocale($locale); + + /** + * Translate + * + * @param array $args + * @return string + */ + public function translate($args); } diff --git a/lib/Magento/Url/ScopeInterface.php b/lib/Magento/Url/ScopeInterface.php index db23cf136dd1adba89ec6053a5d223bb74e2688c..5f0a556c543ce13b4911f9421a227155f326922b 100644 --- a/lib/Magento/Url/ScopeInterface.php +++ b/lib/Magento/Url/ScopeInterface.php @@ -24,7 +24,7 @@ namespace Magento\Url; -interface ScopeInterface +interface ScopeInterface extends \Magento\BaseScopeInterface { /** * Retrieve base URL @@ -35,13 +35,6 @@ interface ScopeInterface */ public function getBaseUrl($type = '', $secure = null); - /** - * Retrieve scope code - * - * @return string - */ - public function getCode(); - /** * Retrieve scope configuration data * diff --git a/lib/Magento/Url/ScopeResolverInterface.php b/lib/Magento/Url/ScopeResolverInterface.php index 7bce54e3139f9c9b0cccb7c03746d820e9c3ffb5..b322418e1ba3721ffbfac8557da14e41cca3ad13 100644 --- a/lib/Magento/Url/ScopeResolverInterface.php +++ b/lib/Magento/Url/ScopeResolverInterface.php @@ -24,17 +24,8 @@ namespace Magento\Url; -interface ScopeResolverInterface +interface ScopeResolverInterface extends \Magento\BaseScopeResolverInterface { - - /** - * Retrieve application scope object - * - * @param null|int $scopeId - * @return \Magento\Url\ScopeInterface - */ - public function getScope($scopeId = null); - /** * Retrieve scopes array * diff --git a/lib/Magento/View/Design/ThemeInterface.php b/lib/Magento/View/Design/ThemeInterface.php index 629a5b2661d6977f34d208c6559e7ecf2d0c78cc..66b7074a5c2de49dfa7f88ac557d9e8dacce1024 100644 --- a/lib/Magento/View/Design/ThemeInterface.php +++ b/lib/Magento/View/Design/ThemeInterface.php @@ -102,4 +102,11 @@ interface ThemeInterface * @return ThemeInterface[] Format: array([<root_theme>, ..., <parent_theme>,] <current_theme>) */ public function getInheritedThemes(); + + /** + * Get theme id + * + * @return int + */ + public function getId(); } diff --git a/pub/lib/mage/gallery-fullscreen.js b/pub/lib/mage/gallery-fullscreen.js new file mode 100644 index 0000000000000000000000000000000000000000..4599c0f1835971169159c940f5461c93482d4ecd --- /dev/null +++ b/pub/lib/mage/gallery-fullscreen.js @@ -0,0 +1,74 @@ +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ + +(function($) { + "use strict"; + /** + * An auxiliary widget + * Wraps gallery into dialog widget and opens the dialog in fullscreen mode + */ + $.widget('mage.galleryFullScreen', { + options: { + selectors: { + trigger: '[data-role=zoom-image], [data-role=zoom-track]' + }, + fullscreenClass: 'magento-zoom-enlarged lightbox' + }, + + /** + * Widget constructor + * @protected + */ + _create: function() { + this._bind(); + }, + + /** + * Bind full screen handler + * @protected + */ + _bind: function() { + var events = {}; + events['click ' + this.options.selectors.trigger] = '_fullScreen'; + this._on(events); + }, + + /** + * Open gallery in dialog + * @param {Object} e - event object + */ + _fullScreen: function() { + this.element + .gallery('option', {showNotice: false, fullSizeMode: true, showButtons: true}) + .dialog({ + resizable: false, + dialogClass: this.options.fullscreenClass, + close: $.proxy(function() { + this.element + .gallery('option', {showNotice: true, fullSizeMode: false, showButtons: false}) + .dialog('destroy').show(); + }, this) + }); + } + }); +})(jQuery); \ No newline at end of file diff --git a/pub/lib/mage/gallery.js b/pub/lib/mage/gallery.js new file mode 100644 index 0000000000000000000000000000000000000000..069b5e62ae247788ced3e7515f996bb806c6eb95 --- /dev/null +++ b/pub/lib/mage/gallery.js @@ -0,0 +1,348 @@ +/** + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/afl-3.0.php + * If you did not receive a copy of the license and are unable to + * obtain it through the world-wide-web, please send an email + * to license@magentocommerce.com so we can send you a copy immediately. + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade Magento to newer + * versions in the future. If you wish to customize Magento for your + * needs please refer to http://www.magentocommerce.com for more information. + * + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ + +/** + @version 0.1.1 + @requires jQuery + + @TODO: - Add more effects; + */ + +(function($){ + "use strict"; + $.widget('mage.gallery', { + options: { + images: null, + sizes: { + small: { + width: 90, + height: 90 + }, + medium: { + width: 400, + height: 400 + } + }, + showThumbs: true, + showButtons: true, + showNotice: true, + activeClass: 'active', + controls: { + thumbs: { + container: '[data-role=gallery-thumbs-container]', + template: '[data-template=gallery-thumbs]' + }, + slideButtons: { + container: '[data-role=gallery-buttons-container]', + template: '[data-template=gallery-buttons]' + }, + baseImage: { + container: '[data-role=gallery-base-image-container]', + template: '[data-template=gallery-base-image]' + }, + notice: { + container: '[data-role=gallery-notice-container]', + template: '[data-template=notice]', + text: null + } + }, + wrapperTemplate: '[data-template=gallery-wrapper]', + selectors: { + thumb: '[data-role=gallery-thumb]', + prev: '[data-role=gallery-prev]', + next: '[data-role=gallery-next]', + notice: '[data-role=gallery-notice]' + }, + fullSizeMode: false + }, + + /** + * Widget constructor + * @protected + */ + _create: function() { + if (!this.options.images) { + this.options.images = this._serializeImages(); + } + this.element.empty(); + this.element.append(this._renderWrapper()); + this._render(); + this._bind(); + }, + + /** + * Serialize images from HTML + * @return {Array} + * @protected + */ + _serializeImages: function() { + var images = []; + $(this.options.selectors.thumb).each(function() { + var thumb = $(this); + var imageData = { + small: thumb.data('image-small'), + medium: thumb.data('image-medium'), + large: thumb.data('image-large') + + }; + if (imageData.small && imageData.medium && imageData.large) { + if (thumb.data('image-selected')) { + imageData.selected = thumb.data('image-selected'); + } + images.push(imageData); + } + }); + return images; + }, + + /** + * Bind widget event handlers + * @protected + */ + _bind: function() { + /* All events delegated to this.element, which means that thumbs and slide controls can be changed any time + * and not required to re-bind events + */ + var events = {}; + events['click ' + this.options.selectors.thumb] = 'select'; + events['click ' + this.options.selectors.prev] = 'prev'; + events['click ' + this.options.selectors.next] = 'next'; + this._on(events); + }, + + /** + * Disable/enable gallery control (thumbs, slide buttons) + * @param {string} control - control name + * @param {boolean} enable + * @protected + */ + _toggleControl: function(control, enable) { + if (enable) { + if (!this[control]) { + this._initControl(control); + } else { + this[control].show(); + } + + } else if (this[control]) { + this[control].hide(); + } + }, + + /** + * Override jQuery widget factory method, to provide possibility disabling/enabling gallery controls + * via changing of widget options + * @override + */ + _setOption: function (key, value) { + var previousValue = this.options[key]; + this._superApply(arguments); + if (value !== previousValue) { + switch(key) { + case 'showThumbs': + this._toggleControl('thumbs', value); + break; + case 'showButtons': + this._toggleControl('slideButtons', value); + break; + case 'showNotice' : + this._toggleControl('notice', value); + break; + case 'fullSizeMode': + this._initControl('baseImage'); + $(this.baseImage).trigger('imageupdated'); + break; + case 'images' : + this._render(); + break; + } + } + }, + + /** + * Trigger 'imageupdated' event after image is changed + * @param {Object} e - event object + */ + select: function(e) { + var index = $(e.currentTarget).data('index'); + if (index !== this._getSelected()) { + this._select(index); + $(this.baseImage).trigger('imageupdated'); + } + }, + + /** + * Select gallery image + * @param {number} index - image index + * @protected + */ + _select: function(index) { + this._setSelected(index); + this._initControl('baseImage'); + this.thumbs.find(this.options.selectors.thumb) + .removeClass(this.options.activeClass) + .eq(index).addClass(this.options.activeClass); + }, + + /** + * @param {number} index - index of next image + * @return {number} resolved index + * @protected + */ + _resolveIndex: function(index) { + var imagesLength = this.options.images.length; + if (index >= imagesLength) { + return 0; + } else if (index < 0) { + return imagesLength -1; + } + return index; + }, + + /** + * Select previous image + */ + prev: function() { + this._select(this._resolveIndex(this._getSelected() - 1)); + }, + + /** + * Select next image + */ + next: function() { + this._select(this._resolveIndex(this._getSelected() + 1)); + }, + + /** + * Render gallery + * @protected + */ + _render: function() { + if (!this._findSelected()) { + this.selected = 0; + } + if (this.options.showNotice) { + this._initControl('notice'); + } + this._initControl('baseImage'); + this.baseImage.trigger('imageupdated'); + if (this.options.showThumbs) { + this._initControl('thumbs'); + } + if (this.options.showButtons) { + this._initControl('slideButtons'); + } + }, + + /** + * Set selected image index + * @param {number} index - image index + * @protected + */ + _setSelected: function(index) { + this.selected = index; + }, + + /** + * Get selected image index + * @return {number} + * @protected + */ + _getSelected: function() { + if (this.selected === null || typeof this.selected === 'undefined') { + this.selected = this._findSelected(); + } + return this.selected; + }, + + /** + * Find selected image in this.options.images + * @return {number} - selected image index + * @protected + */ + _findSelected: function() { + var mapped = $.map(this.options.images, function(image, index) { + return image.selected ? index : null; + }); + return mapped[0]; + }, + + /** + * Render placeholders for gallery controls + * @return {Element} DOM-element + * @protected + */ + _renderWrapper: function() { + return $.tmpl($(this.options.wrapperTemplate), {}); + }, + + /** + * Render gallery control (base image, thumbs, slide buttons, etc.) + * @param {string} control - name of the control + * @return {Element} DOM-element + * @protected + */ + _renderControl: function(control) { + var options = this.options, + templateData; + switch(control) { + case 'baseImage': + templateData = $.extend( + {notice: options.notice, fullSizeMode: this.options.fullSizeMode}, + options.images[this._getSelected()], + options.sizes.medium + ); + break; + case 'thumbs': + templateData = {images: this.options.images, size: this.options.sizes.small}; + break; + case 'slideButtons': + templateData = {}; + break; + case 'notice': + templateData = {text: this.options.controls.notice.text || ''}; + break; + } + if (this[control]) { + this[control].remove(); + } + this[control] = $.tmpl($(options.controls[control].template), templateData); + this._on(this[control].find('a').add(this[control]), { + click: function(e){ + e.preventDefault(); + } + }); + return this[control]; + }, + + /** + * Append rendered control to this.element + * @param {string} control - control name + * @protected + */ + _initControl: function(control) { + this.element.find(this.options.controls[control].container) + .prepend(this._renderControl(control)); + } + }); +})(jQuery); \ No newline at end of file diff --git a/pub/lib/mage/loader.js b/pub/lib/mage/loader.js index 0cbf70684fdc20c1a569ac4b1a6ba41e80224dd3..3bea4dea8a537586505a0820b1524f95aaaafee3 100644 --- a/pub/lib/mage/loader.js +++ b/pub/lib/mage/loader.js @@ -17,8 +17,6 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category mage - * @package mage * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */ @@ -72,17 +70,26 @@ * @param event * @private */ - _contentUpdated: function(event) { - this.show(); + _contentUpdated: function(e) { + this.show(e); }, /** * Show loader */ - show: function() { + show: function(e, ctx) { this._render(); this.loaderStarted++; this.spinner.show(); + if (ctx) { + this.spinner + .css({width: ctx.outerWidth(), height: ctx.outerHeight(), position: 'absolute'}) + .position({ + my: 'top left', + at: 'top left', + of: ctx + }); + } return false; }, @@ -110,23 +117,6 @@ this.element.prepend(this.spinner); }, - /** - * Prepare object with css properties for loader - * @protected - */ - _getCssObj: function() { - var isBodyElement = this.element.is('[data-container=body]'), - width = isBodyElement ? $(window).width() : this.element.outerWidth(), - height = isBodyElement ? $(window).height() : this.element.outerHeight(), - position = isBodyElement ? 'fixed' : 'relative'; - return { - height: height + 'px', - width: width + 'px', - position: position, - 'margin-bottom': '-' + height + 'px' - }; - }, - /** * Destroy loader */ diff --git a/pub/lib/mage/zoom.js b/pub/lib/mage/zoom.js index 3808a74f2f1b0b9b94e4d64e97756d8bf6e09651..a40105cdb87625aa522db145b8f2faec1ef25b92 100644 --- a/pub/lib/mage/zoom.js +++ b/pub/lib/mage/zoom.js @@ -17,1233 +17,447 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * - * @category Mage - * @package js * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */ -/** - @version 0.1.1 - @requires jQuery - - @TODO: - Add more effects; - - Add more documentation over file for other developers; - */ -;(function($, document, window, undefined){ -"use strict"; - - /** - @static - @private - @see jQuery.magentoZoom#defaults for default values - @description Represents variables of magentoZoom plugin with different configurations - @default {@see data} - @field [pageX, pageY, timer, state] used for plugin internal use - */ -var data = { pageX:0, pageY:0, timer:0, loading: false, currentItem:-1, switchDirection:null }, - - /** - @private - @description Utilities for plugin use - */ - utils = { - - /** - @event - @description Binds keyup event for document on gallery opening - - @TODO: custom event handler ? - */ - bindDocumentEvents: function(){ - $(document).bind('keyup', function(event){ - var code = event.keyCode || event.which; - - event.preventDefault(); - event.stopPropagation(); - - switch(code){ - case 40: // Down arrow - case 37: // left arrow - if(!data.main.isSingleInCollection){ - method.galleryPrev(); - } - break; - case 32: // Space - case 38: // Up arrow - case 39: // Right arrow - if(!data.main.isSingleInCollection){ - method.galleryNext(); - } - break; - case 27: // Escape - method.hideGallery(); - break; +(function($) { + "use strict"; + $.widget('mage.zoom', { + options: { + largeImage: null, + startZoomEvent: 'click', + stopZoomEvent: 'mouseleave', + hideDelay: '100', + effects: { + show: {effect: "fade", duration: 100}, + hide: {effect: "fade", duration: 100} + }, + controls:{ + lens: { + template: '[data-template=zoom-lens]', + opacity: 0.7, + background: '#ffffff' + }, + track: { + template: '[data-template=zoom-track]' + }, + display: { + template: '[data-template=zoom-display]', + width: 400, + height: 400 + }, + notice: { + template: '[data-template=notice]', + text: null, + container: '[data-role=gallery-notice-container]' } - }); + }, + selectors: { + image: '[data-role=zoom-image]', + imageContainer: '[data-role=gallery-base-image-container]', + zoomInner: '[data-role=zoom-inner]', + track: '[data-role=zoom-track]', + notice: '[data-role=notice]' + } }, + noticeOriginal: '', /** - @description Unbinds keyup event for document on gallery close + * Widget constructor + * @protected */ - unBindDocumentEvents: function(){ - $(document).unbind('keyup'); + _create: function() { + this._setZoomData(); + this._render(); + this._bind(); + if(this.largeImage[0].complete) { + this._largeImageLoaded(); + } + this._hide(this.display); + this._hide(this.track); }, /** - @description Recalculate sizes and setData() for necessary objects - @param {jQuery} image Zoomed image - [@param {Object -> Function} callback After setup recalculation after: {@borrows img as this}, - @returns {jQuery} img + * Render zoom controls + * @protected */ - recalculateSize: function(sImg, lImg, callback){ - var settings = data.settings, - h = lImg.outerHeight(), - w = lImg.outerWidth(), - ratio = ( ( w >= h ) ? ( w / sImg.outerWidth() ) : ( h / sImg.outerHeight() ) ), - isLarger = (ratio > 1), - trackW = utils.ceil(w / ratio), - trackH = utils.ceil(h / ratio), - ieMT = ((data.main.wrapper.height() - trackH) / 2) >> 0, - ieML = ((data.main.wrapper.width() - trackW) / 2) >> 0, - moveOnX = (w > settings.enlarged.width), - moveOnY = (h > settings.enlarged.height), - wrapperWidth = (w > settings.enlarged.width) ? settings.enlarged.width : w, - wrapperHeight = (h > settings.enlarged.height) ? settings.enlarged.height : h, - lW = moveOnX ? utils.ceil((trackW / w) * settings.enlarged.width) : trackW, - lH = moveOnY ? utils.ceil((trackH / h) * settings.enlarged.height) : trackH, - track = data.main.track, - opacity = ((settings.lens.mode === 'standart') ? settings.lens.opacity : 1 ); - - track.unbind(); - utils.switchNotice(settings.messages.noticeDefault); - utils.switchNotice('show'); - - data.enlarged.wrapper.css({ - width: wrapperWidth, - height: wrapperHeight - }); - - track.css({ - width: trackW, - height: trackH - }); - - if($.browser.msie && $.browser.version == 7){ - track.css({ - 'margin-top': ieMT, - 'margin-left': ieML - }); - } - - if(isLarger){ - - if(settings.useLens && isLarger){ - data.lens.magnifier.css({ - width: lW, - height: lH, - opacity: opacity - }).hide(); - } - - method.attachTrackEvents.call(track); - - - } else if(settings.useGallery && (!data.main.image.hasClass('isPlaceholder'))) { - track.bind('click', method.showGallery); - } - - if(settings.useGallery && !isLarger){ - if(data.main.image.hasClass('isPlaceholder')){ - utils.switchNotice('hide'); - } else { - utils.switchNotice(settings.messages.noticeLightBox); - } - } else { - if(!isLarger){ - utils.switchNotice('hide'); - } - } - - if((!isLarger && !settings.useGallery) || data.main.image.hasClass('isPlaceholder')) { - track.addClass('non-active'); - } else { - track.removeClass('non-active'); - } - - utils.setData({ - enlarged: { - image: lImg, - width: w, - height: h, - ratio: ratio, - isLarger: isLarger - }, - lens: { - width: lW, - height: lH, - moveOnX: moveOnX, - moveOnY: moveOnY - }, - main: { - trackWidth: trackW - } - }); - - if(callback && $.isFunction(callback.after)) { callback.after.call(lImg); } + _render: function() { + this.element.append(this._renderControl('track').append(this._renderControl('lens'))); + this.element.append(this._renderControl('display')) + .find(this.options.selectors.zoomInner) + .append(this._renderLargeImage()); + var noticeContainer = this.element.find(this.options.controls.notice.container); + noticeContainer = noticeContainer.length ? + noticeContainer : + this.element; + noticeContainer.append(this._renderControl('notice')); }, /** - @description recalculates sizes of lightbox each time when image switches - - @TODO: Refactor ! + * Toggle zoom notice + * @protected */ - reCalculateGallerySize: function(){ - var mt, wH, wW, vCorrection, - gallery = data.gallery, - wrapper = gallery.gallery, - thumbs = gallery.thumbsContainer, - thumbsH = thumbs.is(':visible') ? thumbs.outerHeight(true) : 0, - img = data.enlarged.image, - vp = { w: $(window).width(), h: $(window).height() }; - - /** Cleanup all CSSs */ - wrapper.css({ - width:'', - height:'', - maxHeight: '', - marginTop:'', - marginLeft:'' - }); - img.css({ - width:'', - height:'' - }); - /** --------------- */ - - // if(wrapper.width() > vp.w){ - // wW = vp.w - (wrapper.innerWidth() - wrapper.width()); - // } - - $(img).parent().css({ - bottom: thumbsH + 15 - }); - -/* if(wrapper.height() > vp.h) { - wH = vp.h - ( wrapper.outerHeight() - wrapper.height()); + _toggleNotice: function() { + this.noticeOriginal = (this.notice.text() !== this.options.controls.notice.text ? + this.notice.text() : + this.noticeOriginal); + if (this.getZoomRatio() > 1 && this.largeImageSrc && !this.activated) { + this.notice.text(this.options.controls.notice.text); } else { - wH = wrapper.outerHeight(); + this.notice.text(this.noticeOriginal); } - - wrapper.css({ - width: wW, - maxHeight: wH, - marginTop: mt - }); - - img.css({ - // maxWidth: wrapper.width(), - maxHeight: wrapper.height() - thumbsH - }); - - vCorrection = img.height() + thumbsH; - - if(vCorrection < wrapper.height()) { - wrapper.height(vCorrection); - } - - - wrapper.css({ - marginLeft: utils.ceil((vp.w - wrapper.width()) / 2) - });*/ - }, /** - @param {jQuery} taget Target image in DOM - @param {String} link Link to new image - [@param {Object -> Function} callback Before and After setup switching - before: {@borrows newImg as this}, - after: {@borrows newImg as this}] - @description Replaces old image with new one using {@see {@param link}} - - @TODO Optimize for reusable base wrapper for callbacks (eg. utils.BaseCallbackCall) - {@see <a href="http://css-tricks.com/custom-events-are-pretty-cool/">Custom events vs Callbacks</a>} + * Render zoom control + * @param {string} control - name of the control + * @return {Element} DOM-element + * @protected */ - switchImage: function(target, link, callback){ - /** @TODO: Need new fix */ - var suffix = ($.browser.msie) ? ("?" + new Date().getTime()):'', - img = $('<img>', { src: link + suffix }); /** will increase CDN hit ratio! {@TODO: try use '#' instead } */ - - if(callback && $.isFunction(callback.before)) { callback.before.call(img); } - - img.load(function(){ - target.replaceWith(img); - - if(callback && $.isFunction(callback.after)) { callback.after.call(img); } - }); - + _renderControl: function(control) { + var controlData = this.options.controls[control], + templateData = {}, + css = {}; + switch(control) { + case 'display': + templateData = {img: this.largeImageSrc}; + css = { + width: controlData.width, + height: controlData.height + }; + break; + case 'notice': + templateData = {text: controlData.text || ''}; + break; + } + var controlElement = this.element.find(this.options.selectors[control]); + controlElement = controlElement.length ? + controlElement : + $.tmpl($(controlData.template), templateData); + this[control] = controlElement.css(css); + return this[control]; }, /** - @event - @param {Function} callback Callback function - @description Prevent default event behavior with callback - ONLY incase if there is no any loading progress animation + * Refresh zoom controls + * @protected */ - click: function(callback){ - this.click(function(event){ - event.preventDefault(); - event.stopPropagation(); - - if(callback && $.isFunction(callback) && !data.loading){ - callback.call(this); - } - }); + _refresh: function() { + this._refreshControl('display'); + this._refreshControl('track'); + this._refreshControl('lens'); }, /** - @param {String} changeTo Config specific string - {incase if changeTo === "hide" notice will hide} - [@param {Object -> Function} callback Before and After setup switching - before: {@borrows target as this}, - after: {@borrows target as this}] - - @TODO Optimize for reusable base wrapper for callbacks (eg. utils.BaseCallbackCall) - {@see <a href="http://css-tricks.com/custom-events-are-pretty-cool/">Custom events vs Callbacks</a>} + * Refresh zoom control position and css + * @param {string} control - name of the control + * @protected */ - switchNotice: function(changeTo, callback){ - var target = data.main.notice; - - if(callback && $.isFunction(callback.before)) { callback.before.call(target); } - - if(changeTo === 'hide'){ - target.css('visibility', 'hidden'); /** dont use $.hide() cuz it will hide element and shift other */ - } else if(changeTo === 'show') { - target.css('visibility', 'visible'); - } else { - target - .text(changeTo) - .css('visibility', 'visible'); /** Incase if it was hidden */ + _refreshControl: function(control) { + var controlData = this.options.controls[control], + position, + css = {position: 'absolute'}; + switch(control) { + case 'display': + position = { + my: 'left+30% top', + at: 'left+' + $(this.image).outerWidth() + ' top', + of: $(this.image) + }; + break; + case 'track': + $.extend(css, { + height: $(this.image).height(), + width: $(this.image).width() + }); + position = { + my: 'left top', + at: 'left top', + of: $(this.image) + }; + break; + case 'lens': + $.extend(css, this._calculateLensSize(), { + background: controlData.background, + opacity: controlData.opacity, + left: 0, + top: 0 + }); + break; + } + this[control].css(css); + if (position) { + this[control].position(position); } - - if(callback && $.isFunction(callback.after)) { callback.after.call(target); } }, /** - @param {jQeury} target Target to dom element that should be replaced by new Image - {@TODO in future flash/video/svg?} - @param {String} link Target lo link that should be fetched - {@TODO: in future parse string or replace with jQuery||SWFObject object} - [@param {Object -> Function} callback Before and After setup switching - before: {@borrows target as this}, - after: {@borrows newImg as this}] - @returns {jQeury} newImg - - @TODO Optimize for reusable base wrapper for callbacks (eg. utils.BaseCallbackCall) - {@see <a href="http://css-tricks.com/custom-events-are-pretty-cool/">Custom events vs Callbacks</a>} + * Bind zoom event handlers + * @protected */ - replaceZoom: function(target, link, callback){ - var newImg = $('<img>', { src: link }); - - if(callback && $.isFunction(callback.before)) { callback.before.call(target); } - - newImg.load(function(){ - target.replaceWith(newImg); - if(callback && $.isFunction(callback.after)) { callback.after.call(newImg); } + _bind: function() { + /* Events delegated to this.element, which means that all zoom controls can be changed any time + * and not required to re-bind events + */ + var events = {}; + events[this.options.startZoomEvent + ' ' + this.options.selectors.image] = 'show'; + events[this.options.stopZoomEvent + ' ' + this.options.selectors.track] = function() { + this._delay(this.hide, this.options.hideDelay || 0); + }; + events['mousemove ' + this.options.selectors.track] = '_move'; + events.imageupdated = '_onImageUpdated'; + this._on(events); + this._on(this.largeImage, { + load: '_largeImageLoaded' }); - - return newImg; }, /** - @param {String|jQuery} target Wrapper where loading wrapper should be appended to - [@param {Object -> Function} callback Before and After setup loading {@borrows target as this}] - @returns {jQeury} Loading container - - @TODO Optimize for reusable base wrapper for callbacks (eg. utils.BaseCallbackCall) - {@see <a href="http://css-tricks.com/custom-events-are-pretty-cool/">Custom events vs Callbacks</a>} + * Store initial zoom data + * @protected */ - setLoading: function(target, callback){ - var settings = data.settings, - prefix = settings.main.prefix, - inner = $('<div>', { id: prefix + "-text" }).text(settings.messages.loadingMessage), - cont = $('<div>', { id: prefix + "-loading" }).append(inner); - - /** If loading in progress none of proccesses should be enabled */ - utils.setData({ loading: true }); - - /** @see Script.aculo.us Effect.Base */ - if(callback && $.isFunction(callback.before)) { callback.before.call(target); } - target.append(cont); - if(callback && $.isFunction(callback.after)) { callback.after.call(target); } - - return cont; + _setZoomData: function() { + this.image = this.element.find(this.options.selectors.image); + this.largeImageSrc = this.options.largeImage || + this.element.find(this.image).data('large'); }, /** - @description Removes loading progress overlay - [@param {Object} Before and After setup loading {@borrows target as this} {@description before event fires before loading flag unset}] - - @TODO Optimize for reusable base wrapper for callbacks (eg. utils.BaseCallbackCall) - {@see <a href="http://css-tricks.com/custom-events-are-pretty-cool/">Custom events vs Callbacks</a>} + * Update zoom when called enable method + * @override */ - unsetLoading: function(callback){ - var vars = data, - settings = vars.settings, - timeout = settings.main.loadingFadeTimeout || 500; - - if(vars.loading){ - - /** @see Script.aculo.us Effect.Base */ - if(callback && $.isFunction(callback.before)) { callback.before(); } - - $('#' + settings.main.prefix + '-loading') - .fadeOut(timeout, function(){ - $(this).remove(); - /** Unset only after "before" event and remove() itself */ - utils.setData({ loading: false }); - - if(callback && $.isFunction(callback.after)) { callback.after(); } - }); - } - return false; + enable: function() { + this._super(); + this._onImageUpdated(); }, /** - @param {Object} obj - @see jQuery.extend() <a href="http://api.jquery.com/jQuery.extend/">jQuery#extend</a> - @description prior jQuery's $.data method for internal plugin variables - @returns {Object} Returns object of plugin hash (key:value pairs) values - - @TODO Optimize to function(Arg1, Arg2, ..., ArgN){...} OR function({ 'key': Arg1, ..., 'keyN': ArgN }){...} + * Toggle notice when called disable method + * @override */ - setData: function(obj){ - data = $.extend(true, {}, data, obj); /** Deep extending {@see <a href="http://api.jquery.com/jQuery.extend/">jQuery#extend</a>} */ - return data; + disable: function() { + this.notice.text(this.noticeOriginal || ''); + this._super(); }, /** - Because it is faster than Math.ceil(n) - @see <a href="http://jsperf.com/math-ceil-vs-bitwise">Math.ceil vs Bitwise</a> + * Show zoom controls + * @param {Object} e - event object */ - ceil: function(n){ - var f = (n << 0); - return f === n ? f : f + 1; - } - - }, - - /** - @private - @description Internal plugin methods - */ - method = { - /** - @constructor - @borrows jQuery.magentoZoom[collection] as this - @param {Object} options Set of custom options - @returns {jQuery} this - */ - init: function(options){ - var settings = $.extend(true, {}, $.fn.magentoZoom.defaults, options), - isSingleInCollection = (this.length === 1 && this.is(settings.main.selector)) || - (this.length === 2 && this[0].href === this[1].href); - - /** Are main image excluded from thumbnails list: - 1. if set through admin - it should return true - 2. if it is placeholder image - it should return false */ - - /** @TODO: parametrize placeholder image */ - var equalsInCollection = this.filter('a[href="' + this.filter(settings.main.selector).attr('href') + '"]'), - isExcluded = (equalsInCollection.length === 1 && - equalsInCollection.attr('href').indexOf('/images/catalog/product/placeholder/') === -1); - - /** Determine current position of item in thumbnails if it is NOT excluded from thumbnails list */ - var index = (!isExcluded) ? this.not(settings.main.selector) - .index(equalsInCollection.not(settings.main.selector)) : -1; - - utils.setData({ settings: settings, main: { - thumbs: this.not(settings.main.selector), - isExcluded: isExcluded, - isSingleInCollection: isSingleInCollection - }, - currentItem: index }); - - /** @TODO: refactor */ - if(!isExcluded){ - equalsInCollection.not(settings.main.selector).addClass('active'); - } - - /** Itterate through collection */ - return this.each(function(){ - var $this = $(this); - - /** Is it a main image? */ - if($this.is(settings.main.selector)) { - - method.drawContainers.call($this); - method.firstLoad.call($this); - - utils.click.call($this); - - /** Otherwise manipulate on thumbnails */ - } else { - /** There are shouldn't be an execution if there is: - 1. Only one image and it is main image; - 2. If there is two images and both of them HREFs are equal - AND preventDefault() set to collection to override native behaviour - */ - if( isSingleInCollection ) { - utils.click.call($this); - } else if(!data.settings.isOldMode) { - utils.click.call($this, function(){ - if($this.hasClass('active')) { - if(settings.useGallery){ - method.showGallery(); - } - } else { - method.thumbnailChange.call(this, data.main.wrapper); - } - }); - } - } - - }); - }, - - /** - @borrows vars.main.thumbs as this - @param {jQuery} container Container for embedding loading progress animation - */ - thumbnailChange: function(container, isGallery){ - var $this = $(this), - isExcluded = data.main.isExcluded, - index = (isGallery) ? data.gallery.thumbs.index($this) : data.main.thumbs.index($this), - correspondingItem = (data.settings.useGallery) ? - $((isGallery) ? data.main.thumbs.get(index) : data.gallery.thumbs.get(index)) : undefined, - small = { - link: $this.attr('rel'), - image: data.main.image.find('img') - }, - large = { - link: $this.attr('href'), - image: data.enlarged.image - }, - thumb = { - link: data.main.image.attr('rel'), - image: $this.find('img') - }; - - if(!data.loading){ - /** Because every image loaded async */ - utils.setData({ loading : true }); - - /** Assume that Large image is largest */ - /** @TODO: Parametrize active class */ - utils.switchImage(large.image, large.link, { - before: function(){ - utils.setLoading(container); - /** Assume that only one placeholder can be in whole gallery */ - if(data.main.image.hasClass('isPlaceholder')){ - data.main.image.removeClass('isPlaceholder'); - } - - utils.switchImage(small.image, small.link, { - after: function(){ - if(isExcluded){ - utils.switchImage(thumb.image, thumb.link , { - after: function(){ - - $this.attr({ - rel: small.image.attr('src'), - href: large.image.attr('src') - }); - data.main.image.attr('rel', thumb.image.attr('src')); - - /** Thumbnails should be changed in gallery too */ - if(correspondingItem){ - utils.switchImage(correspondingItem.find('img'), thumb.link, { - after: function(){ - correspondingItem.attr({ - rel: small.image.attr('src'), - href: large.image.attr('src') - }); - } - }); - - } - - } - }); - } else { - /** - @TODO: parametrize active class - */ - data.main.thumbs.removeClass('active'); - if(data.settings.useGallery){ - data.gallery.thumbs.removeClass('active'); - } - - $this.addClass('active'); - if(data.settings.useGallery){ - correspondingItem.addClass('active'); - } - } - } - }); - }, - after: function(){ - data.enlarged.wrapper.show(); - utils.recalculateSize(data.main.image, this, { - after: function(){ - if(!isGallery){ - data.enlarged.wrapper.hide(); - } else { - utils.reCalculateGallerySize(); - } - if(data.loading){ - if(!isExcluded) { - utils.setData({ currentItem: index }); - } - utils.unsetLoading(); - } - } - }); - } + show: function(e) { + e.preventDefault(); + if (this.getZoomRatio() > 1 && this.largeImageSrc) { + e.stopImmediatePropagation(); + this.activated = true; + this._show(this.display, this.options.effects.show); + this._show(this.track, this.options.effects.show); + this._refresh(); + this.lens.position({ + my: 'center', + at: 'center', + of: e, + using: $.proxy(this._refreshZoom, this) }); + this._toggleNotice(); + this._trigger('show'); } }, /** - @description Draw containers for unobtrusive purposes - @borrows jQuery(settings.main.selector) as this + * Hide zoom controls */ - drawContainers: function(){ - var wrapper, track, notice, zoom, lens, - body = $(document.body), - settings = data.settings, - prefix = settings.main.prefix; - - this.wrap($('<div>', { id: prefix + '-wrapper' })) - .after($('<div>', { id: prefix + '-track' })); - - body.append($('<div>', { "class": prefix + '-enlarged' })); - - track = $('#' + prefix + '-track'); - wrapper = $('#' + prefix + '-wrapper'); - notice = wrapper.parent().children('.notice'); - zoom = $('.' + prefix + '-enlarged'); - - track.append($('<div>', { id: prefix + '-lens' })); - lens = $('#' + prefix + '-lens'); - - if($.browser.msie) { - track.css('background', 'url(".")'); - zoom.css('background', 'url(".")'); - } - - utils.setData({ - main: { - image: this, - track: track, - wrapper: wrapper, - notice: notice - }, - enlarged: { - wrapper: zoom - }, - lens: { - magnifier: lens - } - }); + hide: function() { + this.activated = false; + this._hide(this.display, this.options.effects.hide); + this._hide(this.track, this.options.effects.hide); + this._toggleNotice(); + this._trigger('hide'); }, /** - @description Loads an image from jQuery(settings.main.selector).attr('href') - & onLoad event append it to zoom container - @borrows jQuery(settings.main.selector) as this + * Refresh zoom when image is updated + * @protected */ - firstLoad: function(){ - var lImg, - sImg = this, - container = data.enlarged.wrapper, - track = data.main.track, - settings = data.settings; - - utils.setLoading(track); - - lImg = $('<img>', { src: this.attr('href') }); - - lImg.bind({ - /** - @event - */ - load: function(){ - //following line failed jslint - //var w,h,ieH,ieW,ieMT,ieML,isLarger; - - container.append(lImg); - utils.recalculateSize(sImg, lImg, { - after: function(){ - if(data.loading){ - container.hide(); - if(settings.useGallery){ - method.prepareGallery.call(this); - } - utils.unsetLoading(); - } - } - }); - }, - - /** - @event - */ - error: function(){ - throw new Error(settings.messages.loadError); + _onImageUpdated: function() { + if (!this.image.is($(this.options.selectors.image))) { + this._setZoomData(); + if (this.largeImageSrc) { + this._refreshLargeImage(); + this._refresh(); + } else { + this.hide(); } - }); - }, - - /** - @description Attach events (according to configuration) to track element - @borrows data.main.track as this - */ - attachTrackEvents: function(){ - var settings = data.settings; - - switch(settings.enlarged.action){ - case 'over': - this.bind('mouseenter', method.showZoom); - break; - case 'click': - this.bind('click', method.showZoom); - break; } - - this.bind({ - mouseleave: method.hideZoom, - mousemove: method.onMouseMove - }); }, /** - @event - @param {Object} e Event object - @description Do as more as posible less actions here for performance purposes - and ONLY incase if no loading animation in progress + * Reset this.ratio when large image is loaded + * @protected */ - onMouseMove: function(e){ - var $this = $(this); - if(!data.loading && $this.hasClass(data.settings.main.activeTrackClass)){ - data.pageX = e.pageX; - data.pageY = e.pageY; - - if($.browser.msie) { - method.redrawZoom(); - } - } + _largeImageLoaded: function() { + this.largeImage.css({width: 'auto', height: 'auto'}); + this.largeImageSize = { + width: this.largeImage.width() || this.largeImage.get(0).naturalWidth, + height: this.largeImage.height() || this.largeImage.get(0).naturalHeight + }; + this.ratio = null; + this._toggleNotice(); + $(this.options.selectors.image).trigger('processStop'); }, /** - @event - @param {Object} e Event object - @description Will reveal enlarged container to the right side (by default) of main image - ONLY incase if no loading animation in progress + * Refresh large image (refresh "src" and initial position) + * @protected */ - showZoom: function(e){ - var $this = $(this), - settings = data.settings, - track = data.main.track, - lens = data.lens, - enlarged = data.enlarged.wrapper; - - if(!data.loading){ - if(!$this.hasClass(settings.main.activeTrackClass) && settings.useLens) { - - utils.setData({ - pageX: e.pageX, - pageY: e.pageY, - - lens: { - max: { - x: track.outerWidth() - lens.width, - y: track.outerHeight() - lens.height - }, - cordsCorrection: { - x: utils.ceil(track.offset().left + ( lens.width / 2 )), - y: utils.ceil(track.offset().top + ( lens.height / 2 )) - } - } - }); - - enlarged.css({ - left: utils.ceil(track.offset().left + data.main.trackWidth + settings.enlarged.adjustment), /** @TODO: FIX IE9 */ - top: utils.ceil(track.offset().top) - }); - - method.redrawZoom(); - - if(settings.useLens){ - lens.magnifier.show(); - } - - if(settings.useGallery && settings.swapNotices){ - utils.switchNotice(settings.messages.noticeLightBox); - } - - $this.addClass(settings.main.activeTrackClass); - enlarged.show(); - - } else if (settings.useGallery){ - method.showGallery(); - } - + _refreshLargeImage: function() { + if (this.largeImage) { + $(this.options.selectors.image).trigger('processStart'); + this.largeImage + .prop('src', this.largeImageSrc) + .css({top: 0, left: 0}); } }, /** - @event - @param {Object} e Event object - @description Will hide enlarged image - ONLY incase if no loading animation in progress + * @return {Element} DOM-element + * @protected */ - hideZoom: function() { - var $this = $(this), - settings = data.settings; - - if(!$this.hasClass(settings.gallery.activeGalleryClass) && !data.loading) { - - data.enlarged.wrapper.hide(); - data.main.track.removeClass(settings.main.activeTrackClass); - - if(settings.useGallery && settings.swapNotices ){ - utils.switchNotice(settings.messages.noticeDefault); - } - - if(settings.useLens) { - data.lens.magnifier.hide(); - } - - $this.removeClass(settings.main.activeTrackClass); - - } - - clearTimeout(data.timer); + _renderLargeImage: function() { + var image = $(this.options.selectors.image); + image.trigger('processStart', [image]); + // No need to create template just for img tag + this.largeImage = $('<img />', {src: this.largeImageSrc}); + return this.largeImage; }, /** - @description Re-position zoomed image for onMouseMove event + * Calculate zoom ratio + * @return {number} + * @protected */ - redrawZoom: function(){ - var vars = data, - x = (vars.pageX - vars.lens.cordsCorrection.x), - y = (vars.pageY - vars.lens.cordsCorrection.y), - max = vars.lens.max; - - if(x < 0) { - x = 0; - } else if (x > max.x) { - x = (data.lens.moveOnX) ? max.x : 0; - } - - if(y < 0) { - y = 0; - } else if (y > max.y) { - y = (data.lens.moveOnY) ? max.y : 0; - } - - if(vars.settings.useLens){ - vars.lens.magnifier.css({ - left: x, - top: y - }); - } - - vars.enlarged.image.css({ - left: -(utils.ceil(x * vars.enlarged.ratio)), - top: -(utils.ceil(y * vars.enlarged.ratio)) - }); - - if(!$.browser.msie) { - data.timer = setTimeout(method.redrawZoom, vars.settings.refreshRate); + getZoomRatio: function() { + if(this.ratio === null || typeof(this.ratio) === 'undefined') { + var imageWidth = $(this.image).width() || $(this.image).prop('width'); + return this.largeImageSize.width / imageWidth; } + return this.ratio; }, - /**************** Lightbox functionality ******************/ - /** - @description Draw additional containers for lightbox functionality - @borrows data.enlarged.image as this - - @TODO: Improve performance on jQuery selectors + * Calculate lens size, depending on zoom ratio + * @return {Object} object contain width and height fields + * @protected */ - prepareGallery: function(){ - var zoom, thumbsContainer, - clone = data.main.thumbs.parent('li').parent().clone(), - thumbs = clone.find('a'), - prefix = data.settings.main.prefix; - - this.wrap($('<div>', { id: prefix + '-enlarged-inner' })) - .wrap($('<div>', { id: prefix + '-enlarged-controls' })); - - zoom = $('#' + prefix + '-enlarged-inner'); - - zoom.append($('<div>', { id: prefix + '-gallery-thumbs' })) - .append($('<div>', { id: prefix + '-gallery-close' })) - .children('#' + prefix + '-enlarged-controls') - .append($('<div>', { rel: prefix + '-prev' }), - $('<div>', { rel: prefix + '-next' })); - - zoom.children('#' + prefix + '-gallery-thumbs') - .css('overflow', 'hidden') /** @TODO: Refactor + parametrize + move to CSS */ - .append(clone); - - thumbsContainer = clone.parent('#' + prefix + '-gallery-thumbs').hide(); - - thumbsContainer.append($('<div>', { rel: prefix + '-prev-slide' }), $('<div>', { rel: prefix + '-next-slide' })); - - utils.setData({ gallery: { - gallery: zoom, - close: $('#' + prefix + '-gallery-close'), - next: zoom.find('[rel=' + prefix + '-next]'), - prev: zoom.find('[rel=' + prefix + '-prev]'), - thumbs: thumbs, - thumbsContainer: thumbsContainer, - prevSlide: thumbsContainer.find('[rel=' + prefix + '-prev-slide]'), - nextSlide: thumbsContainer.find('[rel=' + prefix + '-next-slide]'), - galleryWrapper: zoom.children('#' + prefix + '-enlarged-controls') - }}); - - data.gallery.close.hide(); - - if($.browser.msie) { - // data.gallery.next.css('background', 'url(".")'); - // data.gallery.prev.css('background', 'url(".")'); - data.enlarged.wrapper.css('background', 'url(".")'); - } - - method.attachGalleryEvents(); - + _calculateLensSize: function() { + var displayData = this.options.controls.display, + ratio = this.getZoomRatio(); + return { + width: Math.ceil(displayData.width / ratio), + height: Math.ceil(displayData.height / ratio) + }; }, /** - @description Attach gallery controls events + * Refresh position of large image depending of position of zoom lens + * @param {Object} position + * @param {Object} ui + * @protected */ - attachGalleryEvents: function(){ - if(!data.main.isSingleInCollection){ - utils.click.call(data.gallery.thumbs, function(){ - method.thumbnailChange.call(this, data.gallery.galleryWrapper, true); - }); - - data.gallery.next.bind('click', method.galleryNext); - data.gallery.prev.bind('click', method.galleryPrev); - - data.gallery.nextSlide.bind('click', method.slideNext); - data.gallery.prevSlide.bind('click', method.slidePrev); - - } - - data.gallery.close.bind('click', method.hideGallery); - - data.enlarged.wrapper.bind('click', function(event){ - if(event.target === this){ - method.hideGallery(); - } - }); + _refreshZoom: function(position, ui) { + $(ui.element.element).css(position); + this.largeImage.css(this._getLargeImageOffset(position)); }, /** - @description Open gallery and attach document events - - @TODO: parametrize names + * @param {Object} position + * @return {Object} + * @private */ - showGallery: function(){ - var settings = data.settings, - isNotSingleInCollection = (!data.main.isSingleInCollection), - thumbsItemWidth, visibleThumbs; - - data.gallery.close.show(); - - if(isNotSingleInCollection){ - data.gallery.thumbsContainer.show(); - } else { - data.gallery.next.hide(); - data.gallery.prev.hide(); - } - - data.main.track - .removeClass(settings.main.activeTrackClass) - .addClass(settings.gallery.activeGalleryClass); - - if(settings.useLens){ - data.lens.magnifier.hide(); - } - - if(data.enlarged.isLarger){ - utils.switchNotice(settings.messages.noticeDefault); - } - - data.enlarged.wrapper - .show() - // .removeAttr('style') - .addClass('lightbox'); - - $('body').addClass('js-lightbox'); - - if(isNotSingleInCollection){ - thumbsItemWidth = $(data.gallery.thumbs[1]).parent().outerWidth(true); - visibleThumbs = (data.gallery.thumbsContainer.width() / thumbsItemWidth) >> 0; - - if(visibleThumbs >= data.gallery.thumbs.length) { - data.gallery.nextSlide.unbind().remove(); - data.gallery.prevSlide.unbind().remove(); - } - } - - utils.reCalculateGallerySize(); - - if(settings.gallery.useHotkeys){ - utils.bindDocumentEvents(); - } + _getLargeImageOffset: function(position) { + var ratio = this.getZoomRatio(); + return {top: -(position.top * ratio), left: -(position.left * ratio)}; }, /** - @description Close gallery and dettach document events - - @TODO: parametrize names + * Mouse move handler + * @param {Object} e - event object + * @protected */ - hideGallery: function(){ - var settings = data.settings; - - if(settings.gallery.useHotkeys){ - utils.unBindDocumentEvents(); - } - - data.enlarged.image.css({maxHeight:'',maxWidth:''}); - - data.main.track.removeClass(settings.gallery.activeGalleryClass); - - data.enlarged.wrapper.removeClass('lightbox'); - $('body').removeClass('js-lightbox'); - - utils.recalculateSize(data.main.image, data.enlarged.image); - - data.gallery.thumbsContainer.hide(); - data.enlarged.wrapper.hide(); - data.gallery.close.hide(); - - - }, + _move: function(e) { + this.lens.position({ + my: "center", + at: "left top", + of: e, + collision: 'fit', + within: this.image, + using: $.proxy(this._refreshZoom, this) + }); + } + }); + /** + * Extension for zoom widget - white borders detection + */ + $.widget('mage.zoom', $.mage.zoom, { /** - @TODO: REFACTOR - */ - /** - @see .goTo + * Get aspect ratio of the element + * @param {Object} element - jQuery collection + * @return {Number} + * @protected */ - galleryNext: function(){ - method.goTo('next'); + _getAspectRatio: function(element) { + if (!element || !element.length) { + return null; + } + var width = element.width() || element.prop('width'), + height = element.height() || element.prop('height'), + aspectRatio = width / height; + return Math.round (aspectRatio * 100) / 100; }, /** - @see .goTo + * Calculate large image offset depending on enabled "white borders" functionality + * @return {Object} + * @protected */ - galleryPrev: function(){ - method.goTo('prev'); + _getWhiteBordersOffset: function() { + var ratio = this.getZoomRatio(), + largeWidth = this.largeImageSize.width / ratio, + largeHeight = this.largeImageSize.height / ratio, + width = this.image.width() || this.image.prop('width'), + height = this.image.height() || this.image.prop('height'), + offsetLeft = (width - largeWidth) > 0 ? + Math.ceil((width - largeWidth) / 2) : + 0, + offsetTop = (height - largeHeight) > 0 ? + Math.ceil((height - largeHeight) / 2) : + 0; + return { + top: offsetTop, + left: offsetLeft + }; }, /** - @description Swaps all images to new ones next/previous to current + * @override */ - goTo: function(direction){ - var $this, index, small, large, thumb, correspondingItem, - thumbs = data.gallery.thumbs, - length = thumbs.length, - isExcluded = data.main.isExcluded, - current = data.currentItem, - sd = data.switchDirection, - wasNext = sd === 'next' || sd === null, - wasPrev = sd === 'prev' || sd === null; - - switch(direction){ - case 'next': - index = (!wasNext) ? current : ((current + 1) === length) ? 0 : current + 1; - if(isExcluded) { - data.switchDirection = 'next'; - } - break; - case 'prev': - index = (!wasPrev) ? current : (current <= 0) ? length - 1 : current - 1; - if(isExcluded) { - data.switchDirection = 'prev'; - } - break; + _largeImageLoaded: function() { + this._super(); + this.whiteBordersOffset = null; + if (this._getAspectRatio(this.image) !== this._getAspectRatio(this.largeImage)) { + this.whiteBordersOffset = this._getWhiteBordersOffset(); } - - $this = $(thumbs.get(index || 0)); - correspondingItem = $(data.main.thumbs.get(index)); - small = { - link: $this.attr('rel'), - image: data.main.image.find('img') - }; - large = { - link: $this.attr('href'), - image: data.enlarged.image - }; - thumb = { - link: data.main.image.attr('rel'), - image: $this.find('img') - }; - - if(!data.loading){ - /** Because every image loaded async */ - utils.setData({ loading : true }); - - /** Assume that Large image is largest */ - /** @TODO: Parametrize active class */ - utils.switchImage(large.image, large.link, { - before: function(){ - utils.setLoading(data.gallery.galleryWrapper); - utils.switchImage(small.image, small.link, { - after: function(){ - if(isExcluded){ - utils.switchImage(thumb.image, thumb.link , { - after: function(){ - $this.attr({ - rel: small.image.attr('src'), - href: large.image.attr('src') - }); - data.main.image.attr('rel', thumb.image.attr('src')); - - /** Thumbnails should be changed in main thumbnails too */ - utils.switchImage(correspondingItem.find('img'), thumb.link, { - after: function(){ - correspondingItem.attr({ - rel: small.image.attr('src'), - href: large.image.attr('src') - }); - } - }); - } - }); - } else { - /** - @TODO: parametrize active class - */ - data.main.thumbs.removeClass('active'); - data.gallery.thumbs.removeClass('active'); - - $this.addClass('active'); - correspondingItem.addClass('active'); - } - } - }); - }, - after: function(){ - utils.recalculateSize(data.main.image, this, { - after: function(){ - utils.reCalculateGallerySize(); - if(data.loading){ - utils.setData({ currentItem: index }); - utils.unsetLoading(); - } - } - }); - } - }); - } - }, - - slidePrev:function(){ - method.triggerSlider('prev'); }, - - slideNext:function(){ - method.triggerSlider('next'); - }, - - triggerSlider: function(direction){ - var itemWidth = $(data.gallery.thumbs[1]).parent().outerWidth(true), - thumbsContainer = data.gallery.thumbsContainer, - container = thumbsContainer.find('> ul'), - currentPosition = parseInt(container.css('left') , 10), - isLastItem = (((data.gallery.thumbs.length * itemWidth) + currentPosition ) - thumbsContainer.width() - 16) <= 0, - isFirstItem = container.css('left') === ('0px' || 'auto'), - _ = (direction === 'prev') ? ((!isFirstItem) ? '+=' + itemWidth : 0) : ((!isLastItem) ? '-=' + itemWidth : currentPosition); - - if(!data.loading){ - data.loading = true; - container.animate({ - left: _ - }, 'fast', function(){ - data.loading = false; - }); - } - } - - }, - - pub = { /** - @TODO: - destroy() - + * @override */ - }; - - - /** - Magento Zoom jQuery plugin - @class Represents accessing to privat and global methods - @param {String|Object} action Method switcher for plugin - */ - $.fn.magentoZoom = function(action) { - if (pub[action]){ - return pub[action].apply(this, [].prototype.slice.call( arguments, 1 )); - } else if (typeof action === 'object' || !action){ - return method.init.apply( this, arguments ); - } else { - $.error('Method ' + action + ' does not exist on jQuery.magentoZoom'); - } - }; - - /** - @private - @default Object - @memberOf jQuery.magentoZoom - */ - $.fn.magentoZoom.defaults = { - main: { - activeTrackClass: 'zoom-activated', - selector: '[data-role=base-image-zoom]', - prefix: 'magento-zoom' - }, - lens: { - mode: 'standart', - opacity: 0.5 - }, - enlarged: { - adjustment: 20, - action: 'click', - width: 370, - height: 800 - }, - gallery: { - activeGalleryClass: 'gallery-activated', - useHotkeys: true - }, - useLens: true, - useGallery: true, - swapNotices: true, - isOldMode: false, - refreshRate: 30, - messages: { - loadError: "Unable to load media file, please check path of source file", - noticeDefault: "Click on image to zoom", - noticeLightBox: "Click on image to view it full sized", - loadingMessage: "Loading..." + _getLargeImageOffset: function(position) { + if (this.whiteBordersOffset) { + position.top = position.top - this.whiteBordersOffset.top; + position.left = position.left - this.whiteBordersOffset.left; + } + return this._superApply([position]); } - }; -})(jQuery, document, window); + }); +})(jQuery); \ No newline at end of file