diff --git a/CHANGELOG.md b/CHANGELOG.md index d32ee5e749d955add479cd49f0e06e62c2f4c088..8837cd299ee9062f01f44f35e209de4e1f28ffa2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,34 @@ +2.0.0.0-dev63 +============= +* Modularity improvements: + * Consolidated all PayPal-related logic in a separate module + * Resolved dependencies on the Magento_GroupedProduct module + * Added the ability to enable/disable/remove the Magento_GroupedProduct module without impact on the system +* Implemented the Oyejorge Less.php adapter +* Implemented the Less files importing mechanism +* Added the ability to configure certain cache frontend, and associate it to multiple cache types, thus avoiding the duplication of cache configuration +* Implemented the more strict format of array definition in the DI configuration: + * Covered array definitions with XSD, and made the whole DI configuration validated with XSD + * Added the ability to define arrays with keys containing invalid XML characters, that was impossible when keys were represented by the node names +* Fixed bugs: + * Fixed an issue with missed image for a cron job for the abandoned cart emails + * Restored the ability to configure cache storage in `local.xml` + * Fixed an issue with the css\js merging functionality + * Fixed an issue with customer selection on the order creation page +* AppInterface renamed to LauncherInterface +* Removed the reinit logic from the Config object +* Framework part of the "URL" functionality removed from modules +* Framework part of the "Config" functionality removed from modules +* Removed the deprecated EAV structure creation method from the EAV setup model +* Updated various PHPDoc with parameter and return types +* Indexer implementation: + * Implemented a new indexer structure +* Refactored Web API Framework to support the Data Object based service interfaces +* Refactored controllers, blocks and templates of the Sales module to use Customer service +* GitHub requests: + * [#275] (https://github.com/magento/magento2/issues/275) -- XSS Vulnerability in app/code/core/Mage/CatalogSearch/Block/Result.php +* Removed the outdated Customer service + 2.0.0.0-dev62 ============= * Modularity improvements: diff --git a/app/code/Magento/AdminNotification/Model/Feed.php b/app/code/Magento/AdminNotification/Model/Feed.php index 6ae518aeda43f45db63144d0b3a046b28685fc14..b99d9b75680b98bae1ea2c606a01b0d79cc31a6d 100644 --- a/app/code/Magento/AdminNotification/Model/Feed.php +++ b/app/code/Magento/AdminNotification/Model/Feed.php @@ -97,7 +97,7 @@ class Feed extends \Magento\Core\Model\AbstractModel */ public function getFeedUrl() { - $httpPath = $this->_backendConfig->getFlag(self::XML_USE_HTTPS_PATH) ? 'https://' : 'http://'; + $httpPath = $this->_backendConfig->isSetFlag(self::XML_USE_HTTPS_PATH) ? 'https://' : 'http://'; if (is_null($this->_feedUrl)) { $this->_feedUrl = $httpPath . $this->_backendConfig->getValue(self::XML_FEED_URL_PATH); } diff --git a/app/code/Magento/AdminNotification/Model/System/Message/Baseurl.php b/app/code/Magento/AdminNotification/Model/System/Message/Baseurl.php index e0dcf3bcc3db69dceae955b4a37fa224654ccbc9..28753875e539cd68feffc5ad13c23582ec870af8 100644 --- a/app/code/Magento/AdminNotification/Model/System/Message/Baseurl.php +++ b/app/code/Magento/AdminNotification/Model/System/Message/Baseurl.php @@ -32,7 +32,7 @@ class Baseurl protected $_urlBuilder; /** - * @var \Magento\Core\Model\Config + * @var \Magento\App\ConfigInterface */ protected $_config; @@ -47,13 +47,13 @@ class Baseurl protected $_configValueFactory; /** - * @param \Magento\Core\Model\Config $config + * @param \Magento\App\ConfigInterface $config * @param \Magento\Core\Model\StoreManagerInterface $storeManager * @param \Magento\UrlInterface $urlBuilder * @param \Magento\Core\Model\Config\ValueFactory $configValueFactory */ public function __construct( - \Magento\Core\Model\Config $config, + \Magento\App\ConfigInterface $config, \Magento\Core\Model\StoreManagerInterface $storeManager, \Magento\UrlInterface $urlBuilder, \Magento\Core\Model\Config\ValueFactory $configValueFactory @@ -91,7 +91,7 @@ class Baseurl $dataCollection = $this->_configValueFactory->create()->getCollection(); $dataCollection->addValueFilter(\Magento\Core\Model\Store::BASE_URL_PLACEHOLDER); - /** @var $data \Magento\Core\Model\Config\Value */ + /** @var $data \Magento\App\Config\ValueInterface */ foreach ($dataCollection as $data) { if ($data->getScope() == 'stores') { $code = $this->_storeManager->getStore($data->getScopeId())->getCode(); diff --git a/app/code/Magento/AdminNotification/Model/System/Message/Security.php b/app/code/Magento/AdminNotification/Model/System/Message/Security.php index b089242adca2e620196aa437dcee3db310e585b5..d4b41ceff5ca8186acb85cc215f75c1b39fa6e07 100644 --- a/app/code/Magento/AdminNotification/Model/System/Message/Security.php +++ b/app/code/Magento/AdminNotification/Model/System/Message/Security.php @@ -55,7 +55,7 @@ class Security protected $_backendConfig; /** - * @var \Magento\Core\Model\Config + * @var \Magento\App\ConfigInterface */ protected $_config; @@ -67,13 +67,13 @@ class Security /** * @param \Magento\App\CacheInterface $cache * @param \Magento\Backend\App\ConfigInterface $backendConfig - * @param \Magento\Core\Model\Config $config + * @param \Magento\App\ConfigInterface $config * @param \Magento\HTTP\Adapter\CurlFactory $curlFactory */ public function __construct( \Magento\App\CacheInterface $cache, \Magento\Backend\App\ConfigInterface $backendConfig, - \Magento\Core\Model\Config $config, + \Magento\App\ConfigInterface $config, \Magento\HTTP\Adapter\CurlFactory $curlFactory ) { $this->_cache = $cache; diff --git a/app/code/Magento/AdminNotification/etc/adminhtml/di.xml b/app/code/Magento/AdminNotification/etc/adminhtml/di.xml index a17fef326e532b75ef8c2319b161fbacc25724fb..d633836e3ffea012e010890c4ae1e6b1378d5cce 100644 --- a/app/code/Magento/AdminNotification/etc/adminhtml/di.xml +++ b/app/code/Magento/AdminNotification/etc/adminhtml/di.xml @@ -26,14 +26,14 @@ <config> <type name="Magento\AdminNotification\Model\System\MessageList"> <param name="messages"> - <value> - <baseurl>Magento\AdminNotification\Model\System\Message\Baseurl</baseurl> - <security>Magento\AdminNotification\Model\System\Message\Security</security> - <cacheOutdated>Magento\AdminNotification\Model\System\Message\CacheOutdated</cacheOutdated> - <survey>Magento\AdminNotification\Model\System\Message\Survey</survey> - <media_synchronization_error>Magento\AdminNotification\Model\System\Message\Media\Synchronization\Error</media_synchronization_error> - <media_synchronization_success>Magento\AdminNotification\Model\System\Message\Media\Synchronization\Success</media_synchronization_success> - </value> + <array> + <item key="baseurl"><value>Magento\AdminNotification\Model\System\Message\Baseurl</value></item> + <item key="security"><value>Magento\AdminNotification\Model\System\Message\Security</value></item> + <item key="cacheOutdated"><value>Magento\AdminNotification\Model\System\Message\CacheOutdated</value></item> + <item key="survey"><value>Magento\AdminNotification\Model\System\Message\Survey</value></item> + <item key="media_synchronization_error"><value>Magento\AdminNotification\Model\System\Message\Media\Synchronization\Error</value></item> + <item key="media_synchronization_success"><value>Magento\AdminNotification\Model\System\Message\Media\Synchronization\Success</value></item> + </array> </param> </type> </config> diff --git a/app/code/Magento/Authorizenet/Controller/Adminhtml/Authorizenet/Directpost/Payment.php b/app/code/Magento/Authorizenet/Controller/Adminhtml/Authorizenet/Directpost/Payment.php index 6cc99bb9c4200a07889b46ccaf73032cf616e496..793087f43489cc81da7be57a90d60a9083e04434 100644 --- a/app/code/Magento/Authorizenet/Controller/Adminhtml/Authorizenet/Directpost/Payment.php +++ b/app/code/Magento/Authorizenet/Controller/Adminhtml/Authorizenet/Directpost/Payment.php @@ -135,7 +135,7 @@ class Payment $requestToAuthorizenet->setOrderSendConfirmation($sendConfirmationFlag); $requestToAuthorizenet->setStoreId($this->_getOrderCreateModel()->getQuote()->getStoreId()); - $adminUrl = $this->_objectManager->get('Magento\Backend\Model\Url'); + $adminUrl = $this->_objectManager->get('Magento\Backend\Model\UrlInterface'); if ($adminUrl->useSecretKey()) { $requestToAuthorizenet->setKey( $adminUrl->getSecretKey('adminhtml', 'authorizenet_directpost_payment', 'redirect') @@ -161,7 +161,7 @@ class Payment $result['success'] = 0; $result['error'] = 1; $result['redirect'] = $this->_objectManager - ->get('Magento\Backend\Model\Url') + ->get('Magento\Backend\Model\UrlInterface') ->getUrl('sales/order_create/'); } diff --git a/app/code/Magento/Authorizenet/Helper/Backend.php b/app/code/Magento/Authorizenet/Helper/Backend.php index 92ba346c82a0513a5fc7b6ea54a6d3f60ac91269..c30b972e3393936b4adfea816501d8d7cb9e629c 100644 --- a/app/code/Magento/Authorizenet/Helper/Backend.php +++ b/app/code/Magento/Authorizenet/Helper/Backend.php @@ -35,13 +35,13 @@ class Backend extends Data * @param \Magento\App\Helper\Context $context * @param \Magento\Core\Model\StoreManagerInterface $storeManager * @param \Magento\Sales\Model\OrderFactory $orderFactory - * @param \Magento\Backend\Model\Url $backendUrl + * @param \Magento\Backend\Model\UrlInterface $backendUrl */ public function __construct( \Magento\App\Helper\Context $context, \Magento\Core\Model\StoreManagerInterface $storeManager, \Magento\Sales\Model\OrderFactory $orderFactory, - \Magento\Backend\Model\Url $backendUrl + \Magento\Backend\Model\UrlInterface $backendUrl ) { parent::__construct($context, $storeManager, $orderFactory); $this->_urlBuilder = $backendUrl; diff --git a/app/code/Magento/Authorizenet/Helper/Data.php b/app/code/Magento/Authorizenet/Helper/Data.php index 3dbcedd6794a7f4c6004a4836afd788d6b9e7719..0cc27f6694c84b0d119708eff9ae2f87229d6967 100644 --- a/app/code/Magento/Authorizenet/Helper/Data.php +++ b/app/code/Magento/Authorizenet/Helper/Data.php @@ -65,7 +65,7 @@ class Data extends \Magento\App\Helper\AbstractHelper implements HelperInterface */ protected function _getUrl($route, $params = array()) { - $params['_type'] = \Magento\Core\Model\Store::URL_TYPE_LINK; + $params['_type'] = \Magento\UrlInterface::URL_TYPE_LINK; if (isset($params['is_secure'])) { $params['_secure'] = (bool)$params['is_secure']; } elseif ($this->_storeManager->getStore()->isCurrentlySecure()) { diff --git a/app/code/Magento/Authorizenet/Model/Directpost.php b/app/code/Magento/Authorizenet/Model/Directpost.php index 9cc9f9b879cf7e7450b0b468a48d0e49683c408b..89c476bbed699fe30f992750447a82581f076a37 100644 --- a/app/code/Magento/Authorizenet/Model/Directpost.php +++ b/app/code/Magento/Authorizenet/Model/Directpost.php @@ -89,7 +89,7 @@ class Directpost extends \Magento\Authorizenet\Model\Authorizenet * @param \Magento\Authorizenet\Model\Directpost\Response $response * @param \Magento\Authorizenet\Helper\HelperInterface $helper * @param array $data - * + * * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ public function __construct( @@ -346,9 +346,9 @@ class Directpost extends \Magento\Authorizenet\Model\Authorizenet } $shouldCloseCaptureTransaction = $payment->getOrder()->canCreditmemo() ? 0 : 1; $payment - ->setIsTransactionClosed(1) - ->setShouldCloseParentTransaction($shouldCloseCaptureTransaction) - ->setTransactionAdditionalInfo($this->_realTransactionIdKey, $result->getTransactionId()); + ->setIsTransactionClosed(1) + ->setShouldCloseParentTransaction($shouldCloseCaptureTransaction) + ->setTransactionAdditionalInfo($this->_realTransactionIdKey, $result->getTransactionId()); return $this; } throw new \Magento\Core\Exception($this->_wrapGatewayError($result->getResponseReasonText())); @@ -520,8 +520,8 @@ class Directpost extends \Magento\Authorizenet\Model\Authorizenet if ($isError) { throw new \Magento\Core\Exception( ($responseText && !$response->isApproved()) ? - $responseText : - __('This payment didn\'t work out because we can\'t find this order.') + $responseText : + __('This payment didn\'t work out because we can\'t find this order.') ); } } @@ -588,7 +588,7 @@ class Directpost extends \Magento\Authorizenet\Model\Authorizenet */ protected function _matchAmount($amount) { - return sprintf('%.2F', $amount) == sprintf('%.2F', $this->getResponse()->getXAmount()); + return sprintf('%.2F', $amount) == sprintf('%.2F', $this->getResponse()->getXAmount()); } /** @@ -702,7 +702,7 @@ class Directpost extends \Magento\Authorizenet\Model\Authorizenet $orderStatus = $this->getConfigData('order_status'); if (!$orderStatus || $order->getIsVirtual()) { $orderStatus = $order->getConfig() - ->getStateDefaultStatus(\Magento\Sales\Model\Order::STATE_PROCESSING); + ->getStateDefaultStatus(\Magento\Sales\Model\Order::STATE_PROCESSING); } if ($orderStatus) { $order->setStatus($orderStatus); diff --git a/app/code/Magento/Authorizenet/etc/frontend/di.xml b/app/code/Magento/Authorizenet/etc/frontend/di.xml index 1d95c6e9a7cf4b29e42ac6e6dae0f99bb517cd58..693fab6c1b85bb1ac13e637be751af5a8a6318e7 100644 --- a/app/code/Magento/Authorizenet/etc/frontend/di.xml +++ b/app/code/Magento/Authorizenet/etc/frontend/di.xml @@ -37,9 +37,9 @@ </type> <type name="Magento\Core\Model\Url\SecurityInfo"> <param name="secureUrlList"> - <value> - <authorizenet>/authorizenet/payment</authorizenet> - </value> + <array> + <item key="authorizenet"><value>/authorizenet/payment</value></item> + </array> </param> </type> <type name="Magento\Authorizenet\Model\Authorizenet"> diff --git a/app/code/Magento/Backend/App/AbstractAction.php b/app/code/Magento/Backend/App/AbstractAction.php index 2ec2f32e6904bfd9949d80884c883a039aa0ae6b..0ca05ec35cb09294b244993e9d4da4d6fa41a449 100644 --- a/app/code/Magento/Backend/App/AbstractAction.php +++ b/app/code/Magento/Backend/App/AbstractAction.php @@ -78,7 +78,7 @@ abstract class AbstractAction extends \Magento\App\Action\Action protected $_auth; /** - * @var \Magento\Backend\Model\Url + * @var \Magento\Backend\Model\UrlInterface */ protected $_backendUrl; @@ -375,7 +375,7 @@ abstract class AbstractAction extends \Magento\App\Action\Action return true; } - $secretKey = $this->getRequest()->getParam(\Magento\Backend\Model\Url::SECRET_KEY_PARAM_NAME, null); + $secretKey = $this->getRequest()->getParam(\Magento\Backend\Model\UrlInterface::SECRET_KEY_PARAM_NAME, null); if (!$secretKey || $secretKey != $this->_backendUrl->getSecretKey()) { return false; } diff --git a/app/code/Magento/Backend/App/Action/Context.php b/app/code/Magento/Backend/App/Action/Context.php index 19003801834030a0dc504d3c335f421af8b08154..6cdccaa8c0bb2f1e1dfb51f30850259e9e73fccd 100644 --- a/app/code/Magento/Backend/App/Action/Context.php +++ b/app/code/Magento/Backend/App/Action/Context.php @@ -47,7 +47,7 @@ class Context extends \Magento\App\Action\Context protected $_helper; /** - * @var \Magento\Backend\Model\Url + * @var \Magento\Backend\Model\UrlInterface */ protected $_backendUrl; @@ -90,7 +90,7 @@ class Context extends \Magento\App\Action\Context * @param \Magento\AuthorizationInterface $authorization * @param \Magento\Backend\Model\Auth $auth * @param \Magento\Backend\Helper\Data $helper - * @param \Magento\Backend\Model\Url $backendUrl + * @param \Magento\Backend\Model\UrlInterface $backendUrl * @param \Magento\Core\App\Action\FormKeyValidator $formKeyValidator * @param \Magento\App\Action\Title $title * @param \Magento\Core\Model\LocaleInterface $locale @@ -110,7 +110,7 @@ class Context extends \Magento\App\Action\Context \Magento\AuthorizationInterface $authorization, \Magento\Backend\Model\Auth $auth, \Magento\Backend\Helper\Data $helper, - \Magento\Backend\Model\Url $backendUrl, + \Magento\Backend\Model\UrlInterface $backendUrl, \Magento\Core\App\Action\FormKeyValidator $formKeyValidator, \Magento\App\Action\Title $title, \Magento\Core\Model\LocaleInterface $locale, @@ -156,7 +156,7 @@ class Context extends \Magento\App\Action\Context } /** - * @return \Magento\Backend\Model\Url + * @return \Magento\Backend\Model\UrlInterface */ public function getBackendUrl() { diff --git a/app/code/Magento/Backend/App/Action/Plugin/Authentication.php b/app/code/Magento/Backend/App/Action/Plugin/Authentication.php index c8da533e4355b740eb088de1b53e616ea28499b0..3fbb8bb3eb834b7b01cb1bc96b150d2f6599df1f 100644 --- a/app/code/Magento/Backend/App/Action/Plugin/Authentication.php +++ b/app/code/Magento/Backend/App/Action/Plugin/Authentication.php @@ -45,7 +45,7 @@ class Authentication ); /** - * @var \Magento\Backend\Model\Url + * @var \Magento\Backend\Model\UrlInterface */ protected $_url; @@ -66,14 +66,14 @@ class Authentication /** * @param \Magento\Backend\Model\Auth $auth - * @param \Magento\Backend\Model\Url $url + * @param \Magento\Backend\Model\UrlInterface $url * @param \Magento\App\ResponseInterface $response * @param \Magento\App\ActionFlag $actionFlag * @param \Magento\Message\ManagerInterface $messageManager */ public function __construct( \Magento\Backend\Model\Auth $auth, - \Magento\Backend\Model\Url $url, + \Magento\Backend\Model\UrlInterface $url, \Magento\App\ResponseInterface $response, \Magento\App\ActionFlag $actionFlag, \Magento\Message\ManagerInterface $messageManager diff --git a/app/code/Magento/Backend/App/Config.php b/app/code/Magento/Backend/App/Config.php index 73585d01e8a1050fb560e1d260a111c3abaeeac1..10bfd964180100b16d3970058094d099c49d0f65 100644 --- a/app/code/Magento/Backend/App/Config.php +++ b/app/code/Magento/Backend/App/Config.php @@ -67,8 +67,6 @@ class Config implements ConfigInterface /** * Reinitialize configuration - * - * @return \Magento\Core\Model\Config */ public function reinit() { @@ -81,7 +79,7 @@ class Config implements ConfigInterface * @param string $path * @return bool */ - public function getFlag($path) + public function isSetFlag($path) { return !!$this->_sectionPool->getSection('default', null)->getValue($path); } diff --git a/app/code/Magento/Backend/App/ConfigInterface.php b/app/code/Magento/Backend/App/ConfigInterface.php index 6bfa8ab1dddc85bf38dd47a62ce74e603afe96ae..916b477a3a0dd5a1dc919f5d4462809173129f63 100644 --- a/app/code/Magento/Backend/App/ConfigInterface.php +++ b/app/code/Magento/Backend/App/ConfigInterface.php @@ -57,5 +57,5 @@ interface ConfigInterface * @param string $path * @return bool */ - public function getFlag($path); + public function isSetFlag($path); } diff --git a/app/code/Magento/Backend/App/Response/Http/FileFactory.php b/app/code/Magento/Backend/App/Response/Http/FileFactory.php index 077620a3f8ea4ee27553658a3c34617dacf34d72..854243ec07f64e4b1b89ed312a13ad20d356f66e 100644 --- a/app/code/Magento/Backend/App/Response/Http/FileFactory.php +++ b/app/code/Magento/Backend/App/Response/Http/FileFactory.php @@ -31,7 +31,7 @@ class FileFactory extends \Magento\App\Response\Http\FileFactory protected $_auth; /** - * @var \Magento\Backend\Model\Url + * @var \Magento\Backend\Model\UrlInterface */ protected $_backendUrl; @@ -59,7 +59,7 @@ class FileFactory extends \Magento\App\Response\Http\FileFactory * @param \Magento\App\ResponseInterface $response * @param \Magento\App\Filesystem $filesystem * @param \Magento\Backend\Model\Auth $auth - * @param \Magento\Backend\Model\Url $backendUrl + * @param \Magento\Backend\Model\UrlInterface $backendUrl * @param \Magento\Backend\Model\Session $session * @param \Magento\App\ActionFlag $flag * @param \Magento\Backend\Helper\Data $helper @@ -68,7 +68,7 @@ class FileFactory extends \Magento\App\Response\Http\FileFactory \Magento\App\ResponseInterface $response, \Magento\App\Filesystem $filesystem, \Magento\Backend\Model\Auth $auth, - \Magento\Backend\Model\Url $backendUrl, + \Magento\Backend\Model\UrlInterface $backendUrl, \Magento\Backend\Model\Session $session, \Magento\App\ActionFlag $flag, \Magento\Backend\Helper\Data $helper diff --git a/app/code/Magento/Backend/App/Router/DefaultRouter.php b/app/code/Magento/Backend/App/Router/DefaultRouter.php index 4d3b84385c2c8d3008bf439a0d9b71dde0588267..7b581c8d4082bde1a258b659e60932bb6c9f2fd0 100644 --- a/app/code/Magento/Backend/App/Router/DefaultRouter.php +++ b/app/code/Magento/Backend/App/Router/DefaultRouter.php @@ -39,7 +39,7 @@ class DefaultRouter extends \Magento\Core\App\Router\Base protected $_url; /** - * @var \Magento\Core\Model\Config + * @var \Magento\App\ConfigInterface */ protected $_coreConfig; @@ -52,9 +52,9 @@ class DefaultRouter extends \Magento\Core\App\Router\Base * @param \Magento\UrlInterface $url * @param \Magento\Core\Model\StoreManagerInterface $storeManager * @param \Magento\Core\Model\Store\Config $storeConfig - * @param \Magento\Core\Model\Url\SecurityInfoInterface $urlSecurityInfo + * @param \Magento\Url\SecurityInfoInterface $urlSecurityInfo * @param string $routerId - * @param \Magento\Core\Model\Config $coreConfig + * @param \Magento\App\ConfigInterface $coreConfig * @param \Magento\Backend\App\ConfigInterface $backendConfig * * @SuppressWarnings(PHPMD.ExcessiveParameterList) @@ -68,9 +68,9 @@ class DefaultRouter extends \Magento\Core\App\Router\Base \Magento\UrlInterface $url, \Magento\Core\Model\StoreManagerInterface $storeManager, \Magento\Core\Model\Store\Config $storeConfig, - \Magento\Core\Model\Url\SecurityInfoInterface $urlSecurityInfo, + \Magento\Url\SecurityInfoInterface $urlSecurityInfo, $routerId, - \Magento\Core\Model\Config $coreConfig, + \Magento\App\ConfigInterface $coreConfig, \Magento\Backend\App\ConfigInterface $backendConfig ) { parent::__construct( @@ -132,7 +132,7 @@ class DefaultRouter extends \Magento\Core\App\Router\Base protected function _shouldBeSecure($path) { return substr((string)$this->_coreConfig->getValue('web/unsecure/base_url', 'default'), 0, 5) === 'https' - || $this->_backendConfig->getFlag('web/secure/use_in_adminhtml') + || $this->_backendConfig->isSetFlag('web/secure/use_in_adminhtml') && substr((string)$this->_coreConfig->getValue('web/secure/base_url', 'default'), 0, 5) === 'https'; } diff --git a/app/code/Magento/Backend/Block/Dashboard/Orders/Grid.php b/app/code/Magento/Backend/Block/Dashboard/Orders/Grid.php index 5b6124e350e8aa4ff1bacf09ab2ebdb91b5e1fc0..1ec575ae10baa4d502c95e85767841999d1f3128 100644 --- a/app/code/Magento/Backend/Block/Dashboard/Orders/Grid.php +++ b/app/code/Magento/Backend/Block/Dashboard/Orders/Grid.php @@ -48,7 +48,6 @@ class Grid extends \Magento\Backend\Block\Dashboard\Grid /** * @param \Magento\Backend\Block\Template\Context $context - * @param \Magento\Core\Model\Url $urlModel * @param \Magento\Backend\Helper\Data $backendHelper * @param \Magento\Module\Manager $moduleManager * @param \Magento\Reports\Model\Resource\Order\CollectionFactory $collectionFactory @@ -56,7 +55,6 @@ class Grid extends \Magento\Backend\Block\Dashboard\Grid */ public function __construct( \Magento\Backend\Block\Template\Context $context, - \Magento\Core\Model\Url $urlModel, \Magento\Backend\Helper\Data $backendHelper, \Magento\Module\Manager $moduleManager, \Magento\Reports\Model\Resource\Order\CollectionFactory $collectionFactory, @@ -64,7 +62,7 @@ class Grid extends \Magento\Backend\Block\Dashboard\Grid ) { $this->_moduleManager = $moduleManager; $this->_collectionFactory = $collectionFactory; - parent::__construct($context, $urlModel, $backendHelper, $data); + parent::__construct($context, $backendHelper, $data); } protected function _construct() diff --git a/app/code/Magento/Backend/Block/Dashboard/Searches/Last.php b/app/code/Magento/Backend/Block/Dashboard/Searches/Last.php index c0e7599df0f1d9edf71ba8413513c71abdc47a90..d4806307300aa61b4cafa9012030ed6971d58d1c 100644 --- a/app/code/Magento/Backend/Block/Dashboard/Searches/Last.php +++ b/app/code/Magento/Backend/Block/Dashboard/Searches/Last.php @@ -50,7 +50,6 @@ class Last extends \Magento\Backend\Block\Dashboard\Grid /** * @param \Magento\Backend\Block\Template\Context $context - * @param \Magento\Core\Model\Url $urlModel * @param \Magento\Backend\Helper\Data $backendHelper * @param \Magento\Module\Manager $moduleManager * @param \Magento\CatalogSearch\Model\Resource\Query\CollectionFactory $queriesFactory @@ -58,7 +57,6 @@ class Last extends \Magento\Backend\Block\Dashboard\Grid */ public function __construct( \Magento\Backend\Block\Template\Context $context, - \Magento\Core\Model\Url $urlModel, \Magento\Backend\Helper\Data $backendHelper, \Magento\Module\Manager $moduleManager, \Magento\CatalogSearch\Model\Resource\Query\CollectionFactory $queriesFactory, @@ -66,7 +64,7 @@ class Last extends \Magento\Backend\Block\Dashboard\Grid ) { $this->_moduleManager = $moduleManager; $this->_queriesFactory = $queriesFactory; - parent::__construct($context, $urlModel, $backendHelper, $data); + parent::__construct($context, $backendHelper, $data); } protected function _construct() diff --git a/app/code/Magento/Backend/Block/Dashboard/Searches/Renderer/Searchquery.php b/app/code/Magento/Backend/Block/Dashboard/Searches/Renderer/Searchquery.php index 2f4e4c5233dbb44cf4794359d3b09fcd18c08418..2b29903a8185eeca4fe6db971eba8b2dc2e856a6 100644 --- a/app/code/Magento/Backend/Block/Dashboard/Searches/Renderer/Searchquery.php +++ b/app/code/Magento/Backend/Block/Dashboard/Searches/Renderer/Searchquery.php @@ -24,21 +24,19 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Backend\Block\Dashboard\Searches\Renderer; /** * Dashboard search query column renderer */ -namespace Magento\Backend\Block\Dashboard\Searches\Renderer; - -class Searchquery - extends \Magento\Backend\Block\Widget\Grid\Column\Renderer\AbstractRenderer +class Searchquery extends \Magento\Backend\Block\Widget\Grid\Column\Renderer\AbstractRenderer { /** * String helper * * @var \Magento\Stdlib\String */ - protected $_stringHelper = null; + protected $stringHelper; /** * @param \Magento\Backend\Block\Context $context @@ -50,16 +48,22 @@ class Searchquery \Magento\Stdlib\String $stringHelper, array $data = array() ) { - $this->_stringHelper = $stringHelper; + $this->stringHelper = $stringHelper; parent::__construct($context, $data); } + /** + * Renders a column + * + * @param \Magento\Object $row + * @return string + */ public function render(\Magento\Object $row) { $value = $row->getData($this->getColumn()->getIndex()); - if ($this->_stringHelper->strlen($value) > 30) { - $value = '<span title="'. $this->escapeHtml($value) .'">' - . $this->escapeHtml($this->_stringHelper->truncate($value, 30)) . '</span>'; + if ($this->stringHelper->strlen($value) > 30) { + $value = '<span title="' . $this->escapeHtml($value) . '">' + . $this->escapeHtml($this->filterManager->truncate($value, array('length' => 30))) . '</span>'; } else { $value = $this->escapeHtml($value); } diff --git a/app/code/Magento/Backend/Block/Dashboard/Searches/Top.php b/app/code/Magento/Backend/Block/Dashboard/Searches/Top.php index b9169d8df25b33ed914521b2c5905ae4be6df903..2f7eea8b353e9857435222a18d48eb1b9df97fef 100644 --- a/app/code/Magento/Backend/Block/Dashboard/Searches/Top.php +++ b/app/code/Magento/Backend/Block/Dashboard/Searches/Top.php @@ -50,7 +50,6 @@ class Top extends \Magento\Backend\Block\Dashboard\Grid /** * @param \Magento\Backend\Block\Template\Context $context - * @param \Magento\Core\Model\Url $urlModel * @param \Magento\Backend\Helper\Data $backendHelper * @param \Magento\Module\Manager $moduleManager * @param \Magento\CatalogSearch\Model\Resource\Query\CollectionFactory $queriesFactory @@ -58,7 +57,6 @@ class Top extends \Magento\Backend\Block\Dashboard\Grid */ public function __construct( \Magento\Backend\Block\Template\Context $context, - \Magento\Core\Model\Url $urlModel, \Magento\Backend\Helper\Data $backendHelper, \Magento\Module\Manager $moduleManager, \Magento\CatalogSearch\Model\Resource\Query\CollectionFactory $queriesFactory, @@ -66,7 +64,7 @@ class Top extends \Magento\Backend\Block\Dashboard\Grid ) { $this->_moduleManager = $moduleManager; $this->_queriesFactory = $queriesFactory; - parent::__construct($context, $urlModel, $backendHelper, $data); + parent::__construct($context, $backendHelper, $data); } protected function _construct() diff --git a/app/code/Magento/Backend/Block/Dashboard/Tab/Customers/Most.php b/app/code/Magento/Backend/Block/Dashboard/Tab/Customers/Most.php index 9a0881d3d77cda3502cddf34d7be4c28a51eea3a..8f2e5535c8e4d57823ee44789e2742d34343e906 100644 --- a/app/code/Magento/Backend/Block/Dashboard/Tab/Customers/Most.php +++ b/app/code/Magento/Backend/Block/Dashboard/Tab/Customers/Most.php @@ -43,20 +43,18 @@ class Most extends \Magento\Backend\Block\Dashboard\Grid /** * @param \Magento\Backend\Block\Template\Context $context - * @param \Magento\Core\Model\Url $urlModel * @param \Magento\Backend\Helper\Data $backendHelper * @param \Magento\Reports\Model\Resource\Order\CollectionFactory $collectionFactory * @param array $data */ public function __construct( \Magento\Backend\Block\Template\Context $context, - \Magento\Core\Model\Url $urlModel, \Magento\Backend\Helper\Data $backendHelper, \Magento\Reports\Model\Resource\Order\CollectionFactory $collectionFactory, array $data = array() ) { $this->_collectionFactory = $collectionFactory; - parent::__construct($context, $urlModel, $backendHelper, $data); + parent::__construct($context, $backendHelper, $data); } protected function _construct() diff --git a/app/code/Magento/Backend/Block/Dashboard/Tab/Customers/Newest.php b/app/code/Magento/Backend/Block/Dashboard/Tab/Customers/Newest.php index 802f5240f5e0aa3d19d381ec8db0bf30fe57195c..50c99dd435904a918a5091e743078e5ec2887558 100644 --- a/app/code/Magento/Backend/Block/Dashboard/Tab/Customers/Newest.php +++ b/app/code/Magento/Backend/Block/Dashboard/Tab/Customers/Newest.php @@ -43,20 +43,18 @@ class Newest extends \Magento\Backend\Block\Dashboard\Grid /** * @param \Magento\Backend\Block\Template\Context $context - * @param \Magento\Core\Model\Url $urlModel * @param \Magento\Backend\Helper\Data $backendHelper * @param \Magento\Reports\Model\Resource\Customer\CollectionFactory $collectionFactory * @param array $data */ public function __construct( \Magento\Backend\Block\Template\Context $context, - \Magento\Core\Model\Url $urlModel, \Magento\Backend\Helper\Data $backendHelper, \Magento\Reports\Model\Resource\Customer\CollectionFactory $collectionFactory, array $data = array() ) { $this->_collectionFactory = $collectionFactory; - parent::__construct($context, $urlModel, $backendHelper, $data); + parent::__construct($context, $backendHelper, $data); } protected function _construct() diff --git a/app/code/Magento/Backend/Block/Dashboard/Tab/Products/Ordered.php b/app/code/Magento/Backend/Block/Dashboard/Tab/Products/Ordered.php index 6b834b469a66aa3f8ea9e1a7fff060d4b4c47a82..e8d1231a282764c47a2d6e1a0b3454f5f8c378a4 100644 --- a/app/code/Magento/Backend/Block/Dashboard/Tab/Products/Ordered.php +++ b/app/code/Magento/Backend/Block/Dashboard/Tab/Products/Ordered.php @@ -48,7 +48,6 @@ class Ordered extends \Magento\Backend\Block\Dashboard\Grid /** * @param \Magento\Backend\Block\Template\Context $context - * @param \Magento\Core\Model\Url $urlModel * @param \Magento\Backend\Helper\Data $backendHelper * @param \Magento\Module\Manager $moduleManager * @param \Magento\Sales\Model\Resource\Report\Bestsellers\CollectionFactory $collectionFactory @@ -56,7 +55,6 @@ class Ordered extends \Magento\Backend\Block\Dashboard\Grid */ public function __construct( \Magento\Backend\Block\Template\Context $context, - \Magento\Core\Model\Url $urlModel, \Magento\Backend\Helper\Data $backendHelper, \Magento\Module\Manager $moduleManager, \Magento\Sales\Model\Resource\Report\Bestsellers\CollectionFactory $collectionFactory, @@ -64,7 +62,7 @@ class Ordered extends \Magento\Backend\Block\Dashboard\Grid ) { $this->_collectionFactory = $collectionFactory; $this->_moduleManager = $moduleManager; - parent::__construct($context, $urlModel, $backendHelper, $data); + parent::__construct($context, $backendHelper, $data); } protected function _construct() diff --git a/app/code/Magento/Backend/Block/Dashboard/Tab/Products/Viewed.php b/app/code/Magento/Backend/Block/Dashboard/Tab/Products/Viewed.php index 57eefcbea49633f9c7c0f1fb377da0de0d6ce4d1..abadcd927e474b4ae8ab620c1d45b41c6b03cf60 100644 --- a/app/code/Magento/Backend/Block/Dashboard/Tab/Products/Viewed.php +++ b/app/code/Magento/Backend/Block/Dashboard/Tab/Products/Viewed.php @@ -43,20 +43,18 @@ class Viewed extends \Magento\Backend\Block\Dashboard\Grid /** * @param \Magento\Backend\Block\Template\Context $context - * @param \Magento\Core\Model\Url $urlModel * @param \Magento\Backend\Helper\Data $backendHelper * @param \Magento\Reports\Model\Resource\Product\CollectionFactory $productsFactory * @param array $data */ public function __construct( \Magento\Backend\Block\Template\Context $context, - \Magento\Core\Model\Url $urlModel, \Magento\Backend\Helper\Data $backendHelper, \Magento\Reports\Model\Resource\Product\CollectionFactory $productsFactory, array $data = array() ) { $this->_productsFactory = $productsFactory; - parent::__construct($context, $urlModel, $backendHelper, $data); + parent::__construct($context, $backendHelper, $data); } protected function _construct() diff --git a/app/code/Magento/Backend/Block/Menu.php b/app/code/Magento/Backend/Block/Menu.php index 9dc4094a83e917fd4a9b2b5f81de02dbce398eb9..2ed7d5a50f7e275b166d050c69bf847e63f1db93 100644 --- a/app/code/Magento/Backend/Block/Menu.php +++ b/app/code/Magento/Backend/Block/Menu.php @@ -49,7 +49,7 @@ class Menu extends \Magento\Backend\Block\Template /** * Backend URL instance * - * @var \Magento\Backend\Model\Url + * @var \Magento\Backend\Model\UrlInterface */ protected $_url; @@ -77,7 +77,7 @@ class Menu extends \Magento\Backend\Block\Template /** * @param \Magento\Backend\Block\Template\Context $context - * @param \Magento\Backend\Model\Url $url + * @param \Magento\Backend\Model\UrlInterface $url * @param \Magento\Backend\Model\Menu\Filter\IteratorFactory $iteratorFactory * @param \Magento\Backend\Model\Auth\Session $authSession * @param \Magento\Backend\Model\Menu\Config $menuConfig @@ -85,7 +85,7 @@ class Menu extends \Magento\Backend\Block\Template */ public function __construct( \Magento\Backend\Block\Template\Context $context, - \Magento\Backend\Model\Url $url, + \Magento\Backend\Model\UrlInterface $url, \Magento\Backend\Model\Menu\Filter\IteratorFactory $iteratorFactory, \Magento\Backend\Model\Auth\Session $authSession, \Magento\Backend\Model\Menu\Config $menuConfig, @@ -238,7 +238,7 @@ class Menu extends \Magento\Backend\Block\Template protected function _afterToHtml($html) { $html = preg_replace_callback( - '#' . \Magento\Backend\Model\Url::SECRET_KEY_PARAM_NAME . '/\$([^\/].*)/([^\/].*)/([^\$].*)\$#U', + '#' . \Magento\Backend\Model\UrlInterface::SECRET_KEY_PARAM_NAME . '/\$([^\/].*)/([^\/].*)/([^\$].*)\$#U', array($this, '_callbackSecretKey'), $html ); @@ -254,7 +254,7 @@ class Menu extends \Magento\Backend\Block\Template */ protected function _callbackSecretKey($match) { - return \Magento\Backend\Model\Url::SECRET_KEY_PARAM_NAME . '/' + return \Magento\Backend\Model\UrlInterface::SECRET_KEY_PARAM_NAME . '/' . $this->_url->getSecretKey($match[1], $match[2], $match[3]); } diff --git a/app/code/Magento/Backend/Block/Page/System/Config/Robots/Reset.php b/app/code/Magento/Backend/Block/Page/System/Config/Robots/Reset.php index 1ef88376c7d083263e042c895c9ff30aeff4c26a..59e0995bc1180e2f1dd8ffe0414e997d7563592c 100644 --- a/app/code/Magento/Backend/Block/Page/System/Config/Robots/Reset.php +++ b/app/code/Magento/Backend/Block/Page/System/Config/Robots/Reset.php @@ -49,12 +49,12 @@ class Reset extends \Magento\Backend\Block\System\Config\Form\Field /** * @param \Magento\Backend\Block\Template\Context $context - * @param \Magento\Core\Model\ConfigInterface $coreConfig + * @param \Magento\App\ConfigInterface $coreConfig * @param array $data */ public function __construct( \Magento\Backend\Block\Template\Context $context, - \Magento\Core\Model\ConfigInterface $coreConfig, + \Magento\App\ConfigInterface $coreConfig, array $data = array() ) { $this->coreConfig = $coreConfig; diff --git a/app/code/Magento/Backend/Block/System/Config/Form.php b/app/code/Magento/Backend/Block/System/Config/Form.php index fb59d2fa5f4ccae5069862e835c77c82e2ec6224..c9db61e9776870892161330037c52f8b3858427b 100644 --- a/app/code/Magento/Backend/Block/System/Config/Form.php +++ b/app/code/Magento/Backend/Block/System/Config/Form.php @@ -120,7 +120,7 @@ class Form extends \Magento\Backend\Block\Widget\Form\Generic /** * Form field factory * - * @var \Magento\Core\Model\Config + * @var \Magento\App\ConfigInterface */ protected $_config; @@ -132,7 +132,7 @@ class Form extends \Magento\Backend\Block\Widget\Form\Generic * @param \Magento\Backend\Model\Config\Structure $configStructure * @param \Magento\Backend\Block\System\Config\Form\Fieldset\Factory $fieldsetFactory * @param \Magento\Backend\Block\System\Config\Form\Field\Factory $fieldFactory - * @param \Magento\Core\Model\Config $coreConfig + * @param \Magento\App\ConfigInterface $coreConfig * @param array $data */ public function __construct( @@ -143,7 +143,7 @@ class Form extends \Magento\Backend\Block\Widget\Form\Generic \Magento\Backend\Model\Config\Structure $configStructure, \Magento\Backend\Block\System\Config\Form\Fieldset\Factory $fieldsetFactory, \Magento\Backend\Block\System\Config\Form\Field\Factory $fieldFactory, - \Magento\Core\Model\Config $coreConfig, + \Magento\App\ConfigInterface $coreConfig, array $data = array() ) { parent::__construct($context, $registry, $formFactory, $data); diff --git a/app/code/Magento/Backend/Block/System/Config/Form/Field.php b/app/code/Magento/Backend/Block/System/Config/Form/Field.php index faaa12bc74e831745833bdb426975d481b9b6118..fee6ae80c6fb704ada0279379b07fc56d1f3552d 100644 --- a/app/code/Magento/Backend/Block/System/Config/Form/Field.php +++ b/app/code/Magento/Backend/Block/System/Config/Form/Field.php @@ -163,7 +163,7 @@ class Field protected function _renderScopeLabel(\Magento\Data\Form\Element\AbstractElement $element) { $html = '<td class="scope-label">'; - if ($element->getScope() && false == $this->_app->isSingleStoreMode()) { + if ($element->getScope() && false == $this->_storeManager->isSingleStoreMode()) { $html .= $element->getScopeLabel(); } $html .= '</td>'; diff --git a/app/code/Magento/Backend/Block/Widget/Grid.php b/app/code/Magento/Backend/Block/Widget/Grid.php index 8b4024be381b7adfa8869988dcdbd2517db8a915..0a469868a0630f4ffb7b9a3bcd198636c5d19f25 100644 --- a/app/code/Magento/Backend/Block/Widget/Grid.php +++ b/app/code/Magento/Backend/Block/Widget/Grid.php @@ -109,11 +109,6 @@ class Grid extends \Magento\Backend\Block\Widget protected $_template = 'Magento_Backend::widget/grid.phtml'; - /** - * @var \Magento\Core\Model\Url - */ - protected $_urlModel; - /** * @var \Magento\Backend\Model\Session */ @@ -126,18 +121,15 @@ class Grid extends \Magento\Backend\Block\Widget /** * @param \Magento\Backend\Block\Template\Context $context - * @param \Magento\Core\Model\Url $urlModel * @param \Magento\Backend\Helper\Data $backendHelper * @param array $data */ public function __construct( \Magento\Backend\Block\Template\Context $context, - \Magento\Core\Model\Url $urlModel, \Magento\Backend\Helper\Data $backendHelper, array $data = array() ) { $this->_backendHelper = $backendHelper; - $this->_urlModel = $urlModel; $this->_backendSession = $context->getBackendSession(); parent::__construct($context, $data); } diff --git a/app/code/Magento/Backend/Helper/Addresses.php b/app/code/Magento/Backend/Helper/Addresses.php index 8f4aa89242e6c76d08c79a55ca61f80d74db69b2..a7a4b722bd1de9935f6bdc6335c4dc48b5574c02 100644 --- a/app/code/Magento/Backend/Helper/Addresses.php +++ b/app/code/Magento/Backend/Helper/Addresses.php @@ -45,7 +45,7 @@ class Addresses extends \Magento\App\Helper\AbstractHelper */ public function processStreetAttribute(\Magento\Customer\Model\Attribute $attribute) { - if($attribute->getScopeMultilineCount() <= 0) { + if ($attribute->getScopeMultilineCount() <= 0) { $attribute->setScopeMultilineCount(self::DEFAULT_STREET_LINES_COUNT); } return $attribute; diff --git a/app/code/Magento/Backend/Helper/Data.php b/app/code/Magento/Backend/Helper/Data.php index 341bed29bb3cc1e1372301a1f11bc21d1b33de2c..6af5e8c5dad1cd2eaeaf418be36021d114daa803 100644 --- a/app/code/Magento/Backend/Helper/Data.php +++ b/app/code/Magento/Backend/Helper/Data.php @@ -46,7 +46,7 @@ class Data extends \Magento\App\Helper\AbstractHelper protected $_app; /** - * @var \Magento\Backend\Model\Url + * @var \Magento\Backend\Model\UrlInterface */ protected $_backendUrl; @@ -68,8 +68,8 @@ class Data extends \Magento\App\Helper\AbstractHelper /** * @param \Magento\App\Helper\Context $context * @param \Magento\App\Route\Config $routeConfig - * @param \Magento\Core\Model\AppInterface $app - * @param \Magento\Backend\Model\Url $backendUrl + * @param \Magento\AppInterface $app + * @param \Magento\Backend\Model\UrlInterface $backendUrl * @param \Magento\Backend\Model\Auth $auth * @param \Magento\Backend\App\Area\FrontNameResolver $frontNameResolver * @param \Magento\Math\Random $mathRandom @@ -77,8 +77,8 @@ class Data extends \Magento\App\Helper\AbstractHelper public function __construct( \Magento\App\Helper\Context $context, \Magento\App\Route\Config $routeConfig, - \Magento\Core\Model\AppInterface $app, - \Magento\Backend\Model\Url $backendUrl, + \Magento\AppInterface $app, + \Magento\Backend\Model\UrlInterface $backendUrl, \Magento\Backend\Model\Auth $auth, \Magento\Backend\App\Area\FrontNameResolver $frontNameResolver, \Magento\Math\Random $mathRandom diff --git a/app/code/Magento/Backend/Model/Auth.php b/app/code/Magento/Backend/Model/Auth.php index 8c439feab24e4ed5032e4743ce2424fc1a301cc9..e808dc5f45c9f839e9b5dc31edc8fd1a513af7c7 100644 --- a/app/code/Magento/Backend/Model/Auth.php +++ b/app/code/Magento/Backend/Model/Auth.php @@ -56,7 +56,7 @@ class Auth protected $_eventManager; /** - * @var \Magento\Core\Model\Config + * @var \Magento\App\ConfigInterface */ protected $_coreConfig; @@ -70,7 +70,7 @@ class Auth * @param \Magento\Backend\Helper\Data $backendData * @param \Magento\Backend\Model\Auth\StorageInterface $authStorage * @param \Magento\Backend\Model\Auth\Credential\StorageInterface $credentialStorage - * @param \Magento\Core\Model\Config $coreConfig + * @param \Magento\App\ConfigInterface $coreConfig * @param \Magento\Core\Model\Factory $modelFactory */ public function __construct( @@ -78,7 +78,7 @@ class Auth \Magento\Backend\Helper\Data $backendData, \Magento\Backend\Model\Auth\StorageInterface $authStorage, \Magento\Backend\Model\Auth\Credential\StorageInterface $credentialStorage, - \Magento\Core\Model\Config $coreConfig, + \Magento\App\ConfigInterface $coreConfig, \Magento\Core\Model\Factory $modelFactory ) { $this->_eventManager = $eventManager; diff --git a/app/code/Magento/Backend/Model/Auth/Session.php b/app/code/Magento/Backend/Model/Auth/Session.php index 67e9c459f6f057c0d08f9be7342c1bb527773ec5..0db4fb38690aa3a49ab7c791710b248240c37f33 100644 --- a/app/code/Magento/Backend/Model/Auth/Session.php +++ b/app/code/Magento/Backend/Model/Auth/Session.php @@ -60,7 +60,7 @@ class Session protected $_aclBuilder; /** - * @var \Magento\Backend\Model\Url + * @var \Magento\Backend\Model\UrlInterface */ protected $_backendUrl; @@ -77,7 +77,7 @@ class Session * @param \Magento\Session\ValidatorInterface $validator * @param \Magento\Session\StorageInterface $storage * @param \Magento\Acl\Builder $aclBuilder - * @param \Magento\Backend\Model\Url $backendUrl + * @param \Magento\Backend\Model\UrlInterface $backendUrl * @param \Magento\Backend\App\ConfigInterface $config */ public function __construct( @@ -88,7 +88,7 @@ class Session \Magento\Session\ValidatorInterface $validator, \Magento\Session\StorageInterface $storage, \Magento\Acl\Builder $aclBuilder, - \Magento\Backend\Model\Url $backendUrl, + \Magento\Backend\Model\UrlInterface $backendUrl, \Magento\Backend\App\ConfigInterface $config ) { $this->_config = $config; diff --git a/app/code/Magento/Backend/Model/Config.php b/app/code/Magento/Backend/Model/Config.php index 6ca34703f43ec273ae83362333d7e7c2a616a18c..17fe9e669da788dedefd25837129032e29b16694 100644 --- a/app/code/Magento/Backend/Model/Config.php +++ b/app/code/Magento/Backend/Model/Config.php @@ -61,14 +61,14 @@ class Config extends \Magento\Object /** * Application config * - * @var \Magento\Core\Model\Config + * @var \Magento\App\ConfigInterface */ protected $_appConfig; /** * Global factory * - * @var \Magento\Core\Model\Config + * @var \Magento\App\ConfigInterface */ protected $_objectFactory; @@ -79,14 +79,7 @@ class Config extends \Magento\Object */ protected $_transactionFactory; - /** - * Global Application - * - * @var \Magento\Core\Model\App - */ - protected $_application; - - /** + /** * Config data loader * * @var \Magento\Backend\Model\Config\Loader @@ -106,8 +99,7 @@ class Config extends \Magento\Object protected $_storeManager; /** - * @param \Magento\Core\Model\App $application - * @param \Magento\Core\Model\Config $config + * @param \Magento\App\ConfigInterface $config * @param \Magento\Event\ManagerInterface $eventManager * @param \Magento\Backend\Model\Config\Structure $configStructure * @param \Magento\Core\Model\Resource\TransactionFactory $transactionFactory @@ -117,8 +109,7 @@ class Config extends \Magento\Object * @param array $data */ public function __construct( - \Magento\Core\Model\App $application, - \Magento\Core\Model\Config $config, + \Magento\App\ConfigInterface $config, \Magento\Event\ManagerInterface $eventManager, \Magento\Backend\Model\Config\Structure $configStructure, \Magento\Core\Model\Resource\TransactionFactory $transactionFactory, @@ -132,7 +123,6 @@ class Config extends \Magento\Object $this->_configStructure = $configStructure; $this->_transactionFactory = $transactionFactory; $this->_appConfig = $config; - $this->_application = $application; $this->_configLoader = $configLoader; $this->_configValueFactory = $configValueFactory; $this->_storeManager = $storeManager; @@ -259,7 +249,7 @@ class Config extends \Magento\Object /** @var $field \Magento\Backend\Model\Config\Structure\Element\Field */ $field = $this->_configStructure->getElement($groupPath . '/' . $originalFieldId); - /** @var \Magento\Core\Model\Config\Value $backendModel */ + /** @var \Magento\App\Config\ValueInterface $backendModel */ $backendModel = $field->hasBackendModel() ? $field->getBackendModel() : $this->_configValueFactory->create(); @@ -424,18 +414,18 @@ class Config extends \Magento\Object * Set correct scope if isSingleStoreMode = true * * @param \Magento\Backend\Model\Config\Structure\Element\Field $fieldConfig - * @param \Magento\Core\Model\Config\Value $dataObject + * @param \Magento\App\Config\ValueInterface $dataObject */ protected function _checkSingleStoreMode( \Magento\Backend\Model\Config\Structure\Element\Field $fieldConfig, $dataObject ) { - $isSingleStoreMode = $this->_application->isSingleStoreMode(); + $isSingleStoreMode = $this->_storeManager->isSingleStoreMode(); if (!$isSingleStoreMode) { return; } if (!$fieldConfig->showInDefault()) { - $websites = $this->_application->getWebsites(); + $websites = $this->_storeManager->getWebsites(); $singleStoreWebsite = array_shift($websites); $dataObject->setScope('websites'); $dataObject->setWebsiteCode($singleStoreWebsite->getCode()); 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 d6226b3c8e7f11252752d9246b21e427b194e7c0..2b5d4201d503e5db30a8a8a6acaaf273405bf80d 100644 --- a/app/code/Magento/Backend/Model/Config/Backend/Admin/Custom.php +++ b/app/code/Magento/Backend/Model/Config/Backend/Admin/Custom.php @@ -55,7 +55,7 @@ class Custom extends \Magento\Core\Model\Config\Value * @param \Magento\Core\Model\Context $context * @param \Magento\Core\Model\Registry $registry * @param \Magento\Core\Model\StoreManagerInterface $storeManager - * @param \Magento\Core\Model\Config $config + * @param \Magento\App\ConfigInterface $config * @param \Magento\Core\Model\Config\Storage\WriterInterface $configWriter * @param \Magento\Core\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection @@ -65,7 +65,7 @@ class Custom extends \Magento\Core\Model\Config\Value \Magento\Core\Model\Context $context, \Magento\Core\Model\Registry $registry, \Magento\Core\Model\StoreManagerInterface $storeManager, - \Magento\Core\Model\Config $config, + \Magento\App\ConfigInterface $config, \Magento\Core\Model\Config\Storage\WriterInterface $configWriter, \Magento\Core\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, diff --git a/app/code/Magento/Backend/Model/Config/Backend/Admin/Robots.php b/app/code/Magento/Backend/Model/Config/Backend/Admin/Robots.php index cf9238ae9554d633698ba28238418e41376ba64c..b27630864e9ff328b78922ed643b50200365de35 100644 --- a/app/code/Magento/Backend/Model/Config/Backend/Admin/Robots.php +++ b/app/code/Magento/Backend/Model/Config/Backend/Admin/Robots.php @@ -45,7 +45,7 @@ class Robots extends \Magento\Core\Model\Config\Value * @param \Magento\Core\Model\Context $context * @param \Magento\Core\Model\Registry $registry * @param \Magento\Core\Model\StoreManagerInterface $storeManager - * @param \Magento\Core\Model\Config $config + * @param \Magento\App\ConfigInterface $config * @param \Magento\App\Filesystem $filesystem * @param \Magento\Core\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection @@ -55,7 +55,7 @@ class Robots extends \Magento\Core\Model\Config\Value \Magento\Core\Model\Context $context, \Magento\Core\Model\Registry $registry, \Magento\Core\Model\StoreManagerInterface $storeManager, - \Magento\Core\Model\Config $config, + \Magento\App\ConfigInterface $config, \Magento\App\Filesystem $filesystem, \Magento\Core\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, 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 0c85a5866d345998b54462090e97b9c2d261143f..65d2a3397125c0197a64625ab5ca79933f7d90b4 100644 --- a/app/code/Magento/Backend/Model/Config/Backend/Admin/Usecustom.php +++ b/app/code/Magento/Backend/Model/Config/Backend/Admin/Usecustom.php @@ -43,7 +43,7 @@ class Usecustom extends \Magento\Core\Model\Config\Value * @param \Magento\Core\Model\Context $context * @param \Magento\Core\Model\Registry $registry * @param \Magento\Core\Model\StoreManagerInterface $storeManager - * @param \Magento\Core\Model\Config $config + * @param \Magento\App\ConfigInterface $config * @param \Magento\Core\Model\Config\Storage\WriterInterface $configWriter * @param \Magento\Core\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection @@ -53,7 +53,7 @@ class Usecustom extends \Magento\Core\Model\Config\Value \Magento\Core\Model\Context $context, \Magento\Core\Model\Registry $registry, \Magento\Core\Model\StoreManagerInterface $storeManager, - \Magento\Core\Model\Config $config, + \Magento\App\ConfigInterface $config, \Magento\Core\Model\Config\Storage\WriterInterface $configWriter, \Magento\Core\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, diff --git a/app/code/Magento/Backend/Model/Config/Backend/Admin/Usesecretkey.php b/app/code/Magento/Backend/Model/Config/Backend/Admin/Usesecretkey.php index 14430f0cdf20ba6477c635d970ffe3f2bde0b5a4..c969bc007dcb11582f21119004cc30a35a3e00b5 100644 --- a/app/code/Magento/Backend/Model/Config/Backend/Admin/Usesecretkey.php +++ b/app/code/Magento/Backend/Model/Config/Backend/Admin/Usesecretkey.php @@ -32,7 +32,7 @@ namespace Magento\Backend\Model\Config\Backend\Admin; class Usesecretkey extends \Magento\Core\Model\Config\Value { /** - * @var \Magento\Backend\Model\Url + * @var \Magento\Backend\Model\UrlInterface */ protected $_backendUrl; @@ -40,8 +40,8 @@ class Usesecretkey extends \Magento\Core\Model\Config\Value * @param \Magento\Core\Model\Context $context * @param \Magento\Core\Model\Registry $registry * @param \Magento\Core\Model\StoreManagerInterface $storeManager - * @param \Magento\Core\Model\Config $config - * @param \Magento\Backend\Model\Url $backendUrl + * @param \Magento\App\ConfigInterface $config + * @param \Magento\Backend\Model\UrlInterface $backendUrl * @param \Magento\Core\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data @@ -50,8 +50,8 @@ class Usesecretkey extends \Magento\Core\Model\Config\Value \Magento\Core\Model\Context $context, \Magento\Core\Model\Registry $registry, \Magento\Core\Model\StoreManagerInterface $storeManager, - \Magento\Core\Model\Config $config, - \Magento\Backend\Model\Url $backendUrl, + \Magento\App\ConfigInterface $config, + \Magento\Backend\Model\UrlInterface $backendUrl, \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/Baseurl.php b/app/code/Magento/Backend/Model/Config/Backend/Baseurl.php index 0eb3354143fc1491755c97a604b5e48da1105552..a30cf63981ac5ac6053fcbaf732b6c0a289a3226 100644 --- a/app/code/Magento/Backend/Model/Config/Backend/Baseurl.php +++ b/app/code/Magento/Backend/Model/Config/Backend/Baseurl.php @@ -34,7 +34,7 @@ class Baseurl extends \Magento\Core\Model\Config\Value * @param \Magento\Core\Model\Context $context * @param \Magento\Core\Model\Registry $registry * @param \Magento\Core\Model\StoreManagerInterface $storeManager - * @param \Magento\Core\Model\Config $config + * @param \Magento\App\ConfigInterface $config * @param \Magento\View\Asset\MergeService $mergeService * @param \Magento\Core\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection @@ -44,7 +44,7 @@ class Baseurl extends \Magento\Core\Model\Config\Value \Magento\Core\Model\Context $context, \Magento\Core\Model\Registry $registry, \Magento\Core\Model\StoreManagerInterface $storeManager, - \Magento\Core\Model\Config $config, + \Magento\App\ConfigInterface $config, \Magento\View\Asset\MergeService $mergeService, \Magento\Core\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, diff --git a/app/code/Magento/Backend/Model/Config/Backend/Currency/AbstractCurrency.php b/app/code/Magento/Backend/Model/Config/Backend/Currency/AbstractCurrency.php index 0c9dd4169d722edce1a68551e2fbf5535ca67776..db7ef1f16b673b753aaf1f588bf4d25a28e2f016 100644 --- a/app/code/Magento/Backend/Model/Config/Backend/Currency/AbstractCurrency.php +++ b/app/code/Magento/Backend/Model/Config/Backend/Currency/AbstractCurrency.php @@ -51,7 +51,7 @@ abstract class AbstractCurrency extends \Magento\Core\Model\Config\Value * @param \Magento\Core\Model\Context $context * @param \Magento\Core\Model\Registry $registry * @param \Magento\Core\Model\StoreManagerInterface $storeManager - * @param \Magento\Core\Model\Config $config + * @param \Magento\App\ConfigInterface $config * @param \Magento\Core\Model\Store\Config $coreStoreConfig * @param \Magento\Core\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection @@ -61,7 +61,7 @@ abstract class AbstractCurrency extends \Magento\Core\Model\Config\Value \Magento\Core\Model\Context $context, \Magento\Core\Model\Registry $registry, \Magento\Core\Model\StoreManagerInterface $storeManager, - \Magento\Core\Model\Config $config, + \Magento\App\ConfigInterface $config, \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/Backend/Model/Config/Backend/Currency/Allow.php b/app/code/Magento/Backend/Model/Config/Backend/Currency/Allow.php index 3c70c7fd40e5a89b06e51a632a28e2e4937af6b2..bea126e62df313a4b14fa78751dd9cae3366ea5c 100644 --- a/app/code/Magento/Backend/Model/Config/Backend/Currency/Allow.php +++ b/app/code/Magento/Backend/Model/Config/Backend/Currency/Allow.php @@ -41,7 +41,7 @@ class Allow extends \Magento\Backend\Model\Config\Backend\Currency\AbstractCurre * @param \Magento\Core\Model\Context $context * @param \Magento\Core\Model\Registry $registry * @param \Magento\Core\Model\StoreManagerInterface $storeManager - * @param \Magento\Core\Model\Config $config + * @param \Magento\App\ConfigInterface $config * @param \Magento\Core\Model\Store\Config $coreStoreConfig * @param \Magento\Core\Model\LocaleInterface $locale * @param \Magento\Core\Model\Resource\AbstractResource $resource @@ -52,7 +52,7 @@ class Allow extends \Magento\Backend\Model\Config\Backend\Currency\AbstractCurre \Magento\Core\Model\Context $context, \Magento\Core\Model\Registry $registry, \Magento\Core\Model\StoreManagerInterface $storeManager, - \Magento\Core\Model\Config $config, + \Magento\App\ConfigInterface $config, \Magento\Core\Model\Store\Config $coreStoreConfig, \Magento\Core\Model\LocaleInterface $locale, \Magento\Core\Model\Resource\AbstractResource $resource = null, diff --git a/app/code/Magento/Backend/Model/Config/Backend/Currency/Cron.php b/app/code/Magento/Backend/Model/Config/Backend/Currency/Cron.php index 9bc85732342410dc02f4306dae5920c13c521777..3e6f042ea97c0f130cfa46fdcaa53c131733e3ed 100644 --- a/app/code/Magento/Backend/Model/Config/Backend/Currency/Cron.php +++ b/app/code/Magento/Backend/Model/Config/Backend/Currency/Cron.php @@ -42,7 +42,7 @@ class Cron extends \Magento\Core\Model\Config\Value * @param \Magento\Core\Model\Context $context * @param \Magento\Core\Model\Registry $registry * @param \Magento\Core\Model\StoreManagerInterface $storeManager - * @param \Magento\Core\Model\Config $config + * @param \Magento\App\ConfigInterface $config * @param \Magento\Core\Model\Config\ValueFactory $configValueFactory * @param \Magento\Core\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection @@ -52,7 +52,7 @@ class Cron extends \Magento\Core\Model\Config\Value \Magento\Core\Model\Context $context, \Magento\Core\Model\Registry $registry, \Magento\Core\Model\StoreManagerInterface $storeManager, - \Magento\Core\Model\Config $config, + \Magento\App\ConfigInterface $config, \Magento\Core\Model\Config\ValueFactory $configValueFactory, \Magento\Core\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, @@ -81,7 +81,7 @@ class Cron extends \Magento\Core\Model\Config\Value $cronExprString = join(' ', $cronExprArray); try { - /** @var $configValue \Magento\Core\Model\Config\Value */ + /** @var $configValue \Magento\App\Config\ValueInterface */ $configValue = $this->_configValueFactory->create(); $configValue->load(self::CRON_STRING_PATH, 'path'); $configValue->setValue($cronExprString) diff --git a/app/code/Magento/Backend/Model/Config/Backend/Encrypted.php b/app/code/Magento/Backend/Model/Config/Backend/Encrypted.php index cfc857b35abb9d7c596e279b4a12fb2244b9dfd2..12917d0d44595b5f3bf2c26ab00a307eb9461452 100644 --- a/app/code/Magento/Backend/Model/Config/Backend/Encrypted.php +++ b/app/code/Magento/Backend/Model/Config/Backend/Encrypted.php @@ -40,7 +40,7 @@ class Encrypted * @param \Magento\Core\Model\Context $context * @param \Magento\Core\Model\Registry $registry * @param \Magento\Core\Model\StoreManagerInterface $storeManager - * @param \Magento\Core\Model\Config $config + * @param \Magento\App\ConfigInterface $config * @param \Magento\Encryption\EncryptorInterface $encryptor * @param \Magento\Core\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection @@ -50,7 +50,7 @@ class Encrypted \Magento\Core\Model\Context $context, \Magento\Core\Model\Registry $registry, \Magento\Core\Model\StoreManagerInterface $storeManager, - \Magento\Core\Model\Config $config, + \Magento\App\ConfigInterface $config, \Magento\Encryption\EncryptorInterface $encryptor, \Magento\Core\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, diff --git a/app/code/Magento/Backend/Model/Config/Backend/File.php b/app/code/Magento/Backend/Model/Config/Backend/File.php index 3c9a6ea9717689eac983ad6067cac805cb6b3ddb..c5f3d1f61ce304f3dffd67cde8a76d9066d3dd83 100644 --- a/app/code/Magento/Backend/Model/Config/Backend/File.php +++ b/app/code/Magento/Backend/Model/Config/Backend/File.php @@ -64,7 +64,7 @@ class File extends \Magento\Core\Model\Config\Value * @param \Magento\Core\Model\Context $context * @param \Magento\Core\Model\Registry $registry * @param \Magento\Core\Model\StoreManagerInterface $storeManager - * @param \Magento\Core\Model\Config $config + * @param \Magento\App\ConfigInterface $config * @param \Magento\Core\Model\File\UploaderFactory $uploaderFactory * @param \Magento\Backend\Model\Config\Backend\File\RequestData\RequestDataInterface $requestData * @param \Magento\App\Filesystem $filesystem @@ -76,7 +76,7 @@ class File extends \Magento\Core\Model\Config\Value \Magento\Core\Model\Context $context, \Magento\Core\Model\Registry $registry, \Magento\Core\Model\StoreManagerInterface $storeManager, - \Magento\Core\Model\Config $config, + \Magento\App\ConfigInterface $config, \Magento\Core\Model\File\UploaderFactory $uploaderFactory, \Magento\Backend\Model\Config\Backend\File\RequestData\RequestDataInterface $requestData, \Magento\App\Filesystem $filesystem, diff --git a/app/code/Magento/Backend/Model/Config/Backend/Image/Adapter.php b/app/code/Magento/Backend/Model/Config/Backend/Image/Adapter.php index 9d99d3808441e234a035aecc66869111bc97b969..70df22d778e19bdbe7a7b696f8562b0ad135ecc4 100644 --- a/app/code/Magento/Backend/Model/Config/Backend/Image/Adapter.php +++ b/app/code/Magento/Backend/Model/Config/Backend/Image/Adapter.php @@ -45,7 +45,7 @@ class Adapter extends \Magento\Core\Model\Config\Value * @param \Magento\Core\Model\Context $context * @param \Magento\Core\Model\Registry $registry * @param \Magento\Core\Model\StoreManagerInterface $storeManager - * @param \Magento\Core\Model\Config $config + * @param \Magento\App\ConfigInterface $config * @param \Magento\Image\AdapterFactory $imageFactory * @param \Magento\Core\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection @@ -55,7 +55,7 @@ class Adapter extends \Magento\Core\Model\Config\Value \Magento\Core\Model\Context $context, \Magento\Core\Model\Registry $registry, \Magento\Core\Model\StoreManagerInterface $storeManager, - \Magento\Core\Model\Config $config, + \Magento\App\ConfigInterface $config, \Magento\Image\AdapterFactory $imageFactory, \Magento\Core\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, diff --git a/app/code/Magento/Backend/Model/Config/Backend/Locale.php b/app/code/Magento/Backend/Model/Config/Backend/Locale.php index 087da00b27222591e5c90c2ffc630119b70d110c..5bf74b97a74479b2c74b9fac654db0386e16bc88 100644 --- a/app/code/Magento/Backend/Model/Config/Backend/Locale.php +++ b/app/code/Magento/Backend/Model/Config/Backend/Locale.php @@ -55,7 +55,7 @@ class Locale extends \Magento\Core\Model\Config\Value * @param \Magento\Core\Model\Context $context * @param \Magento\Core\Model\Registry $registry * @param \Magento\Core\Model\StoreManagerInterface $storeManager - * @param \Magento\Core\Model\Config $config + * @param \Magento\App\ConfigInterface $config * @param \Magento\Core\Model\Resource\Config\Data\CollectionFactory $configsFactory * @param \Magento\Core\Model\LocaleInterface $locale * @param \Magento\Core\Model\Website\Factory $websiteFactory @@ -70,7 +70,7 @@ class Locale extends \Magento\Core\Model\Config\Value \Magento\Core\Model\Context $context, \Magento\Core\Model\Registry $registry, \Magento\Core\Model\StoreManagerInterface $storeManager, - \Magento\Core\Model\Config $config, + \Magento\App\ConfigInterface $config, \Magento\Core\Model\Resource\Config\Data\CollectionFactory $configsFactory, \Magento\Core\Model\LocaleInterface $locale, \Magento\Core\Model\Website\Factory $websiteFactory, diff --git a/app/code/Magento/Backend/Model/Config/Backend/Log/Cron.php b/app/code/Magento/Backend/Model/Config/Backend/Log/Cron.php index c19a6c641c616e1ae9a2a8f0ced5a94f19c2fcd4..61897521bc82fe4d25ffe331bce335562041dce3 100644 --- a/app/code/Magento/Backend/Model/Config/Backend/Log/Cron.php +++ b/app/code/Magento/Backend/Model/Config/Backend/Log/Cron.php @@ -48,7 +48,7 @@ class Cron extends \Magento\Core\Model\Config\Value * @param \Magento\Core\Model\Context $context * @param \Magento\Core\Model\Registry $registry * @param \Magento\Core\Model\StoreManagerInterface $storeManager - * @param \Magento\Core\Model\Config $config + * @param \Magento\App\ConfigInterface $config * @param \Magento\Core\Model\Config\ValueFactory $configValueFactory * @param \Magento\Core\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection @@ -59,7 +59,7 @@ class Cron extends \Magento\Core\Model\Config\Value \Magento\Core\Model\Context $context, \Magento\Core\Model\Registry $registry, \Magento\Core\Model\StoreManagerInterface $storeManager, - \Magento\Core\Model\Config $config, + \Magento\App\ConfigInterface $config, \Magento\Core\Model\Config\ValueFactory $configValueFactory, \Magento\Core\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, @@ -100,14 +100,14 @@ class Cron extends \Magento\Core\Model\Config\Value } try { - /** @var $configValue \Magento\Core\Model\Config\Value */ + /** @var $configValue \Magento\App\Config\ValueInterface */ $configValue = $this->_configValueFactory->create(); $configValue->load(self::CRON_STRING_PATH, 'path'); $configValue->setValue($cronExprString) ->setPath(self::CRON_STRING_PATH) ->save(); - /** @var $configValue \Magento\Core\Model\Config\Value */ + /** @var $configValue \Magento\App\Config\ValueInterface */ $configValue = $this->_configValueFactory->create(); $configValue->load(self::CRON_MODEL_PATH, 'path'); $configValue->setValue($this->_runModelPath) diff --git a/app/code/Magento/Backend/Model/Config/Backend/Secure.php b/app/code/Magento/Backend/Model/Config/Backend/Secure.php index b910c4a9467118cb063f85a98f9529f46ecb7a4f..c8438f0d7f650383cebca47bbfed4cf84aefa604 100644 --- a/app/code/Magento/Backend/Model/Config/Backend/Secure.php +++ b/app/code/Magento/Backend/Model/Config/Backend/Secure.php @@ -34,7 +34,7 @@ class Secure extends \Magento\Core\Model\Config\Value * @param \Magento\Core\Model\Context $context * @param \Magento\Core\Model\Registry $registry * @param \Magento\Core\Model\StoreManagerInterface $storeManager - * @param \Magento\Core\Model\Config $config + * @param \Magento\App\ConfigInterface $config * @param \Magento\View\Asset\MergeService $mergeService * @param \Magento\Core\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection @@ -44,7 +44,7 @@ class Secure extends \Magento\Core\Model\Config\Value \Magento\Core\Model\Context $context, \Magento\Core\Model\Registry $registry, \Magento\Core\Model\StoreManagerInterface $storeManager, - \Magento\Core\Model\Config $config, + \Magento\App\ConfigInterface $config, \Magento\View\Asset\MergeService $mergeService, \Magento\Core\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, diff --git a/app/code/Magento/Backend/Model/Config/Backend/Storage/Media/Database.php b/app/code/Magento/Backend/Model/Config/Backend/Storage/Media/Database.php index e6ce0872d7a6c44b51f0c306c9d2ce380969de66..459d4dd18d9f3f118ddd7fad170bdf468fd4b538 100644 --- a/app/code/Magento/Backend/Model/Config/Backend/Storage/Media/Database.php +++ b/app/code/Magento/Backend/Model/Config/Backend/Storage/Media/Database.php @@ -40,7 +40,7 @@ class Database extends \Magento\Core\Model\Config\Value * @param \Magento\Core\Model\Context $context * @param \Magento\Core\Model\Registry $registry * @param \Magento\Core\Model\StoreManagerInterface $storeManager - * @param \Magento\Core\Model\Config $config + * @param \Magento\App\ConfigInterface $config * @param \Magento\Core\Helper\File\Storage $coreFileStorage * @param \Magento\Core\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection @@ -50,7 +50,7 @@ class Database extends \Magento\Core\Model\Config\Value \Magento\Core\Model\Context $context, \Magento\Core\Model\Registry $registry, \Magento\Core\Model\StoreManagerInterface $storeManager, - \Magento\Core\Model\Config $config, + \Magento\App\ConfigInterface $config, \Magento\Core\Helper\File\Storage $coreFileStorage, \Magento\Core\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, diff --git a/app/code/Magento/Backend/Model/Config/Backend/Translate.php b/app/code/Magento/Backend/Model/Config/Backend/Translate.php index 862240c37599451dd0feb95b94dade29bd87d952..52d1217bde88e705c262106f4d881e3a2c7a671c 100644 --- a/app/code/Magento/Backend/Model/Config/Backend/Translate.php +++ b/app/code/Magento/Backend/Model/Config/Backend/Translate.php @@ -56,7 +56,7 @@ class Translate extends \Magento\Core\Model\Config\Value * @param \Magento\Core\Model\Context $context * @param \Magento\Core\Model\Registry $registry * @param \Magento\Core\Model\StoreManagerInterface $storeManager - * @param \Magento\Core\Model\Config $config + * @param \Magento\App\ConfigInterface $config * @param \Magento\Core\Model\Store\Config $coreStoreConfig * @param \Magento\App\Cache\TypeListInterface $cacheTypeList * @param \Magento\Core\Model\Resource\AbstractResource $resource @@ -67,7 +67,7 @@ class Translate extends \Magento\Core\Model\Config\Value \Magento\Core\Model\Context $context, \Magento\Core\Model\Registry $registry, \Magento\Core\Model\StoreManagerInterface $storeManager, - \Magento\Core\Model\Config $config, + \Magento\App\ConfigInterface $config, \Magento\Core\Model\Store\Config $coreStoreConfig, \Magento\App\Cache\TypeListInterface $cacheTypeList, \Magento\Core\Model\Resource\AbstractResource $resource = null, diff --git a/app/code/Magento/Backend/Model/Config/BackendClone/Factory.php b/app/code/Magento/Backend/Model/Config/BackendClone/Factory.php index 860ddcb7be4db3bfde20cb75ebc48c15a9e7a0c3..b8a267a2a515832553b7fe26ee4fd43f5058e75b 100644 --- a/app/code/Magento/Backend/Model/Config/BackendClone/Factory.php +++ b/app/code/Magento/Backend/Model/Config/BackendClone/Factory.php @@ -48,7 +48,7 @@ class Factory * Create new clone model * * @param string $cloneModel - * @return \Magento\Core\Model\Config\Value + * @return mixed */ public function create($cloneModel) { diff --git a/app/code/Magento/Backend/Model/Config/BackendFactory.php b/app/code/Magento/Backend/Model/Config/BackendFactory.php index 1d9f9eb0f31606f32a888651a44fb55caca8511c..3ea0b53e668df8b155e76e6610f90cab840840e7 100644 --- a/app/code/Magento/Backend/Model/Config/BackendFactory.php +++ b/app/code/Magento/Backend/Model/Config/BackendFactory.php @@ -47,13 +47,13 @@ class BackendFactory * Create backend model by name * * @param string $modelName - * @return \Magento\Core\Model\Config\Value + * @return \Magento\App\Config\ValueInterface * @throws \InvalidArgumentException */ public function create($modelName) { $model = $this->_objectManager->create($modelName); - if (!$model instanceof \Magento\Core\Model\Config\Value) { + if (!$model instanceof \Magento\App\Config\ValueInterface) { throw new \InvalidArgumentException('Invalid config field backend model: ' . $modelName); } return $model; diff --git a/app/code/Magento/Backend/Model/Config/Source/Admin/Page.php b/app/code/Magento/Backend/Model/Config/Source/Admin/Page.php index 719b6de9dce0fb3b492a10d36151b09826da5197..e312cd705fe458ef7aa39e2cea6a58a1cb3b5c51 100644 --- a/app/code/Magento/Backend/Model/Config/Source/Admin/Page.php +++ b/app/code/Magento/Backend/Model/Config/Source/Admin/Page.php @@ -34,13 +34,6 @@ class Page implements \Magento\Core\Model\Option\ArrayInterface */ protected $_menu; - /** - * @var \Magento\Backend\Model\Menu\Filter\IteratorFactory - * - * @var \Magento\Core\Model\Config - */ - protected $_objectFactory; - /** * @var \Magento\Backend\Model\Menu\Filter\IteratorFactory */ diff --git a/app/code/Magento/Backend/Model/Config/Source/Storage/Media/Database.php b/app/code/Magento/Backend/Model/Config/Source/Storage/Media/Database.php index 0efd885c3513897d1b653136b470fe4594feff74..415fcfd1a80a06b09e07c20ce34389d29b2aa1cf 100644 --- a/app/code/Magento/Backend/Model/Config/Source/Storage/Media/Database.php +++ b/app/code/Magento/Backend/Model/Config/Source/Storage/Media/Database.php @@ -32,16 +32,16 @@ namespace Magento\Backend\Model\Config\Source\Storage\Media; class Database implements \Magento\Core\Model\Option\ArrayInterface { /** - * @var \Magento\App\Config + * @var \Magento\App\Arguments */ - protected $_config; + protected $_arguments; /** - * @param \Magento\App\Config + * @param \Magento\App\Arguments */ - public function __construct(\Magento\App\Config $config) + public function __construct(\Magento\App\Arguments $arguments) { - $this->_config = $config; + $this->_arguments = $arguments; } /** @@ -52,7 +52,7 @@ class Database implements \Magento\Core\Model\Option\ArrayInterface public function toOptionArray() { $resourceOptions = array(); - foreach (array_keys($this->_config->getResources()) as $resourceName) { + foreach (array_keys($this->_arguments->getResources()) as $resourceName) { $resourceOptions[] = array('value' => $resourceName, 'label' => $resourceName); } sort($resourceOptions); diff --git a/app/code/Magento/Backend/Model/Config/Structure/AbstractElement.php b/app/code/Magento/Backend/Model/Config/Structure/AbstractElement.php index 7d4ce2e5725b621fc9d105942b1280c274efa5a9..578732088e1c97934942237cdae239a15839fb70 100644 --- a/app/code/Magento/Backend/Model/Config/Structure/AbstractElement.php +++ b/app/code/Magento/Backend/Model/Config/Structure/AbstractElement.php @@ -44,18 +44,18 @@ abstract class AbstractElement protected $_scope; /** - * Application object + * Store manager * - * @var \Magento\Core\Model\App + * @var \Magento\Core\Model\StoreManagerInterface */ - protected $_application; + protected $_storeManager; /** - * @param \Magento\Core\Model\App $application + * @param \Magento\Core\Model\StoreManagerInterface */ - public function __construct(\Magento\Core\Model\App $application) + public function __construct(\Magento\Core\Model\StoreManagerInterface $storeManager) { - $this->_application = $application; + $this->_storeManager = $storeManager; } /** @@ -158,7 +158,7 @@ abstract class AbstractElement \Magento\Backend\Model\Config\ScopeDefiner::SCOPE_DEFAULT => $this->_hasVisibilityValue('showInDefault'), ); - if ($this->_application->isSingleStoreMode()) { + if ($this->_storeManager->isSingleStoreMode()) { $result = !$this->_hasVisibilityValue('hide_in_single_store_mode') && array_sum($showInScope); return $result; diff --git a/app/code/Magento/Backend/Model/Config/Structure/Element/AbstractComposite.php b/app/code/Magento/Backend/Model/Config/Structure/Element/AbstractComposite.php index 55412c7f17c973b578540907b9bda2414f488cfc..09b1a7397d17078d1b319a00bf7abddc4f6eef8f 100644 --- a/app/code/Magento/Backend/Model/Config/Structure/Element/AbstractComposite.php +++ b/app/code/Magento/Backend/Model/Config/Structure/Element/AbstractComposite.php @@ -37,14 +37,14 @@ abstract class AbstractComposite protected $_childrenIterator; /** - * @param \Magento\Core\Model\App $application + * @param \Magento\Core\Model\StoreManagerInterface $storeManager * @param \Magento\Backend\Model\Config\Structure\Element\Iterator $childrenIterator */ public function __construct( - \Magento\Core\Model\App $application, + \Magento\Core\Model\StoreManagerInterface $storeManager, \Magento\Backend\Model\Config\Structure\Element\Iterator $childrenIterator ) { - parent::__construct($application); + parent::__construct($storeManager); $this->_childrenIterator = $childrenIterator; } diff --git a/app/code/Magento/Backend/Model/Config/Structure/Element/Dependency/Mapper.php b/app/code/Magento/Backend/Model/Config/Structure/Element/Dependency/Mapper.php index d40729515434a62bc2b9fea61271ffa3f44650ba..75db42e38bf6fba5b0d7c2804712ff81694dcc43 100644 --- a/app/code/Magento/Backend/Model/Config/Structure/Element/Dependency/Mapper.php +++ b/app/code/Magento/Backend/Model/Config/Structure/Element/Dependency/Mapper.php @@ -43,25 +43,25 @@ class Mapper protected $_fieldFactory; /** - * Application object + * Store Manager * - * @var \Magento\Core\Model\App + * @var \Magento\Core\Model\StoreManagerInterface */ - protected $_application; + protected $_storeManager; /** - * @param \Magento\Core\Model\App $application + * @param \Magento\Core\Model\StoreManagerInterface $storeManager * @param \Magento\Backend\Model\Config\Structure\SearchInterface $fieldLocator * @param \Magento\Backend\Model\Config\Structure\Element\Dependency\FieldFactory $fieldFactory */ public function __construct( - \Magento\Core\Model\App $application, + \Magento\Core\Model\StoreManagerInterface $storeManager, \Magento\Backend\Model\Config\Structure\SearchInterface $fieldLocator, \Magento\Backend\Model\Config\Structure\Element\Dependency\FieldFactory $fieldFactory ) { $this->_fieldLocator = $fieldLocator; - $this->_application = $application; + $this->_storeManager = $storeManager; $this->_fieldFactory = $fieldFactory; } @@ -88,7 +88,7 @@ class Mapper * based on not shown field (not rendered field) */ if (false == $dependentField->isVisible()) { - $valueInStore = $this->_application + $valueInStore = $this->_storeManager ->getStore($storeCode) ->getConfig($dependentField->getPath($fieldPrefix)); $shouldAddDependency = !$field->isValueSatisfy($valueInStore); diff --git a/app/code/Magento/Backend/Model/Config/Structure/Element/Field.php b/app/code/Magento/Backend/Model/Config/Structure/Element/Field.php index 2a39df68ba78dbe579ab242acca927c4a4651bd1..12cb2e6f6ac883cdbe96ec93c126e6a7533e3031 100644 --- a/app/code/Magento/Backend/Model/Config/Structure/Element/Field.php +++ b/app/code/Magento/Backend/Model/Config/Structure/Element/Field.php @@ -70,7 +70,7 @@ class Field protected $_blockFactory; /** - * @param \Magento\Core\Model\App $application + * @param \Magento\Core\Model\StoreManagerInterface $storeManager * @param \Magento\Backend\Model\Config\BackendFactory $backendFactory * @param \Magento\Backend\Model\Config\SourceFactory $sourceFactory * @param \Magento\Backend\Model\Config\CommentFactory $commentFactory @@ -78,14 +78,14 @@ class Field * @param \Magento\Backend\Model\Config\Structure\Element\Dependency\Mapper $dependencyMapper */ public function __construct( - \Magento\Core\Model\App $application, + \Magento\Core\Model\StoreManagerInterface $storeManager, \Magento\Backend\Model\Config\BackendFactory $backendFactory, \Magento\Backend\Model\Config\SourceFactory $sourceFactory, \Magento\Backend\Model\Config\CommentFactory $commentFactory, \Magento\View\Element\BlockFactory $blockFactory, \Magento\Backend\Model\Config\Structure\Element\Dependency\Mapper $dependencyMapper ) { - parent::__construct($application); + parent::__construct($storeManager); $this->_backendFactory = $backendFactory; $this->_sourceFactory = $sourceFactory; $this->_commentFactory = $commentFactory; @@ -234,7 +234,7 @@ class Field /** * Retrieve backend model * - * @return \Magento\Core\Model\Config\Value + * @return \Magento\App\Config\ValueInterface */ public function getBackendModel() { diff --git a/app/code/Magento/Backend/Model/Config/Structure/Element/Group.php b/app/code/Magento/Backend/Model/Config/Structure/Element/Group.php index 7cd7fdecf4a9d27308dcc1b75580dd64ee306f60..5921eb20c1f66290d27842e1cdbd5194aa712d71 100644 --- a/app/code/Magento/Backend/Model/Config/Structure/Element/Group.php +++ b/app/code/Magento/Backend/Model/Config/Structure/Element/Group.php @@ -43,18 +43,18 @@ class Group protected $_dependencyMapper; /** - * @param \Magento\Core\Model\App $application + * @param \Magento\Core\Model\StoreManagerInterface $storeManager * @param \Magento\Backend\Model\Config\Structure\Element\Iterator\Field $childrenIterator * @param \Magento\Backend\Model\Config\BackendClone\Factory $cloneModelFactory * @param \Magento\Backend\Model\Config\Structure\Element\Dependency\Mapper $dependencyMapper */ public function __construct( - \Magento\Core\Model\App $application, + \Magento\Core\Model\StoreManagerInterface $storeManager, \Magento\Backend\Model\Config\Structure\Element\Iterator\Field $childrenIterator, \Magento\Backend\Model\Config\BackendClone\Factory $cloneModelFactory, \Magento\Backend\Model\Config\Structure\Element\Dependency\Mapper $dependencyMapper ) { - parent::__construct($application, $childrenIterator); + parent::__construct($storeManager, $childrenIterator); $this->_cloneModelFactory = $cloneModelFactory; $this->_dependencyMapper = $dependencyMapper; } diff --git a/app/code/Magento/Backend/Model/Config/Structure/Element/Section.php b/app/code/Magento/Backend/Model/Config/Structure/Element/Section.php index 44e63a45f0942980f84b6e7628c8efa6d0959ad1..ba1a3a3584834953e77b09886477d676dac87058 100644 --- a/app/code/Magento/Backend/Model/Config/Structure/Element/Section.php +++ b/app/code/Magento/Backend/Model/Config/Structure/Element/Section.php @@ -37,16 +37,16 @@ class Section protected $_authorization; /** - * @param \Magento\Core\Model\App $application + * @param \Magento\Core\Model\StoreManagerInterface $storeManager * @param \Magento\Backend\Model\Config\Structure\Element\Iterator $childrenIterator * @param \Magento\AuthorizationInterface $authorization */ public function __construct( - \Magento\Core\Model\App $application, + \Magento\Core\Model\StoreManagerInterface $storeManager, \Magento\Backend\Model\Config\Structure\Element\Iterator $childrenIterator, \Magento\AuthorizationInterface $authorization ) { - parent::__construct($application, $childrenIterator); + parent::__construct($storeManager, $childrenIterator); $this->_authorization = $authorization; } diff --git a/app/code/Magento/Backend/Model/Config/Structure/Reader.php b/app/code/Magento/Backend/Model/Config/Structure/Reader.php index bca858dc8451b64fa88424d5583f882daf9b06e8..c70db6d1c9f2cc92083a0779402ebc5c9a34d799 100644 --- a/app/code/Magento/Backend/Model/Config/Structure/Reader.php +++ b/app/code/Magento/Backend/Model/Config/Structure/Reader.php @@ -36,25 +36,10 @@ class Reader extends \Magento\Config\Reader\Filesystem protected $_idAttributes = array( '/config/system/tab' => 'id', '/config/system/section' => 'id', - '/config/system/section/group' => 'id', - '/config/system/section/group/field' => 'id', - '/config/system/section/group/field/depends/field' => 'id', - '/config/system/section/group/group' => 'id', - '/config/system/section/group/group/field' => 'id', - '/config/system/section/group/group/field/depends/field' => 'id', - '/config/system/section/group/group/group' => 'id', - '/config/system/section/group/group/group/field' => 'id', - '/config/system/section/group/group/group/field/depends/field' => 'id', - '/config/system/section/group/group/group/group' => 'id', - '/config/system/section/group/group/group/group/field' => 'id', - '/config/system/section/group/group/group/group/field/depends/field' => 'id', - '/config/system/section/group/group/group/group/group' => 'id', - '/config/system/section/group/group/group/group/group/field' => 'id', - '/config/system/section/group/group/group/group/group/field/depends/field' => 'id', - '/config/system/section/group/field/options/option' => 'label', - '/config/system/section/group/group/field/options/option' => 'label', - '/config/system/section/group/group/group/field/options/option' => 'label', - '/config/system/section/group/group/group/group/field/options/option' => 'label', + '/config/system/section(/group)+' => 'id', + '/config/system/section(/group)+/field' => 'id', + '/config/system/section(/group)+/field/depends/field' => 'id', + '/config/system/section(/group)+/field/options/option' => 'label', ); /** diff --git a/app/code/Magento/Backend/Model/Menu/Item.php b/app/code/Magento/Backend/Model/Menu/Item.php index ac247936947252719a07d264e3a80a0dd7ad024f..d7782fc3abd487bbc502af370a4c281920243236 100644 --- a/app/code/Magento/Backend/Model/Menu/Item.php +++ b/app/code/Magento/Backend/Model/Menu/Item.php @@ -130,7 +130,7 @@ class Item protected $_menuFactory; /** - * @var \Magento\Backend\Model\Url + * @var \Magento\Backend\Model\UrlInterface */ protected $_urlModel; @@ -168,7 +168,7 @@ class Item * @param \Magento\AuthorizationInterface $authorization * @param \Magento\Core\Model\Store\Config $storeConfig * @param \Magento\Backend\Model\MenuFactory $menuFactory - * @param \Magento\Backend\Model\Url $urlModel + * @param \Magento\Backend\Model\UrlInterface $urlModel * @param \Magento\Module\ModuleListInterface $moduleList * @param \Magento\Module\Manager $moduleManager * @param array $data @@ -178,7 +178,7 @@ class Item \Magento\AuthorizationInterface $authorization, \Magento\Core\Model\Store\Config $storeConfig, \Magento\Backend\Model\MenuFactory $menuFactory, - \Magento\Backend\Model\Url $urlModel, + \Magento\Backend\Model\UrlInterface $urlModel, \Magento\Module\ModuleListInterface $moduleList, \Magento\Module\Manager $moduleManager, array $data = array() @@ -491,7 +491,7 @@ class Item $this->_acl = $objectManager->get('Magento\AuthorizationInterface'); $this->_storeConfig = $objectManager->get('Magento\Core\Model\Store\Config'); $this->_menuFactory = $objectManager->get('Magento\Backend\Model\MenuFactory'); - $this->_urlModel = $objectManager->get('Magento\Backend\Model\Url'); + $this->_urlModel = $objectManager->get('Magento\Backend\Model\UrlInterface'); $this->_moduleList = $objectManager->get('Magento\Module\ModuleListInterface'); if ($this->_serializedSubmenu) { $this->_submenu = $this->_menuFactory->create(); diff --git a/app/code/Magento/Backend/Model/Observer.php b/app/code/Magento/Backend/Model/Observer.php index fef6039adf85dc1f93760b7a2aa5748be65622f3..f336e59f8e1c686dd654be4d9c413f4dc751304f 100644 --- a/app/code/Magento/Backend/Model/Observer.php +++ b/app/code/Magento/Backend/Model/Observer.php @@ -112,7 +112,7 @@ class Observer /** @var $store \Magento\Core\Model\Store */ foreach ($storeCollection as $store) { if ($store->getId() == 0) { - $store->setUrlClassName('Magento\Backend\Model\Url'); + $store->setUrlClassName('Magento\Backend\Model\UrlInterface'); break; } } diff --git a/app/code/Magento/Backend/Model/Translate/Inline/Config.php b/app/code/Magento/Backend/Model/Translate/Inline/Config.php index a692af573255a5116a5f9219bd3ac1cf5d34c84b..fa701b4b06b444278831134a9881748cbc75d58f 100644 --- a/app/code/Magento/Backend/Model/Translate/Inline/Config.php +++ b/app/code/Magento/Backend/Model/Translate/Inline/Config.php @@ -52,6 +52,6 @@ class Config implements \Magento\Core\Model\Translate\Inline\ConfigInterface */ public function isActive($store = null) { - return $this->_config->getFlag('dev/translate_inline/active_admin'); + return $this->_config->isSetFlag('dev/translate_inline/active_admin'); } } diff --git a/app/code/Magento/Backend/Model/Url.php b/app/code/Magento/Backend/Model/Url.php index 3c5a4105945d9f286f2f19bcb7827c4c691ac3e1..ffa5254b2072378515345ca832a5a23d85e045c1 100644 --- a/app/code/Magento/Backend/Model/Url.php +++ b/app/code/Magento/Backend/Model/Url.php @@ -29,22 +29,12 @@ use Magento\Backend\Model\Auth; use Magento\Backend\Model\Menu; /** - * Class \Magento\Backend\Model\Url + * Class \Magento\Backend\Model\UrlInterface * * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class Url extends \Magento\Core\Model\Url +class Url extends \Magento\Url implements \Magento\Backend\Model\UrlInterface { - /** - * Secret key query param name - */ - const SECRET_KEY_PARAM_NAME = 'key'; - - /** - * xpath to startup page in configuration - */ - const XML_PATH_STARTUP_MENU_ITEM = 'admin/startup/menu_item_id'; - /** * Authentication session * @@ -97,10 +87,15 @@ class Url extends \Magento\Core\Model\Url protected $_storeFactory; /** - * @var \Magento\Core\Model\ConfigInterface + * @var \Magento\App\ConfigInterface */ protected $_coreConfig; + /** + * @var \Magento\Core\Model\Store\Config + */ + protected $_coreStoreConfig; + /** * @var \Magento\Data\Form\FormKey */ @@ -109,12 +104,12 @@ class Url extends \Magento\Core\Model\Url /** * @param \Magento\App\Route\ConfigInterface $routeConfig * @param \Magento\App\RequestInterface $request - * @param \Magento\Core\Model\Url\SecurityInfoInterface $urlSecurityInfo - * @param \Magento\Core\Model\Store\Config $coreStoreConfig - * @param \Magento\Core\Model\App $app - * @param \Magento\Core\Model\StoreManagerInterface $storeManager + * @param \Magento\Url\SecurityInfoInterface $urlSecurityInfo + * @param \Magento\Backend\Model\Url\ScopeResolver $scopeResolver * @param \Magento\Core\Model\Session $session * @param \Magento\Session\SidResolverInterface $sidResolver + * @param \Magento\Url\RouteParamsResolverFactory $routeParamsResolver + * @param \Magento\Url\QueryParamsResolverInterface $queryParamsResolver * @param \Magento\Backend\Helper\Data $backendHelper * @param Menu\Config $menuConfig * @param \Magento\App\CacheInterface $cache @@ -122,22 +117,22 @@ class Url extends \Magento\Core\Model\Url * @param \Magento\Encryption\EncryptorInterface $encryptor * @param \Magento\Backend\App\ConfigInterface $config * @param \Magento\Core\Model\StoreFactory $storeFactory - * @param \Magento\Core\Model\ConfigInterface $coreConfig + * @param \Magento\App\ConfigInterface $coreConfig * @param \Magento\Data\Form\FormKey $formKey - * @param null $areaCode + * @param \Magento\Core\Model\Store\Config $coreStoreConfig * @param array $data - * + * * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ public function __construct( \Magento\App\Route\ConfigInterface $routeConfig, \Magento\App\RequestInterface $request, - \Magento\Core\Model\Url\SecurityInfoInterface $urlSecurityInfo, - \Magento\Core\Model\Store\Config $coreStoreConfig, - \Magento\Core\Model\App $app, - \Magento\Core\Model\StoreManagerInterface $storeManager, + \Magento\Url\SecurityInfoInterface $urlSecurityInfo, + \Magento\Backend\Model\Url\ScopeResolver $scopeResolver, \Magento\Core\Model\Session $session, \Magento\Session\SidResolverInterface $sidResolver, + \Magento\Url\RouteParamsResolverFactory $routeParamsResolver, + \Magento\Url\QueryParamsResolverInterface $queryParamsResolver, \Magento\Backend\Helper\Data $backendHelper, \Magento\Backend\Model\Menu\Config $menuConfig, \Magento\App\CacheInterface $cache, @@ -145,9 +140,9 @@ class Url extends \Magento\Core\Model\Url \Magento\Encryption\EncryptorInterface $encryptor, \Magento\Backend\App\ConfigInterface $config, \Magento\Core\Model\StoreFactory $storeFactory, - \Magento\Core\Model\ConfigInterface $coreConfig, + \Magento\App\ConfigInterface $coreConfig, \Magento\Data\Form\FormKey $formKey, - $areaCode = null, + \Magento\Core\Model\Store\Config $coreStoreConfig, array $data = array() ) { $this->_encryptor = $encryptor; @@ -155,16 +150,14 @@ class Url extends \Magento\Core\Model\Url $routeConfig, $request, $urlSecurityInfo, - $coreStoreConfig, - $app, - $storeManager, + $scopeResolver, $session, $sidResolver, - $areaCode, + $routeParamsResolver, + $queryParamsResolver, $data ); $this->_config = $config; - $this->_startupMenuItemId = $coreStoreConfig->getConfig(self::XML_PATH_STARTUP_MENU_ITEM); $this->_backendHelper = $backendHelper; $this->_menuConfig = $menuConfig; $this->_cache = $cache; @@ -172,6 +165,7 @@ class Url extends \Magento\Core\Model\Url $this->formKey = $formKey; $this->_storeFactory = $storeFactory; $this->_coreConfig = $coreConfig; + $this->_coreStoreConfig = $coreStoreConfig; } /** @@ -179,12 +173,12 @@ class Url extends \Magento\Core\Model\Url * * @return bool */ - public function isSecure() + protected function _isSecure() { if ($this->hasData('secure_is_forced')) { return $this->getData('secure'); } - return $this->_config->getFlag('web/secure/use_in_adminhtml'); + return $this->_config->isSetFlag('web/secure/use_in_adminhtml'); } /** @@ -192,9 +186,9 @@ class Url extends \Magento\Core\Model\Url * * @param array $data * @param bool $unsetOldParams - * @return \Magento\Backend\Model\Url + * @return \Magento\Backend\Model\UrlInterface */ - public function setRouteParams(array $data, $unsetOldParams = true) + protected function _setRouteParams(array $data, $unsetOldParams = true) { if (isset($data['_nosecret'])) { $this->setNoSecret(true); @@ -202,8 +196,8 @@ class Url extends \Magento\Core\Model\Url } else { $this->setNoSecret(false); } - unset($data['_store_to_url']); - return parent::setRouteParams($data, $unsetOldParams); + unset($data['_scope_to_url']); + return parent::_setRouteParams($data, $unsetOldParams); } /** @@ -224,9 +218,9 @@ class Url extends \Magento\Core\Model\Url if (!$this->useSecretKey()) { return $result; } - $routeName = $this->getRouteName('*'); - $controllerName = $this->getControllerName($this->getDefaultControllerName()); - $actionName = $this->getActionName($this->getDefaultActionName()); + $routeName = $this->_getRouteName('*'); + $controllerName = $this->_getControllerName($this->_getDefaultControllerName()); + $actionName = $this->_getActionName($this->_getDefaultActionName()); if ($cacheSecretKey) { $secret = array(self::SECRET_KEY_PARAM_NAME => "\${$routeName}/{$controllerName}/{$actionName}\$"); } else { @@ -239,8 +233,8 @@ class Url extends \Magento\Core\Model\Url } else { $routeParams = $secret; } - if (is_array($this->getRouteParams())) { - $routeParams = array_merge($this->getRouteParams(), $routeParams); + if (is_array($this->_getRouteParams())) { + $routeParams = array_merge($this->_getRouteParams(), $routeParams); } return parent::getUrl("{$routeName}/{$controllerName}/{$actionName}", $routeParams); } @@ -256,7 +250,7 @@ class Url extends \Magento\Core\Model\Url public function getSecretKey($routeName = null, $controller = null, $action = null) { $salt = $this->formKey->getFormKey(); - $request = $this->getRequest(); + $request = $this->_getRequest(); if (!$routeName) { if ($request->getBeforeForwardInfo('route_name') !== null) { $routeName = $request->getBeforeForwardInfo('route_name'); @@ -289,13 +283,13 @@ class Url extends \Magento\Core\Model\Url */ public function useSecretKey() { - return $this->_config->getFlag('admin/security/use_form_key') && !$this->getNoSecret(); + return $this->_config->isSetFlag('admin/security/use_form_key') && !$this->getNoSecret(); } /** * Enable secret key using * - * @return \Magento\Backend\Model\Url + * @return \Magento\Backend\Model\UrlInterface */ public function turnOnSecretKey() { @@ -306,7 +300,7 @@ class Url extends \Magento\Core\Model\Url /** * Disable secret key using * - * @return \Magento\Backend\Model\Url + * @return \Magento\Backend\Model\UrlInterface */ public function turnOffSecretKey() { @@ -317,7 +311,7 @@ class Url extends \Magento\Core\Model\Url /** * Refresh admin menu cache etc. * - * @return \Magento\Backend\Model\Url + * @return \Magento\Backend\Model\UrlInterface */ public function renewSecretUrls() { @@ -331,7 +325,7 @@ class Url extends \Magento\Core\Model\Url */ public function getStartupPageUrl() { - $menuItem = $this->_getMenu()->get($this->_startupMenuItemId); + $menuItem = $this->_getMenu()->get($this->_coreStoreConfig->getConfig(self::XML_PATH_STARTUP_MENU_ITEM)); if (!is_null($menuItem)) { if ($menuItem->isAllowed() && $menuItem->getAction()) { return $menuItem->getAction(); @@ -378,7 +372,7 @@ class Url extends \Magento\Core\Model\Url * Set custom auth session * * @param \Magento\Backend\Model\Auth\Session $session - * @return \Magento\Backend\Model\Url + * @return \Magento\Backend\Model\UrlInterface */ public function setSession(\Magento\Backend\Model\Auth\Session $session) { @@ -415,9 +409,9 @@ class Url extends \Magento\Core\Model\Url * * @return string */ - public function getActionPath() + protected function _getActionPath() { - $path = parent::getActionPath(); + $path = parent::_getActionPath(); if ($path) { if ($this->getAreaFrontName()) { $path = $this->getAreaFrontName() . '/' . $path; @@ -427,11 +421,11 @@ class Url extends \Magento\Core\Model\Url } /** - * Get fake store for the url instance + * Get scope for the url instance * * @return \Magento\Core\Model\Store */ - public function getStore() + protected function _getScope() { return $this->_storeFactory->create(array('url' => $this, 'data' => array( 'code' => 'admin', diff --git a/app/code/Magento/PaypalUk/sql/paypaluk_setup/install-1.6.0.0.php b/app/code/Magento/Backend/Model/Url/ScopeResolver.php similarity index 87% rename from app/code/Magento/PaypalUk/sql/paypaluk_setup/install-1.6.0.0.php rename to app/code/Magento/Backend/Model/Url/ScopeResolver.php index 09c23983ea2223d114905831875abc16e58b4ace..07f64f5d41ec844f0cf0321b745275df5f612448 100644 --- a/app/code/Magento/PaypalUk/sql/paypaluk_setup/install-1.6.0.0.php +++ b/app/code/Magento/Backend/Model/Url/ScopeResolver.php @@ -18,11 +18,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_PaypalUk * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -$installer = $this; -/* @var $installer \Magento\Core\Model\Resource\Setup */ +namespace Magento\Backend\Model\Url; + +class ScopeResolver extends \Magento\Core\Model\Url\ScopeResolver +{ +} diff --git a/app/code/Magento/Backend/Model/UrlInterface.php b/app/code/Magento/Backend/Model/UrlInterface.php new file mode 100644 index 0000000000000000000000000000000000000000..ab9eba4d410dac72a287a7cb5f8c3840bc01ce4f --- /dev/null +++ b/app/code/Magento/Backend/Model/UrlInterface.php @@ -0,0 +1,104 @@ +<?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; + +interface UrlInterface extends \Magento\UrlInterface +{ + /** + * Secret key query param name + */ + const SECRET_KEY_PARAM_NAME = 'key'; + + /** + * xpath to startup page in configuration + */ + const XML_PATH_STARTUP_MENU_ITEM = 'admin/startup/menu_item_id'; + + /** + * Generate secret key for controller and action based on form key + * + * @param string $routeName + * @param string $controller Controller name + * @param string $action Action name + * @return string + */ + public function getSecretKey($routeName = null, $controller = null, $action = null); + + /** + * Return secret key settings flag + * + * @return boolean + */ + public function useSecretKey(); + + /** + * Enable secret key using + * + * @return \Magento\Backend\Model\UrlInterface + */ + public function turnOnSecretKey(); + + /** + * Disable secret key using + * + * @return \Magento\Backend\Model\UrlInterface + */ + public function turnOffSecretKey(); + + /** + * Refresh admin menu cache etc. + * + * @return \Magento\Backend\Model\UrlInterface + */ + public function renewSecretUrls(); + + /** + * Find admin start page url + * + * @return string + */ + public function getStartupPageUrl(); + + /** + * Set custom auth session + * + * @param \Magento\Backend\Model\Auth\Session $session + * @return \Magento\Backend\Model\UrlInterface + */ + public function setSession(\Magento\Backend\Model\Auth\Session $session); + + /** + * Return backend area front name, defined in configuration + * + * @return string + */ + public function getAreaFrontName(); + + /** + * Find first menu item that user is able to access + * + * @return string + */ + public function findFirstAvailableMenu(); +} diff --git a/app/code/Magento/Backend/Model/Widget/Grid/Row/UrlGenerator.php b/app/code/Magento/Backend/Model/Widget/Grid/Row/UrlGenerator.php index 82990ebc1ad48497436aac4621391dfa6866372e..816372f3eff61486ee42027a97c49dd32741626c 100644 --- a/app/code/Magento/Backend/Model/Widget/Grid/Row/UrlGenerator.php +++ b/app/code/Magento/Backend/Model/Widget/Grid/Row/UrlGenerator.php @@ -32,7 +32,7 @@ namespace Magento\Backend\Model\Widget\Grid\Row; class UrlGenerator implements \Magento\Backend\Model\Widget\Grid\Row\GeneratorInterface { /** - * @var \Magento\Backend\Model\Url + * @var \Magento\Backend\Model\UrlInterface */ protected $_urlModel; @@ -52,11 +52,11 @@ class UrlGenerator implements \Magento\Backend\Model\Widget\Grid\Row\GeneratorIn protected $_extraParamsTemplate = array(); /** - * @param \Magento\Backend\Model\Url $backendUrl + * @param \Magento\Backend\Model\UrlInterface $backendUrl * @param array $args * @throws \InvalidArgumentException */ - public function __construct(\Magento\Backend\Model\Url $backendUrl, array $args = array()) + public function __construct(\Magento\Backend\Model\UrlInterface $backendUrl, array $args = array()) { if (!isset($args['path'])) { throw new \InvalidArgumentException('Not all required parameters passed'); diff --git a/app/code/Magento/Backend/etc/adminhtml/di.xml b/app/code/Magento/Backend/etc/adminhtml/di.xml index 7a6e5ddda068a7303fd91f73aa8dfa8220c8e4b9..df67d5802826ac9612a7f5dab5e60dd8f6f9e5f0 100644 --- a/app/code/Magento/Backend/etc/adminhtml/di.xml +++ b/app/code/Magento/Backend/etc/adminhtml/di.xml @@ -27,7 +27,7 @@ <preference for="Magento\Authorization\RoleLocator" type="Magento\Backend\Model\Authorization\RoleLocator" /> <preference for="Magento\Core\Model\LocaleInterface" type="Magento\Backend\Model\Locale" /> <preference for="Magento\App\Action\Context" type="Magento\Backend\App\Action\Context" /> - <preference for="Magento\UrlInterface" type="Magento\Backend\Model\Url" /> + <preference for="Magento\UrlInterface" type="Magento\Backend\Model\UrlInterface" /> <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" /> <preference for="Magento\Backend\Model\Config\Backend\File\RequestData\RequestDataInterface" type="Magento\Backend\Model\Config\Backend\File\RequestData" /> @@ -41,7 +41,7 @@ <preference for="Magento\App\View" type="Magento\Backend\Model\View" /> <type name="Magento\Backend\Model\Translate\Inline"> <param name="url"> - <instance type="Magento\Backend\Model\Url" /> + <instance type="Magento\Backend\Model\UrlInterface" /> </param> </type> <type name="Magento\Backend\App\Action\Context"> @@ -51,7 +51,7 @@ </type> <type name="Magento\Backend\Model\Auth\Session"> <param name="backendUrl"> - <instance type="Magento\Backend\Model\Url\Proxy" /> + <instance type="Magento\Backend\Model\UrlInterface\Proxy" /> </param> </type> <type name="Magento\Core\Model\Session"> @@ -100,18 +100,22 @@ </type> <type name="Magento\App\RouterList"> <param name="routerList"> - <value> - <admin> - <instance>Magento\Backend\App\Router\DefaultRouter</instance> - <disable type="bool">false</disable> - <sortOrder>10</sortOrder> - </admin> - <default> - <instance>Magento\App\Router\DefaultRouter</instance> - <disable type="bool">false</disable> - <sortOrder>100</sortOrder> - </default> - </value> + <array> + <item key="admin"> + <array> + <item key="instance"><value>Magento\Backend\App\Router\DefaultRouter</value></item> + <item key="disable"><value type="bool">false</value></item> + <item key="sortOrder"><value>10</value></item> + </array> + </item> + <item key="default"> + <array> + <item key="instance"><value>Magento\App\Router\DefaultRouter</value></item> + <item key="disable"><value type="bool">false</value></item> + <item key="sortOrder"><value>100</value></item> + </array> + </item> + </array> </param> </type> <type name="Magento\Core\App\Action\Plugin\Session"> diff --git a/app/code/Magento/Backend/etc/di.xml b/app/code/Magento/Backend/etc/di.xml index 221b6eaafe276a9810e9c47e01716ff28ec13333..3c53c7aa790eee877eab431227a9f045e9396c93 100644 --- a/app/code/Magento/Backend/etc/di.xml +++ b/app/code/Magento/Backend/etc/di.xml @@ -32,14 +32,17 @@ <preference for="Magento\Backend\Model\Auth\Credential\StorageInterface" type="Magento\User\Model\User" /> <preference for="Magento\Adminhtml\Helper\Data" type="Magento\Backend\Helper\Data" /> <preference for="Magento\Backend\App\ConfigInterface" type="Magento\Backend\App\Config" /> + <preference for="Magento\Backend\Model\UrlInterface" type="Magento\Backend\Model\Url" /> <type name="Magento\App\AreaList"> <param name="areas"> - <value> - <adminhtml> - <frontNameResolver>Magento\Backend\App\Area\FrontNameResolver</frontNameResolver> - <router>admin</router> - </adminhtml> - </value> + <array> + <item key="adminhtml"> + <array> + <item key="frontNameResolver"><value>Magento\Backend\App\Area\FrontNameResolver</value></item> + <item key="router"><value>admin</value></item> + </array> + </item> + </array> </param> </type> <type name="Magento\Backend\App\Router\DefaultRouter"> @@ -62,7 +65,7 @@ </type> <type name="Magento\Backend\Helper\Data"> <param name="backendUrl"> - <instance type="Magento\Backend\Model\Url\Proxy" /> + <instance type="Magento\Backend\Model\UrlInterface\Proxy" /> </param> <param name="auth"> <instance type="Magento\Backend\Model\Auth\Proxy" /> @@ -70,17 +73,19 @@ </type> <type name="Magento\App\Router\NoRouteHandlerList"> <param name="handlerClassesList"> - <value> - <backend> - <instance>Magento\Backend\App\Router\NoRouteHandler</instance> - <sortOrder>10</sortOrder> - </backend> - </value> + <array> + <item key="backend"> + <array> + <item key="instance"><value>Magento\Backend\App\Router\NoRouteHandler</value></item> + <item key="sortOrder"><value>10</value></item> + </array> + </item> + </array> </param> </type> <type name="Magento\Backend\Model\Widget\Grid\Row\UrlGenerator"> <param name="backendUrl"> - <instance type="Magento\Backend\Model\Url\Proxy" /> + <instance type="Magento\Backend\Model\UrlInterface\Proxy" /> </param> </type> <type name="\Magento\Backend\Model\Observer"> @@ -88,6 +93,11 @@ <instance type="Magento\Backend\Model\Session\Proxy" /> </param> </type> + <type name="Magento\Backend\Model\Url\ScopeResolver"> + <param name="areaCode"> + <value>adminhtml</value> + </param> + </type> <type name="Magento\Backend\Model\Url"> <param name="authSession"> <instance type="Magento\Backend\Model\Auth\Session\Proxy" /> @@ -95,14 +105,6 @@ <param name="formKey"> <instance type="Magento\Data\Form\FormKey\Proxy" /> </param> - <param name="areaCode"> - <value>adminhtml</value> - </param> - </type> - <type name="Magento\Core\Model\Url"> - <param name="areaCode"> - <value>frontend</value> - </param> </type> <type name="Magento\Backend\Helper\Dashboard\Data"> <param name="installDate"> @@ -139,20 +141,26 @@ </type> <type name="Magento\Backend\Controller\Adminhtml\Index"> <param name="searchModules"> - <value> - <products> - <class>Magento\Backend\Model\Search\Catalog</class> - <acl>Magento_Catalog::catalog</acl> - </products> - <customers> - <class>Magento\Backend\Model\Search\Customer</class> - <acl>Magento_Customer::customer</acl> - </customers> - <sales> - <class>Magento\Backend\Model\Search\Order</class> - <acl>Magento_Sales::sales</acl> - </sales> - </value> + <array> + <item key="products"> + <array> + <item key="class"><value>Magento\Backend\Model\Search\Catalog</value></item> + <item key="acl"><value>Magento_Catalog::catalog</value></item> + </array> + </item> + <item key="customers"> + <array> + <item key="class"><value>Magento\Backend\Model\Search\Customer</value></item> + <item key="acl"><value>Magento_Customer::customer</value></item> + </array> + </item> + <item key="sales"> + <array> + <item key="class"><value>Magento\Backend\Model\Search\Order</value></item> + <item key="acl"><value>Magento_Sales::sales</value></item> + </array> + </item> + </array> </param> </type> <virtualType name="Magento\Backend\Model\Auth\Session\Storage" type="Magento\Session\Storage"> diff --git a/app/code/Magento/Backup/Model/Config/Backend/Cron.php b/app/code/Magento/Backup/Model/Config/Backend/Cron.php index 9c9a3bdc3a5318a7ccdbbdbf3141fd87a0f227de..10efaae7054416c3ab8a65451493d4429951a6ad 100644 --- a/app/code/Magento/Backup/Model/Config/Backend/Cron.php +++ b/app/code/Magento/Backup/Model/Config/Backend/Cron.php @@ -39,7 +39,7 @@ class Cron extends \Magento\Core\Model\Config\Value /** * Config value factory * - * @var \Magento\Core\Model\Config\Value + * @var \Magento\Core\Model\Config\ValueFactory */ protected $_configValueFactory; @@ -52,7 +52,7 @@ class Cron extends \Magento\Core\Model\Config\Value * @param \Magento\Core\Model\Context $context * @param \Magento\Core\Model\Registry $registry * @param \Magento\Core\Model\StoreManagerInterface $storeManager - * @param \Magento\Core\Model\Config $config + * @param \Magento\App\ConfigInterface $config * @param \Magento\Core\Model\Config\ValueFactory $configValueFactory * @param \Magento\Core\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection @@ -63,7 +63,7 @@ class Cron extends \Magento\Core\Model\Config\Value \Magento\Core\Model\Context $context, \Magento\Core\Model\Registry $registry, \Magento\Core\Model\StoreManagerInterface $storeManager, - \Magento\Core\Model\Config $config, + \Magento\App\ConfigInterface $config, \Magento\Core\Model\Config\ValueFactory $configValueFactory, \Magento\Core\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, diff --git a/app/code/Magento/Bundle/Block/Adminhtml/Catalog/Product/Edit/Tab/Bundle/Option/Search/Grid.php b/app/code/Magento/Bundle/Block/Adminhtml/Catalog/Product/Edit/Tab/Bundle/Option/Search/Grid.php index e16dc110396acbd01aeec50465d2137299c7b7ac..5f73dc89263aeb24e3b80ac9245fc6babc187cb0 100644 --- a/app/code/Magento/Bundle/Block/Adminhtml/Catalog/Product/Edit/Tab/Bundle/Option/Search/Grid.php +++ b/app/code/Magento/Bundle/Block/Adminhtml/Catalog/Product/Edit/Tab/Bundle/Option/Search/Grid.php @@ -50,7 +50,6 @@ class Grid /** * @param \Magento\Backend\Block\Template\Context $context - * @param \Magento\Core\Model\Url $urlModel * @param \Magento\Backend\Helper\Data $backendHelper * @param \Magento\Catalog\Model\ProductFactory $productFactory * @param \Magento\Bundle\Helper\Data $bundleData @@ -58,7 +57,6 @@ class Grid */ public function __construct( \Magento\Backend\Block\Template\Context $context, - \Magento\Core\Model\Url $urlModel, \Magento\Backend\Helper\Data $backendHelper, \Magento\Catalog\Model\ProductFactory $productFactory, \Magento\Bundle\Helper\Data $bundleData, @@ -66,7 +64,7 @@ class Grid ) { $this->_bundleData = $bundleData; $this->_productFactory = $productFactory; - parent::__construct($context, $urlModel, $backendHelper, $data); + parent::__construct($context, $backendHelper, $data); } protected function _construct() diff --git a/app/code/Magento/Bundle/Model/Product/CatalogPrice.php b/app/code/Magento/Bundle/Model/Product/CatalogPrice.php new file mode 100644 index 0000000000000000000000000000000000000000..2e544ed26caebe0aada22cedd2bd8bdc517879cf --- /dev/null +++ b/app/code/Magento/Bundle/Model/Product/CatalogPrice.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\Bundle\Model\Product; + +/** + * Price model for external catalogs + */ +class CatalogPrice implements \Magento\Catalog\Model\Product\CatalogPriceInterface +{ + /** + * @var \Magento\Core\Model\StoreManagerInterface + */ + protected $storeManager; + + /** + * @var \Magento\Catalog\Model\Product\CatalogPrice + */ + protected $commonPriceModel; + + /** + * @var \Magento\Core\Model\Registry + */ + protected $coreRegistry; + + /** + * @param \Magento\Core\Model\StoreManagerInterface $storeManager + * @param \Magento\Catalog\Model\Product\CatalogPrice $commonPriceModel + * @param \Magento\Core\Model\Registry $coreRegistry + */ + public function __construct( + \Magento\Core\Model\StoreManagerInterface $storeManager, + \Magento\Catalog\Model\Product\CatalogPrice $commonPriceModel, + \Magento\Core\Model\Registry $coreRegistry + ) { + $this->storeManager = $storeManager; + $this->commonPriceModel = $commonPriceModel; + $this->coreRegistry = $coreRegistry; + } + + /** + * Minimal price for "regular" user + * + * @param \Magento\Catalog\Model\Product $product + * @param null|\Magento\Core\Model\Store $store Store view + * @param bool $inclTax + * @return null|float + */ + public function getCatalogPrice(\Magento\Catalog\Model\Product $product, $store = null, $inclTax = false) + { + if ($store instanceof \Magento\Core\Model\Store) { + $oldStore = $this->storeManager->getStore(); + $this->storeManager->setCurrentStore($store); + } + + $this->coreRegistry->unregister('rule_data'); + $this->coreRegistry->register('rule_data', new \Magento\Object(array( + 'store_id' => $product->getStoreId(), + 'website_id' => $product->getWebsiteId(), + 'customer_group_id' => $product->getCustomerGroupId()))); + + $minPrice = $product->getPriceModel()->getTotalPrices($product, 'min', $inclTax); + + if ($store instanceof \Magento\Core\Model\Store) { + $this->storeManager->setCurrentStore($oldStore); + } + return $minPrice; + } + + /** + * Regular catalog price not applicable for bundle product + * + * @param \Magento\Catalog\Model\Product $product + * @return null + */ + public function getCatalogRegularPrice(\Magento\Catalog\Model\Product $product) + { + return null; + } +} \ No newline at end of file diff --git a/app/code/Magento/Bundle/Model/Sales/Order/Pdf/Items/AbstractItems.php b/app/code/Magento/Bundle/Model/Sales/Order/Pdf/Items/AbstractItems.php index b690c4e497cdc04f49115021f934d22bcdf57fc9..4e87df9fe7a06ec3987ce29d0a4400846d0b1b63 100644 --- a/app/code/Magento/Bundle/Model/Sales/Order/Pdf/Items/AbstractItems.php +++ b/app/code/Magento/Bundle/Model/Sales/Order/Pdf/Items/AbstractItems.php @@ -24,15 +24,13 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Bundle\Model\Sales\Order\Pdf\Items; + +use Magento\Catalog\Model\Product\Type\AbstractType; + /** * Sales Order Pdf Items renderer - * - * @category Magento - * @package Magento_Bundle - * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\Bundle\Model\Sales\Order\Pdf\Items; - abstract class AbstractItems extends \Magento\Sales\Model\Order\Pdf\Items\AbstractItems { /** @@ -43,29 +41,30 @@ abstract class AbstractItems extends \Magento\Sales\Model\Order\Pdf\Items\Abstra */ public function getChilds($item) { - $_itemsArray = array(); + $itemsArray = array(); + $items = null; if ($item instanceof \Magento\Sales\Model\Order\Invoice\Item) { - $_items = $item->getInvoice()->getAllItems(); - } else if ($item instanceof \Magento\Sales\Model\Order\Shipment\Item) { - $_items = $item->getShipment()->getAllItems(); - } else if ($item instanceof \Magento\Sales\Model\Order\Creditmemo\Item) { - $_items = $item->getCreditmemo()->getAllItems(); + $items = $item->getInvoice()->getAllItems(); + } elseif ($item instanceof \Magento\Sales\Model\Order\Shipment\Item) { + $items = $item->getShipment()->getAllItems(); + } elseif ($item instanceof \Magento\Sales\Model\Order\Creditmemo\Item) { + $items = $item->getCreditmemo()->getAllItems(); } - if ($_items) { - foreach ($_items as $_item) { - $parentItem = $_item->getOrderItem()->getParentItem(); + if ($items) { + foreach ($items as $invoiceItem) { + $parentItem = $invoiceItem->getOrderItem()->getParentItem(); if ($parentItem) { - $_itemsArray[$parentItem->getId()][$_item->getOrderItemId()] = $_item; + $itemsArray[$parentItem->getId()][$invoiceItem->getOrderItemId()] = $invoiceItem; } else { - $_itemsArray[$_item->getOrderItem()->getId()][$_item->getOrderItemId()] = $_item; + $itemsArray[$invoiceItem->getOrderItem()->getId()][$invoiceItem->getOrderItemId()] = $invoiceItem; } } } - if (isset($_itemsArray[$item->getOrderItem()->getId()])) { - return $_itemsArray[$item->getOrderItem()->getId()]; + if (isset($itemsArray[$item->getOrderItem()->getId()])) { + return $itemsArray[$item->getOrderItem()->getId()]; } else { return null; } @@ -89,7 +88,8 @@ abstract class AbstractItems extends \Magento\Sales\Model\Order\Pdf\Items\Abstra $options = $parentItem->getProductOptions(); if ($options) { if (isset($options['shipment_type']) - && $options['shipment_type'] == \Magento\Catalog\Model\Product\Type\AbstractType::SHIPMENT_SEPARATELY) { + && $options['shipment_type'] == AbstractType::SHIPMENT_SEPARATELY + ) { return true; } else { return false; @@ -99,7 +99,8 @@ abstract class AbstractItems extends \Magento\Sales\Model\Order\Pdf\Items\Abstra $options = $item->getProductOptions(); if ($options) { if (isset($options['shipment_type']) - && $options['shipment_type'] == \Magento\Catalog\Model\Product\Type\AbstractType::SHIPMENT_SEPARATELY) { + && $options['shipment_type'] == AbstractType::SHIPMENT_SEPARATELY + ) { return false; } else { return true; @@ -111,7 +112,8 @@ abstract class AbstractItems extends \Magento\Sales\Model\Order\Pdf\Items\Abstra $options = $this->getOrderItem()->getProductOptions(); if ($options) { if (isset($options['shipment_type']) - && $options['shipment_type'] == \Magento\Catalog\Model\Product\Type\AbstractType::SHIPMENT_SEPARATELY) { + && $options['shipment_type'] == AbstractType::SHIPMENT_SEPARATELY + ) { return true; } } @@ -135,8 +137,8 @@ abstract class AbstractItems extends \Magento\Sales\Model\Order\Pdf\Items\Abstra if ($parentItem) { $options = $parentItem->getProductOptions(); if ($options) { - if (isset($options['product_calculations']) && - $options['product_calculations'] == \Magento\Catalog\Model\Product\Type\AbstractType::CALCULATE_CHILD + if (isset($options['product_calculations']) + && $options['product_calculations'] == AbstractType::CALCULATE_CHILD ) { return true; } else { @@ -146,8 +148,8 @@ abstract class AbstractItems extends \Magento\Sales\Model\Order\Pdf\Items\Abstra } else { $options = $item->getProductOptions(); if ($options) { - if (isset($options['product_calculations']) && - $options['product_calculations'] == \Magento\Catalog\Model\Product\Type\AbstractType::CALCULATE_CHILD + if (isset($options['product_calculations']) + && $options['product_calculations'] == AbstractType::CALCULATE_CHILD ) { return false; } else { @@ -160,7 +162,8 @@ abstract class AbstractItems extends \Magento\Sales\Model\Order\Pdf\Items\Abstra $options = $this->getOrderItem()->getProductOptions(); if ($options) { if (isset($options['product_calculations']) - && $options['product_calculations'] == \Magento\Catalog\Model\Product\Type\AbstractType::CALCULATE_CHILD) { + && $options['product_calculations'] == AbstractType::CALCULATE_CHILD + ) { return true; } } @@ -212,7 +215,6 @@ abstract class AbstractItems extends \Magento\Sales\Model\Order\Pdf\Items\Abstra public function getOrderOptions($item = null) { $result = array(); - $options = $this->getOrderItem()->getProductOptions(); if ($options) { if (isset($options['options'])) { @@ -250,17 +252,19 @@ abstract class AbstractItems extends \Magento\Sales\Model\Order\Pdf\Items\Abstra */ public function getValueHtml($item) { - $result = strip_tags($item->getName()); + $result = $this->filterManager->stripTags($item->getName()); if (!$this->isShipmentSeparately($item)) { $attributes = $this->getSelectionAttributes($item); if ($attributes) { - $result = sprintf('%d', $attributes['qty']) . ' x ' . $result; + $result = $this->filterManager->sprintf($attributes['qty'], array('format' => '%d')) . ' x ' . $result; } } if (!$this->isChildCalculated($item)) { $attributes = $this->getSelectionAttributes($item); if ($attributes) { - $result .= " " . strip_tags($this->getOrderItem()->getOrder()->formatPrice($attributes['price'])); + $result .= " " . $this->filterManager->stripTags( + $this->getOrderItem()->getOrder()->formatPrice($attributes['price']) + ); } } return $result; @@ -275,7 +279,8 @@ abstract class AbstractItems extends \Magento\Sales\Model\Order\Pdf\Items\Abstra public function canShowPriceInfo($item) { if (($item->getOrderItem()->getParentItem() && $this->isChildCalculated()) - || (!$item->getOrderItem()->getParentItem() && !$this->isChildCalculated())) { + || (!$item->getOrderItem()->getParentItem() && !$this->isChildCalculated()) + ) { return true; } return false; diff --git a/app/code/Magento/Bundle/Model/Sales/Order/Pdf/Items/Creditmemo.php b/app/code/Magento/Bundle/Model/Sales/Order/Pdf/Items/Creditmemo.php index de78c696d2a003948ca1fee4c44fbbf2de321e8e..86f22d882b24c6da649ea8970e30f8cff258a41c 100644 --- a/app/code/Magento/Bundle/Model/Sales/Order/Pdf/Items/Creditmemo.php +++ b/app/code/Magento/Bundle/Model/Sales/Order/Pdf/Items/Creditmemo.php @@ -24,15 +24,11 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Bundle\Model\Sales\Order\Pdf\Items; + /** * Sales Order Creditmemo Pdf default items renderer - * - * @category Magento - * @package Magento_Sales - * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\Bundle\Model\Sales\Order\Pdf\Items; - class Creditmemo extends \Magento\Bundle\Model\Sales\Order\Pdf\Items\AbstractItems { /** @@ -47,6 +43,7 @@ class Creditmemo extends \Magento\Bundle\Model\Sales\Order\Pdf\Items\AbstractIte * @param \Magento\Core\Model\Registry $registry * @param \Magento\Tax\Helper\Data $taxData * @param \Magento\App\Filesystem $filesystem + * @param \Magento\Filter\FilterManager $filterManager * @param \Magento\Stdlib\String $string * @param \Magento\Core\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection @@ -57,18 +54,27 @@ class Creditmemo extends \Magento\Bundle\Model\Sales\Order\Pdf\Items\AbstractIte \Magento\Core\Model\Registry $registry, \Magento\Tax\Helper\Data $taxData, \Magento\App\Filesystem $filesystem, + \Magento\Filter\FilterManager $filterManager, \Magento\Stdlib\String $string, \Magento\Core\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { $this->string = $string; - parent::__construct($context, $registry, $taxData, $filesystem, $resource, $resourceCollection, $data); + parent::__construct( + $context, + $registry, + $taxData, + $filesystem, + $filterManager, + $resource, + $resourceCollection, + $data + ); } /** * Draw item line - * */ public function draw() { @@ -78,20 +84,19 @@ class Creditmemo extends \Magento\Bundle\Model\Sales\Order\Pdf\Items\AbstractIte $page = $this->getPage(); $items = $this->getChilds($item); - $_prevOptionId = ''; + $prevOptionId = ''; $drawItems = array(); $leftBound = 35; $rightBound = 565; - foreach ($items as $_item) { + foreach ($items as $childItem) { $x = $leftBound; $line = array(); - $attributes = $this->getSelectionAttributes($_item); + $attributes = $this->getSelectionAttributes($childItem); if (is_array($attributes)) { - $optionId = $attributes['option_id']; - } - else { + $optionId = $attributes['option_id']; + } else { $optionId = 0; } @@ -103,8 +108,8 @@ class Creditmemo extends \Magento\Bundle\Model\Sales\Order\Pdf\Items\AbstractIte } // draw selection attributes - if ($_item->getOrderItem()->getParentItem()) { - if ($_prevOptionId != $attributes['option_id']) { + if ($childItem->getOrderItem()->getParentItem()) { + if ($prevOptionId != $attributes['option_id']) { $line[0] = array( 'font' => 'italic', 'text' => $this->string->split($attributes['option_label'], 38, true, true), @@ -117,17 +122,17 @@ class Creditmemo extends \Magento\Bundle\Model\Sales\Order\Pdf\Items\AbstractIte ); $line = array(); - $_prevOptionId = $attributes['option_id']; + $prevOptionId = $attributes['option_id']; } } // draw product titles - if ($_item->getOrderItem()->getParentItem()) { + if ($childItem->getOrderItem()->getParentItem()) { $feed = $x + 5; - $name = $this->getValueHtml($_item); + $name = $this->getValueHtml($childItem); } else { $feed = $x; - $name = $_item->getName(); + $name = $childItem->getName(); } $line[] = array( @@ -138,7 +143,7 @@ class Creditmemo extends \Magento\Bundle\Model\Sales\Order\Pdf\Items\AbstractIte $x += 220; // draw SKUs - if (!$_item->getOrderItem()->getParentItem()) { + if (!$childItem->getOrderItem()->getParentItem()) { $text = array(); foreach ($this->string->split($item->getSku(), 17) as $part) { $text[] = $part; @@ -152,9 +157,9 @@ class Creditmemo extends \Magento\Bundle\Model\Sales\Order\Pdf\Items\AbstractIte $x += 100; // draw prices - if ($this->canShowPriceInfo($_item)) { + if ($this->canShowPriceInfo($childItem)) { // draw Total(ex) - $text = $order->formatPriceTxt($_item->getRowTotal()); + $text = $order->formatPriceTxt($childItem->getRowTotal()); $line[] = array( 'text' => $text, 'feed' => $x, @@ -165,7 +170,7 @@ class Creditmemo extends \Magento\Bundle\Model\Sales\Order\Pdf\Items\AbstractIte $x += 50; // draw Discount - $text = $order->formatPriceTxt(-$_item->getDiscountAmount()); + $text = $order->formatPriceTxt(-$childItem->getDiscountAmount()); $line[] = array( 'text' => $text, 'feed' => $x, @@ -176,9 +181,9 @@ class Creditmemo extends \Magento\Bundle\Model\Sales\Order\Pdf\Items\AbstractIte $x += 50; // draw QTY - $text = $_item->getQty() * 1; + $text = $childItem->getQty() * 1; $line[] = array( - 'text' => $_item->getQty()*1, + 'text' => $childItem->getQty() * 1, 'feed' => $x, 'font' => 'bold', 'align' => 'center', @@ -187,7 +192,7 @@ class Creditmemo extends \Magento\Bundle\Model\Sales\Order\Pdf\Items\AbstractIte $x += 30; // draw Tax - $text = $order->formatPriceTxt($_item->getTaxAmount()); + $text = $order->formatPriceTxt($childItem->getTaxAmount()); $line[] = array( 'text' => $text, 'feed' => $x, @@ -199,7 +204,7 @@ class Creditmemo extends \Magento\Bundle\Model\Sales\Order\Pdf\Items\AbstractIte // draw Total(inc) $text = $order->formatPriceTxt( - $_item->getRowTotal() + $_item->getTaxAmount() - $_item->getDiscountAmount() + $childItem->getRowTotal() + $childItem->getTaxAmount() - $childItem->getDiscountAmount() ); $line[] = array( 'text' => $text, @@ -220,20 +225,25 @@ class Creditmemo extends \Magento\Bundle\Model\Sales\Order\Pdf\Items\AbstractIte foreach ($options['options'] as $option) { $lines = array(); $lines[][] = array( - 'text' => $this->string->split(strip_tags($option['label']), 40, true, true), + 'text' => $this->string->split( + $this->filterManager->stripTags($option['label']), + 40, + true, + true + ), 'font' => 'italic', 'feed' => $leftBound ); if ($option['value']) { $text = array(); - $_printValue = isset($option['print_value']) + $printValue = isset($option['print_value']) ? $option['print_value'] - : strip_tags($option['value']); - $values = explode(', ', $_printValue); + : $this->filterManager->stripTags($option['value']); + $values = explode(', ', $printValue); foreach ($values as $value) { - foreach ($this->string->split($value, 30, true, true) as $_value) { - $text[] = $_value; + foreach ($this->string->split($value, 30, true, true) as $subValue) { + $text[] = $subValue; } } diff --git a/app/code/Magento/Bundle/Model/Sales/Order/Pdf/Items/Invoice.php b/app/code/Magento/Bundle/Model/Sales/Order/Pdf/Items/Invoice.php index c465a5f5c294376e921c3f1578b4befaea2c6b18..0f70db38908b59743986957255a65f0de8ca9471 100644 --- a/app/code/Magento/Bundle/Model/Sales/Order/Pdf/Items/Invoice.php +++ b/app/code/Magento/Bundle/Model/Sales/Order/Pdf/Items/Invoice.php @@ -24,15 +24,11 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Bundle\Model\Sales\Order\Pdf\Items; + /** * Sales Order Invoice Pdf default items renderer - * - * @category Magento - * @package Magento_Sales - * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\Bundle\Model\Sales\Order\Pdf\Items; - class Invoice extends \Magento\Bundle\Model\Sales\Order\Pdf\Items\AbstractItems { /** @@ -45,6 +41,7 @@ class Invoice extends \Magento\Bundle\Model\Sales\Order\Pdf\Items\AbstractItems * @param \Magento\Core\Model\Registry $registry * @param \Magento\Tax\Helper\Data $taxData * @param \Magento\App\Filesystem $filesystem + * @param \Magento\Filter\FilterManager $filterManager * @param \Magento\Stdlib\String $coreString * @param \Magento\Core\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection @@ -55,18 +52,27 @@ class Invoice extends \Magento\Bundle\Model\Sales\Order\Pdf\Items\AbstractItems \Magento\Core\Model\Registry $registry, \Magento\Tax\Helper\Data $taxData, \Magento\App\Filesystem $filesystem, + \Magento\Filter\FilterManager $filterManager, \Magento\Stdlib\String $coreString, \Magento\Core\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { $this->string = $coreString; - parent::__construct($context, $registry, $taxData, $filesystem, $resource, $resourceCollection, $data); + parent::__construct( + $context, + $registry, + $taxData, + $filesystem, + $filterManager, + $resource, + $resourceCollection, + $data + ); } /** * Draw item line - * */ public function draw() { @@ -78,17 +84,16 @@ class Invoice extends \Magento\Bundle\Model\Sales\Order\Pdf\Items\AbstractItems $this->_setFontRegular(); $items = $this->getChilds($item); - $_prevOptionId = ''; + $prevOptionId = ''; $drawItems = array(); - foreach ($items as $_item) { + foreach ($items as $childItem) { $line = array(); - $attributes = $this->getSelectionAttributes($_item); + $attributes = $this->getSelectionAttributes($childItem); if (is_array($attributes)) { $optionId = $attributes['option_id']; - } - else { + } else { $optionId = 0; } @@ -99,8 +104,8 @@ class Invoice extends \Magento\Bundle\Model\Sales\Order\Pdf\Items\AbstractItems ); } - if ($_item->getOrderItem()->getParentItem()) { - if ($_prevOptionId != $attributes['option_id']) { + if ($childItem->getOrderItem()->getParentItem()) { + if ($prevOptionId != $attributes['option_id']) { $line[0] = array( 'font' => 'italic', 'text' => $this->string->split($attributes['option_label'], 45, true, true), @@ -113,18 +118,17 @@ class Invoice extends \Magento\Bundle\Model\Sales\Order\Pdf\Items\AbstractItems ); $line = array(); - - $_prevOptionId = $attributes['option_id']; + $prevOptionId = $attributes['option_id']; } } /* in case Product name is longer than 80 chars - it is written in a few lines */ - if ($_item->getOrderItem()->getParentItem()) { + if ($childItem->getOrderItem()->getParentItem()) { $feed = 40; - $name = $this->getValueHtml($_item); + $name = $this->getValueHtml($childItem); } else { $feed = 35; - $name = $_item->getName(); + $name = $childItem->getName(); } $line[] = array( 'text' => $this->string->split($name, 35, true, true), @@ -132,7 +136,7 @@ class Invoice extends \Magento\Bundle\Model\Sales\Order\Pdf\Items\AbstractItems ); // draw SKUs - if (!$_item->getOrderItem()->getParentItem()) { + if (!$childItem->getOrderItem()->getParentItem()) { $text = array(); foreach ($this->string->split($item->getSku(), 17) as $part) { $text[] = $part; @@ -144,8 +148,8 @@ class Invoice extends \Magento\Bundle\Model\Sales\Order\Pdf\Items\AbstractItems } // draw prices - if ($this->canShowPriceInfo($_item)) { - $price = $order->formatPriceTxt($_item->getPrice()); + if ($this->canShowPriceInfo($childItem)) { + $price = $order->formatPriceTxt($childItem->getPrice()); $line[] = array( 'text' => $price, 'feed' => 395, @@ -153,12 +157,12 @@ class Invoice extends \Magento\Bundle\Model\Sales\Order\Pdf\Items\AbstractItems 'align' => 'right' ); $line[] = array( - 'text' => $_item->getQty()*1, + 'text' => $childItem->getQty() * 1, 'feed' => 435, 'font' => 'bold', ); - $tax = $order->formatPriceTxt($_item->getTaxAmount()); + $tax = $order->formatPriceTxt($childItem->getTaxAmount()); $line[] = array( 'text' => $tax, 'feed' => 495, @@ -166,7 +170,7 @@ class Invoice extends \Magento\Bundle\Model\Sales\Order\Pdf\Items\AbstractItems 'align' => 'right' ); - $row_total = $order->formatPriceTxt($_item->getRowTotal()); + $row_total = $order->formatPriceTxt($childItem->getRowTotal()); $line[] = array( 'text' => $row_total, 'feed' => 565, @@ -185,20 +189,25 @@ class Invoice extends \Magento\Bundle\Model\Sales\Order\Pdf\Items\AbstractItems foreach ($options['options'] as $option) { $lines = array(); $lines[][] = array( - 'text' => $this->string->split(strip_tags($option['label']), 40, true, true), + 'text' => $this->string->split( + $this->filterManager->stripTags($option['label']), + 40, + true, + true + ), 'font' => 'italic', 'feed' => 35 ); if ($option['value']) { $text = array(); - $_printValue = isset($option['print_value']) + $printValue = isset($option['print_value']) ? $option['print_value'] - : strip_tags($option['value']); - $values = explode(', ', $_printValue); + : $this->filterManager->stripTags($option['value']); + $values = explode(', ', $printValue); foreach ($values as $value) { - foreach ($this->string->split($value, 30, true, true) as $_value) { - $text[] = $_value; + foreach ($this->string->split($value, 30, true, true) as $subValue) { + $text[] = $subValue; } } diff --git a/app/code/Magento/Bundle/Model/Sales/Order/Pdf/Items/Shipment.php b/app/code/Magento/Bundle/Model/Sales/Order/Pdf/Items/Shipment.php index f2ef29591a763548e94b9b0e0b87cbb3d2494d64..68a3656f529fcd37fb431632e562cbd85d79d4e6 100644 --- a/app/code/Magento/Bundle/Model/Sales/Order/Pdf/Items/Shipment.php +++ b/app/code/Magento/Bundle/Model/Sales/Order/Pdf/Items/Shipment.php @@ -24,15 +24,11 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Bundle\Model\Sales\Order\Pdf\Items; + /** * Sales Order Shipment Pdf items renderer - * - * @category Magento - * @package Magento_Bundle - * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\Bundle\Model\Sales\Order\Pdf\Items; - class Shipment extends \Magento\Bundle\Model\Sales\Order\Pdf\Items\AbstractItems { /** @@ -45,6 +41,7 @@ class Shipment extends \Magento\Bundle\Model\Sales\Order\Pdf\Items\AbstractItems * @param \Magento\Core\Model\Registry $registry * @param \Magento\Tax\Helper\Data $taxData * @param \Magento\App\Filesystem $filesystem + * @param \Magento\Filter\FilterManager $filterManager * @param \Magento\Stdlib\String $string * @param \Magento\Core\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection @@ -55,18 +52,27 @@ class Shipment extends \Magento\Bundle\Model\Sales\Order\Pdf\Items\AbstractItems \Magento\Core\Model\Registry $registry, \Magento\Tax\Helper\Data $taxData, \Magento\App\Filesystem $filesystem, + \Magento\Filter\FilterManager $filterManager, \Magento\Stdlib\String $string, \Magento\Core\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { $this->string = $string; - parent::__construct($context, $registry, $taxData, $filesystem, $resource, $resourceCollection, $data); + parent::__construct( + $context, + $registry, + $taxData, + $filesystem, + $filterManager, + $resource, + $resourceCollection, + $data + ); } /** * Draw item line - * */ public function draw() { @@ -79,17 +85,16 @@ class Shipment extends \Magento\Bundle\Model\Sales\Order\Pdf\Items\AbstractItems $shipItems = $this->getChilds($item); $items = array_merge(array($item->getOrderItem()), $item->getOrderItem()->getChildrenItems()); - $_prevOptionId = ''; + $prevOptionId = ''; $drawItems = array(); - foreach ($items as $_item) { + foreach ($items as $childItem) { $line = array(); - $attributes = $this->getSelectionAttributes($_item); + $attributes = $this->getSelectionAttributes($childItem); if (is_array($attributes)) { $optionId = $attributes['option_id']; - } - else { + } else { $optionId = 0; } @@ -100,8 +105,8 @@ class Shipment extends \Magento\Bundle\Model\Sales\Order\Pdf\Items\AbstractItems ); } - if ($_item->getParentItem()) { - if ($_prevOptionId != $attributes['option_id']) { + if ($childItem->getParentItem()) { + if ($prevOptionId != $attributes['option_id']) { $line[0] = array( 'font' => 'italic', 'text' => $this->string->split($attributes['option_label'], 60, true, true), @@ -115,16 +120,16 @@ class Shipment extends \Magento\Bundle\Model\Sales\Order\Pdf\Items\AbstractItems $line = array(); - $_prevOptionId = $attributes['option_id']; + $prevOptionId = $attributes['option_id']; } } - if (($this->isShipmentSeparately() && $_item->getParentItem()) - || (!$this->isShipmentSeparately() && !$_item->getParentItem()) + if (($this->isShipmentSeparately() && $childItem->getParentItem()) + || (!$this->isShipmentSeparately() && !$childItem->getParentItem()) ) { - if (isset($shipItems[$_item->getId()])) { - $qty = $shipItems[$_item->getId()]->getQty()*1; - } else if ($_item->getIsVirtual()) { + if (isset($shipItems[$childItem->getId()])) { + $qty = $shipItems[$childItem->getId()]->getQty() * 1; + } elseif ($childItem->getIsVirtual()) { $qty = __('N/A'); } else { $qty = 0; @@ -139,12 +144,12 @@ class Shipment extends \Magento\Bundle\Model\Sales\Order\Pdf\Items\AbstractItems ); // draw Name - if ($_item->getParentItem()) { + if ($childItem->getParentItem()) { $feed = 65; - $name = $this->getValueHtml($_item); + $name = $this->getValueHtml($childItem); } else { $feed = 60; - $name = $_item->getName(); + $name = $childItem->getName(); } $text = array(); foreach ($this->string->split($name, 60, true, true) as $part) { @@ -157,7 +162,7 @@ class Shipment extends \Magento\Bundle\Model\Sales\Order\Pdf\Items\AbstractItems // draw SKUs $text = array(); - foreach ($this->string->split($_item->getSku(), 25) as $part) { + foreach ($this->string->split($childItem->getSku(), 25) as $part) { $text[] = $part; } $line[] = array( @@ -175,20 +180,25 @@ class Shipment extends \Magento\Bundle\Model\Sales\Order\Pdf\Items\AbstractItems foreach ($options['options'] as $option) { $lines = array(); $lines[][] = array( - 'text' => $this->string->split(strip_tags($option['label']), 70, true, true), + 'text' => $this->string->split( + $this->filterManager->stripTags($option['label']), + 70, + true, + true + ), 'font' => 'italic', 'feed' => 60 ); if ($option['value']) { $text = array(); - $_printValue = isset($option['print_value']) + $printValue = isset($option['print_value']) ? $option['print_value'] - : strip_tags($option['value']); - $values = explode(', ', $_printValue); + : $this->filterManager->stripTags($option['value']); + $values = explode(', ', $printValue); foreach ($values as $value) { - foreach ($this->string->split($value, 50, true, true) as $_value) { - $text[] = $_value; + foreach ($this->string->split($value, 50, true, true) as $subValue) { + $text[] = $subValue; } } diff --git a/app/code/Magento/Bundle/etc/adminhtml/di.xml b/app/code/Magento/Bundle/etc/adminhtml/di.xml index 47e2e147f448d7cdf4e8c3661a98834e807b1bb9..5c9770590a68fdf655f1beafe02a44e697f5f7a1 100644 --- a/app/code/Magento/Bundle/etc/adminhtml/di.xml +++ b/app/code/Magento/Bundle/etc/adminhtml/di.xml @@ -32,9 +32,16 @@ </type> <type name="Magento\Catalog\Model\Product\CopyConstructor\Composite"> <param name="constructors"> - <value> - <bundle>Magento\Bundle\Model\Product\CopyConstructor\Bundle</bundle> - </value> + <array> + <item key="bundle"><value>Magento\Bundle\Model\Product\CopyConstructor\Bundle</value></item> + </array> + </param> + </type> + <type name="Magento\CatalogInventory\Block\Adminhtml\Form\Field\Stock"> + <param name="complexProductTypes"> + <array> + <item key="bundle"><value type="const">Magento\Catalog\Model\Product\Type::TYPE_BUNDLE</value></item> + </array> </param> </type> </config> diff --git a/app/code/Magento/Bundle/etc/di.xml b/app/code/Magento/Bundle/etc/di.xml index 4525ce62cd50fcb1d4a3a391e2a45bf7f60552f9..4c3acec63c1f06accf5a856cbd7f276039e92d5f 100644 --- a/app/code/Magento/Bundle/etc/di.xml +++ b/app/code/Magento/Bundle/etc/di.xml @@ -26,19 +26,26 @@ <config> <type name="Magento\Bundle\Model\Source\Option\Type"> <param name="options"> - <value> - <select>Drop-down</select> - <radio>Radio Buttons</radio> - <checkbox>Checkbox</checkbox> - <multi>Multiple Select</multi> - </value> + <array> + <item key="select"><value>Drop-down</value></item> + <item key="radio"><value>Radio Buttons</value></item> + <item key="checkbox"><value>Checkbox</value></item> + <item key="multi"><value>Multiple Select</value></item> + </array> </param> </type> <type name="Magento\Module\Updater\SetupFactory"> <param name="resourceTypes"> - <value> - <bundle_setup>Magento\Catalog\Model\Resource\Setup</bundle_setup> - </value> + <array> + <item key="bundle_setup"><value>Magento\Catalog\Model\Resource\Setup</value></item> + </array> + </param> + </type> + <type name="Magento\Catalog\Model\Product\CatalogPrice"> + <param name="priceModelPool"> + <array> + <item key="bundle"><value>Magento\Bundle\Model\Product\CatalogPrice</value></item> + </array> </param> </type> </config> diff --git a/app/code/Magento/Bundle/etc/module.xml b/app/code/Magento/Bundle/etc/module.xml index f137dc77683f2b8a4d1e90fb05530dbbf9f1a9b4..725e8ad266a98a2b4c4b3fe90c0c91842c26f0e3 100755 --- a/app/code/Magento/Bundle/etc/module.xml +++ b/app/code/Magento/Bundle/etc/module.xml @@ -43,7 +43,6 @@ <module name="Magento_GiftMessage"/> <module name="Magento_Theme"/> <module name="Magento_Wishlist"/> - <module name="Magento_Multishipping" type="soft"/> </depends> </module> </config> diff --git a/app/code/Magento/Bundle/etc/product_types.xml b/app/code/Magento/Bundle/etc/product_types.xml index 484fb77f110f50dc0a7812332cd14303fdd38483..5afd7b68e6798640f0b449cc231d1eecf77049b8 100644 --- a/app/code/Magento/Bundle/etc/product_types.xml +++ b/app/code/Magento/Bundle/etc/product_types.xml @@ -32,5 +32,8 @@ <type name="simple" /> <type name="virtual" /> </allowedSelectionTypes> + <customAttributes> + <attribute name="refundable" value="true"/> + </customAttributes> </type> </config> diff --git a/app/code/Magento/Bundle/view/frontend/layout/catalog_product_rss_feed_renderer_list.xml b/app/code/Magento/Bundle/view/frontend/layout/catalog_product_rss_feed_renderer_list.xml new file mode 100644 index 0000000000000000000000000000000000000000..736c975003722f21552d3d227f89f7ff0be22706 --- /dev/null +++ b/app/code/Magento/Bundle/view/frontend/layout/catalog_product_rss_feed_renderer_list.xml @@ -0,0 +1,30 @@ +<?xml version="1.0"?> +<!-- +/** + * 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) + */ +--> +<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <referenceBlock name="catalog.product.rss.feed.renderer.list"> + <block class="Magento\Bundle\Block\Catalog\Product\Price" as="bundle" template="rss/catalog/product/price.phtml" /> + </referenceBlock> +</layout> diff --git a/app/code/Magento/Bundle/view/frontend/layout/checkout_cart_index.xml b/app/code/Magento/Bundle/view/frontend/layout/checkout_cart_index.xml index df2305b67233b93f6d0e0074e7d24a188e5f3f21..429929d32a17ede505a47005a37d06c37c8ba2ab 100644 --- a/app/code/Magento/Bundle/view/frontend/layout/checkout_cart_index.xml +++ b/app/code/Magento/Bundle/view/frontend/layout/checkout_cart_index.xml @@ -24,9 +24,6 @@ */ --> <layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> - <referenceBlock name="checkout.cart.form"> - <block class="Magento\Bundle\Block\Checkout\Cart\Item\Renderer" as="bundle" template="Magento_Checkout::cart/item/default.phtml" cacheable="false"/> - </referenceBlock> <referenceBlock name="checkout.cart.crosssell"> <action method="addPriceBlockType"> <argument name="type" xsi:type="string">bundle</argument> diff --git a/app/code/Magento/Bundle/view/frontend/layout/multishipping_checkout_addresses.xml b/app/code/Magento/Bundle/view/frontend/layout/checkout_cart_item_renderers.xml similarity index 88% rename from app/code/Magento/Bundle/view/frontend/layout/multishipping_checkout_addresses.xml rename to app/code/Magento/Bundle/view/frontend/layout/checkout_cart_item_renderers.xml index 784a79eab627df1f671d5ba7b445d49520008200..a73407879fd1a44154a4fcf098f7ad72cc755a78 100644 --- a/app/code/Magento/Bundle/view/frontend/layout/multishipping_checkout_addresses.xml +++ b/app/code/Magento/Bundle/view/frontend/layout/checkout_cart_item_renderers.xml @@ -24,7 +24,7 @@ */ --> <layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> - <referenceBlock name="checkout_addresses"> - <block class="Magento\Bundle\Block\Checkout\Cart\Item\Renderer" as="bundle" template="Magento_Multishipping::checkout/item/default.phtml" cacheable="false"/> + <referenceBlock name="checkout.cart.item.renderers"> + <block class="Magento\Bundle\Block\Checkout\Cart\Item\Renderer" as="bundle" template="Magento_Checkout::cart/item/default.phtml" cacheable="false"/> </referenceBlock> </layout> diff --git a/app/code/Magento/Bundle/view/frontend/layout/multishipping_checkout_overview.xml b/app/code/Magento/Bundle/view/frontend/layout/checkout_cart_sidebar_item_renderers.xml similarity index 87% rename from app/code/Magento/Bundle/view/frontend/layout/multishipping_checkout_overview.xml rename to app/code/Magento/Bundle/view/frontend/layout/checkout_cart_sidebar_item_renderers.xml index 3c03cba7a9207ff8090b9219cb67ccb070477371..1412ba97b3362224adcb3cf479bd9e3ce1d8cc5f 100644 --- a/app/code/Magento/Bundle/view/frontend/layout/multishipping_checkout_overview.xml +++ b/app/code/Magento/Bundle/view/frontend/layout/checkout_cart_sidebar_item_renderers.xml @@ -24,7 +24,7 @@ */ --> <layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> - <referenceBlock name="checkout_overview"> - <block class="Magento\Bundle\Block\Checkout\Cart\Item\Renderer" as="bundle" template="Magento_Multishipping::checkout/item/default.phtml" cacheable="false"/> + <referenceBlock name="checkout.cart.sidebar.item.renderers"> + <block class="Magento\Bundle\Block\Checkout\Cart\Item\Renderer" as="bundle" template="Magento_Checkout::cart/sidebar/default.phtml" cacheable="false"/> </referenceBlock> </layout> diff --git a/app/code/Magento/Bundle/view/frontend/layout/checkout_onepage_review.xml b/app/code/Magento/Bundle/view/frontend/layout/checkout_onepage_review_item_renderers.xml similarity index 94% rename from app/code/Magento/Bundle/view/frontend/layout/checkout_onepage_review.xml rename to app/code/Magento/Bundle/view/frontend/layout/checkout_onepage_review_item_renderers.xml index 10b6e9f7103f56afa41ab9e3eac1085a74237514..53bc55d854ced6a286f4115fe7bdd1769d7dbf29 100644 --- a/app/code/Magento/Bundle/view/frontend/layout/checkout_onepage_review.xml +++ b/app/code/Magento/Bundle/view/frontend/layout/checkout_onepage_review_item_renderers.xml @@ -24,7 +24,7 @@ */ --> <layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> - <referenceBlock name="order_review"> + <referenceBlock name="checkout.onepage.review.item.renderers"> <block class="Magento\Bundle\Block\Checkout\Cart\Item\Renderer" as="bundle" template="Magento_Checkout::onepage/review/item.phtml" cacheable="false"/> </referenceBlock> </layout> diff --git a/app/code/Magento/Bundle/view/frontend/layout/default.xml b/app/code/Magento/Bundle/view/frontend/layout/default.xml index 13ff3855a5e7a1cb508e416af32fa99027cbc3a3..f21db31f3fb6ceee4a2424c66df2ee7a7f51666a 100644 --- a/app/code/Magento/Bundle/view/frontend/layout/default.xml +++ b/app/code/Magento/Bundle/view/frontend/layout/default.xml @@ -38,7 +38,4 @@ <argument name="template" xsi:type="string">catalog/product/price.phtml</argument> </action> </referenceBlock> - <referenceBlock name="minicart"> - <block class="Magento\Bundle\Block\Checkout\Cart\Item\Renderer" as="bundle" template="Magento_Checkout::cart/sidebar/default.phtml" cacheable="false"/> - </referenceBlock> </layout> diff --git a/app/code/Magento/Bundle/view/frontend/layout/paypal_express_review_details.xml b/app/code/Magento/Bundle/view/frontend/layout/paypal_express_review_details.xml deleted file mode 100644 index 657757e4e4a6d5a803e36f73c61c8b0f1b5d6ea2..0000000000000000000000000000000000000000 --- a/app/code/Magento/Bundle/view/frontend/layout/paypal_express_review_details.xml +++ /dev/null @@ -1,30 +0,0 @@ -<?xml version="1.0"?> -<!-- -/** - * 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) - */ ---> -<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> - <referenceBlock name="paypal.express.review.details"> - <block class="Magento\Bundle\Block\Checkout\Cart\Item\Renderer" as="bundle" template="Magento_Checkout::onepage/review/item.phtml" cacheable="false"/> - </referenceBlock> -</layout> diff --git a/app/code/Magento/Bundle/view/frontend/layout/paypaluk_express_review.xml b/app/code/Magento/Bundle/view/frontend/layout/paypaluk_express_review.xml deleted file mode 100644 index 657757e4e4a6d5a803e36f73c61c8b0f1b5d6ea2..0000000000000000000000000000000000000000 --- a/app/code/Magento/Bundle/view/frontend/layout/paypaluk_express_review.xml +++ /dev/null @@ -1,30 +0,0 @@ -<?xml version="1.0"?> -<!-- -/** - * 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) - */ ---> -<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> - <referenceBlock name="paypal.express.review.details"> - <block class="Magento\Bundle\Block\Checkout\Cart\Item\Renderer" as="bundle" template="Magento_Checkout::onepage/review/item.phtml" cacheable="false"/> - </referenceBlock> -</layout> diff --git a/app/code/Magento/Bundle/view/frontend/layout/rss_catalog_category.xml b/app/code/Magento/Bundle/view/frontend/layout/rss_catalog_category.xml deleted file mode 100644 index d89e84903bd939620503f5e9c544be50a81645ad..0000000000000000000000000000000000000000 --- a/app/code/Magento/Bundle/view/frontend/layout/rss_catalog_category.xml +++ /dev/null @@ -1,34 +0,0 @@ -<?xml version="1.0"?> -<!-- -/** - * 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) - */ ---> -<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> - <referenceBlock name="rss.catalog.category"> - <action method="addPriceBlockType"> - <argument name="type" xsi:type="string">bundle</argument> - <argument name="block" xsi:type="string">Magento\Bundle\Block\Catalog\Product\Price</argument> - <argument name="template" xsi:type="string">rss/catalog/product/price.phtml</argument> - </action> - </referenceBlock> -</layout> diff --git a/app/code/Magento/Bundle/view/frontend/layout/rss_catalog_new.xml b/app/code/Magento/Bundle/view/frontend/layout/rss_catalog_new.xml deleted file mode 100644 index 397549add09539754d22932b5580f945a63033a2..0000000000000000000000000000000000000000 --- a/app/code/Magento/Bundle/view/frontend/layout/rss_catalog_new.xml +++ /dev/null @@ -1,34 +0,0 @@ -<?xml version="1.0"?> -<!-- -/** - * 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) - */ ---> -<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> - <referenceBlock name="rss.catalog.new"> - <action method="addPriceBlockType"> - <argument name="type" xsi:type="string">bundle</argument> - <argument name="block" xsi:type="string">Magento\Bundle\Block\Catalog\Product\Price</argument> - <argument name="template" xsi:type="string">rss/catalog/product/price.phtml</argument> - </action> - </referenceBlock> -</layout> diff --git a/app/code/Magento/Bundle/view/frontend/layout/sales_email_order_creditmemo_items.xml b/app/code/Magento/Bundle/view/frontend/layout/sales_email_order_creditmemo_renderers.xml similarity index 94% rename from app/code/Magento/Bundle/view/frontend/layout/sales_email_order_creditmemo_items.xml rename to app/code/Magento/Bundle/view/frontend/layout/sales_email_order_creditmemo_renderers.xml index 604bef30a51f27cf6ef278cedd0a2bf5d9401f50..b45c2c8e5a54c23437179635fa60716807a42ee1 100644 --- a/app/code/Magento/Bundle/view/frontend/layout/sales_email_order_creditmemo_items.xml +++ b/app/code/Magento/Bundle/view/frontend/layout/sales_email_order_creditmemo_renderers.xml @@ -24,7 +24,7 @@ */ --> <layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> - <referenceBlock name="items"> + <referenceBlock name="sales.email.order.creditmemo.renderers"> <block class="Magento\Bundle\Block\Sales\Order\Items\Renderer" as="bundle" template="email/order/items/creditmemo/default.phtml"/> </referenceBlock> </layout> diff --git a/app/code/Magento/Bundle/view/frontend/layout/sales_email_order_invoice_items.xml b/app/code/Magento/Bundle/view/frontend/layout/sales_email_order_invoice_renderers.xml similarity index 94% rename from app/code/Magento/Bundle/view/frontend/layout/sales_email_order_invoice_items.xml rename to app/code/Magento/Bundle/view/frontend/layout/sales_email_order_invoice_renderers.xml index 0749c879c7f016eb24a5d4af602e388e774a5b7a..8222fbf4a89007b6e4370c1bdc6233fa02fd2f5f 100644 --- a/app/code/Magento/Bundle/view/frontend/layout/sales_email_order_invoice_items.xml +++ b/app/code/Magento/Bundle/view/frontend/layout/sales_email_order_invoice_renderers.xml @@ -24,7 +24,7 @@ */ --> <layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> - <referenceBlock name="items"> + <referenceBlock name="sales.email.order.invoice.renderers"> <block class="Magento\Bundle\Block\Sales\Order\Items\Renderer" as="bundle" template="email/order/items/invoice/default.phtml"/> </referenceBlock> </layout> diff --git a/app/code/Magento/Bundle/view/frontend/layout/sales_email_order_items.xml b/app/code/Magento/Bundle/view/frontend/layout/sales_email_order_renderers.xml similarity index 95% rename from app/code/Magento/Bundle/view/frontend/layout/sales_email_order_items.xml rename to app/code/Magento/Bundle/view/frontend/layout/sales_email_order_renderers.xml index 55ce7a7e0a752703c054dd5c4a58040cc6f6c611..b7ca647029f26da6e2ff90f6fc03cf10aad4508a 100644 --- a/app/code/Magento/Bundle/view/frontend/layout/sales_email_order_items.xml +++ b/app/code/Magento/Bundle/view/frontend/layout/sales_email_order_renderers.xml @@ -24,7 +24,7 @@ */ --> <layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> - <referenceBlock name="items"> + <referenceBlock name="sales.email.order.renderers"> <block class="Magento\Bundle\Block\Sales\Order\Items\Renderer" as="bundle" template="email/order/items/order/default.phtml"/> </referenceBlock> </layout> diff --git a/app/code/Magento/Bundle/view/frontend/layout/sales_email_order_shipment_items.xml b/app/code/Magento/Bundle/view/frontend/layout/sales_email_order_shipment_renderers.xml similarity index 94% rename from app/code/Magento/Bundle/view/frontend/layout/sales_email_order_shipment_items.xml rename to app/code/Magento/Bundle/view/frontend/layout/sales_email_order_shipment_renderers.xml index 39d1d6cf39498ebaba871fe3e6771fc2e710d733..3300fad73fe6269fe287344d7f2fc3e7efaab38f 100644 --- a/app/code/Magento/Bundle/view/frontend/layout/sales_email_order_shipment_items.xml +++ b/app/code/Magento/Bundle/view/frontend/layout/sales_email_order_shipment_renderers.xml @@ -24,7 +24,7 @@ */ --> <layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> - <referenceBlock name="items"> + <referenceBlock name="sales.email.order.shipment.renderers"> <block class="Magento\Bundle\Block\Sales\Order\Items\Renderer" as="bundle" template="email/order/items/shipment/default.phtml"/> </referenceBlock> </layout> diff --git a/app/code/Magento/Bundle/view/frontend/layout/sales_guest_creditmemo.xml b/app/code/Magento/Bundle/view/frontend/layout/sales_order_creditmemo_renderers.xml similarity index 95% rename from app/code/Magento/Bundle/view/frontend/layout/sales_guest_creditmemo.xml rename to app/code/Magento/Bundle/view/frontend/layout/sales_order_creditmemo_renderers.xml index 0de2252d1d8d4f4f2dce88fb6faa775b3b2f8e99..bf0677f8696120f3b695c634de713b66db5a75de 100644 --- a/app/code/Magento/Bundle/view/frontend/layout/sales_guest_creditmemo.xml +++ b/app/code/Magento/Bundle/view/frontend/layout/sales_order_creditmemo_renderers.xml @@ -24,7 +24,7 @@ */ --> <layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> - <referenceBlock name="creditmemo_items"> + <referenceBlock name="sales.order.creditmemo.renderers"> <block class="Magento\Bundle\Block\Sales\Order\Items\Renderer" as="bundle" template="sales/order/creditmemo/items/renderer.phtml"/> </referenceBlock> </layout> diff --git a/app/code/Magento/Bundle/view/frontend/layout/sales_guest_invoice.xml b/app/code/Magento/Bundle/view/frontend/layout/sales_order_invoice_renderers.xml similarity index 95% rename from app/code/Magento/Bundle/view/frontend/layout/sales_guest_invoice.xml rename to app/code/Magento/Bundle/view/frontend/layout/sales_order_invoice_renderers.xml index 861baa1c1087f9f748001b0b099acbdbfa1349fc..6a1ac057b5900a03b56efd6dac375c6a6f54b5ab 100644 --- a/app/code/Magento/Bundle/view/frontend/layout/sales_guest_invoice.xml +++ b/app/code/Magento/Bundle/view/frontend/layout/sales_order_invoice_renderers.xml @@ -24,7 +24,7 @@ */ --> <layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> - <referenceBlock name="invoice_items"> + <referenceBlock name="sales.order.invoice.renderers"> <block class="Magento\Bundle\Block\Sales\Order\Items\Renderer" as="bundle" template="sales/order/invoice/items/renderer.phtml"/> </referenceBlock> </layout> diff --git a/app/code/Magento/Bundle/view/frontend/layout/sales_guest_printorder.xml b/app/code/Magento/Bundle/view/frontend/layout/sales_order_item_renderers.xml similarity index 95% rename from app/code/Magento/Bundle/view/frontend/layout/sales_guest_printorder.xml rename to app/code/Magento/Bundle/view/frontend/layout/sales_order_item_renderers.xml index bea81de24d9742052a68b02145956393f579c329..f81b5292bd38cac6ff20042824afe6e890842a13 100644 --- a/app/code/Magento/Bundle/view/frontend/layout/sales_guest_printorder.xml +++ b/app/code/Magento/Bundle/view/frontend/layout/sales_order_item_renderers.xml @@ -24,7 +24,7 @@ */ --> <layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> - <referenceBlock name="sales.order.print"> + <referenceBlock name="sales.order.items.renderers"> <block class="Magento\Bundle\Block\Sales\Order\Items\Renderer" as="bundle" template="sales/order/items/renderer.phtml"/> </referenceBlock> </layout> diff --git a/app/code/Magento/Bundle/view/frontend/layout/sales_guest_printordercreditmemo.xml b/app/code/Magento/Bundle/view/frontend/layout/sales_order_print_creditmemo_renderers.xml similarity index 94% rename from app/code/Magento/Bundle/view/frontend/layout/sales_guest_printordercreditmemo.xml rename to app/code/Magento/Bundle/view/frontend/layout/sales_order_print_creditmemo_renderers.xml index 69041a6c1f4f23661723a5c13cf786c2e25c2bd4..546983ccff300d917600aa0217ddf9d9e7761075 100644 --- a/app/code/Magento/Bundle/view/frontend/layout/sales_guest_printordercreditmemo.xml +++ b/app/code/Magento/Bundle/view/frontend/layout/sales_order_print_creditmemo_renderers.xml @@ -24,7 +24,7 @@ */ --> <layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> - <referenceBlock name="sales.order.print.creditmemo"> + <referenceBlock name="sales.order.print.creditmemo.renderers"> <block class="Magento\Bundle\Block\Sales\Order\Items\Renderer" as="bundle" template="sales/order/creditmemo/items/renderer.phtml"/> </referenceBlock> </layout> diff --git a/app/code/Magento/Bundle/view/frontend/layout/sales_guest_printorderinvoice.xml b/app/code/Magento/Bundle/view/frontend/layout/sales_order_print_invoice_renderers.xml similarity index 94% rename from app/code/Magento/Bundle/view/frontend/layout/sales_guest_printorderinvoice.xml rename to app/code/Magento/Bundle/view/frontend/layout/sales_order_print_invoice_renderers.xml index 09224f79e5a1a1be14f49bdb937ad8a1bc57c96d..b99bf71820d1e50913073059055d681ed89afb24 100644 --- a/app/code/Magento/Bundle/view/frontend/layout/sales_guest_printorderinvoice.xml +++ b/app/code/Magento/Bundle/view/frontend/layout/sales_order_print_invoice_renderers.xml @@ -24,7 +24,7 @@ */ --> <layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> - <referenceBlock name="sales.order.print.invoice"> + <referenceBlock name="sales.order.print.invoice.renderers"> <block class="Magento\Bundle\Block\Sales\Order\Items\Renderer" as="bundle" template="sales/order/invoice/items/renderer.phtml"/> </referenceBlock> </layout> diff --git a/app/code/Magento/Bundle/view/frontend/layout/sales_guest_view.xml b/app/code/Magento/Bundle/view/frontend/layout/sales_order_print_renderers.xml similarity index 95% rename from app/code/Magento/Bundle/view/frontend/layout/sales_guest_view.xml rename to app/code/Magento/Bundle/view/frontend/layout/sales_order_print_renderers.xml index 22abd2c96402d60708556d98b67914009d476d7d..528cda12b35e8884cfc6bed6658bbb6e756f18b0 100644 --- a/app/code/Magento/Bundle/view/frontend/layout/sales_guest_view.xml +++ b/app/code/Magento/Bundle/view/frontend/layout/sales_order_print_renderers.xml @@ -24,7 +24,7 @@ */ --> <layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> - <referenceBlock name="order_items"> + <referenceBlock name="sales.order.print.renderers"> <block class="Magento\Bundle\Block\Sales\Order\Items\Renderer" as="bundle" template="sales/order/items/renderer.phtml"/> </referenceBlock> </layout> diff --git a/app/code/Magento/Bundle/view/frontend/layout/sales_order_printordershipment.xml b/app/code/Magento/Bundle/view/frontend/layout/sales_order_print_shipment_renderers.xml similarity index 94% rename from app/code/Magento/Bundle/view/frontend/layout/sales_order_printordershipment.xml rename to app/code/Magento/Bundle/view/frontend/layout/sales_order_print_shipment_renderers.xml index 47f834decd5b8fe2459f6d4f686f56e6c0713cb2..d989534dd02acc72504af1f4aa6a6e3bb8850d16 100644 --- a/app/code/Magento/Bundle/view/frontend/layout/sales_order_printordershipment.xml +++ b/app/code/Magento/Bundle/view/frontend/layout/sales_order_print_shipment_renderers.xml @@ -24,7 +24,7 @@ */ --> <layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> - <referenceBlock name="sales.order.print.shipment"> + <referenceBlock name="sales.order.print.shipment.renderers"> <block class="Magento\Bundle\Block\Sales\Order\Items\Renderer" as="bundle" template="sales/order/shipment/items/renderer.phtml"/> </referenceBlock> </layout> diff --git a/app/code/Magento/Bundle/view/frontend/layout/sales_order_printordercreditmemo.xml b/app/code/Magento/Bundle/view/frontend/layout/sales_order_printordercreditmemo.xml deleted file mode 100644 index 69041a6c1f4f23661723a5c13cf786c2e25c2bd4..0000000000000000000000000000000000000000 --- a/app/code/Magento/Bundle/view/frontend/layout/sales_order_printordercreditmemo.xml +++ /dev/null @@ -1,30 +0,0 @@ -<?xml version="1.0"?> -<!-- -/** - * 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) - */ ---> -<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> - <referenceBlock name="sales.order.print.creditmemo"> - <block class="Magento\Bundle\Block\Sales\Order\Items\Renderer" as="bundle" template="sales/order/creditmemo/items/renderer.phtml"/> - </referenceBlock> -</layout> diff --git a/app/code/Magento/Bundle/view/frontend/layout/sales_order_printorderinvoice.xml b/app/code/Magento/Bundle/view/frontend/layout/sales_order_printorderinvoice.xml deleted file mode 100644 index 09224f79e5a1a1be14f49bdb937ad8a1bc57c96d..0000000000000000000000000000000000000000 --- a/app/code/Magento/Bundle/view/frontend/layout/sales_order_printorderinvoice.xml +++ /dev/null @@ -1,30 +0,0 @@ -<?xml version="1.0"?> -<!-- -/** - * 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) - */ ---> -<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> - <referenceBlock name="sales.order.print.invoice"> - <block class="Magento\Bundle\Block\Sales\Order\Items\Renderer" as="bundle" template="sales/order/invoice/items/renderer.phtml"/> - </referenceBlock> -</layout> diff --git a/app/code/Magento/Bundle/view/frontend/layout/sales_order_shipment.xml b/app/code/Magento/Bundle/view/frontend/layout/sales_order_shipment.xml deleted file mode 100644 index d34a37f904840f4b2c8932aff3c1530eee0eb824..0000000000000000000000000000000000000000 --- a/app/code/Magento/Bundle/view/frontend/layout/sales_order_shipment.xml +++ /dev/null @@ -1,30 +0,0 @@ -<?xml version="1.0"?> -<!-- -/** - * 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) - */ ---> -<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> - <referenceBlock name="shipment_items"> - <block class="Magento\Bundle\Block\Sales\Order\Items\Renderer" as="bundle" template="sales/order/shipment/items/renderer.phtml"/> - </referenceBlock> -</layout> diff --git a/app/code/Magento/Bundle/view/frontend/layout/sales_guest_printordershipment.xml b/app/code/Magento/Bundle/view/frontend/layout/sales_order_shipment_renderers.xml similarity index 95% rename from app/code/Magento/Bundle/view/frontend/layout/sales_guest_printordershipment.xml rename to app/code/Magento/Bundle/view/frontend/layout/sales_order_shipment_renderers.xml index 47f834decd5b8fe2459f6d4f686f56e6c0713cb2..6d2b5fa72ad46e5bed5620f902f60948b7b3c65e 100644 --- a/app/code/Magento/Bundle/view/frontend/layout/sales_guest_printordershipment.xml +++ b/app/code/Magento/Bundle/view/frontend/layout/sales_order_shipment_renderers.xml @@ -24,7 +24,7 @@ */ --> <layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> - <referenceBlock name="sales.order.print.shipment"> + <referenceBlock name="sales.order.shipment.renderers"> <block class="Magento\Bundle\Block\Sales\Order\Items\Renderer" as="bundle" template="sales/order/shipment/items/renderer.phtml"/> </referenceBlock> </layout> diff --git a/app/code/Magento/Captcha/Block/Adminhtml/Captcha/DefaultCaptcha.php b/app/code/Magento/Captcha/Block/Adminhtml/Captcha/DefaultCaptcha.php index a2029d23116600b757f110b64c660408294bc6ad..b36e27063bc86ba2f057f826309e54a5feea5160 100644 --- a/app/code/Magento/Captcha/Block/Adminhtml/Captcha/DefaultCaptcha.php +++ b/app/code/Magento/Captcha/Block/Adminhtml/Captcha/DefaultCaptcha.php @@ -36,7 +36,7 @@ namespace Magento\Captcha\Block\Adminhtml\Captcha; class DefaultCaptcha extends \Magento\Captcha\Block\Captcha\DefaultCaptcha { /** - * @var \Magento\Backend\Model\Url + * @var \Magento\Backend\Model\UrlInterface */ protected $_url; @@ -48,14 +48,14 @@ class DefaultCaptcha extends \Magento\Captcha\Block\Captcha\DefaultCaptcha /** * @param \Magento\View\Element\Template\Context $context * @param \Magento\Captcha\Helper\Data $captchaData - * @param \Magento\Backend\Model\Url $url + * @param \Magento\Backend\Model\UrlInterface $url * @param \Magento\Backend\App\ConfigInterface $config * @param array $data */ public function __construct( \Magento\View\Element\Template\Context $context, \Magento\Captcha\Helper\Data $captchaData, - \Magento\Backend\Model\Url $url, + \Magento\Backend\Model\UrlInterface $url, \Magento\Backend\App\ConfigInterface $config, array $data = array() ) { @@ -73,7 +73,7 @@ class DefaultCaptcha extends \Magento\Captcha\Block\Captcha\DefaultCaptcha public function getRefreshUrl() { return $this->_url->getUrl('adminhtml/refresh/refresh', array( - '_secure' => $this->_config->getFlag('web/secure/use_in_adminhtml'), + '_secure' => $this->_config->isSetFlag('web/secure/use_in_adminhtml'), '_nosecret' => true )); } diff --git a/app/code/Magento/Captcha/Helper/Adminhtml/Data.php b/app/code/Magento/Captcha/Helper/Adminhtml/Data.php index 4c94651463a5a08f69c6e6dcfc39dd7f0a7f0122..7911475bce1d18f0362a17c09404ad109e00e7f5 100644 --- a/app/code/Magento/Captcha/Helper/Adminhtml/Data.php +++ b/app/code/Magento/Captcha/Helper/Adminhtml/Data.php @@ -43,7 +43,7 @@ class Data extends \Magento\Captcha\Helper\Data /** * @param \Magento\App\Helper\Context $context * @param \Magento\Core\Model\StoreManager $storeManager - * @param \Magento\Core\Model\Config $config + * @param \Magento\App\ConfigInterface $config * @param \Magento\App\Filesystem $filesystem * @param \Magento\Captcha\Model\CaptchaFactory $factory * @param \Magento\Backend\App\ConfigInterface $backendConfig @@ -51,7 +51,7 @@ class Data extends \Magento\Captcha\Helper\Data public function __construct( \Magento\App\Helper\Context $context, \Magento\Core\Model\StoreManager $storeManager, - \Magento\Core\Model\Config $config, + \Magento\App\ConfigInterface $config, \Magento\App\Filesystem $filesystem, \Magento\Captcha\Model\CaptchaFactory $factory, \Magento\Backend\App\ConfigInterface $backendConfig diff --git a/app/code/Magento/Captcha/Helper/Data.php b/app/code/Magento/Captcha/Helper/Data.php index 60738374319140454117bfcf80ddfce6493ad805..debcddc06ea24b44d590b392d77397abbd6ef97e 100644 --- a/app/code/Magento/Captcha/Helper/Data.php +++ b/app/code/Magento/Captcha/Helper/Data.php @@ -63,7 +63,7 @@ class Data extends \Magento\App\Helper\AbstractHelper protected $_captcha = array(); /** - * @var \Magento\Core\Model\Config + * @var \Magento\App\ConfigInterface */ protected $_config; @@ -85,14 +85,14 @@ class Data extends \Magento\App\Helper\AbstractHelper /** * @param \Magento\App\Helper\Context $context * @param \Magento\Core\Model\StoreManagerInterface $storeManager - * @param \Magento\Core\Model\Config $config + * @param \Magento\App\ConfigInterface $config * @param \Magento\App\Filesystem $filesystem * @param \Magento\Captcha\Model\CaptchaFactory $factory */ public function __construct( \Magento\App\Helper\Context $context, \Magento\Core\Model\StoreManagerInterface $storeManager, - \Magento\Core\Model\Config $config, + \Magento\App\ConfigInterface $config, \Magento\App\Filesystem $filesystem, \Magento\Captcha\Model\CaptchaFactory $factory ) { diff --git a/app/code/Magento/Captcha/Model/Observer.php b/app/code/Magento/Captcha/Model/Observer.php index 9c5858995981a7059308728d70de90f29d942388..1d4ae616c716a35e7ac9ad3e26924f54b936e8eb 100644 --- a/app/code/Magento/Captcha/Model/Observer.php +++ b/app/code/Magento/Captcha/Model/Observer.php @@ -45,7 +45,7 @@ class Observer /** * URL manager * - * @var \Magento\Core\Model\Url + * @var \Magento\UrlInterface */ protected $_urlManager; @@ -105,7 +105,7 @@ class Observer * @param \Magento\Core\Helper\Data $coreData * @param \Magento\Customer\Helper\Data $customerData * @param \Magento\Captcha\Helper\Data $helper - * @param \Magento\Core\Model\Url $urlManager + * @param \Magento\UrlInterface $urlManager * @param \Magento\App\RequestInterface $request * @param \Magento\App\ActionFlag $actionFlag * @param \Magento\Message\ManagerInterface $messageManager @@ -120,7 +120,7 @@ class Observer \Magento\Core\Helper\Data $coreData, \Magento\Customer\Helper\Data $customerData, \Magento\Captcha\Helper\Data $helper, - \Magento\Core\Model\Url $urlManager, + \Magento\UrlInterface $urlManager, \Magento\App\RequestInterface $request, \Magento\App\ActionFlag $actionFlag, \Magento\Message\ManagerInterface $messageManager, diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Category/Helper/Image.php b/app/code/Magento/Catalog/Block/Adminhtml/Category/Helper/Image.php index d65a7f8c15cad900fed76fe76cf7031712786014..22d25b0ee82b743548e9d0b0867010fae7a59c53 100644 --- a/app/code/Magento/Catalog/Block/Adminhtml/Category/Helper/Image.php +++ b/app/code/Magento/Catalog/Block/Adminhtml/Category/Helper/Image.php @@ -64,7 +64,8 @@ class Image extends \Magento\Data\Form\Element\Image { $url = false; if ($this->getValue()) { - $url = $this->_storeManager->getStore()->getBaseUrl('media') . 'catalog/category/' . $this->getValue(); + $url = $this->_storeManager->getStore() + ->getBaseUrl(\Magento\UrlInterface::URL_TYPE_MEDIA) . 'catalog/category/' . $this->getValue(); } return $url; } diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Category/Tab/Product.php b/app/code/Magento/Catalog/Block/Adminhtml/Category/Tab/Product.php index 935c500b9f58f0442ac00a24db9e70c0a3de7868..714420ec31ba22afa0ca8d7cf113c71ac6c93ec7 100644 --- a/app/code/Magento/Catalog/Block/Adminhtml/Category/Tab/Product.php +++ b/app/code/Magento/Catalog/Block/Adminhtml/Category/Tab/Product.php @@ -49,7 +49,6 @@ class Product extends \Magento\Backend\Block\Widget\Grid\Extended /** * @param \Magento\Backend\Block\Template\Context $context - * @param \Magento\Core\Model\Url $urlModel * @param \Magento\Backend\Helper\Data $backendHelper * @param \Magento\Catalog\Model\ProductFactory $productFactory * @param \Magento\Core\Model\Registry $coreRegistry @@ -57,7 +56,6 @@ class Product extends \Magento\Backend\Block\Widget\Grid\Extended */ public function __construct( \Magento\Backend\Block\Template\Context $context, - \Magento\Core\Model\Url $urlModel, \Magento\Backend\Helper\Data $backendHelper, \Magento\Catalog\Model\ProductFactory $productFactory, \Magento\Core\Model\Registry $coreRegistry, @@ -65,7 +63,7 @@ class Product extends \Magento\Backend\Block\Widget\Grid\Extended ) { $this->_productFactory = $productFactory; $this->_coreRegistry = $coreRegistry; - parent::__construct($context, $urlModel, $backendHelper, $data); + parent::__construct($context, $backendHelper, $data); } protected function _construct() diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Product/Attribute/Edit/Tab/Main.php b/app/code/Magento/Catalog/Block/Adminhtml/Product/Attribute/Edit/Tab/Main.php index 25b94f558b9e6eabc092a4f8c010ebdda3a0f541..0c29fb85e1ad9f5e7e03f3ab7ef32fecf6168fbb 100644 --- a/app/code/Magento/Catalog/Block/Adminhtml/Product/Attribute/Edit/Tab/Main.php +++ b/app/code/Magento/Catalog/Block/Adminhtml/Product/Attribute/Edit/Tab/Main.php @@ -92,12 +92,8 @@ class Main extends \Magento\Eav\Block\Adminhtml\Attribute\Edit\Main\AbstractMain if (isset($type['hide_fields'])) { $_hiddenFields[$type['value']] = $type['hide_fields']; } - if (isset($type['disabled_types'])) { - $_disabledTypes[$type['value']] = $type['disabled_types']; - } } $this->_coreRegistry->register('attribute_type_hidden_fields', $_hiddenFields); - $this->_coreRegistry->register('attribute_type_disabled_types', $_disabledTypes); $frontendInputValues = array_merge($frontendInputElm->getValues(), $additionalTypes); $frontendInputElm->setValues($frontendInputValues); diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Product/Attribute/Grid.php b/app/code/Magento/Catalog/Block/Adminhtml/Product/Attribute/Grid.php index 443cab7468013c51020ffb5fea6e2c913d0d1351..c42694f1f64f312d09a2535e07082196ce3f0517 100644 --- a/app/code/Magento/Catalog/Block/Adminhtml/Product/Attribute/Grid.php +++ b/app/code/Magento/Catalog/Block/Adminhtml/Product/Attribute/Grid.php @@ -42,21 +42,19 @@ class Grid extends \Magento\Eav\Block\Adminhtml\Attribute\Grid\AbstractGrid /** * @param \Magento\Backend\Block\Template\Context $context - * @param \Magento\Core\Model\Url $urlModel * @param \Magento\Backend\Helper\Data $backendHelper * @param \Magento\Catalog\Model\Resource\Product\Attribute\CollectionFactory $collectionFactory * @param array $data */ public function __construct( \Magento\Backend\Block\Template\Context $context, - \Magento\Core\Model\Url $urlModel, \Magento\Backend\Helper\Data $backendHelper, \Magento\Catalog\Model\Resource\Product\Attribute\CollectionFactory $collectionFactory, array $data = array() ) { $this->_collectionFactory = $collectionFactory; $this->_module = 'catalog'; - parent::__construct($context, $urlModel, $backendHelper, $data); + parent::__construct($context, $backendHelper, $data); } /** diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Alerts/Price.php b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Alerts/Price.php index 8ad952bfd736bd55fd000101dc0cff7d6378feec..7f78cb96fb7044ec28c1d46cb8decff97c2dd9d0 100644 --- a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Alerts/Price.php +++ b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Alerts/Price.php @@ -50,7 +50,6 @@ class Price extends \Magento\Backend\Block\Widget\Grid\Extended /** * @param \Magento\Backend\Block\Template\Context $context - * @param \Magento\Core\Model\Url $urlModel * @param \Magento\Backend\Helper\Data $backendHelper * @param \Magento\ProductAlert\Model\PriceFactory $priceFactory * @param \Magento\Catalog\Helper\Data $catalogData @@ -58,7 +57,6 @@ class Price extends \Magento\Backend\Block\Widget\Grid\Extended */ public function __construct( \Magento\Backend\Block\Template\Context $context, - \Magento\Core\Model\Url $urlModel, \Magento\Backend\Helper\Data $backendHelper, \Magento\ProductAlert\Model\PriceFactory $priceFactory, \Magento\Catalog\Helper\Data $catalogData, @@ -66,7 +64,7 @@ class Price extends \Magento\Backend\Block\Widget\Grid\Extended ) { $this->_priceFactory = $priceFactory; $this->_catalogData = $catalogData; - parent::__construct($context, $urlModel, $backendHelper, $data); + parent::__construct($context, $backendHelper, $data); } protected function _construct() diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Alerts/Stock.php b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Alerts/Stock.php index 52c58018791c156576236a9d2d3ceba34d774056..3abdd6e4b3b6a2e5f222863fae6b783bca49e57a 100644 --- a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Alerts/Stock.php +++ b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Alerts/Stock.php @@ -50,7 +50,6 @@ class Stock extends \Magento\Backend\Block\Widget\Grid\Extended /** * @param \Magento\Backend\Block\Template\Context $context - * @param \Magento\Core\Model\Url $urlModel * @param \Magento\Backend\Helper\Data $backendHelper * @param \Magento\ProductAlert\Model\StockFactory $stockFactory * @param \Magento\Catalog\Helper\Data $catalogData @@ -58,7 +57,6 @@ class Stock extends \Magento\Backend\Block\Widget\Grid\Extended */ public function __construct( \Magento\Backend\Block\Template\Context $context, - \Magento\Core\Model\Url $urlModel, \Magento\Backend\Helper\Data $backendHelper, \Magento\ProductAlert\Model\StockFactory $stockFactory, \Magento\Catalog\Helper\Data $catalogData, @@ -66,7 +64,7 @@ class Stock extends \Magento\Backend\Block\Widget\Grid\Extended ) { $this->_stockFactory = $stockFactory; $this->_catalogData = $catalogData; - parent::__construct($context, $urlModel, $backendHelper, $data); + parent::__construct($context, $backendHelper, $data); } protected function _construct() diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Crosssell.php b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Crosssell.php index a6fd4b95cf4299b1ba459e84a0605a725910acd1..af1959479e24da2c1891dff39a798d6d4b9c898e 100644 --- a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Crosssell.php +++ b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Crosssell.php @@ -74,7 +74,6 @@ class Crosssell extends \Magento\Backend\Block\Widget\Grid\Extended /** * @param \Magento\Backend\Block\Template\Context $context - * @param \Magento\Core\Model\Url $urlModel * @param \Magento\Backend\Helper\Data $backendHelper * @param \Magento\Catalog\Model\Product\LinkFactory $linkFactory * @param \Magento\Eav\Model\Resource\Entity\Attribute\Set\CollectionFactory $setsFactory @@ -89,7 +88,6 @@ class Crosssell extends \Magento\Backend\Block\Widget\Grid\Extended */ public function __construct( \Magento\Backend\Block\Template\Context $context, - \Magento\Core\Model\Url $urlModel, \Magento\Backend\Helper\Data $backendHelper, \Magento\Catalog\Model\Product\LinkFactory $linkFactory, \Magento\Eav\Model\Resource\Entity\Attribute\Set\CollectionFactory $setsFactory, @@ -107,7 +105,7 @@ class Crosssell extends \Magento\Backend\Block\Widget\Grid\Extended $this->_status = $status; $this->_visibility = $visibility; $this->_coreRegistry = $coreRegistry; - parent::__construct($context, $urlModel, $backendHelper, $data); + parent::__construct($context, $backendHelper, $data); } /** diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Related.php b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Related.php index db0ee3f840e92c52c5a3ef8009a818e8c0daa5fd..ecbc97934debce0ff89270399347b359271dfcc1 100644 --- a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Related.php +++ b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Related.php @@ -74,7 +74,6 @@ class Related extends \Magento\Backend\Block\Widget\Grid\Extended /** * @param \Magento\Backend\Block\Template\Context $context - * @param \Magento\Core\Model\Url $urlModel * @param \Magento\Backend\Helper\Data $backendHelper * @param \Magento\Catalog\Model\Product\LinkFactory $linkFactory * @param \Magento\Eav\Model\Resource\Entity\Attribute\Set\CollectionFactory $setsFactory @@ -89,7 +88,6 @@ class Related extends \Magento\Backend\Block\Widget\Grid\Extended */ public function __construct( \Magento\Backend\Block\Template\Context $context, - \Magento\Core\Model\Url $urlModel, \Magento\Backend\Helper\Data $backendHelper, \Magento\Catalog\Model\Product\LinkFactory $linkFactory, \Magento\Eav\Model\Resource\Entity\Attribute\Set\CollectionFactory $setsFactory, @@ -107,7 +105,7 @@ class Related extends \Magento\Backend\Block\Widget\Grid\Extended $this->_status = $status; $this->_visibility = $visibility; $this->_coreRegistry = $coreRegistry; - parent::__construct($context, $urlModel, $backendHelper, $data); + parent::__construct($context, $backendHelper, $data); } /** diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Upsell.php b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Upsell.php index 861b0f493099d302dd48340431fc0517f7e2406a..a34c27ab753e5e886ff565661f61e278d6c45cc7 100644 --- a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Upsell.php +++ b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Upsell.php @@ -74,7 +74,6 @@ class Upsell extends \Magento\Backend\Block\Widget\Grid\Extended /** * @param \Magento\Backend\Block\Template\Context $context - * @param \Magento\Core\Model\Url $urlModel * @param \Magento\Backend\Helper\Data $backendHelper * @param \Magento\Catalog\Model\Product\LinkFactory $linkFactory * @param \Magento\Eav\Model\Resource\Entity\Attribute\Set\CollectionFactory $setsFactory @@ -89,7 +88,6 @@ class Upsell extends \Magento\Backend\Block\Widget\Grid\Extended */ public function __construct( \Magento\Backend\Block\Template\Context $context, - \Magento\Core\Model\Url $urlModel, \Magento\Backend\Helper\Data $backendHelper, \Magento\Catalog\Model\Product\LinkFactory $linkFactory, \Magento\Eav\Model\Resource\Entity\Attribute\Set\CollectionFactory $setsFactory, @@ -107,7 +105,7 @@ class Upsell extends \Magento\Backend\Block\Widget\Grid\Extended $this->_status = $status; $this->_visibility = $visibility; $this->_coreRegistry = $coreRegistry; - parent::__construct($context, $urlModel, $backendHelper, $data); + parent::__construct($context, $backendHelper, $data); } /** diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Product/Grid.php b/app/code/Magento/Catalog/Block/Adminhtml/Product/Grid.php index ace24f16369238a9a67c7c6ce1c8990d42c6e800..3598be070252146fa40e333c9f35161c4a799192 100644 --- a/app/code/Magento/Catalog/Block/Adminhtml/Product/Grid.php +++ b/app/code/Magento/Catalog/Block/Adminhtml/Product/Grid.php @@ -74,7 +74,6 @@ class Grid extends \Magento\Backend\Block\Widget\Grid\Extended /** * @param \Magento\Backend\Block\Template\Context $context - * @param \Magento\Core\Model\Url $urlModel * @param \Magento\Backend\Helper\Data $backendHelper * @param \Magento\Core\Model\WebsiteFactory $websiteFactory * @param \Magento\Eav\Model\Resource\Entity\Attribute\Set\CollectionFactory $setsFactory @@ -89,7 +88,6 @@ class Grid extends \Magento\Backend\Block\Widget\Grid\Extended */ public function __construct( \Magento\Backend\Block\Template\Context $context, - \Magento\Core\Model\Url $urlModel, \Magento\Backend\Helper\Data $backendHelper, \Magento\Core\Model\WebsiteFactory $websiteFactory, \Magento\Eav\Model\Resource\Entity\Attribute\Set\CollectionFactory $setsFactory, @@ -107,7 +105,7 @@ class Grid extends \Magento\Backend\Block\Widget\Grid\Extended $this->_status = $status; $this->_visibility = $visibility; $this->_catalogData = $catalogData; - parent::__construct($context, $urlModel, $backendHelper, $data); + parent::__construct($context, $backendHelper, $data); } protected function _construct() diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Product/Helper/Form/BaseImage.php b/app/code/Magento/Catalog/Block/Adminhtml/Product/Helper/Form/BaseImage.php index 89ef905df691f3362c002a0d1edc92fd501dd5f2..cbf7773c3390ae02a2f9e71633ce488682fc85bd 100644 --- a/app/code/Magento/Catalog/Block/Adminhtml/Product/Helper/Form/BaseImage.php +++ b/app/code/Magento/Catalog/Block/Adminhtml/Product/Helper/Form/BaseImage.php @@ -38,7 +38,7 @@ class BaseImage extends \Magento\Data\Form\Element\AbstractElement /** * Model Url instance * - * @var \Magento\Backend\Model\Url + * @var \Magento\Backend\Model\UrlInterface */ protected $_url; diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Product/Helper/Form/Image.php b/app/code/Magento/Catalog/Block/Adminhtml/Product/Helper/Form/Image.php index 818aa1b307c9eb1f785bf94835b93a3ab6b5857e..eeaadb8c5b25113f1e7f97309b74fd28f54631cc 100644 --- a/app/code/Magento/Catalog/Block/Adminhtml/Product/Helper/Form/Image.php +++ b/app/code/Magento/Catalog/Block/Adminhtml/Product/Helper/Form/Image.php @@ -39,7 +39,8 @@ class Image extends \Magento\Data\Form\Element\Image { $url = false; if ($this->getValue()) { - $url = $this->_urlBuilder->getBaseUrl('media') . 'catalog/product/' . $this->getValue(); + $url = $this->_urlBuilder + ->getBaseUrl(\Magento\UrlInterface::URL_TYPE_MEDIA) . 'catalog/product/' . $this->getValue(); } return $url; } diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Product/Widget/Chooser.php b/app/code/Magento/Catalog/Block/Adminhtml/Product/Widget/Chooser.php index cefd646a4af7662cf5b8be04936c1e66fc7384a4..41d5c69761014698fe26875f04a9af3073ed67fc 100644 --- a/app/code/Magento/Catalog/Block/Adminhtml/Product/Widget/Chooser.php +++ b/app/code/Magento/Catalog/Block/Adminhtml/Product/Widget/Chooser.php @@ -59,7 +59,6 @@ class Chooser extends \Magento\Backend\Block\Widget\Grid\Extended /** * @param \Magento\Backend\Block\Template\Context $context - * @param \Magento\Core\Model\Url $urlModel * @param \Magento\Backend\Helper\Data $backendHelper * @param \Magento\Catalog\Model\CategoryFactory $categoryFactory * @param \Magento\Catalog\Model\Resource\Product\CollectionFactory $collectionFactory @@ -69,7 +68,6 @@ class Chooser extends \Magento\Backend\Block\Widget\Grid\Extended */ public function __construct( \Magento\Backend\Block\Template\Context $context, - \Magento\Core\Model\Url $urlModel, \Magento\Backend\Helper\Data $backendHelper, \Magento\Catalog\Model\CategoryFactory $categoryFactory, \Magento\Catalog\Model\Resource\Product\CollectionFactory $collectionFactory, @@ -81,7 +79,7 @@ class Chooser extends \Magento\Backend\Block\Widget\Grid\Extended $this->_collectionFactory = $collectionFactory; $this->_resourceCategory = $resourceCategory; $this->_resourceProduct = $resourceProduct; - parent::__construct($context, $urlModel, $backendHelper, $data); + parent::__construct($context, $backendHelper, $data); } /** diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Search/Edit.php b/app/code/Magento/Catalog/Block/Adminhtml/Search/Edit.php index 7c19a1dfa31272452abb28e879a1261d0da93a58..ac370e5d6f3be0759629d594f92fa83e8092fcb4 100644 --- a/app/code/Magento/Catalog/Block/Adminhtml/Search/Edit.php +++ b/app/code/Magento/Catalog/Block/Adminhtml/Search/Edit.php @@ -24,12 +24,11 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Catalog\Block\Adminhtml\Search; + /** * Admin tag edit block */ - -namespace Magento\Catalog\Block\Adminhtml\Search; - class Edit extends \Magento\Backend\Block\Widget\Form\Container { /** @@ -37,7 +36,7 @@ class Edit extends \Magento\Backend\Block\Widget\Form\Container * * @var \Magento\Core\Model\Registry */ - protected $_coreRegistry = null; + protected $coreRegistry; /** * @param \Magento\Backend\Block\Template\Context $context @@ -49,7 +48,7 @@ class Edit extends \Magento\Backend\Block\Widget\Form\Container \Magento\Core\Model\Registry $registry, array $data = array() ) { - $this->_coreRegistry = $registry; + $this->coreRegistry = $registry; parent::__construct($context, $data); } @@ -67,8 +66,8 @@ class Edit extends \Magento\Backend\Block\Widget\Form\Container public function getHeaderText() { - if ($this->_coreRegistry->registry('current_catalog_search')->getId()) { - $queryText = $this->escapeHtml($this->_coreRegistry->registry('current_catalog_search')->getQueryText()); + if ($this->coreRegistry->registry('current_catalog_search')->getId()) { + $queryText = $this->escapeHtml($this->coreRegistry->registry('current_catalog_search')->getQueryText()); return __("Edit Search '%1'", $queryText); } else { return __('New Search'); diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Category.php b/app/code/Magento/Catalog/Controller/Adminhtml/Category.php index aaea81d1869836c767d2f007679b3e18884c8816..839971c48ed20cc26c0f8929156ee3d72652e1eb 100644 --- a/app/code/Magento/Catalog/Controller/Adminhtml/Category.php +++ b/app/code/Magento/Catalog/Controller/Adminhtml/Category.php @@ -214,7 +214,7 @@ class Category extends \Magento\Backend\App\Action $elementId = $this->getRequest()->getParam('element_id', md5(microtime())); $storeId = $this->getRequest()->getParam('store_id', 0); $storeMediaUrl = $this->_objectManager->get('Magento\Core\Model\StoreManagerInterface')->getStore($storeId) - ->getBaseUrl(\Magento\Core\Model\Store::URL_TYPE_MEDIA); + ->getBaseUrl(\Magento\UrlInterface::URL_TYPE_MEDIA); $content = $this->_view->getLayout()->createBlock( 'Magento\Catalog\Block\Adminhtml\Helper\Form\Wysiwyg\Content', diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Product.php b/app/code/Magento/Catalog/Controller/Adminhtml/Product.php index 9200887cd11c19d1c3211a7a608efa964fd6434a..347e2c1ac0e29598f6ce28688cebd79c6c7993dc 100644 --- a/app/code/Magento/Catalog/Controller/Adminhtml/Product.php +++ b/app/code/Magento/Catalog/Controller/Adminhtml/Product.php @@ -350,7 +350,7 @@ class Product extends \Magento\Backend\App\Action $elementId = $this->getRequest()->getParam('element_id', md5(microtime())); $storeId = $this->getRequest()->getParam('store_id', 0); $storeMediaUrl = $this->_objectManager->get('Magento\Core\Model\StoreManagerInterface') - ->getStore($storeId)->getBaseUrl(\Magento\Core\Model\Store::URL_TYPE_MEDIA); + ->getStore($storeId)->getBaseUrl(\Magento\UrlInterface::URL_TYPE_MEDIA); $content = $this->_view->getLayout()->createBlock( 'Magento\Catalog\Block\Adminhtml\Helper\Form\Wysiwyg\Content', diff --git a/app/code/Magento/Catalog/Helper/Data.php b/app/code/Magento/Catalog/Helper/Data.php index e345eb2223693d1f865b93cf8288674abe33f54c..8bf63ef90843f83d02941dba7be5b16b604e8a85 100644 --- a/app/code/Magento/Catalog/Helper/Data.php +++ b/app/code/Magento/Catalog/Helper/Data.php @@ -337,20 +337,6 @@ class Data extends \Magento\App\Helper\AbstractHelper } } - /** - * Retrieve attribute disabled types - * - * @return array - */ - public function getAttributeDisabledTypes() - { - if ($this->_coreRegistry->registry('attribute_type_disabled_types')) { - return $this->_coreRegistry->registry('attribute_type_disabled_types'); - } else { - return array(); - } - } - /** * Retrieve Catalog Price Scope * diff --git a/app/code/Magento/Catalog/Helper/Product.php b/app/code/Magento/Catalog/Helper/Product.php index a5d62dbc206dcf761df4198488ab399f5eab3331..e6180db8cffe40860a4dd845b018690e5cb65a89 100644 --- a/app/code/Magento/Catalog/Helper/Product.php +++ b/app/code/Magento/Catalog/Helper/Product.php @@ -89,7 +89,7 @@ class Product extends \Magento\Core\Helper\Url protected $_coreStoreConfig; /** - * @var \Magento\Core\Model\Config + * @var \Magento\App\ConfigInterface */ protected $_coreConfig; @@ -129,7 +129,7 @@ class Product extends \Magento\Core\Helper\Url * @param \Magento\Core\Model\Registry $coreRegistry * @param \Magento\Catalog\Model\Attribute\Config $attributeConfig * @param \Magento\Core\Model\Store\Config $coreStoreConfig - * @param \Magento\Core\Model\Config $coreConfig + * @param \Magento\App\ConfigInterface $coreConfig * @param string $typeSwitcherLabel */ public function __construct( @@ -142,7 +142,7 @@ class Product extends \Magento\Core\Helper\Url \Magento\Core\Model\Registry $coreRegistry, \Magento\Catalog\Model\Attribute\Config $attributeConfig, \Magento\Core\Model\Store\Config $coreStoreConfig, - \Magento\Core\Model\Config $coreConfig, + \Magento\App\ConfigInterface $coreConfig, $typeSwitcherLabel ) { $this->_categoryFactory = $categoryFactory; diff --git a/app/code/Magento/Catalog/Helper/Product/Configuration.php b/app/code/Magento/Catalog/Helper/Product/Configuration.php index 1d76313ee475f1b6a36a510646a6f736e28e238a..e5f7b9e9628380c5f23ce51dd4cb8acb9ac52fe9 100644 --- a/app/code/Magento/Catalog/Helper/Product/Configuration.php +++ b/app/code/Magento/Catalog/Helper/Product/Configuration.php @@ -262,11 +262,10 @@ class Configuration extends \Magento\App\Helper\AbstractHelper /** * Get allowed product types for configurable product * - * @return \SimpleXMLElement + * @return array */ public function getConfigurableAllowedTypes() { - $configData = $this->_config->getType('configurable'); - return isset($configData['allow_product_types']) ? $configData['allow_product_types'] : array(); + return $this->_config->getComposableTypes(); } } diff --git a/app/code/Magento/Catalog/Helper/Product/Edit/Action/Attribute.php b/app/code/Magento/Catalog/Helper/Product/Edit/Action/Attribute.php index 2a870d49488e39d15e85ec8942c39a851d27bb0b..d589e7de04a936dbf772b654706d2944f6cab35a 100644 --- a/app/code/Magento/Catalog/Helper/Product/Edit/Action/Attribute.php +++ b/app/code/Magento/Catalog/Helper/Product/Edit/Action/Attribute.php @@ -70,8 +70,8 @@ class Attribute extends \Magento\Backend\Helper\Data /** * @param \Magento\App\Helper\Context $context * @param \Magento\App\Route\Config $routeConfig - * @param \Magento\Core\Model\AppInterface $app - * @param \Magento\Backend\Model\Url $backendUrl + * @param \Magento\AppInterface $app + * @param \Magento\Backend\Model\UrlInterface $backendUrl * @param \Magento\Backend\Model\Auth $auth * @param \Magento\Backend\App\Area\FrontNameResolver $frontNameResolver * @param \Magento\Math\Random $mathRandom @@ -82,8 +82,8 @@ class Attribute extends \Magento\Backend\Helper\Data public function __construct( \Magento\App\Helper\Context $context, \Magento\App\Route\Config $routeConfig, - \Magento\Core\Model\AppInterface $app, - \Magento\Backend\Model\Url $backendUrl, + \Magento\AppInterface $app, + \Magento\Backend\Model\UrlInterface $backendUrl, \Magento\Backend\Model\Auth $auth, \Magento\Backend\App\Area\FrontNameResolver $frontNameResolver, \Magento\Math\Random $mathRandom, diff --git a/app/code/Magento/Catalog/Helper/Product/Url.php b/app/code/Magento/Catalog/Helper/Product/Url.php index a1a24ba55d63a5310709e2053b672ba5da34e2e5..4747d633f2085a480712e1a53c4fc5e2c2c12720 100644 --- a/app/code/Magento/Catalog/Helper/Product/Url.php +++ b/app/code/Magento/Catalog/Helper/Product/Url.php @@ -100,12 +100,12 @@ class Url extends \Magento\Core\Helper\Url /** * @param \Magento\App\Helper\Context $context * @param \Magento\Core\Model\StoreManagerInterface $storeManager - * @param \Magento\Core\Model\Config $config + * @param \Magento\App\ConfigInterface $config */ public function __construct( \Magento\App\Helper\Context $context, \Magento\Core\Model\StoreManagerInterface $storeManager, - \Magento\Core\Model\Config $config + \Magento\App\ConfigInterface $config ) { parent::__construct($context, $storeManager); $convertConfig = $config->getValue('url/convert', 'default'); diff --git a/app/code/Magento/Catalog/Helper/Product/View.php b/app/code/Magento/Catalog/Helper/Product/View.php index 42f2458b0b174c61ac460e01d258f02461b573ad..946d73ff0a37e52bc2070310c124a2e3040396d9 100644 --- a/app/code/Magento/Catalog/Helper/Product/View.php +++ b/app/code/Magento/Catalog/Helper/Product/View.php @@ -129,10 +129,11 @@ class View extends \Magento\App\Helper\AbstractHelper * * @param \Magento\Catalog\Model\Product $product * @param \Magento\App\Action\Action $controller + * @param null|\Magento\Object $params * * @return \Magento\Catalog\Helper\Product\View */ - public function initProductLayout($product, $controller) + public function initProductLayout($product, $controller, $params = null) { $settings = $this->_catalogDesign->getDesignSettings($product); @@ -142,9 +143,30 @@ class View extends \Magento\App\Helper\AbstractHelper $update = $this->_view->getLayout()->getUpdate(); $update->addHandle('default'); + + if ($params && $params->getBeforeHandles()) { + foreach ($params->getBeforeHandles() as $handle) { + $this->_view->addPageLayoutHandles( + array('id' => $product->getId(), 'sku' => $product->getSku(), 'type' => $product->getTypeId()), + $handle + ); + } + } + $this->_view->addPageLayoutHandles( array('id' => $product->getId(), 'sku' => $product->getSku(), 'type' => $product->getTypeId()) ); + + if ($params && $params->getAfterHandles()) { + foreach ($params->getAfterHandles() as $handle) { + $this->_view->addPageLayoutHandles( + array('id' => $product->getId(), 'sku' => $product->getSku(), 'type' => $product->getTypeId()), + $handle + ); + + } + } + $this->_view->loadLayoutUpdates(); // Apply custom layout update once layout is loaded $layoutUpdates = $settings->getLayoutUpdates(); @@ -229,7 +251,7 @@ class View extends \Magento\App\Helper\AbstractHelper $this->_catalogSession->setLastViewedProductId($product->getId()); - $this->initProductLayout($product, $controller); + $this->initProductLayout($product, $controller, $params); if ($controller instanceof \Magento\Catalog\Controller\Product\View\ViewInterface) { $this->_view->getLayout()->initMessages($this->messageGroups); diff --git a/app/code/Magento/Catalog/Model/Category.php b/app/code/Magento/Catalog/Model/Category.php index 857a2c412eedd2ceb21f596d99f6f06588fc04a4..0ff486480c73cfea615ebbbd05a7d188dca056e9 100644 --- a/app/code/Magento/Catalog/Model/Category.php +++ b/app/code/Magento/Catalog/Model/Category.php @@ -72,7 +72,7 @@ class Category extends \Magento\Catalog\Model\AbstractModel /** * URL Model instance * - * @var \Magento\Core\Model\Url + * @var \Magento\UrlInterface */ protected $_url; @@ -247,7 +247,7 @@ class Category extends \Magento\Catalog\Model\AbstractModel /** * Retrieve URL instance * - * @return \Magento\Core\Model\Url + * @return \Magento\UrlInterface */ public function getUrlInstance() { @@ -583,7 +583,7 @@ class Category extends \Magento\Catalog\Model\AbstractModel $url = false; $image = $this->getImage(); if ($image) { - $url = $this->_storeManager->getStore()->getBaseUrl(\Magento\Core\Model\Store::URL_TYPE_MEDIA) + $url = $this->_storeManager->getStore()->getBaseUrl(\Magento\UrlInterface::URL_TYPE_MEDIA) . 'catalog/category/' . $image; } return $url; diff --git a/app/code/Magento/Catalog/Model/Config/Backend/Category.php b/app/code/Magento/Catalog/Model/Config/Backend/Category.php index 71fcb9b7ac223f19ff25f43eb80a084207f47175..9bb344fbd7e7da3c3c7222d70722687140baed41 100644 --- a/app/code/Magento/Catalog/Model/Config/Backend/Category.php +++ b/app/code/Magento/Catalog/Model/Config/Backend/Category.php @@ -46,7 +46,7 @@ class Category extends \Magento\Core\Model\Config\Value * @param \Magento\Core\Model\Context $context * @param \Magento\Core\Model\Registry $registry * @param \Magento\Core\Model\StoreManagerInterface $storeManager - * @param \Magento\Core\Model\Config $config + * @param \Magento\App\ConfigInterface $config * @param \Magento\Catalog\Model\Category $catalogCategory * @param \Magento\Core\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection @@ -56,7 +56,7 @@ class Category extends \Magento\Core\Model\Config\Value \Magento\Core\Model\Context $context, \Magento\Core\Model\Registry $registry, \Magento\Core\Model\StoreManagerInterface $storeManager, - \Magento\Core\Model\Config $config, + \Magento\App\ConfigInterface $config, \Magento\Catalog\Model\Category $catalogCategory, \Magento\Core\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, diff --git a/app/code/Magento/Catalog/Model/Config/CatalogClone/Media/Image.php b/app/code/Magento/Catalog/Model/Config/CatalogClone/Media/Image.php index 08328fa629d196d64f849c975c2bc379ac36a115..c84d18b7ff765c42d3a89f1f6fdd403937b40e5b 100644 --- a/app/code/Magento/Catalog/Model/Config/CatalogClone/Media/Image.php +++ b/app/code/Magento/Catalog/Model/Config/CatalogClone/Media/Image.php @@ -51,7 +51,7 @@ class Image extends \Magento\Core\Model\Config\Value * @param \Magento\Core\Model\Context $context * @param \Magento\Core\Model\Registry $registry * @param \Magento\Core\Model\StoreManagerInterface $storeManager - * @param \Magento\Core\Model\Config $config + * @param \Magento\App\ConfigInterface $config * @param \Magento\Catalog\Model\Resource\Product\Attribute\CollectionFactory $attributeCollectionFactory * @param \Magento\Eav\Model\Config $eavConfig * @param \Magento\Core\Model\Resource\AbstractResource $resource @@ -62,7 +62,7 @@ class Image extends \Magento\Core\Model\Config\Value \Magento\Core\Model\Context $context, \Magento\Core\Model\Registry $registry, \Magento\Core\Model\StoreManagerInterface $storeManager, - \Magento\Core\Model\Config $config, + \Magento\App\ConfigInterface $config, \Magento\Catalog\Model\Resource\Product\Attribute\CollectionFactory $attributeCollectionFactory, \Magento\Eav\Model\Config $eavConfig, \Magento\Core\Model\Resource\AbstractResource $resource = null, diff --git a/app/code/Magento/Catalog/Model/Indexer/Url.php b/app/code/Magento/Catalog/Model/Indexer/Url.php index cd08ea39f806de5319f2af9b3f6261a16a5af495..44fbeb9e86a4377f12b565fd4647a7e793a54268 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Url.php +++ b/app/code/Magento/Catalog/Model/Indexer/Url.php @@ -61,7 +61,7 @@ class Url extends \Magento\Index\Model\Indexer\AbstractIndexer \Magento\Core\Model\Store\Group::ENTITY => array( \Magento\Index\Model\Event::TYPE_SAVE ), - \Magento\Core\Model\Config\Value::ENTITY => array( + \Magento\App\Config\ValueInterface::ENTITY => array( \Magento\Index\Model\Event::TYPE_SAVE ), ); @@ -160,7 +160,7 @@ class Url extends \Magento\Index\Model\Indexer\AbstractIndexer } else { $result = false; } - } else if ($entity == \Magento\Core\Model\Config\Value::ENTITY) { + } else if ($entity == \Magento\App\Config\ValueInterface::ENTITY) { $configData = $event->getDataObject(); if ($configData && in_array($configData->getPath(), $this->_relatedConfigSettings)) { $result = $configData->isValueChanged(); @@ -196,7 +196,7 @@ class Url extends \Magento\Index\Model\Indexer\AbstractIndexer case \Magento\Core\Model\Store::ENTITY: case \Magento\Core\Model\Store\Group::ENTITY: - case \Magento\Core\Model\Config\Value::ENTITY: + case \Magento\App\Config\ValueInterface::ENTITY: $process = $event->getProcess(); $process->changeStatus(\Magento\Index\Model\Process::STATUS_REQUIRE_REINDEX); break; diff --git a/app/code/Magento/Catalog/Model/Observer.php b/app/code/Magento/Catalog/Model/Observer.php index 044b8f424e79261be20cd57f9f639d4d5bb327e6..12bf8d2369f73ca3723f5d5273510ef0ab1646b5 100644 --- a/app/code/Magento/Catalog/Model/Observer.php +++ b/app/code/Magento/Catalog/Model/Observer.php @@ -58,7 +58,7 @@ class Observer protected $_catalogCategory = null; /** - * @var \Magento\Core\Model\Config + * @var \Magento\App\ReinitableConfigInterface */ protected $_coreConfig; @@ -130,7 +130,7 @@ class Observer * @param \Magento\Catalog\Helper\Category $catalogCategory * @param \Magento\Catalog\Helper\Data $catalogData * @param \Magento\Catalog\Helper\Category\Flat $catalogCategoryFlat - * @param \Magento\Core\Model\Config $coreConfig + * @param \Magento\App\ReinitableConfigInterface $coreConfig * @param \Magento\Catalog\Model\Resource\Category\FlatFactory $flatResourceFactory * @param \Magento\Catalog\Model\Resource\ProductFactory $productResourceFactory */ @@ -144,7 +144,7 @@ class Observer \Magento\Catalog\Helper\Category $catalogCategory, \Magento\Catalog\Helper\Data $catalogData, \Magento\Catalog\Helper\Category\Flat $catalogCategoryFlat, - \Magento\Core\Model\Config $coreConfig, + \Magento\App\ReinitableConfigInterface $coreConfig, \Magento\Catalog\Model\Resource\Category\FlatFactory $flatResourceFactory, \Magento\Catalog\Model\Resource\ProductFactory $productResourceFactory ) { diff --git a/app/code/Magento/Catalog/Model/Product/Attribute/Backend/Groupprice.php b/app/code/Magento/Catalog/Model/Product/Attribute/Backend/Groupprice.php index 59b1f60d2b9ade5c78a5b8d26eed128ed66135e9..936370028fc67f6b1feae4f1876f9bc748c99cee 100644 --- a/app/code/Magento/Catalog/Model/Product/Attribute/Backend/Groupprice.php +++ b/app/code/Magento/Catalog/Model/Product/Attribute/Backend/Groupprice.php @@ -46,7 +46,7 @@ class Groupprice * @param \Magento\Directory\Model\CurrencyFactory $currencyFactory * @param \Magento\Core\Model\StoreManagerInterface $storeManager * @param \Magento\Catalog\Helper\Data $catalogData - * @param \Magento\Core\Model\Config $config + * @param \Magento\App\ConfigInterface $config * @param \Magento\Catalog\Model\Product\Type $catalogProductType * @param \Magento\Catalog\Model\Resource\Product\Attribute\Backend\Groupprice $productAttributeBackendGroupprice */ @@ -55,7 +55,7 @@ class Groupprice \Magento\Directory\Model\CurrencyFactory $currencyFactory, \Magento\Core\Model\StoreManagerInterface $storeManager, \Magento\Catalog\Helper\Data $catalogData, - \Magento\Core\Model\Config $config, + \Magento\App\ConfigInterface $config, \Magento\Catalog\Model\Product\Type $catalogProductType, \Magento\Catalog\Model\Resource\Product\Attribute\Backend\Groupprice $productAttributeBackendGroupprice ) { diff --git a/app/code/Magento/Catalog/Model/Product/Attribute/Backend/Groupprice/AbstractGroupprice.php b/app/code/Magento/Catalog/Model/Product/Attribute/Backend/Groupprice/AbstractGroupprice.php index 1d4f7da43a4948609fc1cf89626de8acfc7d6a04..3aa56d5ba6cedf4650f5d585b2f3377dceec1586 100644 --- a/app/code/Magento/Catalog/Model/Product/Attribute/Backend/Groupprice/AbstractGroupprice.php +++ b/app/code/Magento/Catalog/Model/Product/Attribute/Backend/Groupprice/AbstractGroupprice.php @@ -64,7 +64,7 @@ abstract class AbstractGroupprice * @param \Magento\Directory\Model\CurrencyFactory $currencyFactory * @param \Magento\Core\Model\StoreManagerInterface $storeManager * @param \Magento\Catalog\Helper\Data $catalogData - * @param \Magento\Core\Model\Config $config + * @param \Magento\App\ConfigInterface $config * @param \Magento\Catalog\Model\Product\Type $catalogProductType */ public function __construct( @@ -72,7 +72,7 @@ abstract class AbstractGroupprice \Magento\Directory\Model\CurrencyFactory $currencyFactory, \Magento\Core\Model\StoreManagerInterface $storeManager, \Magento\Catalog\Helper\Data $catalogData, - \Magento\Core\Model\Config $config, + \Magento\App\ConfigInterface $config, \Magento\Catalog\Model\Product\Type $catalogProductType ) { $this->_catalogProductType = $catalogProductType; diff --git a/app/code/Magento/Catalog/Model/Product/Attribute/Backend/Price.php b/app/code/Magento/Catalog/Model/Product/Attribute/Backend/Price.php index 2bbd62451bc2edde6c7fc8f68aebe08e1c439455..96c5d04af8d6807db0d02e71867766853933fd49 100644 --- a/app/code/Magento/Catalog/Model/Product/Attribute/Backend/Price.php +++ b/app/code/Magento/Catalog/Model/Product/Attribute/Backend/Price.php @@ -60,7 +60,7 @@ class Price extends \Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend /** * Core config model * - * @var \Magento\Core\Model\ConfigInterface + * @var \Magento\App\ConfigInterface */ protected $_config; @@ -71,14 +71,14 @@ class Price extends \Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend * @param \Magento\Directory\Model\CurrencyFactory $currencyFactory * @param \Magento\Core\Model\StoreManagerInterface $storeManager * @param \Magento\Catalog\Helper\Data $catalogData - * @param \Magento\Core\Model\Config $config + * @param \Magento\App\ConfigInterface $config */ public function __construct( \Magento\Logger $logger, \Magento\Directory\Model\CurrencyFactory $currencyFactory, \Magento\Core\Model\StoreManagerInterface $storeManager, \Magento\Catalog\Helper\Data $catalogData, - \Magento\Core\Model\Config $config + \Magento\App\ConfigInterface $config ) { $this->_currencyFactory = $currencyFactory; $this->_storeManager = $storeManager; diff --git a/app/code/Magento/Catalog/Model/Product/Attribute/Backend/Tierprice.php b/app/code/Magento/Catalog/Model/Product/Attribute/Backend/Tierprice.php index 7b24c5a5d01e470ac1c5205bbe60900899274210..88e0baead0d204114ada0c0b6c51cefd03e81be2 100644 --- a/app/code/Magento/Catalog/Model/Product/Attribute/Backend/Tierprice.php +++ b/app/code/Magento/Catalog/Model/Product/Attribute/Backend/Tierprice.php @@ -49,7 +49,7 @@ class Tierprice * @param \Magento\Directory\Model\CurrencyFactory $currencyFactory * @param \Magento\Core\Model\StoreManagerInterface $storeManager * @param \Magento\Catalog\Helper\Data $catalogData - * @param \Magento\Core\Model\Config $config + * @param \Magento\App\ConfigInterface $config * @param \Magento\Catalog\Model\Product\Type $catalogProductType * @param \Magento\Catalog\Model\Resource\Product\Attribute\Backend\Tierprice $productAttributeTierprice */ @@ -58,7 +58,7 @@ class Tierprice \Magento\Directory\Model\CurrencyFactory $currencyFactory, \Magento\Core\Model\StoreManagerInterface $storeManager, \Magento\Catalog\Helper\Data $catalogData, - \Magento\Core\Model\Config $config, + \Magento\App\ConfigInterface $config, \Magento\Catalog\Model\Product\Type $catalogProductType, \Magento\Catalog\Model\Resource\Product\Attribute\Backend\Tierprice $productAttributeTierprice ) { diff --git a/app/code/Magento/Catalog/Model/Product/Attribute/Frontend/Image.php b/app/code/Magento/Catalog/Model/Product/Attribute/Frontend/Image.php index aa64a449341b705f2e20477e8e046e48a846842d..7f5a1ad83b5a5f21290678ebdd6fe2e2382a6bd3 100644 --- a/app/code/Magento/Catalog/Model/Product/Attribute/Frontend/Image.php +++ b/app/code/Magento/Catalog/Model/Product/Attribute/Frontend/Image.php @@ -65,7 +65,7 @@ class Image extends \Magento\Eav\Model\Entity\Attribute\Frontend\AbstractFronten $image = $product->getData($this->getAttribute()->getAttributeCode()); if ($image) { $url = $this->_storeManager->getStore($product->getStore()) - ->getBaseUrl('media') . 'catalog/product/' . $image; + ->getBaseUrl(\Magento\UrlInterface::URL_TYPE_MEDIA) . 'catalog/product/' . $image; } else { $url = false; } diff --git a/app/code/Magento/Catalog/Model/Product/Attribute/Source/Inputtype.php b/app/code/Magento/Catalog/Model/Product/Attribute/Source/Inputtype.php index d8e5c9f40612c61e0c316bc8aad579efe7407754..4b70899f9851ed8d7e7d1d39e67dfaf69eb7489f 100644 --- a/app/code/Magento/Catalog/Model/Product/Attribute/Source/Inputtype.php +++ b/app/code/Magento/Catalog/Model/Product/Attribute/Source/Inputtype.php @@ -84,18 +84,11 @@ class Inputtype extends \Magento\Eav\Model\Adminhtml\System\Config\Source\Inputt if (isset($type['hide_fields'])) { $_hiddenFields[$type['value']] = $type['hide_fields']; } - if (isset($type['disabled_types'])) { - $_disabledTypes[$type['value']] = $type['disabled_types']; - } } if ($this->_coreRegistry->registry('attribute_type_hidden_fields') === null) { $this->_coreRegistry->register('attribute_type_hidden_fields', $_hiddenFields); } - if ($this->_coreRegistry->registry('attribute_type_disabled_types') === null) { - $this->_coreRegistry->register('attribute_type_disabled_types', $_disabledTypes); - } - return array_merge(parent::toOptionArray(), $inputTypes); } } diff --git a/dev/tests/unit/testsuite/Magento/GroupedProduct/Model/ProductTypes/Config/Converter/Plugin/GroupedTest.php b/app/code/Magento/Catalog/Model/Product/CartConfiguration.php similarity index 50% rename from dev/tests/unit/testsuite/Magento/GroupedProduct/Model/ProductTypes/Config/Converter/Plugin/GroupedTest.php rename to app/code/Magento/Catalog/Model/Product/CartConfiguration.php index 05cb2cdf712024d9b09b6463aab347168ec8864c..2a5bbf8165a594b37eb0e3eaba4b7bce459d4743 100644 --- a/dev/tests/unit/testsuite/Magento/GroupedProduct/Model/ProductTypes/Config/Converter/Plugin/GroupedTest.php +++ b/app/code/Magento/Catalog/Model/Product/CartConfiguration.php @@ -22,34 +22,32 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\GroupedProduct\Model\ProductTypes\Config\Converter\Plugin; +/** + * Cart product configuration model + */ +namespace Magento\Catalog\Model\Product; -class GroupedTest extends \PHPUnit_Framework_TestCase +class CartConfiguration { /** + * Decide whether product has been configured for cart or not + * + * @param \Magento\Catalog\Model\Product $product * @param array $config - * @param array $result - * @dataProvider afterConvertDataProvider - */ - public function testAfterConvert($config, $result) - { - $model = new \Magento\GroupedProduct\Model\ProductTypes\Config\Converter\Plugin\Grouped(); - $this->assertEquals($result, $model->afterConvert($config)); - } - - /** - * @return array + * @return bool */ - public function afterConvertDataProvider() + public function isProductConfigured(\Magento\Catalog\Model\Product $product, $config) { - $index = \Magento\GroupedProduct\Model\Product\Type\Grouped::TYPE_CODE; - $emptyConfig = array(1, 2, 3); - $config = array($index => array(1)); - $result = array($index => array(1, 'is_product_set' => true)); - - return array( - 'empty config' => array($emptyConfig, $emptyConfig), - 'with grouped' => array($config, $result), - ); + // If below POST fields were submitted - this is product's options, it has been already configured + switch ($product->getTypeId()) { + case \Magento\Catalog\Model\Product\Type::TYPE_SIMPLE: + case \Magento\Catalog\Model\Product\Type::TYPE_VIRTUAL: + return isset($config['options']); + case \Magento\Catalog\Model\Product\Type::TYPE_CONFIGURABLE: + return isset($config['super_attribute']); + case \Magento\Catalog\Model\Product\Type::TYPE_BUNDLE: + return isset($config['bundle_option']); + } + return false; } } diff --git a/app/code/Magento/Catalog/Model/Product/CatalogPrice.php b/app/code/Magento/Catalog/Model/Product/CatalogPrice.php new file mode 100644 index 0000000000000000000000000000000000000000..47dca13bd137edfe321b04859ec3108100ac2965 --- /dev/null +++ b/app/code/Magento/Catalog/Model/Product/CatalogPrice.php @@ -0,0 +1,92 @@ +<?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\Catalog\Model\Product; +use Magento\ObjectManager; + +/** + * Price model for external catalogs + */ +class CatalogPrice implements CatalogPriceInterface +{ + /** + * @var CatalogPriceFactory + */ + protected $priceModelFactory; + + /** + * @var array catalog price models for different product types + */ + protected $priceModelPool; + + /** + * + * @param CatalogPriceFactory $priceModelFactory + * @param array $priceModelPool + */ + public function __construct( + CatalogPriceFactory $priceModelFactory, + array $priceModelPool + ) { + $this->priceModelFactory = $priceModelFactory; + $this->priceModelPool = $priceModelPool; + } + + /** + * Minimal price for "regular" user + * + * @param \Magento\Catalog\Model\Product $product + * @param null|\Magento\Core\Model\Store $store Store view + * @param bool $inclTax + * @throws \UnexpectedValueException + * @return null|float + */ + public function getCatalogPrice(\Magento\Catalog\Model\Product $product, $store = null, $inclTax = false) + { + if (array_key_exists($product->getTypeId(), $this->priceModelPool)) { + $catalogPriceModel = $this->priceModelFactory->create($this->priceModelPool[$product->getTypeId()]); + return $catalogPriceModel->getCatalogPrice($product, $store, $inclTax); + } + + return $product->getFinalPrice(); + } + + /** + * Regular catalog price + * + * @param \Magento\Catalog\Model\Product $product + * @throws \UnexpectedValueException + * @return null + */ + public function getCatalogRegularPrice(\Magento\Catalog\Model\Product $product) + { + if (array_key_exists($product->getTypeId(), $this->priceModelPool)) { + $catalogPriceModel = $this->priceModelFactory->create($this->priceModelPool[$product->getTypeId()]); + return $catalogPriceModel->getCatalogRegularPrice($product); + } + + return $product->getPrice(); + } + +} \ No newline at end of file diff --git a/app/code/Magento/Catalog/Model/Product/CatalogPriceFactory.php b/app/code/Magento/Catalog/Model/Product/CatalogPriceFactory.php new file mode 100644 index 0000000000000000000000000000000000000000..ae79697b29a3c67edaa33b261fd84b77de1298b5 --- /dev/null +++ b/app/code/Magento/Catalog/Model/Product/CatalogPriceFactory.php @@ -0,0 +1,63 @@ +<?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\Catalog\Model\Product; + +/** + * Price model for external catalogs + */ +class CatalogPriceFactory +{ + /** + * @var \Magento\ObjectManager + */ + protected $objectManager; + + + /** + * @param \Magento\ObjectManager $objectManager + */ + public function __construct(\Magento\ObjectManager $objectManager) { + $this->objectManager = $objectManager; + } + + + /** + * Provide custom price model with basic validation + * + * @param string $name + * @return \Magento\Catalog\Model\Product\CatalogPriceInterface + * @throws \UnexpectedValueException + */ + public function create($name) + { + $customPriceModel = $this->objectManager->get($name); + if (!($customPriceModel instanceof \Magento\Catalog\Model\Product\CatalogPriceInterface)) { + throw new \UnexpectedValueException('Class ' . $name + . ' should be an instance of \Magento\Catalog\Model\Product\CatalogPriceInterface'); + } + + return $customPriceModel; + } +} \ No newline at end of file diff --git a/app/code/Magento/Catalog/Model/Product/CatalogPriceInterface.php b/app/code/Magento/Catalog/Model/Product/CatalogPriceInterface.php new file mode 100644 index 0000000000000000000000000000000000000000..4f5896ef26a9f86f25990f168dc6326680de8c12 --- /dev/null +++ b/app/code/Magento/Catalog/Model/Product/CatalogPriceInterface.php @@ -0,0 +1,49 @@ +<?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) + */ + +/** + * Product price interface for external catalogs + */ +namespace Magento\Catalog\Model\Product; + +interface CatalogPriceInterface +{ + /** + * Minimal price for "regular" user + * + * @param \Magento\Catalog\Model\Product $product + * @param null|\Magento\Core\Model\Store $store Store view + * @param bool $inclTax + * @return null|float + */ + public function getCatalogPrice(\Magento\Catalog\Model\Product $product, $store = null, $inclTax = false); + + /** + * Calculate price without discount for external catalogs if applicable + * + * @param \Magento\Catalog\Model\Product $product + * @return mixed + */ + public function getCatalogRegularPrice(\Magento\Catalog\Model\Product $product); +} \ No newline at end of file diff --git a/app/code/Magento/Catalog/Model/Product/Image.php b/app/code/Magento/Catalog/Model/Product/Image.php index 54461a0d16e0db7a3dbc6ec8a8cc59c6a56b4856..ea6461360d853541d267c78e39079c2e400a90e2 100644 --- a/app/code/Magento/Catalog/Model/Product/Image.php +++ b/app/code/Magento/Catalog/Model/Product/Image.php @@ -584,7 +584,7 @@ class Image extends \Magento\Core\Model\AbstractModel "Magento_Catalog::images/product/placeholder/{$this->getDestinationSubdir()}.jpg" ); } else { - $url = $this->_storeManager->getStore()->getBaseUrl(Store::URL_TYPE_MEDIA) . $this->_newFile; + $url = $this->_storeManager->getStore()->getBaseUrl(\Magento\UrlInterface::URL_TYPE_MEDIA) . $this->_newFile; } return $url; diff --git a/app/code/Magento/Catalog/Model/Product/Indexer/Price.php b/app/code/Magento/Catalog/Model/Product/Indexer/Price.php index 21e7d601feac984e90583492f4f351c961f58d84..67f8352b2796a6391dd05b890a4afe30574ae204 100644 --- a/app/code/Magento/Catalog/Model/Product/Indexer/Price.php +++ b/app/code/Magento/Catalog/Model/Product/Indexer/Price.php @@ -74,7 +74,7 @@ class Price extends \Magento\Index\Model\Indexer\AbstractIndexer \Magento\Index\Model\Event::TYPE_MASS_ACTION, self::EVENT_TYPE_REINDEX_PRICE, ), - \Magento\Core\Model\Config\Value::ENTITY => array( + \Magento\App\Config\ValueInterface::ENTITY => array( \Magento\Index\Model\Event::TYPE_SAVE ), \Magento\Customer\Model\Group::ENTITY => array( @@ -149,7 +149,7 @@ class Price extends \Magento\Index\Model\Indexer\AbstractIndexer return $data[self::EVENT_MATCH_RESULT_KEY]; } - if ($event->getEntity() == \Magento\Core\Model\Config\Value::ENTITY) { + if ($event->getEntity() == \Magento\App\Config\ValueInterface::ENTITY) { $data = $event->getDataObject(); if ($data && in_array($data->getPath(), $this->_relatedConfigSettings)) { $result = $data->isValueChanged(); @@ -250,7 +250,7 @@ class Price extends \Magento\Index\Model\Indexer\AbstractIndexer $event->addNewData(self::EVENT_MATCH_RESULT_KEY, true); $entity = $event->getEntity(); - if ($entity == \Magento\Core\Model\Config\Value::ENTITY || $entity == \Magento\Customer\Model\Group::ENTITY) { + if ($entity == \Magento\App\Config\ValueInterface::ENTITY || $entity == \Magento\Customer\Model\Group::ENTITY) { $process = $event->getProcess(); $process->changeStatus(\Magento\Index\Model\Process::STATUS_REQUIRE_REINDEX); } else if ($entity == \Magento\Catalog\Model\Product::ENTITY) { diff --git a/app/code/Magento/Catalog/Model/Product/LinkTypeProvider.php b/app/code/Magento/Catalog/Model/Product/LinkTypeProvider.php new file mode 100644 index 0000000000000000000000000000000000000000..ee5c19332b405838381d0d8caaa2a8ec976dddab --- /dev/null +++ b/app/code/Magento/Catalog/Model/Product/LinkTypeProvider.php @@ -0,0 +1,57 @@ +<?php +/** + * Collection of the available product link types + * + * 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\Catalog\Model\Product; + +class LinkTypeProvider +{ + /** + * Available product link types + * + * Represented by an assoc array with the following format 'product_link_name' => 'product_link_code' + * + * @var array + */ + protected $_linkTypes; + + /** + * @param array $linkTypes + */ + public function __construct( + array $linkTypes = array() + ) { + $this->_linkTypes = $linkTypes; + } + + /** + * Retrieve information about available product link types + * + * @return array + */ + public function getLinkTypes() + { + return $this->_linkTypes; + } +} diff --git a/app/code/Magento/Catalog/Model/Product/Media/Config.php b/app/code/Magento/Catalog/Model/Product/Media/Config.php index fbfa9e2f6c5d6885dd8724ae73411c7ac546aeb8..56b09e0b956251881509d6a36f299c81747ca002 100644 --- a/app/code/Magento/Catalog/Model/Product/Media/Config.php +++ b/app/code/Magento/Catalog/Model/Product/Media/Config.php @@ -86,7 +86,7 @@ class Config implements ConfigInterface public function getBaseMediaUrl() { return $this->storeManager->getStore() - ->getBaseUrl(\Magento\Core\Model\Store::URL_TYPE_MEDIA) . 'catalog/product'; + ->getBaseUrl(\Magento\UrlInterface::URL_TYPE_MEDIA) . 'catalog/product'; } /** @@ -106,7 +106,7 @@ class Config implements ConfigInterface public function getBaseTmpMediaUrl() { return $this->storeManager->getStore() - ->getBaseUrl(\Magento\Core\Model\Store::URL_TYPE_MEDIA) . 'tmp/' . $this->getBaseMediaUrlAddition(); + ->getBaseUrl(\Magento\UrlInterface::URL_TYPE_MEDIA) . 'tmp/' . $this->getBaseMediaUrlAddition(); } /** diff --git a/app/code/Magento/Catalog/Model/Product/Url.php b/app/code/Magento/Catalog/Model/Product/Url.php index c59b004ad8fd16b48d0e86ab81bbafa1a4565249..3c8277c772d7d94723629e516064f3ed2baa2b69 100644 --- a/app/code/Magento/Catalog/Model/Product/Url.php +++ b/app/code/Magento/Catalog/Model/Product/Url.php @@ -41,7 +41,7 @@ class Url extends \Magento\Object /** * Static URL instance * - * @var \Magento\Core\Model\Url + * @var \Magento\UrlInterface */ protected $_url; @@ -74,11 +74,9 @@ class Url extends \Magento\Object protected $_storeManager; /** - * App model - * - * @var \Magento\Core\Model\App + * @var \Magento\Session\SidResolverInterface */ - protected $_app; + protected $_sidResolver; /** * Construct @@ -88,7 +86,7 @@ class Url extends \Magento\Object * @param \Magento\Core\Model\StoreManagerInterface $storeManager * @param \Magento\Catalog\Helper\Category $catalogCategory * @param \Magento\Catalog\Helper\Product\Url $catalogProductUrl - * @param \Magento\Core\Model\App $app + * @param \Magento\Session\SidResolverInterface $sidResolver * @param array $data */ public function __construct( @@ -97,7 +95,7 @@ class Url extends \Magento\Object \Magento\Core\Model\StoreManagerInterface $storeManager, \Magento\Catalog\Helper\Category $catalogCategory, \Magento\Catalog\Helper\Product\Url $catalogProductUrl, - \Magento\Core\Model\App $app, + \Magento\Session\SidResolverInterface $sidResolver, array $data = array() ) { $this->_urlRewrite = $urlRewriteFactory->create(); @@ -105,14 +103,14 @@ class Url extends \Magento\Object $this->_storeManager = $storeManager; $this->_catalogCategory = $catalogCategory; $this->_catalogProductUrl = $catalogProductUrl; - $this->_app = $app; + $this->_sidResolver = $sidResolver; parent::__construct($data); } /** * Retrieve URL Instance * - * @return \Magento\Core\Model\Url + * @return \Magento\UrlInterface */ public function getUrlInstance() { @@ -152,7 +150,7 @@ class Url extends \Magento\Object */ public function getUrlInStore(\Magento\Catalog\Model\Product $product, $params = array()) { - $params['_store_to_url'] = true; + $params['_scope_to_url'] = true; return $this->getUrl($product, $params); } @@ -166,7 +164,7 @@ class Url extends \Magento\Object public function getProductUrl($product, $useSid = null) { if ($useSid === null) { - $useSid = $this->_app->getUseSessionInUrl(); + $useSid = $this->_sidResolver->getUseSessionInUrl(); } $params = array(); @@ -239,7 +237,7 @@ class Url extends \Magento\Object if ($product->hasUrlDataObject()) { $requestPath = $product->getUrlDataObject()->getUrlRewrite(); - $routeParams['_store'] = $product->getUrlDataObject()->getStoreId(); + $routeParams['_scope'] = $product->getUrlDataObject()->getStoreId(); } else { $requestPath = $product->getRequestPath(); if (empty($requestPath) && $requestPath !== false) { @@ -259,12 +257,12 @@ class Url extends \Magento\Object } } - if (isset($routeParams['_store'])) { - $storeId = $this->_storeManager->getStore($routeParams['_store'])->getId(); + if (isset($routeParams['_scope'])) { + $storeId = $this->_storeManager->getStore($routeParams['_scope'])->getId(); } if ($storeId != $this->_storeManager->getStore()->getId()) { - $routeParams['_store_to_url'] = true; + $routeParams['_scope_to_url'] = true; } if (!empty($requestPath)) { @@ -283,7 +281,7 @@ class Url extends \Magento\Object $routeParams['_query'] = array(); } - return $this->getUrlInstance()->setStore($storeId) + return $this->getUrlInstance()->setScope($storeId) ->getUrl($routePath, $routeParams); } } diff --git a/app/code/Magento/Catalog/Model/ProductTypes/Config.php b/app/code/Magento/Catalog/Model/ProductTypes/Config.php index 3e68285f783e60d765876282e211ddff82147755..e07b60fa5a14ad1c096bebae55d6ed81c051ea3c 100644 --- a/app/code/Magento/Catalog/Model/ProductTypes/Config.php +++ b/app/code/Magento/Catalog/Model/ProductTypes/Config.php @@ -46,7 +46,7 @@ class Config extends \Magento\Config\Data implements \Magento\Catalog\Model\Prod */ public function getType($name) { - return $this->get($name, array()); + return $this->get('types/' . $name, array()); } /** @@ -56,7 +56,7 @@ class Config extends \Magento\Config\Data implements \Magento\Catalog\Model\Prod */ public function getAll() { - return $this->get(); + return $this->get('types'); } /** @@ -67,6 +67,16 @@ class Config extends \Magento\Config\Data implements \Magento\Catalog\Model\Prod */ public function isProductSet($typeId) { - return $this->get($typeId . '/is_product_set', false); + return 'true' == $this->get('types/' . $typeId . '/custom_attributes/is_product_set', false); + } + + /** + * Get composable types + * + * @return array + */ + public function getComposableTypes() + { + return $this->get('composableTypes', array()); } } diff --git a/app/code/Magento/Catalog/Model/ProductTypes/Config/Converter.php b/app/code/Magento/Catalog/Model/ProductTypes/Config/Converter.php index 60a43b9e88e4462f8f4b2c92f608df85f603952b..a9997336173702537dd5c0cb34e7c49382bb8f9f 100644 --- a/app/code/Magento/Catalog/Model/ProductTypes/Config/Converter.php +++ b/app/code/Magento/Catalog/Model/ProductTypes/Config/Converter.php @@ -39,7 +39,7 @@ class Converter implements \Magento\Config\ConverterInterface $output = array(); $xpath = new \DOMXPath($source); $types = $xpath->evaluate('/config/type'); - /** @var $typeNode DOMNode */ + /** @var $typeNode \DOMNode */ foreach ($types as $typeNode) { $typeName = $this->_getAttributeValue($typeNode, 'name'); $isComposite = $this->_getAttributeValue($typeNode, 'composite', 'false'); @@ -54,7 +54,7 @@ class Converter implements \Magento\Config\ConverterInterface $data['can_use_qty_decimals'] = !empty($isDecimal) && 'false' !== $isDecimal; $data['is_qty'] = !empty($isQty) && 'false' !== $isQty; - /** @var $childNode DOMNode */ + /** @var $childNode \DOMNode */ foreach ($typeNode->childNodes as $childNode) { if ($childNode->nodeType != XML_ELEMENT_NODE) { continue; @@ -70,18 +70,8 @@ class Converter implements \Magento\Config\ConverterInterface case 'stockIndexerModel': $data['stock_indexer'] = $this->_getAttributeValue($childNode, 'instance'); break; - case 'allowProductTypes': - /** @var $allowedTypes DOMNode */ - foreach ($childNode->childNodes as $allowedTypes) { - if ($allowedTypes->nodeType != XML_ELEMENT_NODE) { - continue; - } - $name = $this->_getAttributeValue($allowedTypes, 'name'); - $data['allow_product_types'][$name] = $name; - } - break; case 'allowedSelectionTypes': - /** @var $selectionsTypes DOMNode */ + /** @var $selectionsTypes \DOMNode */ foreach ($childNode->childNodes as $selectionsTypes) { if ($selectionsTypes->nodeType != XML_ELEMENT_NODE) { continue; @@ -90,18 +80,37 @@ class Converter implements \Magento\Config\ConverterInterface $data['allowed_selection_types'][$name] = $name; } break; + case 'customAttributes': + /** @var $customAttributes \DOMNode */ + foreach ($childNode->childNodes as $customAttributes) { + if ($customAttributes->nodeType != XML_ELEMENT_NODE) { + continue; + } + $name = $this->_getAttributeValue($customAttributes, 'name'); + $value = $this->_getAttributeValue($customAttributes, 'value'); + $data['custom_attributes'][$name] = $value; + } + break; } } - $output[$typeName] = $data; + $output['types'][$typeName] = $data; + } + + $composableTypes = $xpath->evaluate('/config/composableTypes/*'); + $output['composableTypes'] = array(); + foreach ($composableTypes as $typeNode) { + $typeName = $this->_getAttributeValue($typeNode, 'name'); + $output['composableTypes'][$typeName] = $typeName; } + return $output; } /** * Get attribute value * - * @param DOMNode $input + * @param \DOMNode $input * @param string $attributeName * @param mixed $default * @return null|string diff --git a/app/code/Magento/Catalog/Model/ProductTypes/Config/Reader.php b/app/code/Magento/Catalog/Model/ProductTypes/Config/Reader.php index 30463aa49d482f9e1a02e31f6bf63ae62a968c6c..71ee55160017d7e60546cfbf83f13a9b132352e2 100644 --- a/app/code/Magento/Catalog/Model/ProductTypes/Config/Reader.php +++ b/app/code/Magento/Catalog/Model/ProductTypes/Config/Reader.php @@ -35,14 +35,14 @@ class Reader extends \Magento\Config\Reader\Filesystem '/config/type/priceModel' => 'instance', '/config/type/indexerModel' => 'instance', '/config/type/stockIndexerModel' => 'instance', - '/config/type/allowProductTypes/type' => 'name', '/config/type/allowedSelectionTypes/type' => 'name', + '/config/composableTypes/type' => 'name', ); /** * @param \Magento\Config\FileResolverInterface $fileResolver - * @param \Magento\Catalog\Model\ProductTypes\Config\Converter $converter - * @param \Magento\Catalog\Model\ProductTypes\Config\SchemaLocator $schemaLocator + * @param Converter $converter + * @param SchemaLocator $schemaLocator * @param \Magento\Config\ValidationStateInterface $validationState * @param string $fileName * @param array $idAttributes @@ -51,8 +51,8 @@ class Reader extends \Magento\Config\Reader\Filesystem */ public function __construct( \Magento\Config\FileResolverInterface $fileResolver, - \Magento\Catalog\Model\ProductTypes\Config\Converter $converter, - \Magento\Catalog\Model\ProductTypes\Config\SchemaLocator $schemaLocator, + Converter $converter, + SchemaLocator $schemaLocator, \Magento\Config\ValidationStateInterface $validationState, $fileName = 'product_types.xml', $idAttributes = array(), diff --git a/app/code/Magento/Catalog/Model/ProductTypes/ConfigInterface.php b/app/code/Magento/Catalog/Model/ProductTypes/ConfigInterface.php index f868e70e8111e1a8571b4165b4919ce837bf17a1..b66db7b741a8e4d45b98e407b81b86a4ee04e1f8 100644 --- a/app/code/Magento/Catalog/Model/ProductTypes/ConfigInterface.php +++ b/app/code/Magento/Catalog/Model/ProductTypes/ConfigInterface.php @@ -47,4 +47,11 @@ interface ConfigInterface * @return bool */ public function isProductSet($typeId); + + /** + * Get composable types + * + * @return array + */ + public function getComposableTypes(); } diff --git a/app/code/Magento/Catalog/Model/Resource/Attribute.php b/app/code/Magento/Catalog/Model/Resource/Attribute.php index 9a284295bc357436a331e5c00a6e7b185d34a226..9add61456d7e1505495a7d053d2698b913d53a87 100644 --- a/app/code/Magento/Catalog/Model/Resource/Attribute.php +++ b/app/code/Magento/Catalog/Model/Resource/Attribute.php @@ -43,34 +43,22 @@ class Attribute extends \Magento\Eav\Model\Resource\Entity\Attribute */ protected $_eavConfig; - /** - * Store manager - * - * @var \Magento\Core\Model\StoreManagerInterface - */ - protected $_storeManager; - /** * Class constructor * * @param \Magento\App\Resource $resource - * @param \Magento\Core\Model\App $app - * @param \Magento\Eav\Model\Resource\Entity\Type $eavEntityType * @param \Magento\Core\Model\StoreManagerInterface $storeManager + * @param \Magento\Eav\Model\Resource\Entity\Type $eavEntityType * @param \Magento\Eav\Model\Config $eavConfig - * @param array $arguments */ public function __construct( \Magento\App\Resource $resource, - \Magento\Core\Model\App $app, - \Magento\Eav\Model\Resource\Entity\Type $eavEntityType, \Magento\Core\Model\StoreManagerInterface $storeManager, - \Magento\Eav\Model\Config $eavConfig, - array $arguments = array() + \Magento\Eav\Model\Resource\Entity\Type $eavEntityType, + \Magento\Eav\Model\Config $eavConfig ) { - $this->_storeManager = $storeManager; $this->_eavConfig = $eavConfig; - parent::__construct($resource, $app, $eavEntityType, $arguments); + parent::__construct($resource, $storeManager, $eavEntityType); } /** diff --git a/app/code/Magento/Catalog/Model/Resource/Category/Attribute/Frontend/Image.php b/app/code/Magento/Catalog/Model/Resource/Category/Attribute/Frontend/Image.php index 6c258dc545dd20d1fc7b2d6f55396295b4719323..7bc25029ff545c61fe01e5d24d6ff6192b1cecb9 100644 --- a/app/code/Magento/Catalog/Model/Resource/Category/Attribute/Frontend/Image.php +++ b/app/code/Magento/Catalog/Model/Resource/Category/Attribute/Frontend/Image.php @@ -68,7 +68,7 @@ class Image $url = false; if ($image = $object->getData($this->getAttribute()->getAttributeCode())) { $url = $this->_storeManager->getStore() - ->getBaseUrl(\Magento\Core\Model\Store::URL_TYPE_MEDIA) . self::IMAGE_PATH_SEGMENT . $image; + ->getBaseUrl(\Magento\UrlInterface::URL_TYPE_MEDIA) . self::IMAGE_PATH_SEGMENT . $image; } return $url; } diff --git a/app/code/Magento/Catalog/Model/Resource/Product/Indexer/Price.php b/app/code/Magento/Catalog/Model/Resource/Product/Indexer/Price.php index c7e79c60892dffd1dccd2cc1dd773d77abbce2de..fb6ca5e5a87e605856774c6087ec7393bb88e310 100644 --- a/app/code/Magento/Catalog/Model/Resource/Product/Indexer/Price.php +++ b/app/code/Magento/Catalog/Model/Resource/Product/Indexer/Price.php @@ -81,7 +81,7 @@ class Price extends \Magento\Index\Model\Resource\AbstractResource /** * Core config model * - * @var \Magento\Core\Model\ConfigInterface + * @var \Magento\App\ConfigInterface */ protected $_config; @@ -103,7 +103,7 @@ class Price extends \Magento\Index\Model\Resource\AbstractResource * @param \Magento\Core\Model\StoreManagerInterface $storeManager * @param \Magento\Core\Model\LocaleInterface $locale * @param \Magento\Catalog\Model\Product\Type $catalogProductType - * @param \Magento\Core\Model\Config $config + * @param \Magento\App\ConfigInterface $config * @param \Magento\Catalog\Model\Resource\Product\Indexer\Price\Factory $indexerPriceFactory * @param \Magento\Stdlib\DateTime $dateTime */ @@ -113,7 +113,7 @@ class Price extends \Magento\Index\Model\Resource\AbstractResource \Magento\Core\Model\StoreManagerInterface $storeManager, \Magento\Core\Model\LocaleInterface $locale, \Magento\Catalog\Model\Product\Type $catalogProductType, - \Magento\Core\Model\Config $config, + \Magento\App\ConfigInterface $config, \Magento\Catalog\Model\Resource\Product\Indexer\Price\Factory $indexerPriceFactory, \Magento\Stdlib\DateTime $dateTime ) { diff --git a/app/code/Magento/Catalog/Model/Resource/Product/Option.php b/app/code/Magento/Catalog/Model/Resource/Product/Option.php index 58c8f0b41e877c2b12db37936af456c1310aa57f..a7fbd81e406cf2f49e6bb977d60e4eb9acacc4ac 100644 --- a/app/code/Magento/Catalog/Model/Resource/Product/Option.php +++ b/app/code/Magento/Catalog/Model/Resource/Product/Option.php @@ -53,7 +53,7 @@ class Option extends \Magento\Core\Model\Resource\Db\AbstractDb /** * Core config model * - * @var \Magento\Core\Model\ConfigInterface + * @var \Magento\App\ConfigInterface */ protected $_config; @@ -63,13 +63,13 @@ class Option extends \Magento\Core\Model\Resource\Db\AbstractDb * @param \Magento\App\Resource $resource * @param \Magento\Directory\Model\CurrencyFactory $currencyFactory * @param \Magento\Core\Model\StoreManagerInterface $storeManager - * @param \Magento\Core\Model\Config $config + * @param \Magento\App\ConfigInterface $config */ public function __construct( \Magento\App\Resource $resource, \Magento\Directory\Model\CurrencyFactory $currencyFactory, \Magento\Core\Model\StoreManagerInterface $storeManager, - \Magento\Core\Model\Config $config + \Magento\App\ConfigInterface $config ) { $this->_currencyFactory = $currencyFactory; $this->_storeManager = $storeManager; diff --git a/app/code/Magento/Catalog/Model/Resource/Product/Option/Value.php b/app/code/Magento/Catalog/Model/Resource/Product/Option/Value.php index dc933d9c78371df51c1d0f3a58cce6d80981e6ec..606ebee79d072c4da55cd629767ede74b8a619a7 100644 --- a/app/code/Magento/Catalog/Model/Resource/Product/Option/Value.php +++ b/app/code/Magento/Catalog/Model/Resource/Product/Option/Value.php @@ -53,7 +53,7 @@ class Value extends \Magento\Core\Model\Resource\Db\AbstractDb /** * Core config model * - * @var \Magento\Core\Model\ConfigInterface + * @var \Magento\App\ConfigInterface */ protected $_config; @@ -63,13 +63,13 @@ class Value extends \Magento\Core\Model\Resource\Db\AbstractDb * @param \Magento\App\Resource $resource * @param \Magento\Directory\Model\CurrencyFactory $currencyFactory * @param \Magento\Core\Model\StoreManagerInterface $storeManager - * @param \Magento\Core\Model\Config $config + * @param \Magento\App\ConfigInterface $config */ public function __construct( \Magento\App\Resource $resource, \Magento\Directory\Model\CurrencyFactory $currencyFactory, \Magento\Core\Model\StoreManagerInterface $storeManager, - \Magento\Core\Model\Config $config + \Magento\App\ConfigInterface $config ) { $this->_currencyFactory = $currencyFactory; $this->_storeManager = $storeManager; diff --git a/app/code/Magento/Catalog/Model/System/Config/Backend/Catalog/Category/Flat.php b/app/code/Magento/Catalog/Model/System/Config/Backend/Catalog/Category/Flat.php index c6b6a5f31b13d725c6d9f4107d9319fff760d0b5..23db87c2c098f1b7dd1dfeb7cf05bc2cad33f1b9 100644 --- a/app/code/Magento/Catalog/Model/System/Config/Backend/Catalog/Category/Flat.php +++ b/app/code/Magento/Catalog/Model/System/Config/Backend/Catalog/Category/Flat.php @@ -42,7 +42,7 @@ class Flat extends \Magento\Core\Model\Config\Value * @param \Magento\Core\Model\Context $context * @param \Magento\Core\Model\Registry $registry * @param \Magento\Core\Model\StoreManagerInterface $storeManager - * @param \Magento\Core\Model\Config $config + * @param \Magento\App\ConfigInterface $config * @param \Magento\Index\Model\IndexerFactory $indexerFactory * @param \Magento\Core\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection @@ -52,7 +52,7 @@ class Flat extends \Magento\Core\Model\Config\Value \Magento\Core\Model\Context $context, \Magento\Core\Model\Registry $registry, \Magento\Core\Model\StoreManagerInterface $storeManager, - \Magento\Core\Model\Config $config, + \Magento\App\ConfigInterface $config, \Magento\Index\Model\IndexerFactory $indexerFactory, \Magento\Core\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, diff --git a/app/code/Magento/Catalog/Model/System/Config/Backend/Catalog/Product/Flat.php b/app/code/Magento/Catalog/Model/System/Config/Backend/Catalog/Product/Flat.php index 556e9fb13b435facdd667904bd8921ae2c3254b8..159e7ac3f4d795596d8241f869e6980b0e092092 100644 --- a/app/code/Magento/Catalog/Model/System/Config/Backend/Catalog/Product/Flat.php +++ b/app/code/Magento/Catalog/Model/System/Config/Backend/Catalog/Product/Flat.php @@ -42,7 +42,7 @@ class Flat extends \Magento\Core\Model\Config\Value * @param \Magento\Core\Model\Context $context * @param \Magento\Core\Model\Registry $registry * @param \Magento\Core\Model\StoreManagerInterface $storeManager - * @param \Magento\Core\Model\Config $config + * @param \Magento\App\ConfigInterface $config * @param \Magento\Index\Model\Indexer $indexIndexer * @param \Magento\Core\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection @@ -52,7 +52,7 @@ class Flat extends \Magento\Core\Model\Config\Value \Magento\Core\Model\Context $context, \Magento\Core\Model\Registry $registry, \Magento\Core\Model\StoreManagerInterface $storeManager, - \Magento\Core\Model\Config $config, + \Magento\App\ConfigInterface $config, \Magento\Index\Model\Indexer $indexIndexer, \Magento\Core\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, diff --git a/app/code/Magento/Catalog/Model/System/Config/Backend/Catalog/Url/Rewrite/Suffix.php b/app/code/Magento/Catalog/Model/System/Config/Backend/Catalog/Url/Rewrite/Suffix.php index 4ae31d45bd1ad656158be1ea587b36a0e11449b3..85063da36fb393d7d3727ad19d83b67611e82099 100644 --- a/app/code/Magento/Catalog/Model/System/Config/Backend/Catalog/Url/Rewrite/Suffix.php +++ b/app/code/Magento/Catalog/Model/System/Config/Backend/Catalog/Url/Rewrite/Suffix.php @@ -42,7 +42,7 @@ class Suffix extends \Magento\Core\Model\Config\Value * @param \Magento\Core\Model\Context $context * @param \Magento\Core\Model\Registry $registry * @param \Magento\Core\Model\StoreManagerInterface $storeManager - * @param \Magento\Core\Model\Config $config + * @param \Magento\App\ConfigInterface $config * @param \Magento\Core\Helper\Url\Rewrite $coreUrlRewrite * @param \Magento\Core\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection @@ -52,7 +52,7 @@ class Suffix extends \Magento\Core\Model\Config\Value \Magento\Core\Model\Context $context, \Magento\Core\Model\Registry $registry, \Magento\Core\Model\StoreManagerInterface $storeManager, - \Magento\Core\Model\Config $config, + \Magento\App\ConfigInterface $config, \Magento\Core\Helper\Url\Rewrite $coreUrlRewrite, \Magento\Core\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, diff --git a/app/code/Magento/Catalog/Model/Template/Filter.php b/app/code/Magento/Catalog/Model/Template/Filter.php index 69d18bff5db99143def878da78ab9e00e1533c43..2a12cdcf4404f6a9e4d9a523c62460b9cde1c5e3 100644 --- a/app/code/Magento/Catalog/Model/Template/Filter.php +++ b/app/code/Magento/Catalog/Model/Template/Filter.php @@ -132,7 +132,7 @@ class Filter extends \Magento\Filter\Template public function mediaDirective($construction) { $params = $this->_getIncludeParameters($construction[2]); - return $this->_storeManager->getStore()->getBaseUrl(\Magento\Core\Model\Store::URL_TYPE_MEDIA) . $params['url']; + return $this->_storeManager->getStore()->getBaseUrl(\Magento\UrlInterface::URL_TYPE_MEDIA) . $params['url']; } /** diff --git a/app/code/Magento/Catalog/etc/adminhtml/di.xml b/app/code/Magento/Catalog/etc/adminhtml/di.xml index 8569d9473101f1334b9687808c3c4f7fbbd3683f..7261a5fdcd0723dc8c6e45fe5663d354d3c2703b 100644 --- a/app/code/Magento/Catalog/etc/adminhtml/di.xml +++ b/app/code/Magento/Catalog/etc/adminhtml/di.xml @@ -36,24 +36,32 @@ </type> <type name="Magento\Catalog\Block\Adminhtml\Product\Frontend\Product\Watermark"> <param name="imageTypes"> - <value> - <small> - <title>Small</title> - <attribute>small_image</attribute> - </small> - <main> - <title>Main</title> - <attribute>image</attribute> - </main> - <cart> - <title>Thumbnail</title> - <attribute>thumbnail</attribute> - </cart> - <custom> - <title>Custom image</title> - <attribute>custom_image</attribute> - </custom> - </value> + <array> + <item key="small"> + <array> + <item key="title"><value>Small</value></item> + <item key="attribute"><value>small_image</value></item> + </array> + </item> + <item key="main"> + <array> + <item key="title"><value>Main</value></item> + <item key="attribute"><value>image</value></item> + </array> + </item> + <item key="cart"> + <array> + <item key="title"><value>Thumbnail</value></item> + <item key="attribute"><value>thumbnail</value></item> + </array> + </item> + <item key="custom"> + <array> + <item key="title"><value>Custom image</value></item> + <item key="attribute"><value>custom_image</value></item> + </array> + </item> + </array> </param> </type> <type name="Magento\Catalog\Helper\Flat\AbstractFlat"> @@ -66,11 +74,11 @@ </type> <type name="Magento\Catalog\Model\Product\CopyConstructor\Composite"> <param name="constructors"> - <value> - <crossSell>Magento\Catalog\Model\Product\CopyConstructor\CrossSell</crossSell> - <upSell>Magento\Catalog\Model\Product\CopyConstructor\UpSell</upSell> - <related>Magento\Catalog\Model\Product\CopyConstructor\Related</related> - </value> + <array> + <item key="crossSell"><value>Magento\Catalog\Model\Product\CopyConstructor\CrossSell</value></item> + <item key="upSell"><value>Magento\Catalog\Model\Product\CopyConstructor\UpSell</value></item> + <item key="related"><value>Magento\Catalog\Model\Product\CopyConstructor\Related</value></item> + </array> </param> </type> <type name="Magento\Catalog\Model\Product\Copier"> diff --git a/app/code/Magento/Catalog/etc/di.xml b/app/code/Magento/Catalog/etc/di.xml index aa1521b927993d95192d1d1d5d277f2740cb45cd..40b3d657c57276e529c30acaa3d29e6b7edbd75e 100644 --- a/app/code/Magento/Catalog/etc/di.xml +++ b/app/code/Magento/Catalog/etc/di.xml @@ -52,9 +52,9 @@ <value type="int">64</value> </param> <param name="flatAttributeGroups"> - <value> - <catalog_product>catalog_product</catalog_product> - </value> + <array> + <item key="catalog_product"><value>catalog_product</value></item> + </array> </param> </type> <type name="Magento\Catalog\Model\Resource\Product\Collection"> @@ -67,16 +67,20 @@ </type> <type name="Magento\Catalog\Model\Entity\Product\Attribute\Design\Options\Container"> <param name="options"> - <value> - <option1> - <value>container1</value> - <label>Product Info Column</label> - </option1> - <option2> - <value>container2</value> - <label>Block after Info Column</label> - </option2> - </value> + <array> + <item key="option1"> + <array> + <item key="value"><value>container1</value></item> + <item key="label"><value>Product Info Column</value></item> + </array> + </item> + <item key="option2"> + <array> + <item key="value"><value>container2</value></item> + <item key="label"><value>Block after Info Column</value></item> + </array> + </item> + </array> </param> </type> <type name="Magento\Catalog\Helper\Product\Flat"> @@ -112,9 +116,9 @@ </type> <type name="Magento\Module\Updater\SetupFactory"> <param name="resourceTypes"> - <value> - <catalog_setup>Magento\Catalog\Model\Resource\Setup</catalog_setup> - </value> + <array> + <item key="catalog_setup"><value>Magento\Catalog\Model\Resource\Setup</value></item> + </array> </param> </type> <type name="Magento\Catalog\Helper\Product\Compare"> @@ -145,4 +149,13 @@ <instance type="Magento\Catalog\Model\System\Config\Source\InputtypeFactory" /> </param> </type> + <type name="Magento\Catalog\Model\Product\LinkTypeProvider"> + <param name="linkTypes"> + <array> + <item key="links_related"><value type="const">Magento\Catalog\Model\Product\Link::LINK_TYPE_RELATED</value></item> + <item key="links_crosssell"><value type="const">Magento\Catalog\Model\Product\Link::LINK_TYPE_CROSSSELL</value></item> + <item key="links_upsell"><value type="const">Magento\Catalog\Model\Product\Link::LINK_TYPE_UPSELL</value></item> + </array> + </param> + </type> </config> diff --git a/app/code/Magento/Catalog/etc/frontend/di.xml b/app/code/Magento/Catalog/etc/frontend/di.xml index cd0ed17bbef3cd8b5b3653a284b4cb79c600e0b9..311d0f60dbe2dcf5bfebbb8acc0fae6969473e3d 100644 --- a/app/code/Magento/Catalog/etc/frontend/di.xml +++ b/app/code/Magento/Catalog/etc/frontend/di.xml @@ -39,9 +39,9 @@ </type> <virtualType name="compareProductInitSession" type="Magento\Core\App\Action\Plugin\Session"> <param name="cookieCheckActions"> - <value> - <compareProductAdd>add</compareProductAdd> - </value> + <array> + <item key="compareProductAdd"><value>add</value></item> + </array> </param> </virtualType> <type name="Magento\Catalog\Controller\Product\Compare"> diff --git a/app/code/Magento/Catalog/etc/product_types.xml b/app/code/Magento/Catalog/etc/product_types.xml index a4e0ddc487a370d9a17e06b4c39860b5be9dd15d..0a093d3e7bdfa836e438c7808cace75018a93630 100644 --- a/app/code/Magento/Catalog/etc/product_types.xml +++ b/app/code/Magento/Catalog/etc/product_types.xml @@ -24,14 +24,26 @@ */ --> <config> - <type name="simple" label="Simple Product" modelInstance="Magento\Catalog\Model\Product\Type\Simple" indexPriority="10" /> + <type name="simple" label="Simple Product" modelInstance="Magento\Catalog\Model\Product\Type\Simple" indexPriority="10"> + <customAttributes> + <attribute name="refundable" value="true"/> + </customAttributes> + </type> <type name="configurable" label="Configurable Product" modelInstance="Magento\Catalog\Model\Product\Type\Configurable" composite='true' indexPriority="30"> <priceModel instance="Magento\Catalog\Model\Product\Type\Configurable\Price" /> <indexerModel instance="Magento\Catalog\Model\Resource\Product\Indexer\Price\Configurable" /> - <allowProductTypes> - <type name="simple" /> - <type name="virtual" /> - </allowProductTypes> + <customAttributes> + <attribute name="refundable" value="true"/> + </customAttributes> + </type> + <type name="virtual" label="Virtual Product" modelInstance="Magento\Catalog\Model\Product\Type\Virtual" indexPriority="20"> + <customAttributes> + <attribute name="is_real_product" value="false"/> + </customAttributes> </type> - <type name="virtual" label="Virtual Product" modelInstance="Magento\Catalog\Model\Product\Type\Virtual" indexPriority="20" /> + + <composableTypes> + <type name="simple" /> + <type name="virtual" /> + </composableTypes> </config> diff --git a/app/code/Magento/Catalog/etc/product_types.xsd b/app/code/Magento/Catalog/etc/product_types.xsd index 610402841553aebde82b5a904dd2d6eb70bed3b3..6f5a6adc8c02428235a0e152ebf10678ac506e9f 100644 --- a/app/code/Magento/Catalog/etc/product_types.xsd +++ b/app/code/Magento/Catalog/etc/product_types.xsd @@ -24,11 +24,14 @@ */ --> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> + <xs:include schemaLocation="product_types_base.xsd" /> + <xs:element name="config"> <xs:complexType> - <xs:sequence> - <xs:element name="type" type="typeDeclaration" minOccurs="1" maxOccurs="unbounded" /> - </xs:sequence> + <xs:choice maxOccurs="unbounded"> + <xs:element name="type" type="typeDeclaration" minOccurs="0" maxOccurs="unbounded" /> + <xs:element name="composableTypes" type="composableTypesDeclaration" minOccurs="0" maxOccurs="unbounded" /> + </xs:choice> </xs:complexType> <xs:unique name="uniqueTypeName"> <xs:annotation> @@ -39,6 +42,15 @@ <xs:selector xpath="type" /> <xs:field xpath="@name" /> </xs:unique> + <xs:unique name="uniquecomposableTypes"> + <xs:annotation> + <xs:documentation> + Composable type name must be unique. + </xs:documentation> + </xs:annotation> + <xs:selector xpath="composableTypes/type" /> + <xs:field xpath="@name" /> + </xs:unique> </xs:element> <xs:complexType name="typeDeclaration"> @@ -48,31 +60,31 @@ </xs:documentation> </xs:annotation> <xs:all minOccurs="0"> - <xs:element name="allowProductTypes" type="allowProductTypesDeclaration" minOccurs="0"> - <xs:unique name="uniqueAllowedTypeName"> + <xs:element name="allowedSelectionTypes" type="allowedSelectionTypesDeclaration" minOccurs="0"> + <xs:unique name="uniqueAllowedSelectionTypeName"> <xs:annotation> <xs:documentation> - Allowed type name must be unique. + Allowed selection type name must be unique. </xs:documentation> </xs:annotation> <xs:selector xpath="type" /> <xs:field xpath="@name" /> </xs:unique> </xs:element> - <xs:element name="allowedSelectionTypes" type="allowedSelectionTypesDeclaration" minOccurs="0"> - <xs:unique name="uniqueAllowedSelectionTypeName"> + <xs:element name="priceModel" type="priceModelDeclaration" minOccurs="0" /> + <xs:element name="indexerModel" type="indexerModelDeclaration" minOccurs="0" /> + <xs:element name="stockIndexerModel" type="stockIndexerModelDeclaration" minOccurs="0" /> + <xs:element name="customAttributes" type="customAttributesDeclaration" minOccurs="0"> + <xs:unique name="uniqueAttributeName"> <xs:annotation> <xs:documentation> - Allowed selection type name must be unique. + Attribute name should be unique. </xs:documentation> </xs:annotation> - <xs:selector xpath="type" /> + <xs:selector xpath="attribute" /> <xs:field xpath="@name" /> </xs:unique> </xs:element> - <xs:element name="priceModel" type="priceModelDeclaration" minOccurs="0" /> - <xs:element name="indexerModel" type="indexerModelDeclaration" minOccurs="0" /> - <xs:element name="stockIndexerModel" type="stockIndexerModelDeclaration" minOccurs="0" /> </xs:all> <xs:attribute name="name" type="xs:string" use="required" /> <xs:attribute name="label" type="xs:string" use="optional" /> @@ -82,82 +94,4 @@ <xs:attribute name="canUseQtyDecimals" type="xs:boolean" use="optional" /> <xs:attribute name="isQty" type="xs:boolean" use="optional" /> </xs:complexType> - - <xs:complexType name="priceModelDeclaration"> - <xs:annotation> - <xs:documentation> - Price model declaration. - </xs:documentation> - </xs:annotation> - <xs:attribute name="instance" type="modelName" use="required" /> - </xs:complexType> - - <xs:complexType name="indexerModelDeclaration"> - <xs:annotation> - <xs:documentation> - Indexer model declaration. - </xs:documentation> - </xs:annotation> - <xs:attribute name="instance" type="modelName" use="required" /> - </xs:complexType> - - <xs:complexType name="allowedSelectionTypesDeclaration"> - <xs:annotation> - <xs:documentation> - Allowed selection types declaration. - </xs:documentation> - </xs:annotation> - <xs:sequence> - <xs:element name="type" type="allowedSelectionTypeDeclaration" minOccurs="1" maxOccurs="unbounded" /> - </xs:sequence> - </xs:complexType> - - <xs:complexType name="stockIndexerModelDeclaration"> - <xs:annotation> - <xs:documentation> - Stock indexer model declaration. - </xs:documentation> - </xs:annotation> - <xs:attribute name="instance" type="modelName" use="required" /> - </xs:complexType> - - <xs:complexType name="allowProductTypesDeclaration"> - <xs:annotation> - <xs:documentation> - Allowed product types declaration. - </xs:documentation> - </xs:annotation> - <xs:sequence> - <xs:element name="type" type="allowedProductTypeDeclaration" minOccurs="1" maxOccurs="unbounded" /> - </xs:sequence> - </xs:complexType> - - <xs:complexType name="allowedProductTypeDeclaration"> - <xs:annotation> - <xs:documentation> - Allowed product type declaration (used to describe possible composite product items). - </xs:documentation> - </xs:annotation> - <xs:attribute name="name" type="xs:string" use="required" /> - </xs:complexType> - - <xs:complexType name="allowedSelectionTypeDeclaration"> - <xs:annotation> - <xs:documentation> - Allowed selection type declaration. - </xs:documentation> - </xs:annotation> - <xs:attribute name="name" type="xs:string" use="required" /> - </xs:complexType> - - <xs:simpleType name="modelName"> - <xs:annotation> - <xs:documentation> - Model name can contain only [a-zA-Z_\\\\]. - </xs:documentation> - </xs:annotation> - <xs:restriction base="xs:string"> - <xs:pattern value="[a-zA-Z_\\\\]+" /> - </xs:restriction> - </xs:simpleType> </xs:schema> diff --git a/app/code/Magento/Catalog/etc/product_types_base.xsd b/app/code/Magento/Catalog/etc/product_types_base.xsd new file mode 100644 index 0000000000000000000000000000000000000000..c7beaae98335c5a518db9fa544c086c9f7f3f38c --- /dev/null +++ b/app/code/Magento/Catalog/etc/product_types_base.xsd @@ -0,0 +1,120 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- +/** + * 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) + */ +--> +<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> + <xs:complexType name="composableTypesDeclaration"> + <xs:annotation> + <xs:documentation> + Composable product types declaration. + </xs:documentation> + </xs:annotation> + <xs:sequence> + <xs:element name="type" type="composableTypeDeclaration" minOccurs="1" maxOccurs="unbounded" /> + </xs:sequence> + </xs:complexType> + + <xs:complexType name="composableTypeDeclaration"> + <xs:annotation> + <xs:documentation> + Composable product type declaration (used to describe possible composite product items). + </xs:documentation> + </xs:annotation> + <xs:attribute name="name" type="xs:string" use="required" /> + </xs:complexType> + + <xs:complexType name="priceModelDeclaration"> + <xs:annotation> + <xs:documentation> + Price model declaration. + </xs:documentation> + </xs:annotation> + <xs:attribute name="instance" type="modelName" use="required" /> + </xs:complexType> + + <xs:complexType name="indexerModelDeclaration"> + <xs:annotation> + <xs:documentation> + Indexer model declaration. + </xs:documentation> + </xs:annotation> + <xs:attribute name="instance" type="modelName" use="required" /> + </xs:complexType> + + <xs:complexType name="allowedSelectionTypesDeclaration"> + <xs:annotation> + <xs:documentation> + Allowed selection types declaration. + </xs:documentation> + </xs:annotation> + <xs:sequence> + <xs:element name="type" type="allowedSelectionTypeDeclaration" minOccurs="1" maxOccurs="unbounded" /> + </xs:sequence> + </xs:complexType> + + <xs:complexType name="stockIndexerModelDeclaration"> + <xs:annotation> + <xs:documentation> + Stock indexer model declaration. + </xs:documentation> + </xs:annotation> + <xs:attribute name="instance" type="modelName" use="required" /> + </xs:complexType> + + <xs:complexType name="customAttributesDeclaration"> + <xs:sequence> + <xs:element name="attribute" type="customAttributeDeclaration" maxOccurs="unbounded"/> + </xs:sequence> + </xs:complexType> + + <xs:complexType name="customAttributeDeclaration"> + <xs:annotation> + <xs:documentation> + Custom attribute definition + </xs:documentation> + </xs:annotation> + <xs:attribute name="name" type="xs:string" use="required"/> + <xs:attribute name="value" type="xs:string" use="optional" default=""/> + </xs:complexType> + + <xs:complexType name="allowedSelectionTypeDeclaration"> + <xs:annotation> + <xs:documentation> + Allowed selection type declaration. + </xs:documentation> + </xs:annotation> + <xs:attribute name="name" type="xs:string" use="required" /> + </xs:complexType> + + <xs:simpleType name="modelName"> + <xs:annotation> + <xs:documentation> + Model name can contain only [a-zA-Z_\\\\]. + </xs:documentation> + </xs:annotation> + <xs:restriction base="xs:string"> + <xs:pattern value="[a-zA-Z_\\\\]+" /> + </xs:restriction> + </xs:simpleType> +</xs:schema> diff --git a/app/code/Magento/Catalog/etc/product_types_merged.xsd b/app/code/Magento/Catalog/etc/product_types_merged.xsd index babd0c07f026d0b2e8bdf8a179b95e447902174b..1cacd516e1b8fd57b899bf4b92ccd80ee017926c 100644 --- a/app/code/Magento/Catalog/etc/product_types_merged.xsd +++ b/app/code/Magento/Catalog/etc/product_types_merged.xsd @@ -24,21 +24,86 @@ */ --> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> - <xs:redefine schemaLocation="product_types.xsd"> - <xs:complexType name="typeDeclaration"> - <xs:complexContent> - <xs:restriction base="typeDeclaration"> - <xs:all minOccurs="0"> - <xs:element name="allowProductTypes" type="allowProductTypesDeclaration" minOccurs="0" /> - <xs:element name="allowedSelectionTypes" type="allowedSelectionTypesDeclaration" minOccurs="0" /> - <xs:element name="priceModel" type="priceModelDeclaration" minOccurs="0" /> - <xs:element name="indexerModel" type="indexerModelDeclaration" minOccurs="0" /> - <xs:element name="stockIndexerModel" type="stockIndexerModelDeclaration" minOccurs="0" /> - </xs:all> - <xs:attribute name="label" type="xs:string" use="required" /> - <xs:attribute name="modelInstance" type="modelName" use="required" /> - </xs:restriction> - </xs:complexContent> + + <xs:include schemaLocation="product_types_base.xsd" /> + + <xs:element name="config"> + <xs:complexType> + <xs:choice maxOccurs="unbounded"> + <xs:element name="type" type="typeDeclaration" minOccurs="0" maxOccurs="unbounded"> + <xs:unique name="uniqueTypeName"> + <xs:annotation> + <xs:documentation> + Product type name must be unique. + </xs:documentation> + </xs:annotation> + <xs:selector xpath="type" /> + <xs:field xpath="@name" /> + </xs:unique> + </xs:element> + <xs:element name="composableTypes" type="composableTypesDeclaration" minOccurs="0" maxOccurs="unbounded"> + <xs:unique name="uniquecomposableTypes"> + <xs:annotation> + <xs:documentation> + Composable type name must be unique. + </xs:documentation> + </xs:annotation> + <xs:selector xpath="type" /> + <xs:field xpath="@name" /> + </xs:unique> + </xs:element> + </xs:choice> </xs:complexType> - </xs:redefine> + <xs:key name="productTypeKey"> + <xs:selector xpath="type"/> + <xs:field xpath="@name"/> + </xs:key> + <xs:keyref name="composableTypesRef" refer="productTypeKey"> + <xs:selector xpath="composableTypes/type"/> + <xs:field xpath="@name"/> + </xs:keyref> + </xs:element> + + <xs:complexType name="typeDeclaration"> + <xs:annotation> + <xs:documentation> + Product type declaration. + </xs:documentation> + </xs:annotation> + <xs:all minOccurs="0"> + <xs:element name="allowedSelectionTypes" type="allowedSelectionTypesDeclaration" minOccurs="0"> + <xs:unique name="uniqueAllowedSelectionTypeName"> + <xs:annotation> + <xs:documentation> + Allowed selection type name must be unique. + </xs:documentation> + </xs:annotation> + <xs:selector xpath="type" /> + <xs:field xpath="@name" /> + </xs:unique> + </xs:element> + <xs:element name="priceModel" type="priceModelDeclaration" minOccurs="0" /> + <xs:element name="indexerModel" type="indexerModelDeclaration" minOccurs="0" /> + <xs:element name="stockIndexerModel" type="stockIndexerModelDeclaration" minOccurs="0" /> + <xs:element name="customAttributes" type="customAttributesDeclaration" minOccurs="0"> + <xs:unique name="uniqueAttributeName"> + <xs:annotation> + <xs:documentation> + Attribute name should be unique. + </xs:documentation> + </xs:annotation> + <xs:selector xpath="attribute" /> + <xs:field xpath="@name" /> + </xs:unique> + </xs:element> + </xs:all> + <xs:attribute name="name" type="xs:string" use="required" /> + <xs:attribute name="label" type="xs:string" use="required" /> + <xs:attribute name="modelInstance" type="modelName" use="required" /> + <xs:attribute name="composite" type="xs:boolean" use="optional" /> + <xs:attribute name="indexPriority" type="xs:nonNegativeInteger" use="optional" /> + <xs:attribute name="canUseQtyDecimals" type="xs:boolean" use="optional" /> + <xs:attribute name="isQty" type="xs:boolean" use="optional" /> + </xs:complexType> </xs:schema> + diff --git a/app/code/Magento/Catalog/view/frontend/layout/catalog_product_rss_feed_renderer_list.xml b/app/code/Magento/Catalog/view/frontend/layout/catalog_product_rss_feed_renderer_list.xml new file mode 100644 index 0000000000000000000000000000000000000000..29358124098b48405ba629a4005b478ec4171deb --- /dev/null +++ b/app/code/Magento/Catalog/view/frontend/layout/catalog_product_rss_feed_renderer_list.xml @@ -0,0 +1,31 @@ +<?xml version="1.0"?> +<!-- +/** + * 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) + */ +--> +<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <referenceBlock name="catalog.product.rss.feed.renderer.list"> + <block class="Magento\Catalog\Block\Product\Price" as="default" template="rss/product/price.phtml" /> + <block class="Magento\Catalog\Block\Product\Price" as="msrp_rss" template="product/price_msrp_rss.phtml" /> + </referenceBlock> +</layout> 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 6a88db7fa1f567af192ed19aa384ad5bc2639870..a8ba20428a5fb02f3a015a7205c4595678a6e7eb 100644 --- a/app/code/Magento/CatalogInventory/Block/Adminhtml/Form/Field/Stock.php +++ b/app/code/Magento/CatalogInventory/Block/Adminhtml/Form/Field/Stock.php @@ -41,7 +41,7 @@ class Stock extends \Magento\Data\Form\Element\Select protected $_qty; /** - * Is product composite (grouped or configurable) + * Is product composite * * @var bool */ @@ -54,11 +54,20 @@ class Stock extends \Magento\Data\Form\Element\Select */ protected $_factoryText; + /** + * List of product types that treated as complex and + * has no quantity option if taken without their children + * + * @var array + */ + protected $complexProductTypes; + /** * @param \Magento\Data\Form\Element\Factory $factoryElement * @param \Magento\Data\Form\Element\CollectionFactory $factoryCollection * @param \Magento\Escaper $escaper * @param \Magento\Data\Form\Element\TextFactory $factoryText + * @param array $complexProductTypes * @param array $data */ public function __construct( @@ -66,10 +75,12 @@ class Stock extends \Magento\Data\Form\Element\Select \Magento\Data\Form\Element\CollectionFactory $factoryCollection, \Magento\Escaper $escaper, \Magento\Data\Form\Element\TextFactory $factoryText, + array $complexProductTypes = array(), array $data = array() ) { $this->_factoryText = $factoryText; $this->_qty = isset($data['qty']) ? $data['qty'] : $this->_createQtyElement(); + $this->complexProductTypes = $complexProductTypes; unset($data['qty']); parent::__construct($factoryElement, $factoryCollection, $escaper, $data); $this->setName($data['name']); @@ -139,7 +150,7 @@ class Stock extends \Magento\Data\Form\Element\Select } /** - * Get whether product is configurable or grouped + * Get whether product is composite * * @return bool */ @@ -190,10 +201,10 @@ class Stock extends \Magento\Data\Form\Element\Select useConfigManageStockField = $('#inventory_use_config_manage_stock'); var disabler = function(event) { + var complexProductTypes = " . json_encode(array_values($this->complexProductTypes)) . "; var hasVariation = $('[data-panel=product-variations]').is('.opened'); if ((productType == 'configurable' && hasVariation) - || productType == 'grouped' - || productType == 'bundle'//@TODO move this check to Magento_Bundle after refactoring as widget + || $.inArray(productType, complexProductTypes) >= 0 || hasVariation ) { return; diff --git a/app/code/Magento/CatalogInventory/Model/Config/Backend/Managestock.php b/app/code/Magento/CatalogInventory/Model/Config/Backend/Managestock.php index f79b1d81bd05fd4ccf2bc5ec6d741218f7059b7d..fcdfb222d30507be7cfd58a3bf51a9ee2707bedd 100644 --- a/app/code/Magento/CatalogInventory/Model/Config/Backend/Managestock.php +++ b/app/code/Magento/CatalogInventory/Model/Config/Backend/Managestock.php @@ -46,7 +46,7 @@ class Managestock * @param \Magento\Core\Model\Context $context * @param \Magento\Core\Model\Registry $registry * @param \Magento\Core\Model\StoreManagerInterface $storeManager - * @param \Magento\Core\Model\Config $config + * @param \Magento\App\ConfigInterface $config * @param \Magento\CatalogInventory\Model\Stock\Status $stockStatus * @param \Magento\Core\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection @@ -56,7 +56,7 @@ class Managestock \Magento\Core\Model\Context $context, \Magento\Core\Model\Registry $registry, \Magento\Core\Model\StoreManagerInterface $storeManager, - \Magento\Core\Model\Config $config, + \Magento\App\ConfigInterface $config, \Magento\CatalogInventory\Model\Stock\Status $stockStatus, \Magento\Core\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, diff --git a/app/code/Magento/CatalogInventory/Model/Indexer/Stock.php b/app/code/Magento/CatalogInventory/Model/Indexer/Stock.php index 4da440e305151fcfc37d84849d267d2784ddf68b..f04f585d554441863664d28e674ce2f1b73fc605 100644 --- a/app/code/Magento/CatalogInventory/Model/Indexer/Stock.php +++ b/app/code/Magento/CatalogInventory/Model/Indexer/Stock.php @@ -71,7 +71,7 @@ class Stock extends \Magento\Index\Model\Indexer\AbstractIndexer \Magento\Core\Model\Store\Group::ENTITY => array( \Magento\Index\Model\Event::TYPE_SAVE ), - \Magento\Core\Model\Config\Value::ENTITY => array( + \Magento\App\Config\ValueInterface::ENTITY => array( \Magento\Index\Model\Event::TYPE_SAVE ), ); @@ -192,7 +192,7 @@ class Stock extends \Magento\Index\Model\Indexer\AbstractIndexer } else { $result = false; } - } else if ($entity == \Magento\Core\Model\Config\Value::ENTITY) { + } else if ($entity == \Magento\App\Config\ValueInterface::ENTITY) { $configData = $event->getDataObject(); if ($configData && in_array($configData->getPath(), $this->_relatedConfigSettings)) { $result = $configData->isValueChanged(); @@ -227,12 +227,12 @@ class Stock extends \Magento\Index\Model\Indexer\AbstractIndexer case \Magento\Core\Model\Store::ENTITY: case \Magento\Core\Model\Store\Group::ENTITY: - case \Magento\Core\Model\Config\Value::ENTITY: + case \Magento\App\Config\ValueInterface::ENTITY: $event->addNewData('cataloginventory_stock_skip_call_event_handler', true); $process = $event->getProcess(); $process->changeStatus(\Magento\Index\Model\Process::STATUS_REQUIRE_REINDEX); - if ($event->getEntity() == \Magento\Core\Model\Config\Value::ENTITY) { + if ($event->getEntity() == \Magento\App\Config\ValueInterface::ENTITY) { $configData = $event->getDataObject(); if ($configData->getPath() == \Magento\CatalogInventory\Helper\Data::XML_PATH_SHOW_OUT_OF_STOCK) { $this->_indexer->getProcessByCode('catalog_product_price') diff --git a/app/code/Magento/CatalogInventory/Model/Observer.php b/app/code/Magento/CatalogInventory/Model/Observer.php index 7ae79d792f6198e572a63596879e12b12472ee48..19c618d5bd4cebdbf3b7671d2ce754fac236ec8a 100644 --- a/app/code/Magento/CatalogInventory/Model/Observer.php +++ b/app/code/Magento/CatalogInventory/Model/Observer.php @@ -109,6 +109,11 @@ class Observer */ protected $_indexerPrice; + /** + * @var \Magento\Catalog\Model\ProductTypes\ConfigInterface + */ + protected $typeConfig; + /** * @param \Magento\Catalog\Model\Resource\Product\Indexer\Price $indexerPrice * @param \Magento\CatalogInventory\Model\Resource\Indexer\Stock $resourceIndexerStock @@ -120,6 +125,7 @@ class Observer * @param \Magento\CatalogInventory\Model\Stock\ItemFactory $stockItemFactory * @param \Magento\CatalogInventory\Model\StockFactory $stockFactory * @param \Magento\CatalogInventory\Model\Stock\StatusFactory $stockStatusFactory + * @param \Magento\Catalog\Model\ProductTypes\ConfigInterface $typeConfig */ public function __construct( \Magento\Catalog\Model\Resource\Product\Indexer\Price $indexerPrice, @@ -131,7 +137,8 @@ class Observer \Magento\CatalogInventory\Helper\Data $catalogInventoryData, \Magento\CatalogInventory\Model\Stock\ItemFactory $stockItemFactory, \Magento\CatalogInventory\Model\StockFactory $stockFactory, - \Magento\CatalogInventory\Model\Stock\StatusFactory $stockStatusFactory + \Magento\CatalogInventory\Model\Stock\StatusFactory $stockStatusFactory, + \Magento\Catalog\Model\ProductTypes\ConfigInterface $typeConfig ) { $this->_indexerPrice = $indexerPrice; $this->_resourceIndexerStock = $resourceIndexerStock; @@ -143,6 +150,7 @@ class Observer $this->_stockItemFactory = $stockItemFactory; $this->_stockFactory = $stockFactory; $this->_stockStatusFactory = $stockStatusFactory; + $this->typeConfig = $typeConfig; } /** @@ -502,7 +510,7 @@ class Observer } /** - * When we work with subitem (as subproduct of bundle or configurable product) + * When we work with subitem (as subproduct of configurable product) */ if ($quoteItem->getParentItem()) { $rowQty = $quoteItem->getParentItem()->getQty() * $qty; @@ -526,8 +534,8 @@ class Observer $productTypeCustomOption = $quoteItem->getProduct()->getCustomOption('product_type'); if (!is_null($productTypeCustomOption)) { - // Check if product related to current item is a part of grouped product - if ($productTypeCustomOption->getValue() == \Magento\GroupedProduct\Model\Product\Type\Grouped::TYPE_CODE) { + // Check if product related to current item is a part of product that represents product set + if ($this->typeConfig->isProductSet($productTypeCustomOption->getValue())) { $stockItem->setProductName($quoteItem->getProduct()->getName()); $stockItem->setIsChildItem(true); } 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 e3833c5935795865de922979cb85d506fd57a958..a0341de77f4c11454c4cf459ce30bd3946f060d6 100644 --- a/app/code/Magento/CatalogInventory/Model/System/Config/Backend/Minsaleqty.php +++ b/app/code/Magento/CatalogInventory/Model/System/Config/Backend/Minsaleqty.php @@ -43,7 +43,7 @@ class Minsaleqty extends \Magento\Core\Model\Config\Value * @param \Magento\Core\Model\Context $context * @param \Magento\Core\Model\Registry $registry * @param \Magento\Core\Model\StoreManagerInterface $storeManager - * @param \Magento\Core\Model\Config $config + * @param \Magento\App\ConfigInterface $config * @param \Magento\CatalogInventory\Helper\Minsaleqty $catalogInventoryMinsaleqty * @param \Magento\Core\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection @@ -53,7 +53,7 @@ class Minsaleqty extends \Magento\Core\Model\Config\Value \Magento\Core\Model\Context $context, \Magento\Core\Model\Registry $registry, \Magento\Core\Model\StoreManagerInterface $storeManager, - \Magento\Core\Model\Config $config, + \Magento\App\ConfigInterface $config, \Magento\CatalogInventory\Helper\Minsaleqty $catalogInventoryMinsaleqty, \Magento\Core\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, diff --git a/app/code/Magento/CatalogInventory/etc/adminhtml/di.xml b/app/code/Magento/CatalogInventory/etc/adminhtml/di.xml index 05457026a73b2d486879ab185bfec4366a743ead..58041a9577b75072b917c475978540063d2bf48c 100644 --- a/app/code/Magento/CatalogInventory/etc/adminhtml/di.xml +++ b/app/code/Magento/CatalogInventory/etc/adminhtml/di.xml @@ -27,9 +27,9 @@ <preference for="Magento\CatalogInventory\Model\Stock\Item" type="Magento\CatalogInventory\Model\Adminhtml\Stock\Item" /> <type name="Magento\Catalog\Model\Product\CopyConstructor\Composite"> <param name="constructors"> - <value> - <catalog_inventory>Magento\CatalogInventory\Model\Product\CopyConstructor\CatalogInventory</catalog_inventory> - </value> + <array> + <item key="catalog_inventory"><value>Magento\CatalogInventory\Model\Product\CopyConstructor\CatalogInventory</value></item> + </array> </param> </type> </config> diff --git a/app/code/Magento/CatalogInventory/etc/di.xml b/app/code/Magento/CatalogInventory/etc/di.xml index 6a94d3033bbe5462952e26156204af04329d7275..729b4eb1a342e3d126651175cf3eb3d1bb713efd 100644 --- a/app/code/Magento/CatalogInventory/etc/di.xml +++ b/app/code/Magento/CatalogInventory/etc/di.xml @@ -49,9 +49,9 @@ </type> <type name="Magento\Module\Updater\SetupFactory"> <param name="resourceTypes"> - <value> - <cataloginventory_setup>Magento\Eav\Model\Entity\Setup</cataloginventory_setup> - </value> + <array> + <item key="cataloginventory_setup"><value>Magento\Eav\Model\Entity\Setup</value></item> + </array> </param> </type> </config> diff --git a/app/code/Magento/CatalogInventory/etc/module.xml b/app/code/Magento/CatalogInventory/etc/module.xml index 5442076b16fe35884b197865acb225991a7c80c8..8b2aa2d84f80ba5d4e9bd4c0c7c03d0a92d5aece 100755 --- a/app/code/Magento/CatalogInventory/etc/module.xml +++ b/app/code/Magento/CatalogInventory/etc/module.xml @@ -30,10 +30,8 @@ </sequence> <depends> <module name="Magento_Catalog"/> - <module name="Magento_GroupedProduct" /> <module name="Magento_Core"/> <module name="Magento_Customer"/> - <module name="Magento_Bundle"/> <module name="Magento_Backend"/> <module name="Magento_Index"/> <module name="Magento_Sales"/> 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 5fbf375118c22f3792e1f717b560442888075196..d8bf2b85a90b5fca54d647fd8784415540db3d54 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 @@ -57,7 +57,6 @@ class Sku extends \Magento\Backend\Block\Widget\Grid\Extended /** * @param \Magento\Backend\Block\Template\Context $context - * @param \Magento\Core\Model\Url $urlModel * @param \Magento\Backend\Helper\Data $backendHelper * @param \Magento\Catalog\Model\ProductFactory $catalogProduct * @param \Magento\Eav\Model\Resource\Entity\Attribute\Set\CollectionFactory $eavAttSetCollection @@ -67,7 +66,6 @@ class Sku extends \Magento\Backend\Block\Widget\Grid\Extended */ public function __construct( \Magento\Backend\Block\Template\Context $context, - \Magento\Core\Model\Url $urlModel, \Magento\Backend\Helper\Data $backendHelper, \Magento\Catalog\Model\ProductFactory $catalogProduct, \Magento\Eav\Model\Resource\Entity\Attribute\Set\CollectionFactory $eavAttSetCollection, @@ -79,7 +77,7 @@ class Sku extends \Magento\Backend\Block\Widget\Grid\Extended $this->_cpCollection = $cpCollection; $this->_eavAttSetCollection = $eavAttSetCollection; $this->_catalogProduct = $catalogProduct; - parent::__construct($context, $urlModel, $backendHelper, $data); + parent::__construct($context, $backendHelper, $data); } protected function _construct() diff --git a/app/code/Magento/CatalogRule/etc/adminhtml/di.xml b/app/code/Magento/CatalogRule/etc/adminhtml/di.xml index e133447269398959ee56a32280b5b71dc1b0f1fd..a0dc1ca7fc5604c425eedde46b037f78849ff6ba 100644 --- a/app/code/Magento/CatalogRule/etc/adminhtml/di.xml +++ b/app/code/Magento/CatalogRule/etc/adminhtml/di.xml @@ -26,9 +26,9 @@ <config> <type name="Magento\CatalogRule\Model\Rule"> <param name="relatedCacheTypes"> - <value> - <blockCache>block_html</blockCache> - </value> + <array> + <item key="blockCache"><value>block_html</value></item> + </array> </param> </type> </config> diff --git a/app/code/Magento/CatalogRule/etc/di.xml b/app/code/Magento/CatalogRule/etc/di.xml index 92048a433502e060f0811f0f0563b8aba45acbba..b31f71d7defe10599de9770080c45f3de1b47098 100644 --- a/app/code/Magento/CatalogRule/etc/di.xml +++ b/app/code/Magento/CatalogRule/etc/di.xml @@ -43,9 +43,9 @@ </type> <type name="Magento\Module\Updater\SetupFactory"> <param name="resourceTypes"> - <value> - <catalogrule_setup>Magento\Core\Model\Resource\Setup\Generic</catalogrule_setup> - </value> + <array> + <item key="catalogrule_setup"><value>Magento\Core\Model\Resource\Setup\Generic</value></item> + </array> </param> </type> </config> diff --git a/app/code/Magento/CatalogSearch/Block/Advanced/Result.php b/app/code/Magento/CatalogSearch/Block/Advanced/Result.php index 7a6dbe69672c64056add45274e731df3b2d0ec76..d7039161ef6bfb6814e53e095f4b4c6f4ee3e8ba 100644 --- a/app/code/Magento/CatalogSearch/Block/Advanced/Result.php +++ b/app/code/Magento/CatalogSearch/Block/Advanced/Result.php @@ -24,21 +24,17 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\CatalogSearch\Block\Advanced; + /** * Advanced search result - * - * @category Magento - * @package Magento_CatalogSearch - * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\CatalogSearch\Block\Advanced; - class Result extends \Magento\View\Element\Template { /** * Url factory * - * @var \Magento\Core\Model\UrlFactory + * @var \Magento\UrlFactory */ protected $_urlFactory; @@ -60,14 +56,14 @@ class Result extends \Magento\View\Element\Template * @param \Magento\View\Element\Template\Context $context * @param \Magento\CatalogSearch\Model\Advanced $catalogSearchAdvanced * @param \Magento\Catalog\Model\Layer $catalogLayer - * @param \Magento\Core\Model\UrlFactory $urlFactory + * @param \Magento\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\Core\Model\UrlFactory $urlFactory, + \Magento\UrlFactory $urlFactory, array $data = array() ) { $this->_catalogSearchAdvanced = $catalogSearchAdvanced; @@ -78,46 +74,52 @@ class Result extends \Magento\View\Element\Template protected function _prepareLayout() { - if ($breadcrumbs = $this->getLayout()->getBlock('breadcrumbs')) { + $breadcrumbs = $this->getLayout()->getBlock('breadcrumbs'); + if ($breadcrumbs) { $breadcrumbs->addCrumb('home', array( - 'label'=>__('Home'), - 'title'=>__('Go to Home Page'), - 'link' => $this->_storeManager->getStore()->getBaseUrl(), + 'label' => __('Home'), + 'title' => __('Go to Home Page'), + 'link' => $this->_storeManager->getStore()->getBaseUrl(), ))->addCrumb('search', array( - 'label'=>__('Catalog Advanced Search'), - 'link'=>$this->getUrl('*/*/') + 'label' => __('Catalog Advanced Search'), + 'link' => $this->getUrl('*/*/') ))->addCrumb('search_result', array( - 'label'=>__('Results') + 'label' => __('Results') )); } return parent::_prepareLayout(); } - public function setListOrders() { - $category = $this->_catalogLayer->getCurrentCategory(); + /** + * Set order options + */ + public function setListOrders() + { /* @var $category \Magento\Catalog\Model\Category */ + $category = $this->_catalogLayer->getCurrentCategory(); $availableOrders = $category->getAvailableSortByOptions(); unset($availableOrders['position']); - $this->getChildBlock('search_result_list') - ->setAvailableOrders($availableOrders); + $this->getChildBlock('search_result_list')->setAvailableOrders($availableOrders); } - public function setListModes() { - $this->getChildBlock('search_result_list') - ->setModes(array( - 'grid' => __('Grid'), - 'list' => __('List')) - ); + /** + * Set view mode options + */ + public function setListModes() + { + $this->getChildBlock('search_result_list')->setModes(array('grid' => __('Grid'), 'list' => __('List'))); } - public function setListCollection() { + public function setListCollection() + { $this->getChildBlock('search_result_list') ->setCollection($this->_getProductCollection()); } - protected function _getProductCollection(){ + protected function _getProductCollection() + { return $this->getSearchModel()->getProductCollection(); } diff --git a/app/code/Magento/CatalogSearch/Block/Result.php b/app/code/Magento/CatalogSearch/Block/Result.php index fd2296201885a60463003c2173013faca48cc1df..93505f0f14efbf097ce619355e2805fc40ef9589 100644 --- a/app/code/Magento/CatalogSearch/Block/Result.php +++ b/app/code/Magento/CatalogSearch/Block/Result.php @@ -24,16 +24,11 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\CatalogSearch\Block; /** * Product search result block - * - * @category Magento - * @package Magento_CatalogSearch - * @module Catalog */ -namespace Magento\CatalogSearch\Block; - class Result extends \Magento\View\Element\Template { /** @@ -41,21 +36,21 @@ class Result extends \Magento\View\Element\Template * * @var \Magento\CatalogSearch\Model\Resource\Fulltext\Collection */ - protected $_productCollection; + protected $productCollection; /** * Catalog search data * * @var \Magento\CatalogSearch\Helper\Data */ - protected $_catalogSearchData = null; + protected $catalogSearchData; /** * Catalog layer * * @var \Magento\Catalog\Model\Layer */ - protected $_catalogLayer; + protected $catalogLayer; /** * @param \Magento\View\Element\Template\Context $context @@ -69,8 +64,8 @@ class Result extends \Magento\View\Element\Template \Magento\CatalogSearch\Helper\Data $catalogSearchData, array $data = array() ) { - $this->_catalogLayer = $catalogLayer; - $this->_catalogSearchData = $catalogSearchData; + $this->catalogLayer = $catalogLayer; + $this->catalogSearchData = $catalogSearchData; parent::__construct($context, $data); } @@ -81,7 +76,7 @@ class Result extends \Magento\View\Element\Template */ protected function _getQuery() { - return $this->_catalogSearchData->getQuery(); + return $this->catalogSearchData->getQuery(); } /** @@ -91,11 +86,12 @@ class Result extends \Magento\View\Element\Template */ protected function _prepareLayout() { + $title = $this->getSearchQueryText(); + $this->getLayout()->getBlock('head')->setTitle($title); + // add Home breadcrumb $breadcrumbs = $this->getLayout()->getBlock('breadcrumbs'); if ($breadcrumbs) { - $title = __("Search results for: '%1'", $this->_catalogSearchData->getQueryText()); - $breadcrumbs->addCrumb('home', array( 'label' => __('Home'), 'title' => __('Go to Home Page'), @@ -106,10 +102,6 @@ class Result extends \Magento\View\Element\Template )); } - // modify page title - $title = __("Search results for: '%1'", $this->_catalogSearchData->getEscapedQueryText()); - $this->getLayout()->getBlock('head')->setTitle($title); - return parent::_prepareLayout(); } @@ -140,7 +132,7 @@ class Result extends \Magento\View\Element\Template */ public function setListOrders() { - $category = $this->_catalogLayer->getCurrentCategory(); + $category = $this->catalogLayer->getCurrentCategory(); /* @var $category \Magento\Catalog\Model\Category */ $availableOrders = $category->getAvailableSortByOptions(); unset($availableOrders['position']); @@ -163,11 +155,8 @@ class Result extends \Magento\View\Element\Template */ public function setListModes() { - $this->getListBlock() - ->setModes(array( - 'grid' => __('Grid'), - 'list' => __('List')) - ); + $test = $this->getListBlock(); + $test->setModes(array('grid' => __('Grid'), 'list' => __('List'))); return $this; } @@ -200,11 +189,21 @@ class Result extends \Magento\View\Element\Template */ protected function _getProductCollection() { - if (is_null($this->_productCollection)) { - $this->_productCollection = $this->getListBlock()->getLoadedProductCollection(); + if (null === $this->productCollection) { + $this->productCollection = $this->getListBlock()->getLoadedProductCollection(); } - return $this->_productCollection; + return $this->productCollection; + } + + /** + * Get search query text + * + * @return string + */ + public function getSearchQueryText() + { + return __("Search results for: '%1'", $this->catalogSearchData->getEscapedQueryText()); } /** @@ -229,7 +228,7 @@ class Result extends \Magento\View\Element\Template */ public function getNoResultText() { - if ($this->_catalogSearchData->isMinQueryLength()) { + if ($this->catalogSearchData->isMinQueryLength()) { return __('Minimum Search query length is %1', $this->_getQuery()->getMinQueryLength()); } return $this->_getData('no_result_text'); @@ -242,6 +241,6 @@ class Result extends \Magento\View\Element\Template */ public function getNoteMessages() { - return $this->_catalogSearchData->getNoteMessages(); + return $this->catalogSearchData->getNoteMessages(); } } diff --git a/app/code/Magento/CatalogSearch/Block/Term.php b/app/code/Magento/CatalogSearch/Block/Term.php index ac6b58702a47ecac2f341886dc5cba1a2a047bfe..ffeea84a9c9d9b9bdc2e963d36af91e089335db7 100644 --- a/app/code/Magento/CatalogSearch/Block/Term.php +++ b/app/code/Magento/CatalogSearch/Block/Term.php @@ -42,7 +42,7 @@ class Term extends \Magento\View\Element\Template /** * Url factory * - * @var \Magento\Core\Model\UrlFactory + * @var \Magento\UrlFactory */ protected $_urlFactory; @@ -56,13 +56,13 @@ class Term extends \Magento\View\Element\Template /** * @param \Magento\View\Element\Template\Context $context * @param \Magento\CatalogSearch\Model\Resource\Query\CollectionFactory $queryCollectionFactory - * @param \Magento\Core\Model\UrlFactory $urlFactory + * @param \Magento\UrlFactory $urlFactory * @param array $data */ public function __construct( \Magento\View\Element\Template\Context $context, \Magento\CatalogSearch\Model\Resource\Query\CollectionFactory $queryCollectionFactory, - \Magento\Core\Model\UrlFactory $urlFactory, + \Magento\UrlFactory $urlFactory, array $data = array() ) { $this->_queryCollectionFactory = $queryCollectionFactory; @@ -119,7 +119,7 @@ class Term extends \Magento\View\Element\Template public function getSearchUrl($obj) { - /** @var $url \Magento\Core\Model\Url */ + /** @var $url \Magento\UrlInterface */ $url = $this->_urlFactory->create(); /* * url encoding will be done in Url.php http_build_query diff --git a/app/code/Magento/CatalogSearch/Controller/Advanced.php b/app/code/Magento/CatalogSearch/Controller/Advanced.php index fbc639a094c267147ce986fceacb39d8d0ef680e..fa435a9da5ee95c8da63f8c32b164abbf273974b 100644 --- a/app/code/Magento/CatalogSearch/Controller/Advanced.php +++ b/app/code/Magento/CatalogSearch/Controller/Advanced.php @@ -39,7 +39,7 @@ class Advanced extends \Magento\App\Action\Action /** * Url factory * - * @var \Magento\Core\Model\UrlFactory + * @var \Magento\UrlFactory */ protected $_urlFactory; @@ -63,13 +63,13 @@ class Advanced extends \Magento\App\Action\Action * @param \Magento\App\Action\Context $context * @param \Magento\Session\Generic $catalogSearchSession * @param \Magento\CatalogSearch\Model\Advanced $catalogSearchAdvanced - * @param \Magento\Core\Model\UrlFactory $urlFactory + * @param \Magento\UrlFactory $urlFactory */ public function __construct( \Magento\App\Action\Context $context, \Magento\Session\Generic $catalogSearchSession, \Magento\CatalogSearch\Model\Advanced $catalogSearchAdvanced, - \Magento\Core\Model\UrlFactory $urlFactory + \Magento\UrlFactory $urlFactory ) { $this->_catalogSearchSession = $catalogSearchSession; $this->_catalogSearchAdvanced = $catalogSearchAdvanced; diff --git a/app/code/Magento/CatalogSearch/Controller/Result.php b/app/code/Magento/CatalogSearch/Controller/Result.php index d42fe07389ede0e434954a0de9c8d3ee7b19208f..6b2060e430603b002c5a11d606105363bb75f6ce 100644 --- a/app/code/Magento/CatalogSearch/Controller/Result.php +++ b/app/code/Magento/CatalogSearch/Controller/Result.php @@ -24,14 +24,13 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\CatalogSearch\Controller; + /** * Catalog Search Controller */ -namespace Magento\CatalogSearch\Controller; - class Result extends \Magento\App\Action\Action { - /** * Catalog session * @@ -59,22 +58,13 @@ class Result extends \Magento\App\Action\Action parent::__construct($context); } - /** - * Retrieve catalog session - * - * @return \Magento\Catalog\Model\Session - */ - protected function _getSession() - { - return $this->_catalogSession; - } /** * Display search result */ public function indexAction() { - $query = $this->_objectManager->get('Magento\CatalogSearch\Helper\Data')->getQuery(); /* @var $query \Magento\CatalogSearch\Model\Query */ + $query = $this->_objectManager->get('Magento\CatalogSearch\Helper\Data')->getQuery(); $query->setStoreId($this->_storeManager->getStore()->getId()); @@ -85,7 +75,7 @@ class Result extends \Magento\App\Action\Action ->setIsProcessed(1); } else { if ($query->getId()) { - $query->setPopularity($query->getPopularity()+1); + $query->setPopularity($query->getPopularity() + 1); } else { $query->setPopularity(1); } 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 886b53c3771a733e7b1ed56426dde8ef1e1561e4..c08d806eefcaaf3b104ba47c8dddacf8f545d6c6 100644 --- a/app/code/Magento/CatalogSearch/Model/Config/Backend/Search/Type.php +++ b/app/code/Magento/CatalogSearch/Model/Config/Backend/Search/Type.php @@ -47,7 +47,7 @@ class Type extends \Magento\Core\Model\Config\Value * @param \Magento\Core\Model\Context $context * @param \Magento\Core\Model\Registry $registry * @param \Magento\Core\Model\StoreManagerInterface $storeManager - * @param \Magento\Core\Model\Config $config + * @param \Magento\App\ConfigInterface $config * @param \Magento\CatalogSearch\Model\Fulltext $catalogSearchFulltext * @param \Magento\Core\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection @@ -57,7 +57,7 @@ class Type extends \Magento\Core\Model\Config\Value \Magento\Core\Model\Context $context, \Magento\Core\Model\Registry $registry, \Magento\Core\Model\StoreManagerInterface $storeManager, - \Magento\Core\Model\Config $config, + \Magento\App\ConfigInterface $config, \Magento\CatalogSearch\Model\Fulltext $catalogSearchFulltext, \Magento\Core\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, diff --git a/app/code/Magento/CatalogSearch/Model/Fulltext/Observer.php b/app/code/Magento/CatalogSearch/Model/Fulltext/Observer.php index 0ced2c08a5df5ab03770d5a1eddd32ba32b228fc..e8e4c0ca8a75a69234d4d107d8fa98b497fe40e0 100644 --- a/app/code/Magento/CatalogSearch/Model/Fulltext/Observer.php +++ b/app/code/Magento/CatalogSearch/Model/Fulltext/Observer.php @@ -59,7 +59,7 @@ class Observer /** * Backend url * - * @var \Magento\Backend\Model\Url + * @var \Magento\Backend\Model\UrlInterface */ protected $_backendUrl; @@ -79,7 +79,7 @@ class Observer * Construct * * @param \Magento\Backend\Model\Session $backendSession - * @param \Magento\Backend\Model\Url $backendUrl + * @param \Magento\Backend\Model\UrlInterface $backendUrl * @param \Magento\Eav\Model\Config $eavConfig * @param \Magento\CatalogSearch\Model\Fulltext $catalogSearchFulltext * @param \Magento\Core\Model\StoreManagerInterface $storeManager @@ -87,7 +87,7 @@ class Observer */ public function __construct( \Magento\Backend\Model\Session $backendSession, - \Magento\Backend\Model\Url $backendUrl, + \Magento\Backend\Model\UrlInterface $backendUrl, \Magento\Eav\Model\Config $eavConfig, \Magento\CatalogSearch\Model\Fulltext $catalogSearchFulltext, \Magento\Core\Model\StoreManagerInterface $storeManager, diff --git a/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext.php b/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext.php index a66df2fdf403da05c7659a9fbd0083e358ffda81..ceca16d9d7b3005fa8998e826b65b0ae4263f951 100644 --- a/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext.php +++ b/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext.php @@ -145,7 +145,7 @@ class Fulltext extends \Magento\Index\Model\Indexer\AbstractIndexer \Magento\Core\Model\Store\Group::ENTITY => array( \Magento\Index\Model\Event::TYPE_SAVE ), - \Magento\Core\Model\Config\Value::ENTITY => array( + \Magento\App\Config\ValueInterface::ENTITY => array( \Magento\Index\Model\Event::TYPE_SAVE ), \Magento\Catalog\Model\Category::ENTITY => array( @@ -241,7 +241,7 @@ class Fulltext extends \Magento\Index\Model\Indexer\AbstractIndexer } else { $result = false; } - } else if ($entity == \Magento\Core\Model\Config\Value::ENTITY) { + } else if ($entity == \Magento\App\Config\ValueInterface::ENTITY) { $data = $event->getDataObject(); if ($data && in_array($data->getPath(), $this->_relatedConfigSettings)) { $result = $data->isValueChanged(); @@ -270,7 +270,7 @@ class Fulltext extends \Magento\Index\Model\Indexer\AbstractIndexer $this->_registerCatalogProductEvent($event); break; - case \Magento\Core\Model\Config\Value::ENTITY: + 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: diff --git a/app/code/Magento/CatalogSearch/Model/Resource/Fulltext.php b/app/code/Magento/CatalogSearch/Model/Resource/Fulltext.php index d78e8c89482a155c57f7664d7cc974d18accc6fb..d923b0060f7ebb7c5f341fff7b376495dc26fa22 100644 --- a/app/code/Magento/CatalogSearch/Model/Resource/Fulltext.php +++ b/app/code/Magento/CatalogSearch/Model/Resource/Fulltext.php @@ -750,14 +750,12 @@ class Fulltext extends \Magento\Core\Model\Resource\Db\AbstractDb if (isset($productData[$attributeCode])) { $value = $this->_getAttributeValue($attribute->getId(), $productData[$attributeCode], $storeId); if ($value) { - //For grouped products if (isset($index[$attributeCode])) { if (!is_array($index[$attributeCode])) { $index[$attributeCode] = array($index[$attributeCode]); } $index[$attributeCode][] = $value; } else { - //For other types of products $index[$attributeCode] = $value; } } diff --git a/app/code/Magento/CatalogSearch/view/frontend/result.phtml b/app/code/Magento/CatalogSearch/view/frontend/result.phtml index c5ad2b2798e48afd6b90b5a73d2885e6f42aa4c8..35e603d96212390cf785b70340e8e993b46c93ea 100644 --- a/app/code/Magento/CatalogSearch/view/frontend/result.phtml +++ b/app/code/Magento/CatalogSearch/view/frontend/result.phtml @@ -22,7 +22,7 @@ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */ ?> -<?php if($this->getResultCount()): ?> +<?php if ($this->getResultCount()): ?> <?php echo $this->getChildHtml('tagged_product_list_rss_link'); ?> <div class="search results"> <?php if ($messages = $this->getNoteMessages()):?> diff --git a/app/code/Magento/Centinel/Block/Adminhtml/Validation/Form.php b/app/code/Magento/Centinel/Block/Adminhtml/Validation/Form.php index 05e5e559976ba8c376e5cfc8289ca32be4f4b6b1..0b196c3fbdbed14e1bdf756598f95e8c68bb305a 100644 --- a/app/code/Magento/Centinel/Block/Adminhtml/Validation/Form.php +++ b/app/code/Magento/Centinel/Block/Adminhtml/Validation/Form.php @@ -38,6 +38,8 @@ class Form extends \Magento\Sales\Block\Adminhtml\Order\Create\AbstractCreate { /** * Prepare validation and template parameters + * + * @return string */ protected function _toHtml() { diff --git a/app/code/Magento/Centinel/Block/Authentication.php b/app/code/Magento/Centinel/Block/Authentication.php index 77a1a694f496bd0622f2d867405b0ccaed589366..4ca57bc93be5a59ebbaf21520d8d6108038b7acd 100644 --- a/app/code/Magento/Centinel/Block/Authentication.php +++ b/app/code/Magento/Centinel/Block/Authentication.php @@ -41,7 +41,7 @@ class Authentication extends \Magento\View\Element\Template /** * Strage for identifiers of related blocks * - * @var array + * @var string[] */ protected $_relatedBlocks = array(); @@ -83,7 +83,7 @@ class Authentication extends \Magento\View\Element\Template /** * Return identifiers of related blocks * - * @return array + * @return string[] */ public function getRelatedBlocks() { diff --git a/app/code/Magento/Centinel/Block/Logo.php b/app/code/Magento/Centinel/Block/Logo.php index 7b7cb30ff5904ff995e7888a656d7f9f88606548..f969b3c16cb7e83397c95418367a1eb8b33cbfab 100644 --- a/app/code/Magento/Centinel/Block/Logo.php +++ b/app/code/Magento/Centinel/Block/Logo.php @@ -32,6 +32,9 @@ namespace Magento\Centinel\Block; class Logo extends \Magento\View\Element\Template { + /** + * @var string + */ protected $_template = 'logo.phtml'; /** diff --git a/app/code/Magento/Centinel/Controller/Adminhtml/Centinel/Index.php b/app/code/Magento/Centinel/Controller/Adminhtml/Centinel/Index.php index 8a631383ddc2c42307374f2e1fe70703a365c9c9..296bd60ceaaa19872af31eee22cdc7a9d9146abe 100644 --- a/app/code/Magento/Centinel/Controller/Adminhtml/Centinel/Index.php +++ b/app/code/Magento/Centinel/Controller/Adminhtml/Centinel/Index.php @@ -57,6 +57,7 @@ class Index extends \Magento\Backend\App\Action /** * Process validate payment data action * + * @return void */ public function validatePaymentDataAction() { @@ -82,6 +83,7 @@ class Index extends \Magento\Backend\App\Action /** * Process autentication start action * + * @return void */ public function authenticationStartAction() { @@ -95,6 +97,7 @@ class Index extends \Magento\Backend\App\Action /** * Process autentication complete action * + * @return void */ public function authenticationCompleteAction() { diff --git a/app/code/Magento/Centinel/Controller/Index.php b/app/code/Magento/Centinel/Controller/Index.php index d386f0c26d35427cbc56697c1ce8b464cb1f0e5a..60268cdc726b58277ec88534b32585c8920691c5 100644 --- a/app/code/Magento/Centinel/Controller/Index.php +++ b/app/code/Magento/Centinel/Controller/Index.php @@ -54,6 +54,7 @@ class Index extends \Magento\App\Action\Action /** * Process autentication start action * + * @return void */ public function authenticationStartAction() { @@ -67,6 +68,7 @@ class Index extends \Magento\App\Action\Action /** * Process autentication complete action * + * @return void */ public function authenticationCompleteAction() { diff --git a/app/code/Magento/Centinel/Model/Api.php b/app/code/Magento/Centinel/Model/Api.php index 3aca6952da4b7806c6f82abf92f43b9bea3d6c58..301798e816fb357a42b7006f2b07bea82f1775ab 100644 --- a/app/code/Magento/Centinel/Model/Api.php +++ b/app/code/Magento/Centinel/Model/Api.php @@ -39,10 +39,13 @@ class Api extends \Magento\Object /** * Fields that should be replaced in debug with '***' * - * @var array + * @var string[] */ protected $_debugReplacePrivateDataKeys = array('TransactionPwd', 'CardNumber', 'CardExpMonth', 'CardExpYear'); + /** + * @var array + */ protected static $_iso4217Currencies = array( 'AED' => '784', 'AFN' => '971', 'ALL' => '008', 'AMD' => '051', 'ANG' => '532', 'AOA' => '973', 'ARS' => '032', 'AUD' => '036', 'AWG' => '533', @@ -122,7 +125,7 @@ class Api extends \Magento\Object /** * Return transaction type. according centinel documetation it should be "C" * - * @return "C" + * @return string */ protected function _getTransactionType() { @@ -152,10 +155,10 @@ class Api extends \Magento\Object /** * Call centinel api methods by given method name and data * - * @param $method string - * @param $data array - * + * @param string $method + * @param array $data * @return \CentinelClient + * @throws \Exception */ protected function _call($method, $data) { @@ -209,7 +212,8 @@ class Api extends \Magento\Object /** * Call centinel api lookup method * - * @return \Magento\Centinel\Model\Api + * @param \Magento\Object $data + * @return \Magento\Object */ public function callLookup($data) { @@ -247,7 +251,8 @@ class Api extends \Magento\Object /** * Call centinel api authentication method * - * @return \Magento\Centinel\Model\Api + * @param \Magento\Object $data + * @return \Magento\Object */ public function callAuthentication($data) { @@ -272,7 +277,7 @@ class Api extends \Magento\Object /** * Log debug data to file * - * @param mixed $debugData + * @param array $debugData */ protected function _debug($debugData) { diff --git a/app/code/Magento/Centinel/Model/Config.php b/app/code/Magento/Centinel/Model/Config.php index 260d9c1166c64b2ae1fe9fd2792b071681c42e00..7a7b171ac97fe3d99ab4977f0d46463e1427e3a2 100644 --- a/app/code/Magento/Centinel/Model/Config.php +++ b/app/code/Magento/Centinel/Model/Config.php @@ -53,7 +53,7 @@ class Config protected $_coreStoreConfig; /** - * @var \Magento\Core\Model\Config + * @var \Magento\App\ConfigInterface */ protected $_coreConfig; @@ -64,12 +64,12 @@ class Config /** * @param \Magento\Core\Model\Store\Config $coreStoreConfig - * @param \Magento\Core\Model\Config $coreConfig + * @param \Magento\App\ConfigInterface $coreConfig * @param \Magento\Encryption\EncryptorInterface $encryptor */ public function __construct( \Magento\Core\Model\Store\Config $coreStoreConfig, - \Magento\Core\Model\Config $coreConfig, + \Magento\App\ConfigInterface $coreConfig, \Magento\Encryption\EncryptorInterface $encryptor ) { $this->_coreStoreConfig = $coreStoreConfig; diff --git a/app/code/Magento/Centinel/Model/Service.php b/app/code/Magento/Centinel/Model/Service.php index 91489f23643436f0d39ac6546b71b9a17061c865..03b3a7def324e3dc36c480b3fde101b5f3d90d24 100644 --- a/app/code/Magento/Centinel/Model/Service.php +++ b/app/code/Magento/Centinel/Model/Service.php @@ -214,6 +214,7 @@ class Service extends \Magento\Object /** * Drop validation state model * + * @return void */ protected function _resetValidationState() { @@ -243,6 +244,7 @@ class Service extends \Magento\Object * Process lookup validation and init new validation state model * * @param \Magento\Object $data + * @return void */ public function lookup($data) { @@ -267,6 +269,8 @@ class Service extends \Magento\Object * Process authenticate validation * * @param \Magento\Object $data + * @return void + * @throws \Exception */ public function authenticate($data) { @@ -290,6 +294,7 @@ class Service extends \Magento\Object * Workflow state is stored validation state model * * @param \Magento\Object $data + * @return void * @throws \Magento\Core\Exception */ public function validate($data) @@ -409,9 +414,9 @@ class Service extends \Magento\Object /** * Export cmpi lookups and authentication information stored in session into array * - * @param mixed $to - * @param array $map - * @return mixed + * @param array|object $to + * @param array|bool $map + * @return array|object */ public function exportCmpiData($to, $map = false) { diff --git a/app/code/Magento/Centinel/etc/adminhtml/di.xml b/app/code/Magento/Centinel/etc/adminhtml/di.xml index 6a4521348d6a690ce29582f986f768e78a48d6ea..57f978e52aa8eb3222ba3a2ecf09e8fee9fdefd6 100644 --- a/app/code/Magento/Centinel/etc/adminhtml/di.xml +++ b/app/code/Magento/Centinel/etc/adminhtml/di.xml @@ -39,7 +39,7 @@ </virtualType> <type name="Magento\Centinel\Model\Service"> <param name="url"> - <instance type="Magento\Backend\Model\Url" /> + <instance type="Magento\Backend\Model\UrlInterface" /> </param> <param name="centinelSession"> <instance type="Magento\Centinel\Model\Session" /> diff --git a/app/code/Magento/Centinel/etc/di.xml b/app/code/Magento/Centinel/etc/di.xml index 37a072e7854d1cd04b5ec0224e3c10c1e8b3a366..cd72f1a5d1d086924ad3ec8598778ee7d861e3b6 100644 --- a/app/code/Magento/Centinel/etc/di.xml +++ b/app/code/Magento/Centinel/etc/di.xml @@ -26,12 +26,12 @@ <config> <type name="Magento\Centinel\Model\StateFactory"> <param name="stateClassMap"> - <value> - <VI>Magento\Centinel\Model\State\Visa</VI> - <MC>Magento\Centinel\Model\State\Mastercard</MC> - <JCB>Magento\Centinel\Model\State\Jcb</JCB> - <SM>Magento\Centinel\Model\State\Mastercard</SM> - </value> + <array> + <item key="VI"><value>Magento\Centinel\Model\State\Visa</value></item> + <item key="MC"><value>Magento\Centinel\Model\State\Mastercard</value></item> + <item key="JCB"><value>Magento\Centinel\Model\State\Jcb</value></item> + <item key="SM"><value>Magento\Centinel\Model\State\Mastercard</value></item> + </array> </param> </type> </config> diff --git a/app/code/Magento/Centinel/etc/frontend/di.xml b/app/code/Magento/Centinel/etc/frontend/di.xml index 191d75eed88406ea5bdc9d2a93549a51ccd00df1..6a73a392867a441f22de690393842b9779ac5e23 100644 --- a/app/code/Magento/Centinel/etc/frontend/di.xml +++ b/app/code/Magento/Centinel/etc/frontend/di.xml @@ -39,9 +39,9 @@ </virtualType> <type name="Magento\Core\Model\Url\SecurityInfo"> <param name="secureUrlList"> - <value> - <centinel>/centinel/</centinel> - </value> + <array> + <item key="centinel"><value>/centinel/</value></item> + </array> </param> </type> <type name="Magento\Centinel\Model\Service"> diff --git a/app/code/Magento/Checkout/Block/Adminhtml/Agreement/Grid.php b/app/code/Magento/Checkout/Block/Adminhtml/Agreement/Grid.php index 7567cede176ce0f9c216923e0f35e7e02a4476bb..3103a36713fa46277d0360bb025c992963daa5b3 100644 --- a/app/code/Magento/Checkout/Block/Adminhtml/Agreement/Grid.php +++ b/app/code/Magento/Checkout/Block/Adminhtml/Agreement/Grid.php @@ -34,20 +34,18 @@ class Grid extends \Magento\Backend\Block\Widget\Grid\Extended /** * @param \Magento\Backend\Block\Template\Context $context - * @param \Magento\Core\Model\Url $urlModel * @param \Magento\Backend\Helper\Data $backendHelper * @param \Magento\Checkout\Model\Resource\Agreement\CollectionFactory $collectionFactory * @param array $data */ public function __construct( \Magento\Backend\Block\Template\Context $context, - \Magento\Core\Model\Url $urlModel, \Magento\Backend\Helper\Data $backendHelper, \Magento\Checkout\Model\Resource\Agreement\CollectionFactory $collectionFactory, array $data = array() ) { $this->_collectionFactory = $collectionFactory; - parent::__construct($context, $urlModel, $backendHelper, $data); + parent::__construct($context, $backendHelper, $data); } protected function _construct() diff --git a/app/code/Magento/Checkout/Block/Cart/AbstractCart.php b/app/code/Magento/Checkout/Block/Cart/AbstractCart.php index 969b1860d9ba85c3bfee064f73d0bbbdc92b999f..4ab8b85cf33f3b78bb8d80cb661a17ba9b6fbb80 100644 --- a/app/code/Magento/Checkout/Block/Cart/AbstractCart.php +++ b/app/code/Magento/Checkout/Block/Cart/AbstractCart.php @@ -84,38 +84,36 @@ class AbstractCart extends \Magento\View\Element\Template } /** - * Initialize default item renderer + * Retrieve renderer list + * + * @return \Magento\View\Element\RendererList */ - protected function _prepareLayout() + protected function _getRendererList() { - if (!$this->getChildBlock(self::DEFAULT_TYPE)) { - $this->addChild( - self::DEFAULT_TYPE, - 'Magento\Checkout\Block\Cart\Item\Renderer', - array('template' => 'cart/item/default.phtml') - ); - } - return parent::_prepareLayout(); + return $this->getRendererListName() + ? $this->getLayout()->getBlock($this->getRendererListName()) + : $this->getChildBlock('renderer.list'); } /** - * Get renderer block instance by product type code + * Retrieve item renderer block * - * @param string $type + * @param string $type + * + * @return \Magento\View\Element\Template * @throws \RuntimeException - * @return \Magento\View\Element\AbstractBlock */ public function getItemRenderer($type) { - $renderer = $this->getChildBlock($type) ?: $this->getChildBlock(self::DEFAULT_TYPE); - if (!$renderer instanceof \Magento\View\Element\BlockInterface) { - throw new \RuntimeException('Renderer for type "' . $type . '" does not exist.'); + $rendererList = $this->_getRendererList(); + if (!$rendererList) { + throw new \RuntimeException('Renderer list for block "' . $this->getNameInLayout() . '" is not defined'); } - $renderer->setRenderedBlock($this); - return $renderer; + $overriddenTemplates = $this->getOverriddenTemplates() ?: array(); + $template = isset($overriddenTemplates[$type]) ? $overriddenTemplates[$type] : $this->getRendererTemplate(); + return $rendererList->getRenderer($type, self::DEFAULT_TYPE, $template); } - /** * Get logged in customer * diff --git a/app/code/Magento/Checkout/Block/Cart/Coupon.php b/app/code/Magento/Checkout/Block/Cart/Coupon.php index 275ce2099d313e434d200e88fc15d1f560915d3e..49186d3a5bddb7567ca8278a268978087aa2f03c 100644 --- a/app/code/Magento/Checkout/Block/Cart/Coupon.php +++ b/app/code/Magento/Checkout/Block/Cart/Coupon.php @@ -24,7 +24,6 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ - namespace Magento\Checkout\Block\Cart; class Coupon extends \Magento\Checkout\Block\Cart\AbstractCart @@ -51,6 +50,4 @@ class Coupon extends \Magento\Checkout\Block\Cart\AbstractCart { return $this->getQuote()->getCouponCode(); } - - } diff --git a/app/code/Magento/Checkout/Block/Cart/Crosssell.php b/app/code/Magento/Checkout/Block/Cart/Crosssell.php index b162fdd602f412be0ea23af8feb0f53c3c110f1f..9690e80677b47ec3b9ee4ff21d6879a9cf38551b 100644 --- a/app/code/Magento/Checkout/Block/Cart/Crosssell.php +++ b/app/code/Magento/Checkout/Block/Cart/Crosssell.php @@ -62,6 +62,11 @@ class Crosssell extends \Magento\Catalog\Block\Product\AbstractProduct */ protected $_productLinkFactory; + /** + * @var \Magento\Sales\Model\Quote\Item\RelatedProducts + */ + protected $_itemRelationsList; + /** * @param \Magento\View\Element\Template\Context $context * @param \Magento\Catalog\Model\Config $catalogConfig @@ -78,9 +83,10 @@ class Crosssell extends \Magento\Catalog\Block\Product\AbstractProduct * @param \Magento\Catalog\Model\Product\Visibility $productVisibility * @param \Magento\CatalogInventory\Model\Stock $stock * @param \Magento\Catalog\Model\Product\LinkFactory $productLinkFactory + * @param \Magento\Sales\Model\Quote\Item\RelatedProducts $itemRelationsList * @param array $data * @param array $priceBlockTypes - * + * * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ public function __construct( @@ -99,6 +105,7 @@ class Crosssell extends \Magento\Catalog\Block\Product\AbstractProduct \Magento\Catalog\Model\Product\Visibility $productVisibility, \Magento\CatalogInventory\Model\Stock $stock, \Magento\Catalog\Model\Product\LinkFactory $productLinkFactory, + \Magento\Sales\Model\Quote\Item\RelatedProducts $itemRelationsList, array $data = array(), array $priceBlockTypes = array() ) { @@ -106,6 +113,7 @@ class Crosssell extends \Magento\Catalog\Block\Product\AbstractProduct $this->_productVisibility = $productVisibility; $this->_stock = $stock; $this->_productLinkFactory = $productLinkFactory; + $this->_itemRelationsList = $itemRelationsList; parent::__construct( $context, $catalogConfig, @@ -152,7 +160,10 @@ class Crosssell extends \Magento\Catalog\Block\Product\AbstractProduct } if (count($items) < $this->_maxItemCount) { - $filterProductIds = array_merge($this->_getCartProductIds(), $this->_getCartProductIdsRel()); + $filterProductIds = array_merge( + $this->_getCartProductIds(), + $this->_itemRelationsList->getRelatedProductIds($this->getQuote()->getAllItems()) + ); $collection = $this->_getCollection() ->addProductFilter($filterProductIds) ->addExcludeProductFilter($ninProductIds) @@ -164,7 +175,6 @@ class Crosssell extends \Magento\Catalog\Block\Product\AbstractProduct $items[] = $item; } } - } $this->setData('items', $items); @@ -203,28 +213,6 @@ class Crosssell extends \Magento\Catalog\Block\Product\AbstractProduct return $ids; } - /** - * Retrieve Array of product ids which have special relation with products in Cart - * For example simple product as part of Grouped product - * - * @return array - */ - protected function _getCartProductIdsRel() - { - $productIds = array(); - foreach ($this->getQuote()->getAllItems() as $quoteItem) { - $productTypeOpt = $quoteItem->getOptionByCode('product_type'); - if ($productTypeOpt instanceof \Magento\Sales\Model\Quote\Item\Option - && $productTypeOpt->getValue() == \Magento\GroupedProduct\Model\Product\Type\Grouped::TYPE_CODE - && $productTypeOpt->getProductId() - ) { - $productIds[] = $productTypeOpt->getProductId(); - } - } - - return $productIds; - } - /** * Get last product ID that was added to cart and remove this information from session * diff --git a/app/code/Magento/Checkout/Block/Cart/Sidebar.php b/app/code/Magento/Checkout/Block/Cart/Sidebar.php index 68d3ada702d9aa16bdf717460ce691130cb20793..6fb944ca95dbfaabc21fdbbbcc424eaa6acc4a1d 100644 --- a/app/code/Magento/Checkout/Block/Cart/Sidebar.php +++ b/app/code/Magento/Checkout/Block/Cart/Sidebar.php @@ -341,11 +341,11 @@ class Sidebar extends \Magento\Checkout\Block\Cart\AbstractCart protected function _serializeRenders() { $result = array(); - foreach ($this->getLayout()->getChildBlocks($this->getNameInLayout()) as $block) { + foreach ($this->getLayout()->getChildBlocks($this->_getRendererList()->getNameInLayout()) as $alias => $block) { /** @var $block \Magento\View\Element\Template */ $result[] = implode('|', array( // skip $this->getNameInLayout() and '.' - substr($block->getNameInLayout(), strlen($this->getNameInLayout()) + 1), + $alias, get_class($block), $block->getTemplate() )); @@ -364,21 +364,21 @@ class Sidebar extends \Magento\Checkout\Block\Cart\AbstractCart if (!is_string($renders)) { return $this; } + $rendererList = $this->addChild('renderer.list', 'Magento\View\Element\RendererList'); $renders = explode('|', $renders); while (!empty($renders)) { $template = array_pop($renders); $block = array_pop($renders); - $type = array_pop($renders); - if (!$template || !$block || !$type) { + $alias = array_pop($renders); + if (!$template || !$block || !$alias) { continue; } - if (!$this->getChildBlock($type)) { - $this->addChild($type, $block, array('template' => $template)); - } + if (!$rendererList->getChildBlock($alias)) { + $rendererList->addChild($alias, $block, array('template' => $template)); + } } - return $this; } } diff --git a/app/code/Magento/Checkout/Block/Onepage.php b/app/code/Magento/Checkout/Block/Onepage.php index 127bf5f671666267dde81faa086de8e59999d712..cf51932dedc02a6d3a4be6f19255e73821eb98a3 100644 --- a/app/code/Magento/Checkout/Block/Onepage.php +++ b/app/code/Magento/Checkout/Block/Onepage.php @@ -41,8 +41,8 @@ class Onepage extends \Magento\Checkout\Block\Onepage\AbstractOnepage * @param \Magento\App\Cache\Type\Config $configCacheType * @param \Magento\Customer\Model\Session $customerSession * @param \Magento\Checkout\Model\Session $resourceSession - * @param \Magento\Directory\Model\Resource\Country\CollectionFactory $countryCollFactory - * @param \Magento\Directory\Model\Resource\Region\CollectionFactory $regionCollFactory + * @param \Magento\Directory\Model\Resource\Country\CollectionFactory $countryCollectionFactory + * @param \Magento\Directory\Model\Resource\Region\CollectionFactory $regionCollectionFactory * @param array $data */ public function __construct( @@ -51,22 +51,17 @@ class Onepage extends \Magento\Checkout\Block\Onepage\AbstractOnepage \Magento\App\Cache\Type\Config $configCacheType, \Magento\Customer\Model\Session $customerSession, \Magento\Checkout\Model\Session $resourceSession, - \Magento\Directory\Model\Resource\Country\CollectionFactory $countryCollFactory, - \Magento\Directory\Model\Resource\Region\CollectionFactory $regionCollFactory, + \Magento\Directory\Model\Resource\Country\CollectionFactory $countryCollectionFactory, + \Magento\Directory\Model\Resource\Region\CollectionFactory $regionCollectionFactory, array $data = array() ) { parent::__construct( - $context, - $coreData, - $configCacheType, - $customerSession, - $resourceSession, - $countryCollFactory, - $regionCollFactory, - $data + $context, $coreData, $configCacheType, $customerSession, $resourceSession, + $countryCollectionFactory, $regionCollectionFactory, $data ); $this->_isScopePrivate = true; } + /** * Get 'one step checkout' step data * diff --git a/app/code/Magento/Checkout/Controller/Cart.php b/app/code/Magento/Checkout/Controller/Cart.php index 1ff7ccd423722acb9547617045a56d416b75ded9..34c043e7c324de65811fb116768ec4e858d7e1fa 100644 --- a/app/code/Magento/Checkout/Controller/Cart.php +++ b/app/code/Magento/Checkout/Controller/Cart.php @@ -621,7 +621,7 @@ class Cart /** @var $store \Magento\Core\Model\Store */ $store = $this->_storeManager->getStore(); $unsecure = (strpos($url, $store->getBaseUrl()) === 0); - $secure = (strpos($url, $store->getBaseUrl($store::URL_TYPE_LINK, true)) === 0); + $secure = (strpos($url, $store->getBaseUrl(\Magento\UrlInterface::URL_TYPE_LINK, true)) === 0); return $unsecure || $secure; } } diff --git a/app/code/Magento/Checkout/Helper/Cart.php b/app/code/Magento/Checkout/Helper/Cart.php index 1f6eafa82e2b3d862fb03719209a988553e68134..a6c511ec72395a55420bed4e4078dabd6c5c4399 100644 --- a/app/code/Magento/Checkout/Helper/Cart.php +++ b/app/code/Magento/Checkout/Helper/Cart.php @@ -119,8 +119,8 @@ class Cart extends \Magento\Core\Helper\Url } if ($product->hasUrlDataObject()) { - $routeParams['_store'] = $product->getUrlDataObject()->getStoreId(); - $routeParams['_store_to_url'] = true; + $routeParams['_scope'] = $product->getUrlDataObject()->getStoreId(); + $routeParams['_scope_to_url'] = true; } if ($this->_getRequest()->getRouteName() == 'checkout' diff --git a/app/code/Magento/Checkout/etc/adminhtml/system.xml b/app/code/Magento/Checkout/etc/adminhtml/system.xml index 9b8adff4ecceb28ecc5577be7eee07763576c272..a7c26534f283859531283712533dd643e1957ce5 100644 --- a/app/code/Magento/Checkout/etc/adminhtml/system.xml +++ b/app/code/Magento/Checkout/etc/adminhtml/system.xml @@ -62,10 +62,6 @@ <label>After Adding a Product Redirect to Shopping Cart</label> <source_model>Magento\Backend\Model\Config\Source\Yesno</source_model> </field> - <field id="grouped_product_image" translate="label" type="select" sortOrder="3" showInDefault="1" showInWebsite="1" showInStore="1"> - <label>Grouped Product Image</label> - <source_model>Magento\Catalog\Model\Config\Source\Product\Thumbnail</source_model> - </field> <field id="configurable_product_image" translate="label" type="select" sortOrder="4" showInDefault="1" showInWebsite="1" showInStore="1"> <label>Configurable Product Image</label> <source_model>Magento\Catalog\Model\Config\Source\Product\Thumbnail</source_model> diff --git a/app/code/Magento/Checkout/etc/config.xml b/app/code/Magento/Checkout/etc/config.xml index 95e76a8fa69d3ee1bb6a5ee109200f073076b861..39c9bc9ff1c179dd1f42169f11312778b3066aae 100644 --- a/app/code/Magento/Checkout/etc/config.xml +++ b/app/code/Magento/Checkout/etc/config.xml @@ -35,7 +35,6 @@ <cart> <delete_quote_after>30</delete_quote_after> <redirect_to_cart>1</redirect_to_cart> - <grouped_product_image>itself</grouped_product_image> <configurable_product_image>parent</configurable_product_image> </cart> <cart_link> diff --git a/app/code/Magento/Checkout/etc/di.xml b/app/code/Magento/Checkout/etc/di.xml index bcbaa44374a1c4573206f8e1e1f9bbc470602814..1a1f221654ee007a5bd3e1cb173f98c19b363ede 100644 --- a/app/code/Magento/Checkout/etc/di.xml +++ b/app/code/Magento/Checkout/etc/di.xml @@ -26,9 +26,9 @@ <config> <type name="Magento\Module\Updater\SetupFactory"> <param name="resourceTypes"> - <value> - <checkout_setup>Magento\Checkout\Model\Resource\Setup</checkout_setup> - </value> + <array> + <item key="checkout_setup"><value>Magento\Checkout\Model\Resource\Setup</value></item> + </array> </param> </type> <virtualType name="Magento\Checkout\Model\Session\Storage" type="Magento\Session\Storage"> diff --git a/app/code/Magento/Checkout/etc/frontend/di.xml b/app/code/Magento/Checkout/etc/frontend/di.xml index dd1ef14930082be1ecff73683deb339608eab7b3..70de95507f1a5e86b33b35ca6c9824bae937a47a 100644 --- a/app/code/Magento/Checkout/etc/frontend/di.xml +++ b/app/code/Magento/Checkout/etc/frontend/di.xml @@ -31,16 +31,16 @@ </type> <type name="Magento\Core\Model\Url\SecurityInfo"> <param name="secureUrlList"> - <value> - <checkout_onepage>/checkout/onepage</checkout_onepage> - </value> + <array> + <item key="checkout_onepage"><value>/checkout/onepage</value></item> + </array> </param> </type> <virtualType name="checkoutCartInitSession" type="Magento\Core\App\Action\Plugin\Session"> <param name="cookieCheckActions"> - <value> - <checkoutCartAdd>add</checkoutCartAdd> - </value> + <array> + <item key="checkoutCartAdd"><value>add</value></item> + </array> </param> </virtualType> <type name="Magento\Checkout\Controller\Cart"> diff --git a/app/code/Magento/Checkout/etc/module.xml b/app/code/Magento/Checkout/etc/module.xml index 13abefbbf374a1781b09d5249e4517d18a267276..9a0762091281d706eec1e6440d4126137cb9b4e1 100755 --- a/app/code/Magento/Checkout/etc/module.xml +++ b/app/code/Magento/Checkout/etc/module.xml @@ -28,7 +28,6 @@ <sequence> <module name="Magento_Sales"/> <module name="Magento_CatalogInventory"/> - <module name="Magento_GroupedProduct" /> </sequence> <depends> <module name="Magento_Sales"/> @@ -36,7 +35,6 @@ <module name="Magento_Core"/> <module name="Magento_Customer"/> <module name="Magento_Catalog"/> - <module name="Magento_GroupedProduct" /> <module name="Magento_Payment"/> <module name="Magento_Tax"/> <module name="Magento_Directory"/> diff --git a/app/code/Magento/Checkout/i18n/de_DE.csv b/app/code/Magento/Checkout/i18n/de_DE.csv index c4ed3e6e86f179cd92f29b8dcb097467a6f7b411..5d44b24a716ee649663a7fcf1bad77f642f37108 100644 --- a/app/code/Magento/Checkout/i18n/de_DE.csv +++ b/app/code/Magento/Checkout/i18n/de_DE.csv @@ -130,7 +130,6 @@ "Get total prices for shopping cart","Gesamtpreis für Warenkorb anzeigen" "Gift Message","Grußnachricht" "Grand Total:","Gesamtbetrag:" -"Grouped Product Image","Gruppiertes Produktbild" "HTML","HTML" "ID","ID" "Incl. Tax","Steuer inkludieren" diff --git a/app/code/Magento/Checkout/i18n/en_US.csv b/app/code/Magento/Checkout/i18n/en_US.csv index 3e24a24ed3c43395b0781b363149de5b930916cf..7103ae458f536e895a81d8e06bd43cbb1b83944f 100644 --- a/app/code/Magento/Checkout/i18n/en_US.csv +++ b/app/code/Magento/Checkout/i18n/en_US.csv @@ -130,7 +130,6 @@ "Get total prices for shopping cart","Get total prices for shopping cart" "Gift Message","Gift Message" "Grand Total:","Grand Total:" -"Grouped Product Image","Grouped Product Image" "HTML","HTML" "ID","ID" "Incl. Tax","Incl. Tax" diff --git a/app/code/Magento/Checkout/i18n/es_ES.csv b/app/code/Magento/Checkout/i18n/es_ES.csv index ffdbd1beabb7351f78b99fe9d4aa8e1df3633c1a..94b5c5f5fd16eb70ef1234f52e909713fe2ce59b 100644 --- a/app/code/Magento/Checkout/i18n/es_ES.csv +++ b/app/code/Magento/Checkout/i18n/es_ES.csv @@ -130,7 +130,6 @@ "Get total prices for shopping cart","Obtener los precios totales del carro de la compra" "Gift Message","Mensaje regalo" "Grand Total:","Total final:" -"Grouped Product Image","Imagen de productos agrupados" "HTML","HTML" "ID","Identificación" "Incl. Tax","Impuestos incluidos" diff --git a/app/code/Magento/Checkout/i18n/fr_FR.csv b/app/code/Magento/Checkout/i18n/fr_FR.csv index e577bfb5b9f40862f40617e52ca82b5374435574..dd8d24a1a118556c9aff075439423cd3a7dd8fb6 100644 --- a/app/code/Magento/Checkout/i18n/fr_FR.csv +++ b/app/code/Magento/Checkout/i18n/fr_FR.csv @@ -130,7 +130,6 @@ "Get total prices for shopping cart","Obtenir le prix total du panier" "Gift Message","Message du cadeau" "Grand Total:","Total :" -"Grouped Product Image","Image groupée du produit" "HTML","HTML" "ID","ID" "Incl. Tax","Taxe comprise" diff --git a/app/code/Magento/Checkout/i18n/nl_NL.csv b/app/code/Magento/Checkout/i18n/nl_NL.csv index febf1ec2a886e0b632be92fba3dc4e7c1486e3d3..02ca950d491301c468b9f36afb5c8e1c88604eb5 100644 --- a/app/code/Magento/Checkout/i18n/nl_NL.csv +++ b/app/code/Magento/Checkout/i18n/nl_NL.csv @@ -130,7 +130,6 @@ "Get total prices for shopping cart","Totale prijs voor winkelmandje verkrijgen" "Gift Message","Cadeauboodschap" "Grand Total:","Alles bij elkaar:" -"Grouped Product Image","Gegroepeerde productafbeelding" "HTML","HTML" "ID","identiteit" "Incl. Tax","inclusief btw" diff --git a/app/code/Magento/Checkout/i18n/pt_BR.csv b/app/code/Magento/Checkout/i18n/pt_BR.csv index 49c363e941d3e74657dad80cf65d9f18a97fea38..597177a82885d0f6c4ad7c482affba4915ab6b47 100644 --- a/app/code/Magento/Checkout/i18n/pt_BR.csv +++ b/app/code/Magento/Checkout/i18n/pt_BR.csv @@ -130,7 +130,6 @@ "Get total prices for shopping cart","Totalizar preços no carrinho de compras" "Gift Message","Mensagem de presente" "Grand Total:","Total geral:" -"Grouped Product Image","Imagem de Produto Agrupado" "HTML","HTML" "ID","Identidade" "Incl. Tax","Incluir taxas" diff --git a/app/code/Magento/Checkout/i18n/zh_CN.csv b/app/code/Magento/Checkout/i18n/zh_CN.csv index 93708cf510d94a0fd9145c5cac31fa1cc1a0b3ba..2ef3aa36adc0a31dc14340c3e671f6875e08566b 100644 --- a/app/code/Magento/Checkout/i18n/zh_CN.csv +++ b/app/code/Magento/Checkout/i18n/zh_CN.csv @@ -130,7 +130,6 @@ "Get total prices for shopping cart","获得è´ç‰©è½¦ä¸æ€»ä»·æ ¼" "Gift Message","ç¤¼å“æ¶ˆæ¯" "Grand Total:","总计:" -"Grouped Product Image","已分组的产å“图片" "HTML","HTML" "ID","ID" "Incl. Tax","å«ç¨Ž" diff --git a/app/code/Magento/Checkout/view/frontend/layout/checkout_cart_index.xml b/app/code/Magento/Checkout/view/frontend/layout/checkout_cart_index.xml index dc6a482cee01a7daa19c19e4b358921c44d1c81a..103313b8873fb2752ededa4b9dee284384f99802 100644 --- a/app/code/Magento/Checkout/view/frontend/layout/checkout_cart_index.xml +++ b/app/code/Magento/Checkout/view/frontend/layout/checkout_cart_index.xml @@ -25,13 +25,12 @@ --> <layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <update handle="page_one_column"/> + <update handle="checkout_cart_item_renderers" /> <referenceContainer name="content"> <block class="Magento\Checkout\Block\Cart" name="checkout.cart" template="cart.phtml" cacheable="false"> <container name="checkout.cart.items" label="invisible" as="with-items"> <block class="Magento\Checkout\Block\Cart" name="checkout.cart.form" as="cart-items" template="cart/form.phtml" cacheable="false"> - <block class="Magento\Checkout\Block\Cart\Item\Renderer" as="simple" template="cart/item/default.phtml" cacheable="false"/> - <block class="Magento\Checkout\Block\Cart\Item\Renderer\Grouped" as="grouped" template="cart/item/default.phtml" cacheable="false"/> - <block class="Magento\Checkout\Block\Cart\Item\Renderer\Configurable" as="configurable" template="cart/item/default.phtml" cacheable="false"/> + <block class="Magento\View\Element\RendererList" name="checkout.cart.item.renderers" as="renderer.list" /> <container name="checkout.cart.form.before" as="form_before" label="Shopping Cart Items Before" htmlTag="div" htmlClass="rewards"/> <container name="checkout.cart.widget" as="checkout_cart_widget" label="Shopping Cart Items After"/> </block> diff --git a/app/code/Magento/Checkout/view/frontend/layout/checkout_cart_item_renderers.xml b/app/code/Magento/Checkout/view/frontend/layout/checkout_cart_item_renderers.xml new file mode 100644 index 0000000000000000000000000000000000000000..22ad3b4d1a26b5ae4dbec326f0e07f846e37fcb9 --- /dev/null +++ b/app/code/Magento/Checkout/view/frontend/layout/checkout_cart_item_renderers.xml @@ -0,0 +1,33 @@ +<?xml version="1.0"?> +<!-- +/** + * 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) + */ +--> +<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <referenceBlock name="checkout.cart.item.renderers"> + <block class="Magento\Checkout\Block\Cart\Item\Renderer" as="default" template="cart/item/default.phtml" cacheable="false"/> + <block class="Magento\Checkout\Block\Cart\Item\Renderer" as="simple" template="cart/item/default.phtml" cacheable="false"/> + <block class="Magento\Checkout\Block\Cart\Item\Renderer\Configurable" as="configurable" template="cart/item/default.phtml" cacheable="false"/> + </referenceBlock> +</layout> + diff --git a/app/code/Magento/PaypalUk/view/frontend/layout/paypal_express_review_details.xml b/app/code/Magento/Checkout/view/frontend/layout/checkout_cart_sidebar_item_renderers.xml similarity index 64% rename from app/code/Magento/PaypalUk/view/frontend/layout/paypal_express_review_details.xml rename to app/code/Magento/Checkout/view/frontend/layout/checkout_cart_sidebar_item_renderers.xml index 00380155449e79efecc7ff30b8b33234e8bf570c..831ddfef5535b09dfd2b2ba0d3fc7fad1f093033 100644 --- a/app/code/Magento/PaypalUk/view/frontend/layout/paypal_express_review_details.xml +++ b/app/code/Magento/Checkout/view/frontend/layout/checkout_cart_sidebar_item_renderers.xml @@ -24,14 +24,10 @@ */ --> <layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> - <block class="Magento\Paypal\Block\Express\Review\Details" name="root" output="1" - template="express/review/details.phtml"> - <block class="Magento\Checkout\Block\Cart\Item\Renderer" as="default" template="onepage/review/item.phtml" cacheable="false"/> - <block class="Magento\Checkout\Block\Cart\Item\Renderer\Grouped" as="grouped" - template="onepage/review/item.phtml" cacheable="false"/> - <block class="Magento\Checkout\Block\Cart\Item\Renderer\Configurable" as="configurable" - template="onepage/review/item.phtml" cacheable="false"/> - <block class="Magento\Checkout\Block\Cart\Totals" name="paypal.express.review.details.totals" as="totals" - template="onepage/review/totals.phtml" cacheable="false"/> - </block> + <referenceBlock name="checkout.cart.sidebar.item.renderers"> + <block class="Magento\Checkout\Block\Cart\Item\Renderer" as="default" template="cart/sidebar/default.phtml" cacheable="false"/> + <block class="Magento\Checkout\Block\Cart\Item\Renderer" as="simple" template="cart/sidebar/default.phtml" cacheable="false"/> + <block class="Magento\Checkout\Block\Cart\Item\Renderer\Configurable" as="configurable" template="cart/sidebar/default.phtml" cacheable="false"/> + <block class="Magento\Checkout\Block\Cart\Item\Renderer" as="virtual" template="cart/sidebar/default.phtml" cacheable="false"/> + </referenceBlock> </layout> diff --git a/app/code/Magento/Checkout/view/frontend/layout/checkout_onepage_review.xml b/app/code/Magento/Checkout/view/frontend/layout/checkout_onepage_review.xml index 8fef618e8628deb178ee4d4b3fec6d06256f0594..c459e890eb70b58dbb50e3eb971242e3f52dacc3 100644 --- a/app/code/Magento/Checkout/view/frontend/layout/checkout_onepage_review.xml +++ b/app/code/Magento/Checkout/view/frontend/layout/checkout_onepage_review.xml @@ -24,10 +24,9 @@ */ --> <layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <update handle="checkout_onepage_review_item_renderers" /> <block class="Magento\Checkout\Block\Onepage\Review\Info" name="order_review" output="1" template="onepage/review/info.phtml" cacheable="false"> - <block class="Magento\Checkout\Block\Cart\Item\Renderer" as="default" template="onepage/review/item.phtml" cacheable="false"/> - <block class="Magento\Checkout\Block\Cart\Item\Renderer\Grouped" as="grouped" template="onepage/review/item.phtml" cacheable="false"/> - <block class="Magento\Checkout\Block\Cart\Item\Renderer\Configurable" as="configurable" template="onepage/review/item.phtml" cacheable="false"/> + <block class="Magento\View\Element\RendererList" name="checkout.onepage.review.item.renderers" as="renderer.list" /> <block class="Magento\Checkout\Block\Cart\Totals" name="checkout.onepage.review.info.totals" as="totals" template="onepage/review/totals.phtml" cacheable="false"/> <container name="checkout.onepage.review.info.items.before" as="items_before" label="Items Before"/> <container name="checkout.onepage.review.info.items.after" as="items_after" label="Items After"/> diff --git a/app/code/Magento/Checkout/view/frontend/layout/checkout_onepage_review_item_renderers.xml b/app/code/Magento/Checkout/view/frontend/layout/checkout_onepage_review_item_renderers.xml new file mode 100644 index 0000000000000000000000000000000000000000..40198c064b498c56e0a2167e8b4f680c2156cb4b --- /dev/null +++ b/app/code/Magento/Checkout/view/frontend/layout/checkout_onepage_review_item_renderers.xml @@ -0,0 +1,32 @@ +<?xml version="1.0"?> +<!-- +/** + * 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) + */ +--> +<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <referenceBlock name="checkout.onepage.review.item.renderers"> + <block class="Magento\Checkout\Block\Cart\Item\Renderer" as="default" template="onepage/review/item.phtml" cacheable="false"/> + <block class="Magento\Checkout\Block\Cart\Item\Renderer\Configurable" as="configurable" template="onepage/review/item.phtml" cacheable="false"/> + </referenceBlock> +</layout> + diff --git a/app/code/Magento/Checkout/view/frontend/layout/default.xml b/app/code/Magento/Checkout/view/frontend/layout/default.xml index 8bf1c13e3c78d3a63629284fb82960c301215241..08e85caa9485579453dad5ce939c43b93adf2dca 100644 --- a/app/code/Magento/Checkout/view/frontend/layout/default.xml +++ b/app/code/Magento/Checkout/view/frontend/layout/default.xml @@ -24,15 +24,13 @@ */ --> <layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <update handle="checkout_cart_sidebar_item_renderers" /> <referenceBlock name="head.components"> <block class="Magento\View\Element\Js\Components" name="checkout_page_head_components" template="Magento_Checkout::js/components.phtml"/> </referenceBlock> <referenceContainer name="header-wrapper"> <block class="Magento\Checkout\Block\Cart\Sidebar" name="minicart" as="minicart" after="logo" template="cart/minicart.phtml" cacheable="false"> - <block class="Magento\Checkout\Block\Cart\Item\Renderer" as="simple" template="cart/sidebar/default.phtml" cacheable="false"/> - <block class="Magento\Checkout\Block\Cart\Item\Renderer\Grouped" as="grouped" template="cart/sidebar/default.phtml" cacheable="false"/> - <block class="Magento\Checkout\Block\Cart\Item\Renderer\Configurable" as="configurable" template="cart/sidebar/default.phtml" cacheable="false"/> - <block class="Magento\Checkout\Block\Cart\Item\Renderer" as="virtual" template="cart/sidebar/default.phtml" cacheable="false"/> + <block class="Magento\View\Element\RendererList" name="checkout.cart.sidebar.item.renderers" as="renderer.list" /> <container name="minicart.extra.info" as="minicart_info" label="My Cart Extra info"/> <container name="topCart.extra_actions" as="extra_actions" label="My Cart Extra Actions"/> </block> diff --git a/app/code/Magento/Cms/Block/Adminhtml/Block/Widget/Chooser.php b/app/code/Magento/Cms/Block/Adminhtml/Block/Widget/Chooser.php index 97523391c0dc87fd5b40c919627c2460974b0ad2..70cb64aada15251d946113c855dafe560230bdec 100644 --- a/app/code/Magento/Cms/Block/Adminhtml/Block/Widget/Chooser.php +++ b/app/code/Magento/Cms/Block/Adminhtml/Block/Widget/Chooser.php @@ -47,7 +47,6 @@ class Chooser extends \Magento\Backend\Block\Widget\Grid\Extended /** * @param \Magento\Backend\Block\Template\Context $context - * @param \Magento\Core\Model\Url $urlModel * @param \Magento\Backend\Helper\Data $backendHelper * @param \Magento\Cms\Model\BlockFactory $blockFactory * @param \Magento\Cms\Model\Resource\Block\CollectionFactory $collectionFactory @@ -55,7 +54,6 @@ class Chooser extends \Magento\Backend\Block\Widget\Grid\Extended */ public function __construct( \Magento\Backend\Block\Template\Context $context, - \Magento\Core\Model\Url $urlModel, \Magento\Backend\Helper\Data $backendHelper, \Magento\Cms\Model\BlockFactory $blockFactory, \Magento\Cms\Model\Resource\Block\CollectionFactory $collectionFactory, @@ -63,7 +61,7 @@ class Chooser extends \Magento\Backend\Block\Widget\Grid\Extended ) { $this->_blockFactory = $blockFactory; $this->_collectionFactory = $collectionFactory; - parent::__construct($context, $urlModel, $backendHelper, $data); + parent::__construct($context, $backendHelper, $data); } /** diff --git a/app/code/Magento/Cms/Block/Adminhtml/Page/Grid.php b/app/code/Magento/Cms/Block/Adminhtml/Page/Grid.php index ee173f4ef506b74942fbcbfef9ac7c5e2550f4c9..ecebc9ed2b1cd9ed7e892b15278047bccea1868b 100644 --- a/app/code/Magento/Cms/Block/Adminhtml/Page/Grid.php +++ b/app/code/Magento/Cms/Block/Adminhtml/Page/Grid.php @@ -52,7 +52,6 @@ class Grid extends \Magento\Backend\Block\Widget\Grid\Extended /** * @param \Magento\Backend\Block\Template\Context $context - * @param \Magento\Core\Model\Url $urlModel * @param \Magento\Backend\Helper\Data $backendHelper * @param \Magento\Theme\Model\Layout\Source\Layout $pageLayout * @param \Magento\Cms\Model\Page $cmsPage @@ -61,7 +60,6 @@ class Grid extends \Magento\Backend\Block\Widget\Grid\Extended */ public function __construct( \Magento\Backend\Block\Template\Context $context, - \Magento\Core\Model\Url $urlModel, \Magento\Backend\Helper\Data $backendHelper, \Magento\Theme\Model\Layout\Source\Layout $pageLayout, \Magento\Cms\Model\Page $cmsPage, @@ -71,7 +69,7 @@ class Grid extends \Magento\Backend\Block\Widget\Grid\Extended $this->_collectionFactory = $collectionFactory; $this->_cmsPage = $cmsPage; $this->_pageLayout = $pageLayout; - parent::__construct($context, $urlModel, $backendHelper, $data); + parent::__construct($context, $backendHelper, $data); } protected function _construct() diff --git a/app/code/Magento/Cms/Block/Adminhtml/Page/Grid/Renderer/Action.php b/app/code/Magento/Cms/Block/Adminhtml/Page/Grid/Renderer/Action.php index b40e692bb8ae814d5182d1c528c759ff97fe846b..e4b638a39e25a09e3d88247253048584c43e2aed 100644 --- a/app/code/Magento/Cms/Block/Adminhtml/Page/Grid/Renderer/Action.php +++ b/app/code/Magento/Cms/Block/Adminhtml/Page/Grid/Renderer/Action.php @@ -30,18 +30,18 @@ class Action extends \Magento\Backend\Block\Widget\Grid\Column\Renderer\AbstractRenderer { /** - * @var \Magento\Core\Model\UrlFactory + * @var \Magento\UrlFactory */ protected $_urlFactory; /** * @param \Magento\Backend\Block\Context $context - * @param \Magento\Core\Model\UrlFactory $urlFactory + * @param \Magento\UrlFactory $urlFactory * @param array $data */ public function __construct( \Magento\Backend\Block\Context $context, - \Magento\Core\Model\UrlFactory $urlFactory, + \Magento\UrlFactory $urlFactory, array $data = array() ) { $this->_urlFactory = $urlFactory; @@ -50,8 +50,8 @@ class Action public function render(\Magento\Object $row) { - /** @var \Magento\Core\Model\Url $urlModel */ - $urlModel = $this->_urlFactory->create()->setStore($row->getData('_first_store_id')); + /** @var \Magento\UrlInterface $urlModel */ + $urlModel = $this->_urlFactory->create()->setScope($row->getData('_first_store_id')); $href = $urlModel->getUrl( $row->getIdentifier(), array( '_current' => false, diff --git a/app/code/Magento/Cms/Block/Adminhtml/Page/Widget/Chooser.php b/app/code/Magento/Cms/Block/Adminhtml/Page/Widget/Chooser.php index ed20e403eed66fec769a350805f7fb43ee9dcebd..b8a094d825a88642e34f80b18fca5dc0033f03e7 100644 --- a/app/code/Magento/Cms/Block/Adminhtml/Page/Widget/Chooser.php +++ b/app/code/Magento/Cms/Block/Adminhtml/Page/Widget/Chooser.php @@ -57,7 +57,6 @@ class Chooser extends \Magento\Backend\Block\Widget\Grid\Extended /** * @param \Magento\Backend\Block\Template\Context $context - * @param \Magento\Core\Model\Url $urlModel * @param \Magento\Backend\Helper\Data $backendHelper * @param \Magento\Theme\Model\Layout\Source\Layout $pageLayout * @param \Magento\Cms\Model\Page $cmsPage @@ -67,7 +66,6 @@ class Chooser extends \Magento\Backend\Block\Widget\Grid\Extended */ public function __construct( \Magento\Backend\Block\Template\Context $context, - \Magento\Core\Model\Url $urlModel, \Magento\Backend\Helper\Data $backendHelper, \Magento\Theme\Model\Layout\Source\Layout $pageLayout, \Magento\Cms\Model\Page $cmsPage, @@ -79,7 +77,7 @@ class Chooser extends \Magento\Backend\Block\Widget\Grid\Extended $this->_cmsPage = $cmsPage; $this->_pageFactory = $pageFactory; $this->_collectionFactory = $collectionFactory; - parent::__construct($context, $urlModel, $backendHelper, $data); + parent::__construct($context, $backendHelper, $data); } /** diff --git a/app/code/Magento/Cms/Controller/Router.php b/app/code/Magento/Cms/Controller/Router.php index 7b5b327bfc8017c04a5588cf5804236e50615970..13bc9727254649310a03cf14d614219073f6ae94 100644 --- a/app/code/Magento/Cms/Controller/Router.php +++ b/app/code/Magento/Cms/Controller/Router.php @@ -159,7 +159,7 @@ class Router extends \Magento\App\Router\AbstractRouter ->setActionName('view') ->setParam('page_id', $pageId); $request->setAlias( - \Magento\Core\Model\Url\Rewrite::REWRITE_REQUEST_PATH_ALIAS, + \Magento\Url::REWRITE_REQUEST_PATH_ALIAS, $identifier ); diff --git a/app/code/Magento/Cms/Helper/Wysiwyg/Images.php b/app/code/Magento/Cms/Helper/Wysiwyg/Images.php index 6b7116a2fb966c2fb8aa053049259056e233b3e6..8a7608e9dd62b8c0d24ad8f1ae846f279d2b740b 100644 --- a/app/code/Magento/Cms/Helper/Wysiwyg/Images.php +++ b/app/code/Magento/Cms/Helper/Wysiwyg/Images.php @@ -132,7 +132,7 @@ class Images extends \Magento\App\Helper\AbstractHelper */ public function getBaseUrl() { - return $this->_storeManager->getStore()->getBaseUrl(\Magento\Core\Model\Store::URL_TYPE_MEDIA); + return $this->_storeManager->getStore()->getBaseUrl(\Magento\UrlInterface::URL_TYPE_MEDIA); } /** @@ -198,7 +198,7 @@ class Images extends \Magento\App\Helper\AbstractHelper public function getImageHtmlDeclaration($filename, $renderAsTag = false) { $fileurl = $this->getCurrentUrl() . $filename; - $mediaUrl = $this->_storeManager->getStore()->getBaseUrl(\Magento\Core\Model\Store::URL_TYPE_MEDIA); + $mediaUrl = $this->_storeManager->getStore()->getBaseUrl(\Magento\UrlInterface::URL_TYPE_MEDIA); $mediaPath = str_replace($mediaUrl, '', $fileurl); $directive = sprintf('{{media url="%s"}}', $mediaPath); if ($renderAsTag) { @@ -259,7 +259,7 @@ class Images extends \Magento\App\Helper\AbstractHelper if (!$this->_currentUrl) { $path = $this->getCurrentPath(); $mediaUrl = $this->_storeManager->getStore($this->_storeId) - ->getBaseUrl(\Magento\Core\Model\Store::URL_TYPE_MEDIA); + ->getBaseUrl(\Magento\UrlInterface::URL_TYPE_MEDIA); $this->_currentUrl = $mediaUrl . $this->_directory->getRelativePath($path) . '/'; } return $this->_currentUrl; diff --git a/app/code/Magento/Cms/Model/Wysiwyg/Config.php b/app/code/Magento/Cms/Model/Wysiwyg/Config.php index b023234a70c33a81eff026d5b46208a6d4bb368e..2d4e04230c9dfdecf0473454cb7757f025c1d8e1 100644 --- a/app/code/Magento/Cms/Model/Wysiwyg/Config.php +++ b/app/code/Magento/Cms/Model/Wysiwyg/Config.php @@ -90,12 +90,12 @@ class Config extends \Magento\Object protected $_windowSize; /** - * @var \Magento\Backend\Model\Url + * @var \Magento\Backend\Model\UrlInterface */ protected $_backendUrl; /** - * @param \Magento\Backend\Model\Url $backendUrl + * @param \Magento\Backend\Model\UrlInterface $backendUrl * @param \Magento\Event\ManagerInterface $eventManager * @param \Magento\Cms\Helper\Data $cmsData * @param \Magento\AuthorizationInterface $authorization @@ -107,7 +107,7 @@ class Config extends \Magento\Object * @param array $data */ public function __construct( - \Magento\Backend\Model\Url $backendUrl, + \Magento\Backend\Model\UrlInterface $backendUrl, \Magento\Event\ManagerInterface $eventManager, \Magento\Cms\Helper\Data $cmsData, \Magento\AuthorizationInterface $authorization, diff --git a/app/code/Magento/Cms/Model/Wysiwyg/Images/Storage.php b/app/code/Magento/Cms/Model/Wysiwyg/Images/Storage.php index f8e67392d676910c2cb5019d16785c7a9b3cf2b7..26a90ca1136c23800444ccc32f58233ef83cc69a 100644 --- a/app/code/Magento/Cms/Model/Wysiwyg/Images/Storage.php +++ b/app/code/Magento/Cms/Model/Wysiwyg/Images/Storage.php @@ -96,7 +96,7 @@ class Storage extends \Magento\Object protected $_dirs; /** - * @var \Magento\Backend\Model\Url + * @var \Magento\Backend\Model\UrlInterface */ protected $_backendUrl; @@ -144,7 +144,7 @@ class Storage extends \Magento\Object * Construct * * @param \Magento\Backend\Model\Session $session - * @param \Magento\Backend\Model\Url $backendUrl + * @param \Magento\Backend\Model\UrlInterface $backendUrl * @param \Magento\Cms\Helper\Wysiwyg\Images $cmsWysiwygImages * @param \Magento\Core\Helper\File\Storage\Database $coreFileStorageDb * @param \Magento\App\Filesystem $filesystem @@ -164,7 +164,7 @@ class Storage extends \Magento\Object */ public function __construct( \Magento\Backend\Model\Session $session, - \Magento\Backend\Model\Url $backendUrl, + \Magento\Backend\Model\UrlInterface $backendUrl, \Magento\Cms\Helper\Wysiwyg\Images $cmsWysiwygImages, \Magento\Core\Helper\File\Storage\Database $coreFileStorageDb, \Magento\App\Filesystem $filesystem, diff --git a/app/code/Magento/Cms/etc/di.xml b/app/code/Magento/Cms/etc/di.xml index 67651d6802f43ab94a0bb4e331e7bf7de23a0fe6..ae12fb9bf390331bc3f770526051ee54589b6727 100644 --- a/app/code/Magento/Cms/etc/di.xml +++ b/app/code/Magento/Cms/etc/di.xml @@ -26,55 +26,61 @@ <config> <type name="Magento\Cms\Model\Wysiwyg\Config"> <param name="windowSize"> - <value> - <height type="int">600</height> - <width type="int">1000</width> - </value> + <array> + <item key="height"><value type="int">600</value></item> + <item key="width"><value type="int">1000</value></item> + </array> </param> </type> <type name="Magento\Cms\Model\Wysiwyg\Images\Storage"> <param name="resizeParameters"> - <value> - <height type="int">75</height> - <width type="int">100</width> - </value> + <array> + <item key="height"><value type="int">75</value></item> + <item key="width"><value type="int">100</value></item> + </array> </param> <param name="extensions"> - <value> - <allowed> - <jpg type="int">1</jpg> - <jpeg type="int">1</jpeg> - <png type="int">1</png> - <gif type="int">1</gif> - </allowed> - <image_allowed> - <jpg type="int">1</jpg> - <jpeg type="int">1</jpeg> - <png type="int">1</png> - <gif type="int">1</gif> - </image_allowed> - <media_allowed> - <flv type="int">1</flv> - <swf type="int">1</swf> - <avi type="int">1</avi> - <mov type="int">1</mov> - <rm type="int">1</rm> - <wmv type="int">1</wmv> - </media_allowed> - </value> + <array> + <item key="allowed"> + <array> + <item key="jpg"><value type="int">1</value></item> + <item key="jpeg"><value type="int">1</value></item> + <item key="png"><value type="int">1</value></item> + <item key="gif"><value type="int">1</value></item> + </array> + </item> + <item key="image_allowed"> + <array> + <item key="jpg"><value type="int">1</value></item> + <item key="jpeg"><value type="int">1</value></item> + <item key="png"><value type="int">1</value></item> + <item key="gif"><value type="int">1</value></item> + </array> + </item> + <item key="media_allowed"> + <array> + <item key="flv"><value type="int">1</value></item> + <item key="swf"><value type="int">1</value></item> + <item key="avi"><value type="int">1</value></item> + <item key="mov"><value type="int">1</value></item> + <item key="rm"><value type="int">1</value></item> + <item key="wmv"><value type="int">1</value></item> + </array> + </item> + </array> </param> <param name="dirs"> - <value> - <exclude /> - <include /> - </value> + <array> + <item key="exclude"><value/></item> + <item key="include"><value/></item> + </array> </param> </type> <type name="Magento\Module\Updater\SetupFactory"> <param name="resourceTypes"> - <value> - <cms_setup>Magento\Cms\Model\Resource\Setup</cms_setup> - </value> + <array> + <item key="cms_setup"><value>Magento\Cms\Model\Resource\Setup</value></item> + </array> </param> </type> </config> diff --git a/app/code/Magento/Cms/etc/frontend/di.xml b/app/code/Magento/Cms/etc/frontend/di.xml index 7c27aa5f50ec871e43b7d67580f78bbf44c7e1c9..f361f75775f3e33029b5d566abe45fe65913a14f 100644 --- a/app/code/Magento/Cms/etc/frontend/di.xml +++ b/app/code/Magento/Cms/etc/frontend/di.xml @@ -26,13 +26,15 @@ <config> <type name="Magento\App\RouterList"> <param name="routerList"> - <value> - <cms> - <instance>Magento\Cms\Controller\Router</instance> - <disable type="bool">false</disable> - <sortOrder>60</sortOrder> - </cms> - </value> + <array> + <item key="cms"> + <array> + <item key="instance"><value>Magento\Cms\Controller\Router</value></item> + <item key="disable"><value type="bool">false</value></item> + <item key="sortOrder"><value>60</value></item> + </array> + </item> + </array> </param> </type> </config> \ No newline at end of file diff --git a/app/code/Magento/Connect/Block/Adminhtml/Extension/Custom/Edit/Tab/Grid.php b/app/code/Magento/Connect/Block/Adminhtml/Extension/Custom/Edit/Tab/Grid.php index 8d196edc9bb68ecf4c2bb985577419b77a337356..6164f6121fc4a641960c4dcf7cf79742d3ed8412 100644 --- a/app/code/Magento/Connect/Block/Adminhtml/Extension/Custom/Edit/Tab/Grid.php +++ b/app/code/Magento/Connect/Block/Adminhtml/Extension/Custom/Edit/Tab/Grid.php @@ -44,20 +44,18 @@ class Grid extends \Magento\Backend\Block\Widget\Grid\Extended /** * @param \Magento\Backend\Block\Template\Context $context - * @param \Magento\Core\Model\Url $urlModel * @param \Magento\Backend\Helper\Data $backendHelper * @param \Magento\Connect\Model\Extension\CollectionFactory $collectionFactory * @param array $data */ public function __construct( \Magento\Backend\Block\Template\Context $context, - \Magento\Core\Model\Url $urlModel, \Magento\Backend\Helper\Data $backendHelper, \Magento\Connect\Model\Extension\CollectionFactory $collectionFactory, array $data = array() ) { $this->_collectionFactory = $collectionFactory; - parent::__construct($context, $urlModel, $backendHelper, $data); + parent::__construct($context, $backendHelper, $data); } /** diff --git a/app/code/Magento/Contacts/Controller/Index.php b/app/code/Magento/Contacts/Controller/Index.php index 295af1086e55a0732312aac8b93403895b3e628b..e3fb5dc36f397515375bc3843555af110944efb9 100644 --- a/app/code/Magento/Contacts/Controller/Index.php +++ b/app/code/Magento/Contacts/Controller/Index.php @@ -65,7 +65,7 @@ class Index extends \Magento\App\Action\Action { $this->_view->loadLayout(); $this->_view->getLayout()->getBlock('contactForm') - ->setFormAction($this->_objectManager->create('Magento\Core\Model\Url')->getUrl('*/*/post')); + ->setFormAction($this->_objectManager->create('Magento\UrlInterface')->getUrl('*/*/post')); $this->_view->getLayout()->initMessages(); $this->_view->renderLayout(); diff --git a/app/code/Magento/Contacts/etc/frontend/di.xml b/app/code/Magento/Contacts/etc/frontend/di.xml index adc9e093fd51ec742a9db2478d302dc157f07478..4047b3ff462e881f2fb9842c607f06d595ec0b0b 100644 --- a/app/code/Magento/Contacts/etc/frontend/di.xml +++ b/app/code/Magento/Contacts/etc/frontend/di.xml @@ -26,9 +26,9 @@ <config> <type name="Magento\Core\Model\Url\SecurityInfo"> <param name="secureUrlList"> - <value> - <contacts>/contacts/</contacts> - </value> + <array> + <item key="contacts"><value>/contacts/</value></item> + </array> </param> </type> </config> diff --git a/app/code/Magento/Core/App/Action/Plugin/Install.php b/app/code/Magento/Core/App/Action/Plugin/Install.php index 1543e6e1cc8b29a1f6cb4774f01b75539233bf6b..7b6f5c5de7d849a5d113615d8a64c705d1143c0d 100644 --- a/app/code/Magento/Core/App/Action/Plugin/Install.php +++ b/app/code/Magento/Core/App/Action/Plugin/Install.php @@ -39,7 +39,7 @@ class Install protected $_response; /** - * @var \Magento\Core\Model\Url + * @var \Magento\UrlInterface */ protected $_url; @@ -51,13 +51,13 @@ class Install /** * @param \Magento\App\State $appState * @param \Magento\App\ResponseInterface $response - * @param \Magento\Core\Model\Url $url + * @param \Magento\UrlInterface $url * @param \Magento\App\ActionFlag $actionFlag */ public function __construct( \Magento\App\State $appState, \Magento\App\ResponseInterface $response, - \Magento\Core\Model\Url $url, + \Magento\UrlInterface $url, \Magento\App\ActionFlag $actionFlag ) { $this->_appState = $appState; diff --git a/app/code/Magento/Core/App/Action/Plugin/LastUrl.php b/app/code/Magento/Core/App/Action/Plugin/LastUrl.php index b841b3306ac086519a67f5e78ffc671453140e33..c00533cb5477b5ccfa892e5b6da0ad02ea90fa39 100644 --- a/app/code/Magento/Core/App/Action/Plugin/LastUrl.php +++ b/app/code/Magento/Core/App/Action/Plugin/LastUrl.php @@ -40,7 +40,7 @@ class LastUrl protected $_session; /** - * @var \Magento\Core\Model\Url + * @var \Magento\UrlInterface */ protected $_url; @@ -53,9 +53,9 @@ class LastUrl /** * @param \Magento\Core\Model\Session $session - * @param \Magento\Core\Model\Url $url + * @param \Magento\UrlInterface $url */ - public function __construct(\Magento\Core\Model\Session $session, \Magento\Core\Model\Url $url) + public function __construct(\Magento\Core\Model\Session $session, \Magento\UrlInterface $url) { $this->_session = $session; $this->_url = $url; diff --git a/app/code/Magento/Core/App/Action/Plugin/Session.php b/app/code/Magento/Core/App/Action/Plugin/Session.php index 62db5b00fb73ef0e9cbbb7a3c163a6587fdb9095..e234583655f1f2d4d577d6321b911bd6a120b49c 100644 --- a/app/code/Magento/Core/App/Action/Plugin/Session.php +++ b/app/code/Magento/Core/App/Action/Plugin/Session.php @@ -47,7 +47,7 @@ class Session protected $_cookieCheckActions; /** - * @var \Magento\Core\Model\Url + * @var \Magento\UrlInterface */ protected $_url; @@ -76,7 +76,7 @@ class Session * @param \Magento\App\ResponseInterface $response * @param \Magento\Core\Model\Session $session * @param \Magento\Stdlib\Cookie $cookie - * @param \Magento\Core\Model\Url $url + * @param \Magento\UrlInterface $url * @param \Magento\Core\Model\Store\Config $storeConfig * @param \Magento\Session\SidResolverInterface $sidResolver * @param string $sessionNamespace @@ -87,7 +87,7 @@ class Session \Magento\App\ResponseInterface $response, \Magento\Core\Model\Session $session, \Magento\Stdlib\Cookie $cookie, - \Magento\Core\Model\Url $url, + \Magento\UrlInterface $url, \Magento\Core\Model\Store\Config $storeConfig, \Magento\Session\SidResolverInterface $sidResolver, $sessionNamespace = '', diff --git a/app/code/Magento/Core/App/FrontController/Plugin/RequestPreprocessor.php b/app/code/Magento/Core/App/FrontController/Plugin/RequestPreprocessor.php index 47a9c24e59cffa0a703b19f89d5f91f08a2f51d7..8ac6239e9a46924130543c05c8abf6ab5b98cb57 100644 --- a/app/code/Magento/Core/App/FrontController/Plugin/RequestPreprocessor.php +++ b/app/code/Magento/Core/App/FrontController/Plugin/RequestPreprocessor.php @@ -36,7 +36,7 @@ class RequestPreprocessor protected $_responseFactory; /** - * @var \Magento\Core\Model\Url + * @var \Magento\UrlInterface */ protected $_url; @@ -53,14 +53,14 @@ class RequestPreprocessor /** * @param \Magento\Core\Model\StoreManagerInterface $storeManager * @param \Magento\App\State $appState - * @param \Magento\Core\Model\Url $url + * @param \Magento\UrlInterface $url * @param \Magento\Core\Model\Store\Config $storeConfig * @param \Magento\App\ResponseFactory $responseFactory */ public function __construct( \Magento\Core\Model\StoreManagerInterface $storeManager, \Magento\App\State $appState, - \Magento\Core\Model\Url $url, + \Magento\UrlInterface $url, \Magento\Core\Model\Store\Config $storeConfig, \Magento\App\ResponseFactory $responseFactory ) { @@ -84,7 +84,7 @@ class RequestPreprocessor $request = $arguments[0]; if ($this->_appState->isInstalled() && !$request->isPost() && $this->_isBaseUrlCheckEnabled()) { $baseUrl = $this->_storeManager->getStore()->getBaseUrl( - \Magento\Core\Model\Store::URL_TYPE_WEB, + \Magento\UrlInterface::URL_TYPE_WEB, $this->_storeManager->getStore()->isCurrentlySecure() ); if ($baseUrl) { diff --git a/app/code/Magento/Core/App/Media.php b/app/code/Magento/Core/App/Media.php index ca7b14d16c0eab89e49902e3a0ce3ce9581f3de6..53d1958344aeb5bc837a931eda8fad1ff61d8bf0 100644 --- a/app/code/Magento/Core/App/Media.php +++ b/app/code/Magento/Core/App/Media.php @@ -26,12 +26,12 @@ namespace Magento\Core\App; use Magento\App\State, - Magento\AppInterface, + Magento\LauncherInterface, Magento\ObjectManager, Magento\Core\Model\File\Storage\Request, Magento\Core\Model\File\Storage\Response; -class Media implements AppInterface +class Media implements LauncherInterface { /** * @var \Magento\App\State @@ -140,7 +140,7 @@ class Media implements AppInterface * * @return \Magento\App\ResponseInterface */ - public function execute() + public function launch() { try { if (!$this->_applicationState->isInstalled()) { diff --git a/app/code/Magento/Core/App/Request/RewriteService.php b/app/code/Magento/Core/App/Request/RewriteService.php index 5706ad56ce3e751a8164e805f6b6ddf0c57f5ee4..2f8d98d36dac4b2ce81fd9b8ed1a90ef2486a3c0 100644 --- a/app/code/Magento/Core/App/Request/RewriteService.php +++ b/app/code/Magento/Core/App/Request/RewriteService.php @@ -31,7 +31,7 @@ class RewriteService protected $_rewriteFactory; /** - * @var \Magento\Core\Model\Config + * @var \Magento\App\ConfigInterface */ protected $_config; @@ -43,7 +43,7 @@ class RewriteService public function __construct( \Magento\App\RouterList $routerList, \Magento\Core\Model\Url\RewriteFactory $rewriteFactory, - \Magento\Core\Model\Config $config + \Magento\App\ConfigInterface $config ) { $this->_rewriteFactory = $rewriteFactory; $this->_config = $config; diff --git a/app/code/Magento/Core/App/Response/Redirect.php b/app/code/Magento/Core/App/Response/Redirect.php index 14dae4a9478cbd584e26d81634b185f983abcf3e..ea4d99d313231be5005652764cdd773f9fcfb43c 100644 --- a/app/code/Magento/Core/App/Response/Redirect.php +++ b/app/code/Magento/Core/App/Response/Redirect.php @@ -58,7 +58,7 @@ class Redirect implements \Magento\App\Response\RedirectInterface protected $_canUseSessionIdInParam; /** - * @var \Magento\Core\Model\Url + * @var \Magento\UrlInterface */ protected $_urlBuilder; @@ -68,7 +68,7 @@ class Redirect implements \Magento\App\Response\RedirectInterface * @param \Magento\Encryption\UrlCoder $urlCoder * @param \Magento\Session\SessionManagerInterface $session * @param \Magento\Session\SidResolverInterface $sidResolver - * @param \Magento\Core\Model\Url $urlBuilder + * @param \Magento\UrlInterface $urlBuilder * @param bool $canUseSessionIdInParam */ public function __construct( @@ -77,7 +77,7 @@ class Redirect implements \Magento\App\Response\RedirectInterface \Magento\Encryption\UrlCoder $urlCoder, \Magento\Session\SessionManagerInterface $session, \Magento\Session\SidResolverInterface $sidResolver, - \Magento\Core\Model\Url $urlBuilder, + \Magento\UrlInterface $urlBuilder, $canUseSessionIdInParam = true ) { $this->_canUseSessionIdInParam = $canUseSessionIdInParam; @@ -209,7 +209,7 @@ class Redirect implements \Magento\App\Response\RedirectInterface $unsecure = (strpos($url, $this->_storeManager->getStore()->getBaseUrl()) === 0); $secure = strpos( $url, - $this->_storeManager->getStore()->getBaseUrl(\Magento\Core\Model\Store::URL_TYPE_LINK, true) + $this->_storeManager->getStore()->getBaseUrl(\Magento\UrlInterface::URL_TYPE_LINK, true) ) === 0; return $unsecure || $secure; } diff --git a/app/code/Magento/Core/App/Router/Base.php b/app/code/Magento/Core/App/Router/Base.php index 30784a1c84a2bde4bd9ae99b795c07a65d0bc4c5..fc22783c3702f69b6239376f835cd0c6ae51558c 100644 --- a/app/code/Magento/Core/App/Router/Base.php +++ b/app/code/Magento/Core/App/Router/Base.php @@ -56,7 +56,7 @@ class Base extends \Magento\App\Router\AbstractRouter /** * Url security information. * - * @var \Magento\Core\Model\Url\SecurityInfoInterface + * @var \Magento\Url\SecurityInfoInterface */ protected $_urlSecurityInfo; @@ -67,13 +67,6 @@ class Base extends \Magento\App\Router\AbstractRouter */ protected $_storeConfig; - /** - * Core config - * - * @var \Magento\Core\Model\Config - */ - protected $_config = null; - /** * @var \Magento\UrlInterface */ @@ -108,7 +101,7 @@ class Base extends \Magento\App\Router\AbstractRouter * @param \Magento\Core\Model\Url|\Magento\UrlInterface $url * @param \Magento\Core\Model\StoreManagerInterface|\Magento\Core\Model\StoreManagerInterface $storeManager * @param \Magento\Core\Model\Store\Config $storeConfig - * @param \Magento\Core\Model\Url\SecurityInfoInterface $urlSecurityInfo + * @param \Magento\Url\SecurityInfoInterface $urlSecurityInfo * @param $routerId * @throws \InvalidArgumentException */ @@ -121,7 +114,7 @@ class Base extends \Magento\App\Router\AbstractRouter \Magento\UrlInterface $url, \Magento\Core\Model\StoreManagerInterface $storeManager, \Magento\Core\Model\Store\Config $storeConfig, - \Magento\Core\Model\Url\SecurityInfoInterface $urlSecurityInfo, + \Magento\Url\SecurityInfoInterface $urlSecurityInfo, $routerId ) { parent::__construct($actionFactory); @@ -188,7 +181,7 @@ class Base extends \Magento\App\Router\AbstractRouter $moduleFrontName = $param; } else { $moduleFrontName = $this->_defaultPath->getPart('module'); - $request->setAlias(\Magento\Core\Model\Url\Rewrite::REWRITE_REQUEST_PATH_ALIAS, ''); + $request->setAlias(\Magento\Url::REWRITE_REQUEST_PATH_ALIAS, ''); } if (!$moduleFrontName) { return null; @@ -212,7 +205,7 @@ class Base extends \Magento\App\Router\AbstractRouter } else { $controller = $this->_defaultPath->getPart('controller'); $request->setAlias( - \Magento\Core\Model\Url\Rewrite::REWRITE_REQUEST_PATH_ALIAS, + \Magento\Url::REWRITE_REQUEST_PATH_ALIAS, ltrim($request->getOriginalPathInfo(), '/') ); } @@ -412,7 +405,7 @@ class Base extends \Magento\App\Router\AbstractRouter */ protected function _getCurrentSecureUrl($request) { - $alias = $request->getAlias(\Magento\Core\Model\Url\Rewrite::REWRITE_REQUEST_PATH_ALIAS); + $alias = $request->getAlias(\Magento\Url::REWRITE_REQUEST_PATH_ALIAS); if ($alias) { return $this->_storeManager->getStore()->getBaseUrl('link', true) . ltrim($alias, '/'); } diff --git a/app/code/Magento/Core/App/Router/NoRouteHandler.php b/app/code/Magento/Core/App/Router/NoRouteHandler.php index 957be8213feca169a8ecf5e1bee9bab4a8cc5caf..e5b95a9a1aed25a2868f01f5832b73c3ad93b445 100644 --- a/app/code/Magento/Core/App/Router/NoRouteHandler.php +++ b/app/code/Magento/Core/App/Router/NoRouteHandler.php @@ -29,14 +29,14 @@ namespace Magento\Core\App\Router; class NoRouteHandler implements \Magento\App\Router\NoRouteHandlerInterface { /** - * @var \Magento\Core\Model\Config + * @var \Magento\App\ConfigInterface */ protected $_config; /** - * @param \Magento\Core\Model\Config $config + * @param \Magento\App\ConfigInterface $config */ - public function __construct(\Magento\Core\Model\Config $config) + public function __construct(\Magento\App\ConfigInterface $config) { $this->_config = $config; } diff --git a/app/code/Magento/Core/Helper/Data.php b/app/code/Magento/Core/Helper/Data.php index af408e81b266691da4bf090a6f00963661040040..b4ed7ae65a05f6ab90bbbbd4d8921fd6013c8f78 100644 --- a/app/code/Magento/Core/Helper/Data.php +++ b/app/code/Magento/Core/Helper/Data.php @@ -133,7 +133,7 @@ class Data extends \Magento\App\Helper\AbstractHelper { try { if (!($store instanceof \Magento\Core\Model\Store)) { - $store = $this->_app->getStore($store); + $store = $this->_storeManager->getStore($store); } $value = $store->convertPrice($value, $format, $includeContainer); diff --git a/app/code/Magento/Core/Helper/File/Storage.php b/app/code/Magento/Core/Helper/File/Storage.php index 4cb961020464b9fbaaf869244cfcef9458738f83..8fab67b1abf48740025f12895efefb59452c589b 100644 --- a/app/code/Magento/Core/Helper/File/Storage.php +++ b/app/code/Magento/Core/Helper/File/Storage.php @@ -71,7 +71,7 @@ class Storage extends \Magento\App\Helper\AbstractHelper protected $_filesystemStorage; /** - * @var \Magento\Core\Model\ConfigInterface + * @var \Magento\App\ConfigInterface */ protected $config; @@ -80,14 +80,14 @@ class Storage extends \Magento\App\Helper\AbstractHelper * @param \Magento\Core\Helper\File\Storage\Database $coreFileStorageDb * @param \Magento\Core\Model\File\Storage $storage * @param \Magento\Core\Model\File\Storage\File $filesystemStorage - * @param \Magento\Core\Model\ConfigInterface $config + * @param \Magento\App\ConfigInterface $config */ public function __construct( \Magento\App\Helper\Context $context, \Magento\Core\Helper\File\Storage\Database $coreFileStorageDb, \Magento\Core\Model\File\Storage $storage, \Magento\Core\Model\File\Storage\File $filesystemStorage, - \Magento\Core\Model\ConfigInterface $config + \Magento\App\ConfigInterface $config ) { $this->_filesystemStorage = $filesystemStorage; $this->_coreFileStorageDb = $coreFileStorageDb; diff --git a/app/code/Magento/Core/Helper/File/Storage/Database.php b/app/code/Magento/Core/Helper/File/Storage/Database.php index f66897ce72e076bf2f1ec0f82dcbfeeed78ee9f1..78614853d751ba05f6e6bf5604f816adc2810d52 100644 --- a/app/code/Magento/Core/Helper/File/Storage/Database.php +++ b/app/code/Magento/Core/Helper/File/Storage/Database.php @@ -77,7 +77,7 @@ class Database extends \Magento\App\Helper\AbstractHelper protected $_fileStorage; /** - * @var \Magento\Core\Model\ConfigInterface + * @var \Magento\App\ConfigInterface */ protected $config; @@ -86,14 +86,14 @@ class Database extends \Magento\App\Helper\AbstractHelper * @param \Magento\Core\Model\File\Storage\DatabaseFactory $dbStorageFactory * @param \Magento\Core\Model\File\Storage\File $fileStorage * @param \Magento\App\Filesystem $filesystem - * @param \Magento\Core\Model\ConfigInterface $config + * @param \Magento\App\ConfigInterface $config */ public function __construct( \Magento\App\Helper\Context $context, \Magento\Core\Model\File\Storage\DatabaseFactory $dbStorageFactory, \Magento\Core\Model\File\Storage\File $fileStorage, \Magento\App\Filesystem $filesystem, - \Magento\Core\Model\ConfigInterface $config + \Magento\App\ConfigInterface $config ) { $this->_filesystem = $filesystem; $this->_dbStorageFactory = $dbStorageFactory; diff --git a/app/code/Magento/Core/Model/App.php b/app/code/Magento/Core/Model/App.php index a3c9e3174cf3316e802be4374e5bd70647a29ef7..dcac8a85672c32348701f558deda58d7056564ba 100644 --- a/app/code/Magento/Core/Model/App.php +++ b/app/code/Magento/Core/Model/App.php @@ -33,7 +33,7 @@ namespace Magento\Core\Model; use Magento\App\CacheInterface; -class App implements \Magento\Core\Model\AppInterface +class App implements \Magento\AppInterface { /**#@+ * Product edition labels @@ -53,7 +53,7 @@ class App implements \Magento\Core\Model\AppInterface /** * Magento version */ - const VERSION = '2.0.0.0-dev62'; + const VERSION = '2.0.0.0-dev63'; /** @@ -77,9 +77,9 @@ class App implements \Magento\Core\Model\AppInterface const PARAM_ALLOWED_MODULES = 'allowed_modules'; /** - * Caching params + * Caching params, that applied for all cache frontends regardless of type */ - const PARAM_CACHE_OPTIONS = 'cache_options'; + const PARAM_CACHE_FORCED_OPTIONS = 'cache_options'; /** * Application loaded areas array @@ -98,7 +98,7 @@ class App implements \Magento\Core\Model\AppInterface /** * Application configuration object * - * @var \Magento\Core\Model\Config + * @var \Magento\App\ConfigInterface */ protected $_config; @@ -137,21 +137,6 @@ class App implements \Magento\Core\Model\AppInterface */ protected $_response; - /** - * Use session in URL flag - * - * @see \Magento\Core\Model\Url - * @var bool - */ - protected $_useSessionInUrl = true; - - /** - * Use session var instead of SID for session in URL - * - * @var bool - */ - protected $_useSessionVar = false; - /** * Object manager * @@ -166,13 +151,6 @@ class App implements \Magento\Core\Model\AppInterface */ protected $_dbUpdater; - /** - * Store list manager - * - * @var \Magento\Core\Model\StoreManagerInterface - */ - protected $_storeManager; - /** * @var \Magento\App\State */ @@ -189,20 +167,18 @@ class App implements \Magento\Core\Model\AppInterface protected $_configScope; /** - * @param Config $config - * @param CacheInterface $cache + * @param \Magento\App\ConfigInterface $config + * @param \Magento\App\CacheInterface $cache * @param \Magento\ObjectManager $objectManager - * @param StoreManagerInterface $storeManager * @param \Magento\Event\ManagerInterface $eventManager * @param \Magento\App\State $appState * @param \Magento\Config\Scope $configScope * @param \Magento\App\FrontControllerInterface $frontController */ public function __construct( - \Magento\Core\Model\Config $config, + \Magento\App\ConfigInterface $config, \Magento\App\CacheInterface $cache, \Magento\ObjectManager $objectManager, - \Magento\Core\Model\StoreManagerInterface $storeManager, \Magento\Event\ManagerInterface $eventManager, \Magento\App\State $appState, \Magento\Config\Scope $configScope, @@ -211,7 +187,6 @@ class App implements \Magento\Core\Model\AppInterface $this->_config = $config; $this->_cache = $cache; $this->_objectManager = $objectManager; - $this->_storeManager = $storeManager; $this->_appState = $appState; $this->_eventManager = $eventManager; $this->_configScope = $configScope; @@ -328,7 +303,7 @@ class App implements \Magento\Core\Model\AppInterface /** * Retrieve configuration object * - * @return \Magento\Core\Model\Config + * @return \Magento\App\ConfigInterface */ public function getConfig() { @@ -484,50 +459,6 @@ class App implements \Magento\Core\Model\AppInterface return $this; } - /** - * Set use session var instead of SID for URL - * - * @param bool $var - * @return \Magento\Core\Model\App - */ - public function setUseSessionVar($var) - { - $this->_useSessionVar = (bool)$var; - return $this; - } - - /** - * Retrieve use flag session var instead of SID for URL - * - * @return bool - */ - public function getUseSessionVar() - { - return $this->_useSessionVar; - } - - /** - * Set Use session in URL flag - * - * @param bool $flag - * @return \Magento\Core\Model\App - */ - public function setUseSessionInUrl($flag = true) - { - $this->_useSessionInUrl = (bool)$flag; - return $this; - } - - /** - * Retrieve use session in URL flag - * - * @return bool - */ - public function getUseSessionInUrl() - { - return $this->_useSessionInUrl; - } - /** * Check if developer mode is enabled * @@ -538,222 +469,6 @@ class App implements \Magento\Core\Model\AppInterface return $this->_appState->getMode() == \Magento\App\State::MODE_DEVELOPER; } - /** - * Retrieve application store object without Store_Exception - * - * @param string|int|\Magento\Core\Model\Store $storeId - * @return \Magento\Core\Model\Store - * - * @deprecated use \Magento\Core\Model\StoreManagerInterface::getSafeStore() - */ - public function getSafeStore($storeId = null) - { - return $this->_storeManager->getSafeStore($storeId); - } - - /** - * Allow or disallow single store mode - * - * @param bool $value - * - * @deprecated use \Magento\Core\Model\StoreManagerInterface::setIsSingleStoreModeAllowed() - */ - public function setIsSingleStoreModeAllowed($value) - { - $this->_storeManager->setIsSingleStoreModeAllowed($value); - } - - /** - * Check if store has only one store view - * - * @return bool - * - * @deprecated use \Magento\Core\Model\StoreManagerInterface::hasSingleStore() - */ - public function hasSingleStore() - { - return $this->_storeManager->hasSingleStore(); - } - - /** - * Check if system is run in the single store mode - * - * @return bool - * - * @deprecated use \Magento\Core\Model\StoreManagerInterface::isSingleStoreMode() - */ - public function isSingleStoreMode() - { - return $this->_storeManager->isSingleStoreMode(); - } - - /** - * @throws \Magento\Core\Model\Store\Exception - * - * @deprecated use \Magento\Core\Model\StoreManagerInterface::throwStoreException() - */ - public function throwStoreException() - { - $this->_storeManager->throwStoreException(); - } - - /** - * Retrieve application store object - * - * @param null|string|bool|int|\Magento\Core\Model\Store $storeId - * @return \Magento\Core\Model\Store - * @throws \Magento\Core\Model\Store\Exception - * - * @deprecated use \Magento\Core\Model\StoreManagerInterface::getStore() - */ - public function getStore($storeId = null) - { - return $this->_storeManager->getStore($storeId); - } - - /** - * Retrieve stores array - * - * @param bool $withDefault - * @param bool $codeKey - * @return \Magento\Core\Model\Store[] - * - * @deprecated use \Magento\Core\Model\StoreManagerInterface::getStores() - */ - public function getStores($withDefault = false, $codeKey = false) - { - return $this->_storeManager->getStores($withDefault, $codeKey); - } - - /** - * Retrieve application website object - * - * @param null|bool|int|string|\Magento\Core\Model\Website $websiteId - * @return \Magento\Core\Model\Website - * @throws \Magento\Core\Exception - * - * @deprecated use \Magento\Core\Model\StoreManagerInterface::getWebsite() - */ - public function getWebsite($websiteId = null) - { - return $this->_storeManager->getWebsite($websiteId); - } - - /** - * Get loaded websites - * - * @param bool $withDefault - * @param bool|string $codeKey - * @return \Magento\Core\Model\Website[] - * - * @deprecated use \Magento\Core\Model\StoreManagerInterface::getWebsites() - */ - public function getWebsites($withDefault = false, $codeKey = false) - { - return $this->_storeManager->getWebsites($withDefault, $codeKey); - } - - /** - * Reinitialize store list - * - * @deprecated use \Magento\Core\Model\StoreManagerInterface::reinitStores() - */ - public function reinitStores() - { - $this->_storeManager->reinitStores(); - } - - /** - * Set current default store - * - * @param string $store - * - * @deprecated use \Magento\Core\Model\StoreManagerInterface::setCurrentStore() - */ - public function setCurrentStore($store) - { - $this->_storeManager->setCurrentStore($store); - } - - /** - * Get current store code - * - * @return string - * - * @deprecated use \Magento\Core\Model\StoreManagerInterface::getCurrentStore() - */ - public function getCurrentStore() - { - return $this->_storeManager->getCurrentStore(); - } - - - /** - * Retrieve default store for default group and website - * - * @return \Magento\Core\Model\Store - * - * @deprecated use \Magento\Core\Model\StoreManagerInterface::getDefaultStoreView() - */ - public function getDefaultStoreView() - { - return $this->_storeManager->getDefaultStoreView(); - } - - /** - * Retrieve application store group object - * - * @param null|\Magento\Core\Model\Store\Group|string $groupId - * @return \Magento\Core\Model\Store\Group - * @throws \Magento\Core\Exception - * - * @deprecated use \Magento\Core\Model\StoreManagerInterface::getGroup() - */ - public function getGroup($groupId = null) - { - return $this->_storeManager->getGroup($groupId); - } - - /** - * Prepare array of store groups - * can be filtered to contain default store group or not by $withDefault flag - * depending on flag $codeKey array keys can be group id or group code - * - * @param bool $withDefault - * @param bool $codeKey - * @return \Magento\Core\Model\Store\Group[] - * - * @deprecated use \Magento\Core\Model\StoreManagerInterface::getGroups() - */ - public function getGroups($withDefault = false, $codeKey = false) - { - return $this->_storeManager->getGroups($withDefault, $codeKey); - } - - /** - * Unset website by id from app cache - * - * @param null|bool|int|string|\Magento\Core\Model\Website $websiteId - * - * @deprecated use \Magento\Core\Model\StoreManagerInterface::clearWebsiteCache() - */ - public function clearWebsiteCache($websiteId = null) - { - $this->_storeManager->clearWebsiteCache($websiteId); - } - - /** - * Get either default or any store view - * - * @return \Magento\Core\Model\Store|null - * - * @deprecated use \Magento\Core\Model\StoreManagerInterface::getAnyStoreView() - */ - public function getAnyStoreView() - { - return $this->_storeManager->getAnyStoreView(); - } - /** * Get current Magento edition * @@ -775,7 +490,6 @@ class App implements \Magento\Core\Model\AppInterface $this->_currentEdition = $edition; } - /** * Gets the current Magento version string * @link http://www.magentocommerce.com/blog/new-community-edition-release-process/ @@ -804,7 +518,7 @@ class App implements \Magento\Core\Model\AppInterface 'revision' => '0', 'patch' => '0', 'stability' => 'dev', - 'number' => '62', + 'number' => '63', ); } } diff --git a/app/code/Magento/Core/Model/App/Area.php b/app/code/Magento/Core/Model/App/Area.php index 4cfde19f9d973e1249a833558a4d88097d22bd8f..f27ab68343562da92d11fcd418d93801df4dbc75 100644 --- a/app/code/Magento/Core/Model/App/Area.php +++ b/app/code/Magento/Core/Model/App/Area.php @@ -77,7 +77,7 @@ class Area /** * Application config * - * @var \Magento\Core\Model\Config + * @var \Magento\App\ConfigInterface */ protected $_config; @@ -122,7 +122,7 @@ class Area * @param \Magento\Logger $logger * @param \Magento\Event\ManagerInterface $eventManager * @param \Magento\Core\Model\Translate $translator - * @param \Magento\Core\Model\Config $config + * @param \Magento\App\ConfigInterface $config * @param \Magento\ObjectManager $objectManager * @param \Magento\App\ObjectManager\ConfigLoader $diConfigLoader * @param \Magento\Core\Model\Store\Config $coreStoreConfig @@ -134,7 +134,7 @@ class Area \Magento\Logger $logger, \Magento\Event\ManagerInterface $eventManager, \Magento\Core\Model\Translate $translator, - \Magento\Core\Model\Config $config, + \Magento\App\ConfigInterface $config, \Magento\ObjectManager $objectManager, \Magento\App\ObjectManager\ConfigLoader $diConfigLoader, \Magento\Core\Model\Store\Config $coreStoreConfig, diff --git a/app/code/Magento/Core/Model/AppInterface.php b/app/code/Magento/Core/Model/AppInterface.php deleted file mode 100644 index 79ff846d4f72c43bebee0f5f78b5b6fcd08e7309..0000000000000000000000000000000000000000 --- a/app/code/Magento/Core/Model/AppInterface.php +++ /dev/null @@ -1,256 +0,0 @@ -<?php -/** - * Application 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\Core\Model; - -interface AppInterface extends \Magento\Core\Model\StoreManagerInterface -{ - /** - * Default application locale - */ - const DISTRO_LOCALE_CODE = 'en_US'; - - /** - * Default store Id (for install) - */ - const DISTRO_STORE_ID = 1; - - /** - * Default store code (for install) - * - */ - const DISTRO_STORE_CODE = \Magento\Core\Model\Store::DEFAULT_CODE; - - /** - * Dependency injection configuration node name - */ - const CONFIGURATION_DI_NODE = 'di'; - - /** - * Throw an exception, if the application has not been installed yet - * - * @throws \Magento\Exception - */ - public function requireInstalledInstance(); - - /** - * Retrieve cookie object - * - * @return \Magento\Stdlib\Cookie - */ - public function getCookie(); - - /** - * Re-declare custom error handler - * - * @param string $handler - * @return \Magento\Core\Model\AppInterface - */ - public function setErrorHandler($handler); - - /** - * Loading part of area data - * - * @param string $area - * @param string $part - * @return \Magento\Core\Model\AppInterface - */ - public function loadAreaPart($area, $part); - - /** - * Retrieve application area - * - * @param string $code - * @return \Magento\Core\Model\App\Area - */ - public function getArea($code); - - /** - * Get distributive locale code - * - * @return string - */ - public function getDistroLocaleCode(); - - /** - * Retrieve application locale object - * - * @return \Magento\Core\Model\LocaleInterface - */ - public function getLocale(); - - /** - * Retrieve layout object - * - * @return \Magento\View\LayoutInterface - */ - public function getLayout(); - - /** - * Retrieve application base currency code - * - * @return string - */ - public function getBaseCurrencyCode(); - - /** - * Retrieve configuration object - * - * @return \Magento\Core\Model\Config - */ - public function getConfig(); - - /** - * Retrieve front controller object - * - * @return \Magento\App\FrontController - */ - public function getFrontController(); - - /** - * Get core cache model - * - * @return \Magento\App\CacheInterface - */ - public function getCacheInstance(); - - - /** - * Retrieve cache object - * - * @return \Zend_Cache_Core - */ - public function getCache(); - - /** - * Loading cache data - * - * @param string $cacheId - * @return mixed - */ - public function loadCache($cacheId); - - /** - * Saving cache data - * - * @param mixed $data - * @param string $cacheId - * @param array $tags - * @param bool $lifeTime - * @return \Magento\Core\Model\AppInterface - */ - public function saveCache($data, $cacheId, $tags = array(), $lifeTime = false); - - /** - * Remove cache - * - * @param string $cacheId - * @return \Magento\Core\Model\AppInterface - */ - public function removeCache($cacheId); - - /** - * Cleaning cache - * - * @param array $tags - * @return \Magento\Core\Model\AppInterface - */ - public function cleanCache($tags = array()); - - /** - * Deletes all session files - * - * @return \Magento\Core\Model\AppInterface - */ - public function cleanAllSessions(); - - /** - * Retrieve request object - * - * @return \Magento\App\RequestInterface - */ - public function getRequest(); - - /** - * Request setter - * - * @param \Magento\App\RequestInterface $request - * @return \Magento\Core\Model\AppInterface - */ - public function setRequest(\Magento\App\RequestInterface $request); - - /** - * Retrieve response object - * - * @return \Magento\App\ResponseInterface - */ - public function getResponse(); - - /** - * Response setter - * - * @param \Magento\App\ResponseInterface $response - * @return \Magento\Core\Model\AppInterface - */ - public function setResponse(\Magento\App\ResponseInterface $response); - - /** - * Set use session var instead of SID for URL - * - * @param bool $var - * @return \Magento\Core\Model\AppInterface - */ - public function setUseSessionVar($var); - - /** - * Retrieve use flag session var instead of SID for URL - * - * @return bool - */ - public function getUseSessionVar(); - - /** - * Set Use session in URL flag - * - * @param bool $flag - * @return \Magento\Core\Model\AppInterface - */ - public function setUseSessionInUrl($flag = true); - - /** - * Retrieve use session in URL flag - * - * @return bool - */ - public function getUseSessionInUrl(); - - /** - * Check if developer mode is enabled. - * - * @return bool - */ - public function isDeveloperMode(); -} diff --git a/app/code/Magento/Core/Model/Asset/Config.php b/app/code/Magento/Core/Model/Asset/Config.php index c0d0ac71ac8f18ac27f8869359e3154e757ec49c..2ef39e82bcb85e01ac9dba88a0e176030d2c00b2 100644 --- a/app/code/Magento/Core/Model/Asset/Config.php +++ b/app/code/Magento/Core/Model/Asset/Config.php @@ -52,7 +52,7 @@ class Config implements \Magento\View\Asset\ConfigInterface const XML_PATH_MINIFICATION_ADAPTER = 'dev/%s/minify_adapter'; /** - * @var \Magento\Core\Model\Config + * @var \Magento\Core\Model\Store\ConfigInterface */ protected $storeConfig; diff --git a/app/code/Magento/Core/Model/Config.php b/app/code/Magento/Core/Model/Config.php index 5f3635b2525cbb33b96e53c33297df30a33a95cb..ebcd853626069e36b0717c3f79154d4b7cd55fe6 100644 --- a/app/code/Magento/Core/Model/Config.php +++ b/app/code/Magento/Core/Model/Config.php @@ -26,28 +26,13 @@ namespace Magento\Core\Model; -class Config implements \Magento\Core\Model\ConfigInterface +class Config implements \Magento\App\ConfigInterface { /** * Config cache tag */ const CACHE_TAG = 'CONFIG'; - /** - * Default configuration scope - */ - const SCOPE_DEFAULT = 'default'; - - /** - * Stores configuration scope - */ - const SCOPE_STORES = 'stores'; - - /** - * Websites configuration scope - */ - const SCOPE_WEBSITES = 'websites'; - /** * @var \Magento\Core\Model\Config\SectionPool */ @@ -88,12 +73,15 @@ class Config implements \Magento\Core\Model\ConfigInterface } /** - * Reinitialize configuration + * Retrieve config flag * - * @return \Magento\Core\Model\Config + * @param string $path + * @param string $scope + * @param null|string $scopeCode + * @return bool */ - public function reinit() + public function isSetFlag($path, $scope = 'default', $scopeCode = null) { - $this->_sectionPool->clean(); + return (bool)$this->getValue($path, $scope, $scopeCode); } } diff --git a/app/code/Magento/Core/Model/Config/Cache.php b/app/code/Magento/Core/Model/Config/Cache.php index d194f8fff27f80da9a3f76659972fe2e84db5995..e93addc966aa3f46cb0ce00e7d3f0dcbd2c35eea 100644 --- a/app/code/Magento/Core/Model/Config/Cache.php +++ b/app/code/Magento/Core/Model/Config/Cache.php @@ -92,7 +92,7 @@ class Cache } /** - * @return \Magento\Core\Model\ConfigInterface|bool + * @return \Magento\App\ConfigInterface|bool */ public function load() { diff --git a/app/code/Magento/Core/Model/Config/FileResolver.php b/app/code/Magento/Core/Model/Config/FileResolver.php index 5b9e320adb6dc2cbd70a20eda2c615b0058cd1c4..f2568be5d4186603b0c57cb9e8db812f88351679 100644 --- a/app/code/Magento/Core/Model/Config/FileResolver.php +++ b/app/code/Magento/Core/Model/Config/FileResolver.php @@ -35,6 +35,8 @@ class FileResolver implements \Magento\Config\FileResolverInterface protected $_moduleReader; /** + * File iterator factory + * * @var \Magento\Config\FileIteratorFactory */ protected $iteratorFactory; diff --git a/app/code/Magento/Core/Model/Config/Value.php b/app/code/Magento/Core/Model/Config/Value.php index a0c247c7457ecf972d671bdfcd000dfb955a8d24..064a131e5954764fa339a515c5ff0c19d173a19b 100644 --- a/app/code/Magento/Core/Model/Config/Value.php +++ b/app/code/Magento/Core/Model/Config/Value.php @@ -32,19 +32,18 @@ namespace Magento\Core\Model\Config; * @method \Magento\Core\Model\Resource\Config\Data _getResource() * @method \Magento\Core\Model\Resource\Config\Data getResource() * @method string getScope() - * @method \Magento\Core\Model\Config\Value setScope(string $value) + * @method \Magento\App\Config\ValueInterface setScope(string $value) * @method int getScopeId() - * @method \Magento\Core\Model\Config\Value setScopeId(int $value) + * @method \Magento\App\Config\ValueInterface setScopeId(int $value) * @method string getPath() - * @method \Magento\Core\Model\Config\Value setPath(string $value) + * @method \Magento\App\Config\ValueInterface setPath(string $value) * @method string getValue() - * @method \Magento\Core\Model\Config\Value setValue(string $value) + * @method \Magento\App\Config\ValueInterface setValue(string $value) * * @SuppressWarnings(PHPMD.NumberOfChildren) */ -class Value extends \Magento\Core\Model\AbstractModel +class Value extends \Magento\Core\Model\AbstractModel implements \Magento\App\Config\ValueInterface { - const ENTITY = 'core_config_data'; /** * Prefix of model events names * @@ -67,7 +66,7 @@ class Value extends \Magento\Core\Model\AbstractModel protected $_storeManager; /** - * @var \Magento\Core\Model\Config + * @var \Magento\App\ConfigInterface */ protected $_config; @@ -75,7 +74,7 @@ class Value extends \Magento\Core\Model\AbstractModel * @param \Magento\Core\Model\Context $context * @param \Magento\Core\Model\Registry $registry * @param \Magento\Core\Model\StoreManagerInterface $storeManager - * @param \Magento\Core\Model\ConfigInterface $config + * @param \Magento\App\ConfigInterface $config * @param \Magento\Core\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data @@ -84,7 +83,7 @@ class Value extends \Magento\Core\Model\AbstractModel \Magento\Core\Model\Context $context, \Magento\Core\Model\Registry $registry, \Magento\Core\Model\StoreManagerInterface $storeManager, - \Magento\Core\Model\ConfigInterface $config, + \Magento\App\ConfigInterface $config, \Magento\Core\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() diff --git a/app/code/Magento/Core/Model/Config/ValueFactory.php b/app/code/Magento/Core/Model/Config/ValueFactory.php new file mode 100644 index 0000000000000000000000000000000000000000..9ea40ed8826c20fc43781d3849fbfeef59e16a82 --- /dev/null +++ b/app/code/Magento/Core/Model/Config/ValueFactory.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\Core\Model\Config; + +/** + * Factory class + */ +class ValueFactory +{ + /** + * Object Manager instance + * + * @var \Magento\ObjectManager + */ + protected $_objectManager = null; + + /** + * Instance name to create + * + * @var string + */ + protected $_instanceName = null; + + /** + * Factory constructor + * + * @param \Magento\ObjectManager $objectManager + * @param string $instanceName + */ + public function __construct( + \Magento\ObjectManager $objectManager, + $instanceName = 'Magento\App\Config\ValueInterface' + ) { + $this->_objectManager = $objectManager; + $this->_instanceName = $instanceName; + } + + /** + * Create class instance with specified parameters + * + * @param array $data + * @return \Magento\App\Config\ValueInterface + * @throws \InvalidArgumentException + */ + public function create(array $data = array()) + { + $model = $this->_objectManager->create($this->_instanceName, $data); + if (!$model instanceof \Magento\App\Config\ValueInterface) { + throw new \InvalidArgumentException('Invalid config field model: ' . $this->_instanceName); + } + return $model; + } +} diff --git a/app/code/Magento/Core/Model/Design/Backend/Exceptions.php b/app/code/Magento/Core/Model/Design/Backend/Exceptions.php index 7259eeb041a6e244ffe94cd435bdcbb6a500b9bb..492d8d3ea714a4d13e8f69630e2e3c6e37f109a0 100644 --- a/app/code/Magento/Core/Model/Design/Backend/Exceptions.php +++ b/app/code/Magento/Core/Model/Design/Backend/Exceptions.php @@ -39,7 +39,7 @@ class Exceptions extends \Magento\Backend\Model\Config\Backend\Serialized\ArrayS * @param \Magento\Core\Model\Context $context * @param \Magento\Core\Model\Registry $registry * @param \Magento\Core\Model\StoreManagerInterface $storeManager - * @param \Magento\Core\Model\Config $config + * @param \Magento\App\ConfigInterface $config * @param \Magento\View\DesignInterface $design * @param \Magento\Core\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection @@ -49,7 +49,7 @@ class Exceptions extends \Magento\Backend\Model\Config\Backend\Serialized\ArrayS \Magento\Core\Model\Context $context, \Magento\Core\Model\Registry $registry, \Magento\Core\Model\StoreManagerInterface $storeManager, - \Magento\Core\Model\Config $config, + \Magento\App\ConfigInterface $config, \Magento\View\DesignInterface $design, \Magento\Core\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, diff --git a/app/code/Magento/Core/Model/Design/Backend/Theme.php b/app/code/Magento/Core/Model/Design/Backend/Theme.php index c45ef0e59665b37fec83abcf537d55177942b048..f94fe88bc44c044d3ca25ef6859fcd96fab939af 100644 --- a/app/code/Magento/Core/Model/Design/Backend/Theme.php +++ b/app/code/Magento/Core/Model/Design/Backend/Theme.php @@ -39,7 +39,7 @@ class Theme extends \Magento\Core\Model\Config\Value * @param \Magento\Core\Model\Context $context * @param \Magento\Core\Model\Registry $registry * @param \Magento\Core\Model\StoreManagerInterface $storeManager - * @param \Magento\Core\Model\Config $config + * @param \Magento\App\ConfigInterface $config * @param \Magento\View\DesignInterface $design * @param \Magento\Core\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection @@ -49,7 +49,7 @@ class Theme extends \Magento\Core\Model\Config\Value \Magento\Core\Model\Context $context, \Magento\Core\Model\Registry $registry, \Magento\Core\Model\StoreManagerInterface $storeManager, - \Magento\Core\Model\Config $config, + \Magento\App\ConfigInterface $config, \Magento\View\DesignInterface $design, \Magento\Core\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, diff --git a/app/code/Magento/Core/Model/File/Storage.php b/app/code/Magento/Core/Model/File/Storage.php index dc48841f1824355b53262ab2505b379db2a4c709..d0bed5f4155051bdc0064c2bcac7b1020e63140b 100644 --- a/app/code/Magento/Core/Model/File/Storage.php +++ b/app/code/Magento/Core/Model/File/Storage.php @@ -70,7 +70,7 @@ class Storage extends \Magento\Core\Model\AbstractModel protected $_coreStoreConfig; /** - * @var \Magento\Core\Model\Config + * @var \Magento\App\ConfigInterface */ protected $_coreConfig; @@ -105,7 +105,7 @@ class Storage extends \Magento\Core\Model\AbstractModel * @param \Magento\Core\Model\Registry $registry * @param \Magento\Core\Helper\File\Storage $coreFileStorage * @param \Magento\Core\Model\Store\Config $coreStoreConfig - * @param \Magento\Core\Model\Config $coreConfig + * @param \Magento\App\ConfigInterface $coreConfig * @param \Magento\Core\Model\File\Storage\Flag $fileFlag * @param \Magento\Core\Model\File\Storage\FileFactory $fileFactory * @param \Magento\Core\Model\File\Storage\DatabaseFactory $databaseFactory @@ -119,7 +119,7 @@ class Storage extends \Magento\Core\Model\AbstractModel \Magento\Core\Model\Registry $registry, \Magento\Core\Helper\File\Storage $coreFileStorage, \Magento\Core\Model\Store\Config $coreStoreConfig, - \Magento\Core\Model\Config $coreConfig, + \Magento\App\ConfigInterface $coreConfig, \Magento\Core\Model\File\Storage\Flag $fileFlag, \Magento\Core\Model\File\Storage\FileFactory $fileFactory, \Magento\Core\Model\File\Storage\DatabaseFactory $databaseFactory, diff --git a/app/code/Magento/Core/Model/Image/Adapter/Config.php b/app/code/Magento/Core/Model/Image/Adapter/Config.php index c3cf2c90ce5d92e1b105127a95a04375d151011b..b19d4d696a096f14e9f370d1f13b5d61e1a44133 100644 --- a/app/code/Magento/Core/Model/Image/Adapter/Config.php +++ b/app/code/Magento/Core/Model/Image/Adapter/Config.php @@ -29,14 +29,14 @@ class Config implements \Magento\Image\Adapter\ConfigInterface const XML_PATH_IMAGE_ADAPTERS = 'dev/image/adapters'; /** - * @var \Magento\Core\Model\ConfigInterface + * @var \Magento\App\ConfigInterface */ protected $config; /** - * @param \Magento\Core\Model\ConfigInterface $config + * @param \Magento\App\ConfigInterface $config */ - public function __construct(\Magento\Core\Model\ConfigInterface $config) + public function __construct(\Magento\App\ConfigInterface $config) { $this->config = $config; } diff --git a/app/code/Magento/Core/Model/Layout.php b/app/code/Magento/Core/Model/Layout.php index 2245462cc8660e38ec059d52186becebc890ca9b..92a3f5559376ec8058f8ebf02eb8fe251230c0f6 100644 --- a/app/code/Magento/Core/Model/Layout.php +++ b/app/code/Magento/Core/Model/Layout.php @@ -1569,7 +1569,7 @@ class Layout extends \Magento\Simplexml\Config implements \Magento\View\LayoutIn ->setTemplate($options['template']) ->assign($data); - echo $block->toHtml(); + echo $this->_renderBlock($block->getNameInLayout()); } } @@ -1613,14 +1613,4 @@ class Layout extends \Magento\Simplexml\Config implements \Magento\View\LayoutIn { return !(boolean)count($this->_xml->xpath('//' . Element::TYPE_BLOCK . '[@cacheable="false"]')); } - - /** - * Check is current layout private - * - * @return bool - */ - public function isPrivate() - { - return !(boolean)count($this->_xml->xpath('//' . Element::TYPE_BLOCK . '[@cache-control="private"]')); - } } diff --git a/app/code/Magento/Core/Model/Layout/Merge.php b/app/code/Magento/Core/Model/Layout/Merge.php index 71fa12c710282a2adefde4a12b5740293c6e3cc6..8a2288d086ff836c8c6b0a073e8b6f7d6a6a93f9 100644 --- a/app/code/Magento/Core/Model/Layout/Merge.php +++ b/app/code/Magento/Core/Model/Layout/Merge.php @@ -494,7 +494,7 @@ class Merge implements \Magento\View\Layout\ProcessorInterface if ($this->_subst === null) { $placeholders = array( 'baseUrl' => $this->_store->getBaseUrl(), - 'baseSecureUrl' => $this->_store->getBaseUrl(\Magento\Core\Model\Store::URL_TYPE_LINK, true), + 'baseSecureUrl' => $this->_store->getBaseUrl(\Magento\UrlInterface::URL_TYPE_LINK, true), ); $this->_subst = array(); foreach ($placeholders as $key => $value) { diff --git a/app/code/Magento/Core/Model/Module/Output/Config.php b/app/code/Magento/Core/Model/Module/Output/Config.php index ff07c360caa285ec4c963b81b35ee27c0018761e..84e7aec65593fa66b754ccf2a6b6922fd7eed653 100644 --- a/app/code/Magento/Core/Model/Module/Output/Config.php +++ b/app/code/Magento/Core/Model/Module/Output/Config.php @@ -51,13 +51,13 @@ class Config implements \Magento\Module\Output\ConfigInterface */ public function isEnabled($moduleName) { - return $this->getFlag(sprintf(self::XML_PATH_MODULE_OUTPUT_STATUS, $moduleName)); + return $this->isSetFlag(sprintf(self::XML_PATH_MODULE_OUTPUT_STATUS, $moduleName)); } /** * @inheritdoc */ - public function getFlag($path) + public function isSetFlag($path) { return $this->_storeConfig->getConfigFlag($path); } diff --git a/app/code/Magento/Core/Model/Mview/View/State.php b/app/code/Magento/Core/Model/Mview/View/State.php new file mode 100644 index 0000000000000000000000000000000000000000..30fdf76b67d403c10f42493c05920b1f2272620b --- /dev/null +++ b/app/code/Magento/Core/Model/Mview/View/State.php @@ -0,0 +1,191 @@ +<?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\Mview\View; + +/** + * @method \Magento\Indexer\Model\Indexer\State setViewId(string $value) + */ +class State extends \Magento\Core\Model\AbstractModel implements \Magento\Mview\View\StateInterface +{ + /** + * Prefix of model events names + * + * @var string + */ + protected $_eventPrefix = 'mview_state'; + + /** + * Parameter name in event + * + * @var string + */ + protected $_eventObject = 'mview_state'; + + /** + * @param \Magento\Core\Model\Context $context + * @param \Magento\Core\Model\Registry $registry + * @param \Magento\Core\Model\Resource\Mview\View\State $resource + * @param \Magento\Core\Model\Resource\Mview\View\State\Collection $resourceCollection + * @param array $data + */ + public function __construct( + \Magento\Core\Model\Context $context, + \Magento\Core\Model\Registry $registry, + \Magento\Core\Model\Resource\Mview\View\State $resource, + \Magento\Core\Model\Resource\Mview\View\State\Collection $resourceCollection, + array $data = array() + ) { + if (!isset($data['mode'])) { + $data['mode'] = self::MODE_DISABLED; + } + if (!isset($data['status'])) { + $data['status'] = self::STATUS_IDLE; + } + parent::__construct($context, $registry, $resource, $resourceCollection, $data); + } + + /** + * Fill object with state data by view ID + * + * @param string $viewId + * @return \Magento\Mview\View\StateInterface + */ + public function loadByView($viewId) + { + $this->load($viewId, 'view_id'); + if (!$this->getId()) { + $this->setViewId($viewId); + } + } + + /** + * Processing object before save data + * + * @return \Magento\Core\Model\Mview\View\State + */ + protected function _beforeSave() + { + $this->setUpdated(time()); + return parent::_beforeSave(); + } + + /** + * Get state view ID + * + * @return string + */ + public function getViewId() + { + return $this->getData('view_id'); + } + + /** + * Get state mode + * + * @return string + */ + public function getMode() + { + return $this->getData('mode'); + } + + /** + * Set state mode + * + * @param string $mode + * @return \Magento\Mview\View\StateInterface + */ + public function setMode($mode) + { + $this->setData('mode', $mode); + return $this; + } + + /** + * Get state status + * + * @return string + */ + public function getStatus() + { + return $this->getData('status'); + } + + /** + * Set state status + * + * @param string $status + * @return \Magento\Mview\View\StateInterface + */ + public function setStatus($status) + { + $this->setData('status', $status); + return $this; + } + + /** + * Get state updated time + * + * @return string + */ + public function getUpdated() + { + return $this->getData('updated'); + } + + /** + * Set state updated time + * + * @param string|int|\Zend_Date $updated + * @return \Magento\Mview\View\StateInterface + */ + public function setUpdated($updated) + { + $this->setData('updated', $updated); + return $this; + } + + /** + * Get state version ID + * + * @return string + */ + public function getVersionId() + { + return $this->getData('version_id'); + } + + /** + * Set state version ID + * + * @param int $versionId + * @return \Magento\Mview\View\StateInterface + */ + public function setVersionId($versionId) + { + $this->setData('version_id', $versionId); + return $this; + } +} diff --git a/app/code/Magento/Core/Model/Observer.php b/app/code/Magento/Core/Model/Observer.php index 867fda9b9db5d17f3617ba62c4302e78a3ecfd5c..cb9d4fd37911346a52c71105cef52729409d4d56 100644 --- a/app/code/Magento/Core/Model/Observer.php +++ b/app/code/Magento/Core/Model/Observer.php @@ -49,7 +49,7 @@ class Observer private $_pageAssets; /** - * @var \Magento\Core\Model\Config + * @var \Magento\App\ReinitableConfigInterface */ protected $_config; @@ -72,7 +72,7 @@ class Observer * @param \Magento\App\Cache\Frontend\Pool $cacheFrontendPool * @param \Magento\View\DesignInterface $design * @param \Magento\View\Asset\GroupedCollection $assets - * @param \Magento\Core\Model\ConfigInterface $config + * @param \Magento\App\ReinitableConfigInterface $config * @param \Magento\View\Asset\PublicFileFactory $assetFileFactory * @param \Magento\Core\Model\Theme\Registration $registration * @param \Magento\Logger $logger @@ -81,7 +81,7 @@ class Observer \Magento\App\Cache\Frontend\Pool $cacheFrontendPool, \Magento\View\DesignInterface $design, \Magento\View\Asset\GroupedCollection $assets, - \Magento\Core\Model\ConfigInterface $config, + \Magento\App\ReinitableConfigInterface $config, \Magento\View\Asset\PublicFileFactory $assetFileFactory, \Magento\Core\Model\Theme\Registration $registration, \Magento\Logger $logger diff --git a/app/code/Magento/Core/Model/ReinitableConfig.php b/app/code/Magento/Core/Model/ReinitableConfig.php new file mode 100644 index 0000000000000000000000000000000000000000..03e3090276ffaf0dbe55d02bf27e7a600c4153bf --- /dev/null +++ b/app/code/Magento/Core/Model/ReinitableConfig.php @@ -0,0 +1,39 @@ +<?php +/** + * Application configuration used to re-initialize config. + * + * 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 ReinitableConfig extends \Magento\Core\Model\Config implements \Magento\App\ReinitableConfigInterface +{ + /** + * (@inheritdoc) + */ + public function reinit() + { + $this->_sectionPool->clean(); + return $this; + } +} diff --git a/app/code/Magento/Core/Model/Resource/Config/Data.php b/app/code/Magento/Core/Model/Resource/Config/Data.php index 1f2b6b4f7d175d1397ebbe0ee7507a346283ac0b..1e2a2073648cef8380bb82a487a345c8d89086d5 100644 --- a/app/code/Magento/Core/Model/Resource/Config/Data.php +++ b/app/code/Magento/Core/Model/Resource/Config/Data.php @@ -67,7 +67,7 @@ class Data extends \Magento\Core\Model\Resource\Db\AbstractDb * Validate unique configuration data before save * Set id to object if exists configuration instead of throw exception * - * @param \Magento\Core\Model\Config\Value $object + * @param \Magento\Core\Model\AbstractModel $object * @return \Magento\Core\Model\Resource\Config\Data */ protected function _checkUnique(\Magento\Core\Model\AbstractModel $object) diff --git a/app/code/Magento/Core/Model/Resource/Mview/View/State.php b/app/code/Magento/Core/Model/Resource/Mview/View/State.php new file mode 100644 index 0000000000000000000000000000000000000000..77d374c66a17017bdb6682cf7e06fde870169d2d --- /dev/null +++ b/app/code/Magento/Core/Model/Resource/Mview/View/State.php @@ -0,0 +1,40 @@ +<?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\Resource\Mview\View; + +class State extends \Magento\Core\Model\Resource\Db\AbstractDb +{ + /** + * Resource initialization + */ + protected function _construct() + { + $this->_init('mview_state', 'state_id'); + $this->addUniqueField(array( + 'field' => array('view_id'), + 'title' => __('State for the same view') + )); + } +} diff --git a/app/code/Magento/Core/Model/Resource/Mview/View/State/Collection.php b/app/code/Magento/Core/Model/Resource/Mview/View/State/Collection.php new file mode 100644 index 0000000000000000000000000000000000000000..e949b1c116cc8783c51344314a34a764d97f944e --- /dev/null +++ b/app/code/Magento/Core/Model/Resource/Mview/View/State/Collection.php @@ -0,0 +1,37 @@ +<?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\Resource\Mview\View\State; + +class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractCollection + implements \Magento\Mview\View\State\CollectionInterface +{ + /** + * Collection initialization + */ + protected function _construct() + { + $this->_init('Magento\Core\Model\Mview\View\State', 'Magento\Core\Model\Resource\Mview\View\State'); + } +} diff --git a/app/code/Magento/Core/Model/Resource/Setup/Migration.php b/app/code/Magento/Core/Model/Resource/Setup/Migration.php index 7614ecc76d96ba6d8959be8c9531bc6086ba18af..ec4c74e28e18d50e2a010fc47096eb8203db6af1 100644 --- a/app/code/Magento/Core/Model/Resource/Setup/Migration.php +++ b/app/code/Magento/Core/Model/Resource/Setup/Migration.php @@ -693,7 +693,6 @@ class Migration extends \Magento\Core\Model\Resource\Setup 'googlebase' => 'Magento_GoogleBase', 'googlecheckout' => 'Magento_GoogleCheckout', 'importexport' => 'Magento_ImportExport', - 'paypaluk' => 'Magento_PaypalUk', 'productalert' => 'Magento_ProductAlert', 'salesrule' => 'Magento_SalesRule', ); diff --git a/app/code/Magento/Core/Model/Resource/Store.php b/app/code/Magento/Core/Model/Resource/Store.php index 37f5c12b757cdb5b9631e486a7e3962a1207e1ce..8f4e1cf0d771190cd83f41b74f1075684d88b36a 100644 --- a/app/code/Magento/Core/Model/Resource/Store.php +++ b/app/code/Magento/Core/Model/Resource/Store.php @@ -101,7 +101,7 @@ class Store extends \Magento\Core\Model\Resource\Db\AbstractDb protected function _afterDelete(\Magento\Core\Model\AbstractModel $model) { $where = array( - 'scope = ?' => \Magento\Core\Model\Config::SCOPE_STORES, + 'scope = ?' => \Magento\Core\Model\ScopeInterface::SCOPE_STORES, 'scope_id = ?' => $model->getStoreId() ); diff --git a/app/code/Magento/Core/Model/Resource/Website.php b/app/code/Magento/Core/Model/Resource/Website.php index 201f52511f3529f7426fc69a30d2ee93b52fe523..36ee0d6f63002914d1c0038e552cd9eb612ef64b 100644 --- a/app/code/Magento/Core/Model/Resource/Website.php +++ b/app/code/Magento/Core/Model/Resource/Website.php @@ -100,7 +100,7 @@ class Website extends \Magento\Core\Model\Resource\Db\AbstractDb protected function _afterDelete(\Magento\Core\Model\AbstractModel $model) { $where = array( - 'scope = ?' => \Magento\Core\Model\Config::SCOPE_WEBSITES, + 'scope = ?' => \Magento\Core\Model\ScopeInterface::SCOPE_WEBSITES, 'scope_id = ?' => $model->getWebsiteId() ); diff --git a/app/code/Magento/Core/Model/ScopeInterface.php b/app/code/Magento/Core/Model/ScopeInterface.php new file mode 100644 index 0000000000000000000000000000000000000000..dbb7f94e56cfd11d4dd5a3df917572e5c7bad457 --- /dev/null +++ b/app/code/Magento/Core/Model/ScopeInterface.php @@ -0,0 +1,35 @@ +<?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; + +interface ScopeInterface +{ + /**#@+ + * Scope types + */ + const SCOPE_DEFAULT = 'default'; + const SCOPE_STORES = 'stores'; + const SCOPE_WEBSITES = 'websites'; + /**#@-*/ +} diff --git a/app/code/Magento/Core/Model/Session/SidResolver.php b/app/code/Magento/Core/Model/Session/SidResolver.php index 15474ade63c27860f3710951cde6cf275304007e..63050bee61787f841b61845102cbbd19202b6d1d 100644 --- a/app/code/Magento/Core/Model/Session/SidResolver.php +++ b/app/code/Magento/Core/Model/Session/SidResolver.php @@ -54,6 +54,21 @@ class SidResolver implements \Magento\Session\SidResolverInterface */ protected $sidNameMap; + /** + * Use session var instead of SID for session in URL + * + * @var bool + */ + protected $_useSessionVar = false; + + /** + * Use session in URL flag + * + * @see \Magento\UrlInterface + * @var bool + */ + protected $_useSessionInUrl = true; + /** * @param \Magento\Core\Model\Store\ConfigInterface $coreStoreConfig * @param \Magento\UrlInterface $urlBuilder @@ -102,4 +117,48 @@ class SidResolver implements \Magento\Session\SidResolverInterface } return self::SESSION_ID_QUERY_PARAM; } + + /** + * Set use session var instead of SID for URL + * + * @param bool $var + * @return \Magento\Session\SidResolverInterface + */ + public function setUseSessionVar($var) + { + $this->_useSessionVar = (bool)$var; + return $this; + } + + /** + * Retrieve use flag session var instead of SID for URL + * + * @return bool + */ + public function getUseSessionVar() + { + return $this->_useSessionVar; + } + + /** + * Set Use session in URL flag + * + * @param bool $flag + * @return \Magento\Session\SidResolverInterface + */ + public function setUseSessionInUrl($flag = true) + { + $this->_useSessionInUrl = (bool)$flag; + return $this; + } + + /** + * Retrieve use session in URL flag + * + * @return bool + */ + public function getUseSessionInUrl() + { + return $this->_useSessionInUrl; + } } diff --git a/app/code/Magento/Core/Model/Store.php b/app/code/Magento/Core/Model/Store.php index 78b512335d47b7ff931ddd5c362d7a3df1a64fbb..38fe3c23a677b04370db39e98f71d311690c5dab 100644 --- a/app/code/Magento/Core/Model/Store.php +++ b/app/code/Magento/Core/Model/Store.php @@ -24,12 +24,11 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Core\Model; + /** * Store model * - * @method \Magento\Core\Model\Resource\Store _getResource() - * @method \Magento\Core\Model\Resource\Store getResource() - * @method \Magento\Core\Model\Store setId(string $value) * @method \Magento\Core\Model\Store setCode(string $value) * @method \Magento\Core\Model\Store setWebsiteId(int $value) * @method \Magento\Core\Model\Store setGroupId(int $value) @@ -39,9 +38,7 @@ * @method \Magento\Core\Model\Store setSortOrder(int $value) * @method \Magento\Core\Model\Store setIsActive(int $value) */ -namespace Magento\Core\Model; - -class Store extends \Magento\Core\Model\AbstractModel +class Store extends AbstractModel implements \Magento\Url\ScopeInterface { /** * Entity name @@ -76,32 +73,21 @@ class Store extends \Magento\Core\Model\AbstractModel const XML_PATH_UNSECURE_BASE_MEDIA_URL = 'web/unsecure/base_media_url'; const XML_PATH_OFFLOADER_HEADER = 'web/secure/offloader_header'; const XML_PATH_PRICE_SCOPE = 'catalog/price/scope'; - /**#@- */ + /**#@-*/ - /** + /**#@+ * Price scope constants */ const PRICE_SCOPE_GLOBAL = 0; const PRICE_SCOPE_WEBSITE = 1; - - /**#@+ - * Possible URL types - */ - const URL_TYPE_LINK = 'link'; - const URL_TYPE_DIRECT_LINK = 'direct_link'; - const URL_TYPE_WEB = 'web'; - const URL_TYPE_LIB = 'lib'; - const URL_TYPE_MEDIA = 'media'; - const URL_TYPE_STATIC = 'static'; - const URL_TYPE_CACHE = 'cache'; - const URL_TYPE_JS = 'js'; /**#@-*/ - /** + /**#@+ * Code constants */ const DEFAULT_CODE = 'default'; const ADMIN_CODE = 'admin'; + /**#@-*/ /** * Cache tag @@ -132,7 +118,12 @@ class Store extends \Magento\Core\Model\AbstractModel * Identifier of default store * used for loading data of default scope */ - const DEFAULT_STORE_ID = 0; + const DEFAULT_STORE_ID = 0; + + /** + * Default store Id (for install) + */ + const DISTRO_STORE_ID = 1; /** * @var \Magento\App\Cache\Type\Config @@ -247,7 +238,7 @@ class Store extends \Magento\Core\Model\AbstractModel /** * Url model for current store * - * @var \Magento\Core\Model\Url + * @var \Magento\UrlInterface */ protected $_url; @@ -288,7 +279,7 @@ class Store extends \Magento\Core\Model\AbstractModel protected $_coreStoreConfig; /** - * @var \Magento\Core\Model\Config + * @var \Magento\App\ReinitableConfigInterface */ protected $_config; @@ -309,12 +300,12 @@ class Store extends \Magento\Core\Model\AbstractModel * @param \Magento\Core\Model\Registry $registry * @param \Magento\Core\Helper\File\Storage\Database $coreFileStorageDatabase * @param \Magento\App\Cache\Type\Config $configCacheType - * @param \Magento\Core\Model\Url $url + * @param \Magento\UrlInterface $url * @param \Magento\App\RequestInterface $request * @param \Magento\Core\Model\Resource\Config\Data $configDataResource * @param \Magento\App\Filesystem $filesystem * @param \Magento\Core\Model\Store\Config $coreStoreConfig - * @param \Magento\Core\Model\Config $coreConfig + * @param \Magento\App\ReinitableConfigInterface $coreConfig * @param \Magento\Core\Model\Resource\Store $resource * @param \Magento\Core\Model\StoreManagerInterface $storeManager * @param \Magento\Session\SidResolverInterface $sidResolver @@ -328,12 +319,12 @@ class Store extends \Magento\Core\Model\AbstractModel \Magento\Core\Model\Registry $registry, \Magento\Core\Helper\File\Storage\Database $coreFileStorageDatabase, \Magento\App\Cache\Type\Config $configCacheType, - \Magento\Core\Model\Url $url, + \Magento\UrlInterface $url, \Magento\App\RequestInterface $request, \Magento\Core\Model\Resource\Config\Data $configDataResource, \Magento\App\Filesystem $filesystem, \Magento\Core\Model\Store\Config $coreStoreConfig, - \Magento\Core\Model\Config $coreConfig, + \Magento\App\ReinitableConfigInterface $coreConfig, \Magento\Core\Model\Resource\Store $resource, \Magento\Core\Model\StoreManagerInterface $storeManager, \Magento\Session\SidResolverInterface $sidResolver, @@ -379,7 +370,7 @@ class Store extends \Magento\Core\Model\AbstractModel $this->_coreStoreConfig = \Magento\App\ObjectManager::getInstance() ->get('Magento\Core\Model\Store\Config'); $this->_config = \Magento\App\ObjectManager::getInstance() - ->get('Magento\Core\Model\Config'); + ->get('Magento\App\ReinitableConfigInterface'); $this->_cookie = \Magento\App\ObjectManager::getInstance() ->get('Magento\Stdlib\Cookie'); } @@ -521,11 +512,10 @@ class Store extends \Magento\Core\Model\AbstractModel */ public function getUrl($route = '', $params = array()) { - /** @var $url \Magento\Core\Model\Url */ - $url = $this->getUrlModel() - ->setStore($this); + /** @var $url \Magento\UrlInterface */ + $url = $this->getUrlModel()->setScope($this); if ($this->_storeManager->getStore()->getId() != $this->getId()) { - $params['_store_to_url'] = true; + $params['_scope_to_url'] = true; } return $url->getUrl($route, $params); @@ -539,64 +529,64 @@ class Store extends \Magento\Core\Model\AbstractModel * @return string * @throws \InvalidArgumentException */ - public function getBaseUrl($type = self::URL_TYPE_LINK, $secure = null) + public function getBaseUrl($type = \Magento\UrlInterface::URL_TYPE_LINK, $secure = null) { $cacheKey = $type . '/' . (is_null($secure) ? 'null' : ($secure ? 'true' : 'false')); if (!isset($this->_baseUrlCache[$cacheKey])) { $secure = is_null($secure) ? $this->isCurrentlySecure() : (bool)$secure; switch ($type) { - case self::URL_TYPE_WEB: + case \Magento\UrlInterface::URL_TYPE_WEB: $path = $secure ? self::XML_PATH_SECURE_BASE_URL : self::XML_PATH_UNSECURE_BASE_URL; $url = $this->getConfig($path); break; - case self::URL_TYPE_LINK: + case \Magento\UrlInterface::URL_TYPE_LINK: $path = $secure ? self::XML_PATH_SECURE_BASE_LINK_URL : self::XML_PATH_UNSECURE_BASE_LINK_URL; $url = $this->getConfig($path); $url = $this->_updatePathUseRewrites($url); $url = $this->_updatePathUseStoreView($url); break; - case self::URL_TYPE_DIRECT_LINK: + case \Magento\UrlInterface::URL_TYPE_DIRECT_LINK: $path = $secure ? self::XML_PATH_SECURE_BASE_LINK_URL : self::XML_PATH_UNSECURE_BASE_LINK_URL; $url = $this->getConfig($path); $url = $this->_updatePathUseRewrites($url); break; - case self::URL_TYPE_LIB: + case \Magento\UrlInterface::URL_TYPE_LIB: $path = $secure ? self::XML_PATH_SECURE_BASE_LIB_URL : self::XML_PATH_UNSECURE_BASE_LIB_URL; $url = $this->getConfig($path); if (!$url) { - $url = $this->getBaseUrl(self::URL_TYPE_WEB, $secure) + $url = $this->getBaseUrl(\Magento\UrlInterface::URL_TYPE_WEB, $secure) . $this->filesystem->getUri(\Magento\App\Filesystem::PUB_LIB_DIR); } break; - case self::URL_TYPE_STATIC: + case \Magento\UrlInterface::URL_TYPE_STATIC: $path = $secure ? self::XML_PATH_SECURE_BASE_STATIC_URL : self::XML_PATH_UNSECURE_BASE_STATIC_URL; $url = $this->getConfig($path); if (!$url) { - $url = $this->getBaseUrl(self::URL_TYPE_WEB, $secure) + $url = $this->getBaseUrl(\Magento\UrlInterface::URL_TYPE_WEB, $secure) . $this->filesystem->getUri(\Magento\App\Filesystem::STATIC_VIEW_DIR); } break; - case self::URL_TYPE_CACHE: + case \Magento\UrlInterface::URL_TYPE_CACHE: $path = $secure ? self::XML_PATH_SECURE_BASE_CACHE_URL : self::XML_PATH_UNSECURE_BASE_CACHE_URL; $url = $this->getConfig($path); if (!$url) { - $url = $this->getBaseUrl(self::URL_TYPE_WEB, $secure) + $url = $this->getBaseUrl(\Magento\UrlInterface::URL_TYPE_WEB, $secure) . $this->filesystem->getUri(\Magento\App\Filesystem::PUB_VIEW_CACHE_DIR); } break; - case self::URL_TYPE_MEDIA: + case \Magento\UrlInterface::URL_TYPE_MEDIA: $url = $this->_getMediaScriptUrl($this->filesystem, $secure); if (!$url) { $path = $secure ? self::XML_PATH_SECURE_BASE_MEDIA_URL : self::XML_PATH_UNSECURE_BASE_MEDIA_URL; $url = $this->getConfig($path); if (!$url) { - $url = $this->getBaseUrl(self::URL_TYPE_WEB, $secure) + $url = $this->getBaseUrl(\Magento\UrlInterface::URL_TYPE_WEB, $secure) . $this->filesystem->getUri(\Magento\App\Filesystem::MEDIA_DIR); } } @@ -606,9 +596,9 @@ class Store extends \Magento\Core\Model\AbstractModel throw new \InvalidArgumentException('Invalid base url type'); } - if (false !== strpos($url, \Magento\Core\Model\Store::BASE_URL_PLACEHOLDER)) { + if (false !== strpos($url, self::BASE_URL_PLACEHOLDER)) { $distroBaseUrl = $this->_request->getDistroBaseUrl(); - $url = str_replace(\Magento\Core\Model\Store::BASE_URL_PLACEHOLDER, $distroBaseUrl, $url); + $url = str_replace(self::BASE_URL_PLACEHOLDER, $distroBaseUrl, $url); } $this->_baseUrlCache[$cacheKey] = rtrim($url, '/') . '/'; @@ -664,8 +654,8 @@ class Store extends \Magento\Core\Model\AbstractModel if (!$this->getConfig(self::XML_PATH_USE_REWRITES) && $this->_coreFileStorageDatabase->checkDbUsage() ) { - return $this->getBaseUrl(self::URL_TYPE_WEB, $secure) . $filesystem->getUri(\Magento\App\Filesystem::PUB_DIR) - . '/' . self::MEDIA_REWRITE_SCRIPT; + return $this->getBaseUrl(\Magento\UrlInterface::URL_TYPE_WEB, $secure) + . $filesystem->getUri(\Magento\App\Filesystem::PUB_DIR) . '/' . self::MEDIA_REWRITE_SCRIPT; } return false; } @@ -692,8 +682,8 @@ class Store extends \Magento\Core\Model\AbstractModel 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); } /** @@ -715,7 +705,7 @@ class Store extends \Magento\Core\Model\AbstractModel { if ($this->_isFrontSecure === null) { $this->_isFrontSecure = $this->_coreStoreConfig->getConfigFlag( - \Magento\Core\Model\Url::XML_PATH_SECURE_IN_FRONT, + self::XML_PATH_SECURE_IN_FRONTEND, $this->getId() ); } @@ -745,8 +735,8 @@ class Store extends \Magento\Core\Model\AbstractModel } if ($this->_appState->isInstalled()) { - $secureBaseUrl = $this->_coreStoreConfig->getConfig(\Magento\Core\Model\Url::XML_PATH_SECURE_URL); - + $secureBaseUrl = $this->_coreStoreConfig->getConfig(self::XML_PATH_SECURE_BASE_URL); + if (!$secureBaseUrl) { return false; } @@ -774,8 +764,8 @@ class Store extends \Magento\Core\Model\AbstractModel */ public function getBaseCurrencyCode() { - $configValue = $this->getConfig(\Magento\Core\Model\Store::XML_PATH_PRICE_SCOPE); - if ($configValue == \Magento\Core\Model\Store::PRICE_SCOPE_GLOBAL) { + $configValue = $this->getConfig(self::XML_PATH_PRICE_SCOPE); + if ($configValue == self::PRICE_SCOPE_GLOBAL) { return \Magento\App\ObjectManager::getInstance() ->get('Magento\Core\Model\App')->getBaseCurrencyCode(); } else { @@ -791,7 +781,7 @@ class Store extends \Magento\Core\Model\AbstractModel public function getBaseCurrency() { $currency = $this->getData('base_currency'); - if (is_null($currency)) { + if (null === $currency) { $currency = \Magento\App\ObjectManager::getInstance()->create('Magento\Directory\Model\Currency') ->load($this->getBaseCurrencyCode()); $this->setData('base_currency', $currency); @@ -818,7 +808,7 @@ class Store extends \Magento\Core\Model\AbstractModel public function getDefaultCurrency() { $currency = $this->getData('default_currency'); - if (is_null($currency)) { + if (null === $currency) { $currency = \Magento\App\ObjectManager::getInstance()->create('Magento\Directory\Model\Currency') ->load($this->getDefaultCurrencyCode()); $this->setData('default_currency', $currency); @@ -884,7 +874,7 @@ class Store extends \Magento\Core\Model\AbstractModel public function getAvailableCurrencyCodes($skipBaseNotAllowed = false) { $codes = $this->getData('available_currency_codes'); - if (is_null($codes)) { + if (null === $codes) { $codes = explode(',', $this->getConfig(\Magento\Directory\Model\Currency::XML_PATH_CURRENCY_ALLOW)); // add base currency, if it is not in allowed currencies $baseCurrencyCode = $this->getBaseCurrencyCode(); @@ -1042,7 +1032,7 @@ class Store extends \Magento\Core\Model\AbstractModel */ public function getGroup() { - if (is_null($this->getGroupId())) { + if (null === $this->getGroupId()) { return false; } return $this->_storeManager->getGroup($this->getGroupId()); @@ -1101,11 +1091,7 @@ class Store extends \Magento\Core\Model\AbstractModel public function getCurrentUrl($fromStore = true) { $sidQueryParam = $this->_sidResolver->getSessionIdQueryParam($this->_getSession()); - $requestString = $this->getUrlModel()->escape(ltrim( - \Magento\App\ObjectManager::getInstance() - ->get('Magento\Core\Model\App')->getRequest()->getRequestString(), - '/' - )); + $requestString = $this->getUrlModel()->escape(ltrim($this->_request->getRequestString(), '/')); $storeUrl = $this->_storeManager->getStore()->isCurrentlySecure() ? $this->getUrl('', array('_secure' => true)) @@ -1129,8 +1115,8 @@ class Store extends \Magento\Core\Model\AbstractModel unset($currQuery[$sidQueryParam]); } - foreach ($currQuery as $k => $v) { - $storeParsedQuery[$k] = $v; + foreach ($currQuery as $key => $value) { + $storeParsedQuery[$key] = $value; } if (!$this->isUseStoreInUrl()) { @@ -1143,9 +1129,9 @@ class Store extends \Magento\Core\Model\AbstractModel } 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, '', '&') : ''); } /** @@ -1245,7 +1231,7 @@ class Store extends \Magento\Core\Model\AbstractModel */ public function getFrontendName() { - if (is_null($this->_frontendName)) { + if (null === $this->_frontendName) { $storeGroupName = (string) $this->_coreStoreConfig->getConfig('general/store_information/name', $this); $this->_frontendName = (!empty($storeGroupName)) ? $storeGroupName : $this->getGroup()->getName(); } @@ -1255,7 +1241,7 @@ class Store extends \Magento\Core\Model\AbstractModel /** * Set url model for current store * - * @param \Magento\Core\Model\Url $urlModel + * @param \Magento\UrlInterface $urlModel * @return \Magento\Core\Model\Store */ public function setUrlModel($urlModel) @@ -1267,7 +1253,7 @@ class Store extends \Magento\Core\Model\AbstractModel /** * Get url model by class name for current store * - * @return \Magento\Core\Model\Url + * @return \Magento\UrlInterface */ public function getUrlModel() { diff --git a/app/code/Magento/Core/Model/Store/Config.php b/app/code/Magento/Core/Model/Store/Config.php index 9af1261021255c8a6a18452ee5bae741484f85d0..454921305060c519fad63b9d0f007c93f75844f4 100644 --- a/app/code/Magento/Core/Model/Store/Config.php +++ b/app/code/Magento/Core/Model/Store/Config.php @@ -34,7 +34,7 @@ class Config implements \Magento\Core\Model\Store\ConfigInterface protected $_storeManager; /** - * @var \Magento\Core\Model\ConfigInterface + * @var \Magento\App\ConfigInterface */ protected $_config; @@ -50,12 +50,12 @@ class Config implements \Magento\Core\Model\Store\ConfigInterface /** * @param \Magento\Core\Model\StoreManagerInterface $storeManager - * @param \Magento\Core\Model\ConfigInterface $config + * @param \Magento\App\ConfigInterface $config * @param \Magento\Core\Model\Resource\Store\CollectionFactory $factory */ public function __construct( \Magento\Core\Model\StoreManagerInterface $storeManager, - \Magento\Core\Model\ConfigInterface $config, + \Magento\App\ConfigInterface $config, \Magento\Core\Model\Resource\Store\CollectionFactory $factory ) { $this->_storeManager = $storeManager; diff --git a/app/code/Magento/Core/Model/Store/Storage/Db.php b/app/code/Magento/Core/Model/Store/Storage/Db.php index 188477a61657112db1155663054a1987804413b7..9c7262ab3f91915d50fd29aa814c9a364156cd6b 100644 --- a/app/code/Magento/Core/Model/Store/Storage/Db.php +++ b/app/code/Magento/Core/Model/Store/Storage/Db.php @@ -25,11 +25,8 @@ */ namespace Magento\Core\Model\Store\Storage; -use Magento\Backend\Model\Url\Proxy; use Magento\Core\Exception; use Magento\App\State; -use Magento\Core\Model\AppInterface; -use Magento\Core\Model\Config; use Magento\Core\Model\Store; use Magento\Core\Model\Store\StorageInterface; use Magento\Core\Model\Store\Group; @@ -107,7 +104,7 @@ class Db implements StorageInterface /** * Config model * - * @var Config + * @var \Magento\App\ConfigInterface */ protected $_config; @@ -142,7 +139,7 @@ class Db implements StorageInterface /** * Cookie model * - * @var Cookie + * @var \Magento\Stdlib\Cookie */ protected $_cookie; @@ -154,7 +151,7 @@ class Db implements StorageInterface protected $_appState; /** - * @var \Magento\Backend\Model\Url\Proxy + * @var \Magento\Backend\Model\UrlInterface */ protected $_url; @@ -162,10 +159,10 @@ class Db implements StorageInterface * @param StoreFactory $storeFactory * @param Website\Factory $websiteFactory * @param Group\Factory $groupFactory - * @param Config $config + * @param \Magento\App\ConfigInterface $config * @param \Magento\Stdlib\Cookie $cookie * @param State $appState - * @param \Magento\Backend\Model\Url $url + * @param \Magento\Backend\Model\UrlInterface $url * @param $isSingleStoreAllowed * @param $scopeCode * @param $scopeType @@ -175,10 +172,10 @@ class Db implements StorageInterface \Magento\Core\Model\StoreFactory $storeFactory, \Magento\Core\Model\Website\Factory $websiteFactory, \Magento\Core\Model\Store\Group\Factory $groupFactory, - \Magento\Core\Model\Config $config, + \Magento\App\ConfigInterface $config, \Magento\Stdlib\Cookie $cookie, \Magento\App\State $appState, - \Magento\Backend\Model\Url $url, + \Magento\Backend\Model\UrlInterface $url, $isSingleStoreAllowed, $scopeCode, $scopeType, @@ -208,8 +205,8 @@ class Db implements StorageInterface { if (empty($this->_store)) { $this->_store = $this->_storeFactory->create() - ->setId(AppInterface::DISTRO_STORE_ID) - ->setCode(AppInterface::DISTRO_STORE_CODE); + ->setId(\Magento\Core\Model\Store::DISTRO_STORE_ID) + ->setCode(\Magento\Core\Model\Store::DEFAULT_CODE); } return $this->_store; } diff --git a/app/code/Magento/Core/Model/Store/Storage/DefaultStorage.php b/app/code/Magento/Core/Model/Store/Storage/DefaultStorage.php index f850075349ab9d061f63fe7b83139504acb3770e..42aa7e06c52e6eb93550746f702e8a8bc82f1fea 100644 --- a/app/code/Magento/Core/Model/Store/Storage/DefaultStorage.php +++ b/app/code/Magento/Core/Model/Store/Storage/DefaultStorage.php @@ -60,8 +60,8 @@ class DefaultStorage implements \Magento\Core\Model\Store\StorageInterface ) { $this->_store = $storeFactory->create(); - $this->_store->setId(\Magento\Core\Model\AppInterface::DISTRO_STORE_ID); - $this->_store->setCode(\Magento\Core\Model\AppInterface::DISTRO_STORE_CODE); + $this->_store->setId(\Magento\Core\Model\Store::DISTRO_STORE_ID); + $this->_store->setCode(\Magento\Core\Model\Store::DEFAULT_CODE); $this->_website = $websiteFactory->create(); $this->_group = $groupFactory->create(); } diff --git a/app/code/Magento/Core/Model/Store/StorageFactory.php b/app/code/Magento/Core/Model/Store/StorageFactory.php index 0b601df16c6e5785d3781d50b48dfa905e06319b..3db1052481d77e2265c7beeb7c6d567951057ce4 100644 --- a/app/code/Magento/Core/Model/Store/StorageFactory.php +++ b/app/code/Magento/Core/Model/Store/StorageFactory.php @@ -60,9 +60,9 @@ class StorageFactory protected $_log; /** - * @var \Magento\Core\Model\AppInterface + * @var \Magento\Session\SidResolverInterface */ - protected $_app; + protected $_sidResolver; /** * @var \Magento\App\State @@ -78,7 +78,7 @@ class StorageFactory * @param \Magento\ObjectManager $objectManager * @param \Magento\Event\ManagerInterface $eventManager * @param \Magento\Logger $logger - * @param \Magento\Core\Model\AppInterface $app + * @param \Magento\Session\SidResolverInterface $sidResolver * @param \Magento\App\State $appState * @param string $defaultStorageClassName * @param string $installedStoreClassName @@ -88,7 +88,7 @@ class StorageFactory \Magento\ObjectManager $objectManager, \Magento\Event\ManagerInterface $eventManager, \Magento\Logger $logger, - \Magento\Core\Model\AppInterface $app, + \Magento\Session\SidResolverInterface $sidResolver, \Magento\App\State $appState, $defaultStorageClassName = 'Magento\Core\Model\Store\Storage\DefaultStorage', $installedStoreClassName = 'Magento\Core\Model\Store\Storage\Db', @@ -100,7 +100,7 @@ class StorageFactory $this->_eventManager = $eventManager; $this->_log = $logger; $this->_appState = $appState; - $this->_app = $app; + $this->_sidResolver = $sidResolver; $this->_writerModel = $writerModel; } @@ -131,7 +131,7 @@ class StorageFactory if ($className === $this->_installedStoreClassName) { $useSid = $instance->getStore() ->getConfig(\Magento\Core\Model\Session\SidResolver::XML_PATH_USE_FRONTEND_SID); - $this->_app->setUseSessionInUrl($useSid); + $this->_sidResolver->setUseSessionInUrl($useSid); $this->_eventManager->dispatch('core_app_init_current_store_after'); diff --git a/app/code/Magento/Core/Model/Theme.php b/app/code/Magento/Core/Model/Theme.php index 064adfabb7a64d5c3d227ab26cbe5fcd82b1bffc..e8344b9fca66b0ff19d6f23801f4f5557ae85ec6 100644 --- a/app/code/Magento/Core/Model/Theme.php +++ b/app/code/Magento/Core/Model/Theme.php @@ -26,10 +26,11 @@ namespace Magento\Core\Model; +use Magento\View\Design\ThemeInterface; + /** * Theme model class * - * @method \Magento\View\Design\ThemeInterface save() * @method string getPackageCode() * @method string getParentThemePath() * @method string getParentId() @@ -40,22 +41,20 @@ namespace Magento\Core\Model; * @method int getThemeId() * @method int getType() * @method array getAssignedStores() - * @method \Magento\Core\Model\Resource\Theme\Collection getCollection() - * @method \Magento\View\Design\ThemeInterface setAssignedStores(array $stores) - * @method \Magento\View\Design\ThemeInterface addData(array $data) - * @method \Magento\View\Design\ThemeInterface setParentId(int $id) - * @method \Magento\View\Design\ThemeInterface setParentTheme($parentTheme) - * @method \Magento\View\Design\ThemeInterface setPackageCode(string $packageCode) - * @method \Magento\View\Design\ThemeInterface setThemeCode(string $themeCode) - * @method \Magento\View\Design\ThemeInterface setThemePath(string $themePath) - * @method \Magento\View\Design\ThemeInterface setThemeVersion(string $themeVersion) - * @method \Magento\View\Design\ThemeInterface setThemeTitle(string $themeTitle) - * @method \Magento\View\Design\ThemeInterface setType(int $type) - * @method \Magento\View\Design\ThemeInterface setCode(string $code) + * @method ThemeInterface setAssignedStores(array $stores) + * @method ThemeInterface setParentId(int $id) + * @method ThemeInterface setParentTheme($parentTheme) + * @method ThemeInterface setPackageCode(string $packageCode) + * @method ThemeInterface setThemeCode(string $themeCode) + * @method ThemeInterface setThemePath(string $themePath) + * @method ThemeInterface setThemeVersion(string $themeVersion) + * @method ThemeInterface setThemeTitle(string $themeTitle) + * @method ThemeInterface setType(int $type) + * @method ThemeInterface setCode(string $code) * * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class Theme extends \Magento\Core\Model\AbstractModel implements \Magento\View\Design\ThemeInterface +class Theme extends \Magento\Core\Model\AbstractModel implements ThemeInterface { /** * Filename of view configuration @@ -106,6 +105,10 @@ class Theme extends \Magento\Core\Model\AbstractModel implements \Magento\View\D */ protected $_customFactory; + /** + * @var ThemeInterface[] + */ + protected $inheritanceSequence; /** * Initialize dependencies @@ -142,9 +145,7 @@ class Theme extends \Magento\Core\Model\AbstractModel implements \Magento\View\D $this->_validator = $validator; $this->_customFactory = $customizationFactory; - $this->addData(array( - 'type' => self::TYPE_VIRTUAL - )); + $this->addData(array('type' => self::TYPE_VIRTUAL)); } /** @@ -375,4 +376,23 @@ class Theme extends \Magento\Core\Model\AbstractModel implements \Magento\View\D $this->getCollection()->updateChildRelations($this); return parent::_afterDelete(); } + + /** + * Return the full theme inheritance sequence, from the root theme till a specified one + * + * @return ThemeInterface[] Format: array([<root_theme>, ..., <parent_theme>,] <current_theme>) + */ + public function getInheritedThemes() + { + if (null === $this->inheritanceSequence) { + $theme = $this; + $result = array(); + while ($theme) { + $result[] = $theme; + $theme = $theme->getParentTheme(); + } + $this->inheritanceSequence = array_reverse($result); + } + return $this->inheritanceSequence; + } } diff --git a/app/code/Magento/Core/Model/Theme/Collection.php b/app/code/Magento/Core/Model/Theme/Collection.php index dd2989605b48d717b44f866fd9933d5d5dae7ecf..2b0f5a089ba31762ab3e111c0dcc08397b4f2a6a 100644 --- a/app/code/Magento/Core/Model/Theme/Collection.php +++ b/app/code/Magento/Core/Model/Theme/Collection.php @@ -24,11 +24,11 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Core\Model\Theme; + /** * Theme filesystem collection */ -namespace Magento\Core\Model\Theme; - class Collection extends \Magento\Data\Collection implements \Magento\View\Design\Theme\ListInterface { /** @@ -50,24 +50,16 @@ class Collection extends \Magento\Data\Collection implements \Magento\View\Desig */ protected $_targetDirs = array(); - /** - * @var \Magento\Config\FileIteratorFactory - */ - protected $fileIteratorFactory; - /** * @param \Magento\Core\Model\EntityFactory $entityFactory - * @param \Magento\App\Filesystem $filesystem - * @param \Magento\Config\FileIteratorFactory $fileIteratorFactory + * @param \Magento\Filesystem $filesystem */ public function __construct( \Magento\Core\Model\EntityFactory $entityFactory, - \Magento\App\Filesystem $filesystem, - \Magento\Config\FileIteratorFactory $fileIteratorFactory + \Magento\Filesystem $filesystem ) { parent::__construct($entityFactory); $this->_directory = $filesystem->getDirectoryRead(\Magento\App\Filesystem::THEMES_DIR); - $this->fileIteratorFactory = $fileIteratorFactory; } /** @@ -217,12 +209,7 @@ class Collection extends \Magento\Data\Collection implements \Magento\View\Desig public function _prepareConfigurationData($configPath) { - $themeConfig = $this->_getConfigModel( - $this->fileIteratorFactory->create( - $this->_directory, - array($this->_directory->getRelativePath($configPath)) - ) - ); + $themeConfig = $this->_getConfigModel($configPath); $pathData = $this->_preparePathData($configPath); $media = $themeConfig->getMedia(); @@ -289,12 +276,12 @@ class Collection extends \Magento\Data\Collection implements \Magento\View\Desig /** * Return configuration model for themes * - * @param $configPaths + * @param $configPath * @return \Magento\Config\Theme */ - protected function _getConfigModel($configPaths) + protected function _getConfigModel($configPath) { - return new \Magento\Config\Theme($configPaths); + return new \Magento\Config\Theme($this->_directory->readFile($this->_directory->getRelativePath($configPath))); } /** diff --git a/app/code/Magento/Core/Model/Theme/Customization/Config.php b/app/code/Magento/Core/Model/Theme/Customization/Config.php index 76f4f1c5b391f644c0d4689b528db1434ef6e907..a87a1e7d620e8d5749256d299c2338bf8fa70c64 100644 --- a/app/code/Magento/Core/Model/Theme/Customization/Config.php +++ b/app/code/Magento/Core/Model/Theme/Customization/Config.php @@ -37,14 +37,14 @@ class Config implements \Magento\View\Design\Theme\Customization\ConfigInterface const XML_PATH_CUSTOM_FILES = 'theme/customization'; /** - * @var \Magento\Core\Model\Config + * @var \Magento\App\ConfigInterface */ protected $config; /** - * @param \Magento\Core\Model\Config $config + * @param \Magento\App\ConfigInterface $config */ - public function __construct(\Magento\Core\Model\Config $config) + public function __construct(\Magento\App\ConfigInterface $config) { $this->config = $config; } diff --git a/app/code/Magento/Core/Model/Theme/Image/Path.php b/app/code/Magento/Core/Model/Theme/Image/Path.php index 8e29888a36a9ba9ff31b1417de2b1cbadc1cc118..5c148acf9c0e1a9d0b00054b6d9530efd95f53a1 100644 --- a/app/code/Magento/Core/Model/Theme/Image/Path.php +++ b/app/code/Magento/Core/Model/Theme/Image/Path.php @@ -75,7 +75,7 @@ class Path implements \Magento\View\Design\Theme\Image\PathInterface */ public function getPreviewImageDirectoryUrl() { - return $this->_storeManager->getStore()->getBaseUrl(\Magento\Core\Model\Store::URL_TYPE_MEDIA) + return $this->_storeManager->getStore()->getBaseUrl(\Magento\UrlInterface::URL_TYPE_MEDIA) . self::PREVIEW_DIRECTORY_PATH . '/'; } diff --git a/app/code/Magento/Core/Model/Translate.php b/app/code/Magento/Core/Model/Translate.php index 2ece5a27e6054a1267160a314017081f9893986f..32d57d70d192c97b88eacda4d15de584da88a64b 100644 --- a/app/code/Magento/Core/Model/Translate.php +++ b/app/code/Magento/Core/Model/Translate.php @@ -215,7 +215,7 @@ class Translate implements TranslateInterface * @param \Magento\Phrase\Renderer\Placeholder $placeholderRender * @param \Magento\Module\ModuleList $moduleList * @param \Magento\Module\Dir\Reader $modulesReader - * @param \Magento\Core\Model\Config $coreConfig + * @param \Magento\App\ConfigInterface $coreConfig * @param \Magento\Core\Model\StoreManagerInterface $storeManager * @param \Magento\Core\Model\Resource\Translate $translate * @param \Magento\Core\Model\App $app @@ -233,7 +233,7 @@ class Translate implements TranslateInterface \Magento\Phrase\Renderer\Placeholder $placeholderRender, \Magento\Module\ModuleList $moduleList, \Magento\Module\Dir\Reader $modulesReader, - \Magento\Core\Model\Config $coreConfig, + \Magento\App\ConfigInterface $coreConfig, \Magento\Core\Model\StoreManagerInterface $storeManager, \Magento\Core\Model\Resource\Translate $translate, \Magento\Core\Model\App $app, diff --git a/app/code/Magento/Core/Model/Translate/Inline.php b/app/code/Magento/Core/Model/Translate/Inline.php index c4721b61adb56f4953377880a3ce37d727fbb3ba..cefcc7d6f4080f2ffd490074d09706df8fb992c9 100644 --- a/app/code/Magento/Core/Model/Translate/Inline.php +++ b/app/code/Magento/Core/Model/Translate/Inline.php @@ -63,7 +63,7 @@ class Inline implements \Magento\Core\Model\Translate\InlineInterface protected $_isScriptInserted = false; /** - * @var \Magento\Core\Model\Url + * @var \Magento\UrlInterface */ protected $_url; @@ -87,7 +87,7 @@ class Inline implements \Magento\Core\Model\Translate\InlineInterface * * @param InlineParser $parser * @param \Magento\Core\Model\Translate $translate - * @param \Magento\Core\Model\Url $url + * @param \Magento\UrlInterface $url * @param \Magento\View\LayoutInterface $layout * @param \Magento\Core\Model\Translate\Inline\ConfigFactory $configFactory * @param \Magento\App\State $appState @@ -95,7 +95,7 @@ class Inline implements \Magento\Core\Model\Translate\InlineInterface public function __construct( \Magento\Core\Model\Translate\InlineParser $parser, \Magento\Core\Model\Translate $translate, - \Magento\Core\Model\Url $url, + \Magento\UrlInterface $url, \Magento\View\LayoutInterface $layout, \Magento\Core\Model\Translate\Inline\ConfigFactory $configFactory, \Magento\App\State $appState diff --git a/app/code/Magento/Core/Model/Url/Rewrite.php b/app/code/Magento/Core/Model/Url/Rewrite.php index 07da290d2a2e07a7bee4418af0a115e71613a9e1..66fcaaafa24c014feebb0cd9b52030c3acb22057 100644 --- a/app/code/Magento/Core/Model/Url/Rewrite.php +++ b/app/code/Magento/Core/Model/Url/Rewrite.php @@ -59,7 +59,6 @@ class Rewrite extends \Magento\Core\Model\AbstractModel const TYPE_CATEGORY = 1; const TYPE_PRODUCT = 2; const TYPE_CUSTOM = 3; - const REWRITE_REQUEST_PATH_ALIAS = 'rewrite_request_path'; /** * Cache tag for clear cache in after save and after delete @@ -299,7 +298,7 @@ class Rewrite extends \Magento\Core\Model\AbstractModel } - $request->setAlias(self::REWRITE_REQUEST_PATH_ALIAS, $this->getRequestPath()); + $request->setAlias(\Magento\Url::REWRITE_REQUEST_PATH_ALIAS, $this->getRequestPath()); $external = substr($this->getTargetPath(), 0, 6); $isPermanentRedirectOption = $this->hasOption('RP'); if ($external === 'http:/' || $external === 'https:') { diff --git a/app/code/Magento/Core/Model/Url/RouteParamsResolver.php b/app/code/Magento/Core/Model/Url/RouteParamsResolver.php new file mode 100644 index 0000000000000000000000000000000000000000..b9c59865fc864a5c382535692158317dd7b54b7b --- /dev/null +++ b/app/code/Magento/Core/Model/Url/RouteParamsResolver.php @@ -0,0 +1,173 @@ +<?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\Url; + +class RouteParamsResolver extends \Magento\Object implements \Magento\Url\RouteParamsResolverInterface +{ + /** + * @var \Magento\App\RequestInterface + */ + protected $_request; + + /** + * @var \Magento\Core\Model\Store\Config + */ + protected $_storeConfig; + + /** + * @var \Magento\Core\Model\StoreManagerInterface + */ + protected $_storeManager; + + /** + * @var \Magento\Url\QueryParamsResolverInterface + */ + protected $_queryParamsResolver; + + /** + * @param \Magento\App\RequestInterface $request + * @param \Magento\Core\Model\Store\Config $storeConfig + * @param \Magento\Core\Model\StoreManagerInterface $storeManager + * @param \Magento\Url\QueryParamsResolverInterface $queryParamsResolver + * @param array $data + */ + public function __construct( + \Magento\App\RequestInterface $request, + \Magento\Core\Model\Store\Config $storeConfig, + \Magento\Core\Model\StoreManagerInterface $storeManager, + \Magento\Url\QueryParamsResolverInterface $queryParamsResolver, + array $data = array() + ) { + parent::__construct($data); + $this->_request = $request; + $this->_storeConfig = $storeConfig; + $this->_storeManager = $storeManager; + $this->_queryParamsResolver = $queryParamsResolver; + } + + /** + * {@inheritdoc} + */ + public function setRouteParams(array $data, $unsetOldParams = true) + { + if (isset($data['_type'])) { + $this->setType($data['_type']); + unset($data['_type']); + } + + if (isset($data['_scope'])) { + $this->setScope($data['_scope']); + unset($data['_scope']); + } + + if (isset($data['_forced_secure'])) { + $this->setSecure((bool)$data['_forced_secure']); + $this->setSecureIsForced(true); + unset($data['_forced_secure']); + } elseif (isset($data['_secure'])) { + $this->setSecure((bool)$data['_secure']); + unset($data['_secure']); + } + + if (isset($data['_absolute'])) { + unset($data['_absolute']); + } + + if ($unsetOldParams) { + $this->unsetData('route_params'); + } + + if (isset($data['_current'])) { + if (is_array($data['_current'])) { + foreach ($data['_current'] as $key) { + if (array_key_exists($key, $data) || !$this->_request->getUserParam($key)) { + continue; + } + $data[$key] = $this->_request->getUserParam($key); + } + } elseif ($data['_current']) { + foreach ($this->_request->getUserParams() as $key => $value) { + if (array_key_exists($key, $data) || $this->getRouteParam($key)) { + continue; + } + $data[$key] = $value; + } + foreach ($this->_request->getQuery() as $key => $value) { + $this->_queryParamsResolver->setQueryParam($key, $value); + } + } + unset($data['_current']); + } + + if (isset($data['_use_rewrite'])) { + unset($data['_use_rewrite']); + } + + if (isset($data['_scope_to_url']) && (bool)$data['_scope_to_url'] === true) { + if (!$this->_storeConfig->getConfig(\Magento\Core\Model\Store::XML_PATH_STORE_IN_URL, $this->getScope()) + && !$this->_storeManager->hasSingleStore() + ) { + $this->_queryParamsResolver->setQueryParam('___store', $this->getScope()->getCode()); + } + } + unset($data['_scope_to_url']); + + foreach ($data as $key => $value) { + $this->setRouteParam($key, $value); + } + + return $this; + } + + /** + * {@inheritdoc} + */ + public function setRouteParam($key, $data) + { + $params = $this->_getData('route_params'); + if (isset($params[$key]) && $params[$key] == $data) { + return $this; + } + $params[$key] = $data; + $this->unsetData('route_path'); + return $this->setData('route_params', $params); + } + + /** + * {@inheritdoc} + */ + public function getRouteParams() + { + return $this->_getData('route_params'); + } + + /** + * {@inheritdoc} + */ + public function getRouteParam($key) + { + return $this->getData('route_params', $key); + } +} diff --git a/app/code/Magento/Core/Model/Url/ScopeResolver.php b/app/code/Magento/Core/Model/Url/ScopeResolver.php new file mode 100644 index 0000000000000000000000000000000000000000..05ead4308a1654cf2335348a7e51cb88c7d9ebff --- /dev/null +++ b/app/code/Magento/Core/Model/Url/ScopeResolver.php @@ -0,0 +1,79 @@ +<?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\Url; + +class ScopeResolver implements \Magento\Url\ScopeResolverInterface +{ + /** + * @var \Magento\Core\Model\StoreManagerInterface + */ + protected $_storeManager; + + /** + * @var null|string + */ + protected $_areaCode; + + /** + * @param \Magento\Core\Model\StoreManagerInterface $storeManager + * @param string|null $areaCode + */ + public function __construct( + \Magento\Core\Model\StoreManagerInterface $storeManager, + $areaCode = null + ) { + $this->_storeManager = $storeManager; + $this->_areaCode = $areaCode; + } + + /** + * {@inheritdoc} + */ + public function getScope($scopeId = null) + { + $scope = $this->_storeManager->getStore($scopeId); + if (!($scope instanceof \Magento\Url\ScopeInterface)) { + throw new \Magento\Exception('Invalid scope object'); + } + + return $scope; + } + + /** + * {@inheritdoc} + */ + public function getScopes() + { + return $this->_storeManager->getStores(); + } + + /** + * {@inheritdoc} + */ + public function getAreaCode() + { + return $this->_areaCode; + } +} diff --git a/app/code/Magento/Core/Model/Url/SecurityInfo.php b/app/code/Magento/Core/Model/Url/SecurityInfo.php index c3fd1df4219cd6df657521497445a09eed69e53b..eb87e17ac728c71ae350afe56ab363d514810684 100644 --- a/app/code/Magento/Core/Model/Url/SecurityInfo.php +++ b/app/code/Magento/Core/Model/Url/SecurityInfo.php @@ -25,7 +25,7 @@ */ namespace Magento\Core\Model\Url; -class SecurityInfo implements \Magento\Core\Model\Url\SecurityInfoInterface +class SecurityInfo implements \Magento\Url\SecurityInfoInterface { /** * Store manager diff --git a/app/code/Magento/Core/Model/Variable/Config.php b/app/code/Magento/Core/Model/Variable/Config.php index 7888563fc56c91a1fa7d91b9191737fbaca4eeaf..7b30dc760529ed6dfac8ae126b3fe9eb9db80227 100644 --- a/app/code/Magento/Core/Model/Variable/Config.php +++ b/app/code/Magento/Core/Model/Variable/Config.php @@ -41,15 +41,15 @@ class Config protected $_viewUrl; /** - * @var \Magento\Backend\Model\Url + * @var \Magento\Backend\Model\UrlInterface */ protected $_url; /** * @param \Magento\View\Url $viewUrl - * @param \Magento\Backend\Model\Url $url + * @param \Magento\Backend\Model\UrlInterface $url */ - public function __construct(\Magento\View\Url $viewUrl, \Magento\Backend\Model\Url $url) + public function __construct(\Magento\View\Url $viewUrl, \Magento\Backend\Model\UrlInterface $url) { $this->_viewUrl = $viewUrl; $this->_url = $url; diff --git a/app/code/Magento/Core/Model/View/Design.php b/app/code/Magento/Core/Model/View/Design.php index 97eb9b1cab5910fcb0fecb92bf2d6b28f8c1e567..be1d006551e124fee483f57d7dc813dd31c94dc4 100644 --- a/app/code/Magento/Core/Model/View/Design.php +++ b/app/code/Magento/Core/Model/View/Design.php @@ -71,7 +71,7 @@ class Design implements \Magento\View\DesignInterface protected $_themeFactory; /** - * @var \Magento\Core\Model\Config + * @var \Magento\App\ConfigInterface */ protected $_config; @@ -93,7 +93,7 @@ class Design implements \Magento\View\DesignInterface /** * @param \Magento\Core\Model\StoreManagerInterface $storeManager * @param \Magento\View\Design\Theme\FlyweightFactory $flyweightFactory - * @param \Magento\Core\Model\ConfigInterface $config + * @param \Magento\App\ConfigInterface $config * @param \Magento\Core\Model\Store\ConfigInterface $storeConfig * @param \Magento\Core\Model\ThemeFactory $themeFactory * @param \Magento\Core\Model\App $app @@ -103,7 +103,7 @@ class Design implements \Magento\View\DesignInterface public function __construct( \Magento\Core\Model\StoreManagerInterface $storeManager, \Magento\View\Design\Theme\FlyweightFactory $flyweightFactory, - \Magento\Core\Model\ConfigInterface $config, + \Magento\App\ConfigInterface $config, \Magento\Core\Model\Store\ConfigInterface $storeConfig, \Magento\Core\Model\ThemeFactory $themeFactory, \Magento\Core\Model\App $app, diff --git a/app/code/Magento/Core/Model/Website.php b/app/code/Magento/Core/Model/Website.php index ad989ed9176d589ef6d83cc5be9d71e83e3a989f..cd404f36c567a9c1f6ce852121006da511741295 100644 --- a/app/code/Magento/Core/Model/Website.php +++ b/app/code/Magento/Core/Model/Website.php @@ -183,7 +183,7 @@ class Website extends \Magento\Core\Model\AbstractModel * @param \Magento\Core\Model\Context $context * @param \Magento\Core\Model\Registry $registry * @param \Magento\Core\Model\Resource\Config\Data $configDataResource - * @param \Magento\Core\Model\Config $coreConfig + * @param \Magento\App\ConfigInterface $coreConfig * @param \Magento\Core\Model\StoreFactory $storeFactory * @param \Magento\Core\Model\Store\GroupFactory $storeGroupFactory * @param \Magento\Core\Model\WebsiteFactory $websiteFactory @@ -198,7 +198,7 @@ class Website extends \Magento\Core\Model\AbstractModel \Magento\Core\Model\Context $context, \Magento\Core\Model\Registry $registry, \Magento\Core\Model\Resource\Config\Data $configDataResource, - \Magento\Core\Model\Config $coreConfig, + \Magento\App\ConfigInterface $coreConfig, \Magento\Core\Model\StoreFactory $storeFactory, \Magento\Core\Model\Store\GroupFactory $storeGroupFactory, \Magento\Core\Model\WebsiteFactory $websiteFactory, diff --git a/app/code/Magento/Core/etc/di.xml b/app/code/Magento/Core/etc/di.xml index 2d878c8d39f609f86ee2a37d701f0bedbff4d0ae..6bbc5c1ce0898f83b8e354bb8992cb8a9063a29e 100644 --- a/app/code/Magento/Core/etc/di.xml +++ b/app/code/Magento/Core/etc/di.xml @@ -32,8 +32,9 @@ <preference for="Magento\Authorization\RoleLocator" type="Magento\Authorization\RoleLocator\DefaultRoleLocator" /> <preference for="Magento\Session\SessionManagerInterface" type="Magento\Core\Model\Session" /> <preference for="Magento\Core\Model\LocaleInterface" type="Magento\Core\Model\Locale" /> - <preference for="Magento\View\Asset\MergeStrategyInterface" type="Magento\View\Asset\MergeStrategy\Direct" /> - <preference for="Magento\Core\Model\ConfigInterface" type="Magento\Core\Model\Config" /> + <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\PubSub\Event\QueueWriterInterface" type="Magento\PubSub\Event\QueueWriter" /> @@ -58,23 +59,38 @@ <preference for="Magento\Core\Model\Translate\InlineInterface" type="Magento\Core\Model\Translate\Inline" /> <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" /> + <preference for="Magento\Url\QueryParamsResolverInterface" type="Magento\Url\QueryParamsResolver" /> + <preference for="Magento\Url\ScopeResolverInterface" type="Magento\Core\Model\Url\ScopeResolver" /> + <preference for="Magento\Url\SecurityInfoInterface" type="Magento\Core\Model\Url\SecurityInfo" /> + <preference for="Magento\Mview\ConfigInterface" type="Magento\Mview\Config" /> + <preference for="Magento\Mview\ViewInterface" type="Magento\Mview\View" /> + <preference for="Magento\Mview\ProcessorInterface" type="Magento\Mview\Processor" /> + <preference for="Magento\Mview\View\StateInterface" type="Magento\Core\Model\Mview\View\State" /> + <preference for="Magento\Mview\View\State\CollectionInterface" type="Magento\Core\Model\Resource\Mview\View\State\Collection" /> + <preference for="Magento\Mview\View\CollectionInterface" type="Magento\Mview\View\Collection" /> + <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" /> <type name="Magento\App\DefaultPath\DefaultPath"> <param name="parts"> - <value> - <module>core</module> - <controller>index</controller> - <action>index</action> - </value> + <array> + <item key="module"><value>core</value></item> + <item key="controller"><value>index</value></item> + <item key="action"><value>index</value></item> + </array> </param> </type> <type name="Magento\App\AreaList"> <param name="areas"> - <value> - <frontend> - <frontName /> - <router>standard</router> - </frontend> - </value> + <array> + <item key="frontend"> + <array> + <item key="frontName"><value/></item> + <item key="router"><value>standard</value></item> + </array> + </item> + </array> </param> <param name="default"> <value>frontend</value> @@ -97,7 +113,7 @@ <value type="argument">Magento\Core\Model\Store::CUSTOM_ENTRY_POINT_PARAM</value> </param> <param name="url"> - <instance type="Magento\Core\Model\Url" shared="false"/> + <instance type="Magento\UrlInterface" shared="false"/> </param> </type> <type name="Magento\Core\Model\Acl\Cache"> @@ -113,9 +129,9 @@ <value>app_</value> </param> <param name="cacheTags"> - <value> - <storeTag type="const">Magento\Core\Model\Website::CACHE_TAG</storeTag> - </value> + <array> + <item key="storeTag"><value type="const">Magento\Core\Model\Website::CACHE_TAG</value></item> + </array> </param> <param name="cacheLifetime"> <value type="bool">false</value> @@ -129,9 +145,9 @@ <value>app_</value> </param> <param name="cacheTags"> - <value> - <storeTag type="const">Magento\Core\Model\Store\Group::CACHE_TAG</storeTag> - </value> + <array> + <item key="storeTag"><value type="const">Magento\Core\Model\Store\Group::CACHE_TAG</value></item> + </array> </param> <param name="cacheLifetime"> <value type="bool">false</value> @@ -145,9 +161,9 @@ <value>app_</value> </param> <param name="cacheTags"> - <value> - <storeTag type="const">Magento\Core\Model\Store::CACHE_TAG</storeTag> - </value> + <array> + <item key="storeTag"><value type="const">Magento\Core\Model\Store::CACHE_TAG</value></item> + </array> </param> <param name="cacheLifetime"> <value type="bool">false</value> @@ -170,11 +186,6 @@ </type> <type name="Magento\View\Asset\Collection" shared="false" /> <type name="Magento\Core\Model\Theme\Collection" shared="false" /> - <type name="Magento\Core\Model\Observer"> - <param name="config"> - <instance type="Magento\Core\Model\Config" /> - </param> - </type> <type name="Magento\Core\Model\Layout\Merge"> <param name="fileSource"> <instance type="Magento\View\Layout\File\Source\Aggregated" /> @@ -284,29 +295,31 @@ </type> <type name="Magento\App\Router\NoRouteHandlerList"> <param name="handlerClassesList"> - <value> - <default> - <instance>Magento\Core\App\Router\NoRouteHandler</instance> - <sortOrder>100</sortOrder> - </default> - </value> + <array> + <item key="default"> + <array> + <item key="instance"><value>Magento\Core\App\Router\NoRouteHandler</value></item> + <item key="sortOrder"><value>100</value></item> + </array> + </item> + </array> </param> </type> <type name="Magento\Core\Model\Session\Validator"> <param name="skippedUserAgentList"> - <value> - <flash>Shockwave Flash</flash> - <flash_mac><![CDATA[Adobe Flash Player\s{1,}\w{1,10}]]></flash_mac> - </value> + <array> + <item key="flash"><value>Shockwave Flash</value></item> + <item key="flash_mac"><value><![CDATA[Adobe Flash Player\s{1,}\w{1,10}]]></value></item> + </array> </param> </type> <type name="Magento\Core\Model\View\Design"> <param name="themes"> - <value> - <frontend>magento_plushe</frontend> - <adminhtml>magento_backend</adminhtml> - <install>magento_basic</install> - </value> + <array> + <item key="frontend"><value>magento_plushe</value></item> + <item key="adminhtml"><value>magento_backend</value></item> + <item key="install"><value>magento_basic</value></item> + </array> </param> </type> <type name="Magento\View\Publisher"> @@ -389,7 +402,7 @@ </type> <type name="Magento\App\Helper\Context"> <param name="urlBuilder"> - <instance type="Magento\Core\Model\Url\Proxy" /> + <instance type="Magento\UrlInterface\Proxy" /> </param> <param name='httpRequest'> <instance type="Magento\App\Request\Http\Proxy" /> @@ -408,9 +421,9 @@ <type name="Magento\View\TemplateEngineFactory"> <plugin name="debug_hints" type="Magento\Core\Model\TemplateEngine\Plugin\DebugHints" sortOrder="10"/> <param name="engines"> - <value> - <phtml>Magento\View\TemplateEngine\Php</phtml> - </value> + <array> + <item key="phtml"><value>Magento\View\TemplateEngine\Php</value></item> + </array> </param> </type> <type name="\Magento\Image"> @@ -447,7 +460,7 @@ </type> <type name="Magento\Core\Model\Store\Storage\Db"> <param name="url"> - <instance type="Magento\Backend\Model\Url\Proxy" /> + <instance type="Magento\Backend\Model\UrlInterface\Proxy" /> </param> </type> <type name="Magento\Core\Model\App"> @@ -502,4 +515,41 @@ <type name="Magento\View\Asset\MergeService"> <plugin name="cleanMergedJsCss" type="Magento\Core\Model\Asset\Plugin\CleanMergedJsCss"/> </type> + <type name="Magento\Core\Model\Url\ScopeResolver"> + <param name="areaCode"> + <value>frontend</value> + </param> + </type> + <type name="Magento\Less\PreProcessor\Instruction\MagentoImport"> + <param name="fileSource"> + <instance type="Magento\Less\File\Source\Aggregated" /> + </param> + </type> + <type name="Magento\Less\File\Source\Aggregated"> + <param name="libraryFiles"> + <instance type="Magento\Less\File\Source\Library" /> + </param> + <param name="baseFiles"> + <instance type="Magento\Less\File\Source\Base" /> + </param> + <param name="themeFiles"> + <instance type="Magento\Less\File\Source\Theme" /> + </param> + </type> + <type name="Magento\Less\PreProcessor"> + <param name="preProcessors"> + <array> + <item key="import"> + <array> + <item key="class"><value>Magento\Less\PreProcessor\Instruction\Import</value></item> + </array> + </item> + <item key="magento_import"> + <array> + <item key="class"><value>Magento\Less\PreProcessor\Instruction\MagentoImport</value></item> + </array> + </item> + </array> + </param> + </type> </config> diff --git a/app/code/Magento/Core/etc/frontend/di.xml b/app/code/Magento/Core/etc/frontend/di.xml index 9522ee1b77dcfefc2deee62c6c3a5fac2203b729..9b1c51a156593e2216706df9c0c7a612cf36b1ed 100644 --- a/app/code/Magento/Core/etc/frontend/di.xml +++ b/app/code/Magento/Core/etc/frontend/di.xml @@ -43,18 +43,22 @@ </type> <type name="Magento\App\RouterList" shared="true"> <param name="routerList"> - <value> - <standard> - <instance>Magento\Core\App\Router\Base</instance> - <disable type="bool">false</disable> - <sortOrder>20</sortOrder> - </standard> - <default> - <instance>Magento\App\Router\DefaultRouter</instance> - <disable type="bool">false</disable> - <sortOrder>100</sortOrder> - </default> - </value> + <array> + <item key="standard"> + <array> + <item key="instance"><value>Magento\Core\App\Router\Base</value></item> + <item key="disable"><value type="bool">false</value></item> + <item key="sortOrder"><value>20</value></item> + </array> + </item> + <item key="default"> + <array> + <item key="instance"><value>Magento\App\Router\DefaultRouter</value></item> + <item key="disable"><value type="bool">false</value></item> + <item key="sortOrder"><value>100</value></item> + </array> + </item> + </array> </param> </type> </config> diff --git a/app/code/Magento/Core/etc/module.xml b/app/code/Magento/Core/etc/module.xml index 2b5c4d33fbca60a2e6a0724cf60b10b823911f1f..abc28f2dcca2a73bfa6137113e47533a1c7c66f6 100755 --- a/app/code/Magento/Core/etc/module.xml +++ b/app/code/Magento/Core/etc/module.xml @@ -24,7 +24,7 @@ */ --> <config> - <module name="Magento_Core" version="1.6.0.15" active="true"> + <module name="Magento_Core" version="1.6.0.16" active="true"> <depends> <module name="Magento_Backend"/> <module name="Magento_Directory"/> @@ -41,7 +41,6 @@ <module name="Magento_GoogleAnalytics"/> <module name="Magento_GoogleCheckout"/> <module name="Magento_ImportExport"/> - <module name="Magento_PaypalUk"/> <module name="Magento_ProductAlert"/> <module name="Magento_SalesRule"/> <module name="Magento_Eav"/> diff --git a/app/code/Magento/Core/sql/core_setup/upgrade-1.6.0.15-1.6.0.16.php b/app/code/Magento/Core/sql/core_setup/upgrade-1.6.0.15-1.6.0.16.php new file mode 100644 index 0000000000000000000000000000000000000000..8cb8fd0eb01f95f35eb7647c8b9a2419920a62f3 --- /dev/null +++ b/app/code/Magento/Core/sql/core_setup/upgrade-1.6.0.15-1.6.0.16.php @@ -0,0 +1,63 @@ +<?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_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) + */ + +/* @var $installer \Magento\Core\Model\Resource\Setup */ +$installer = $this; + +$installer->startSetup(); + +/** + * Create table 'mview_state' + */ +$table = $installer->getConnection() + ->newTable($installer->getTable('mview_state')) + ->addColumn('state_id', \Magento\DB\Ddl\Table::TYPE_INTEGER, null, array( + 'identity' => true, + 'unsigned' => true, + 'nullable' => false, + 'primary' => true, + ), 'View State Id') + ->addColumn('view_id', \Magento\DB\Ddl\Table::TYPE_TEXT, 255, array( + ), 'View Id') + ->addColumn('mode', \Magento\DB\Ddl\Table::TYPE_TEXT, 16, array( + 'default' => \Magento\Mview\View\StateInterface::MODE_DISABLED, + ), 'View Mode') + ->addColumn('status', \Magento\DB\Ddl\Table::TYPE_TEXT, 16, array( + 'default' => \Magento\Mview\View\StateInterface::STATUS_IDLE, + ), 'View Status') + ->addColumn('updated', \Magento\DB\Ddl\Table::TYPE_DATETIME, null, array( + ), 'View updated time') + ->addColumn('version_id', \Magento\DB\Ddl\Table::TYPE_INTEGER, null, array( + 'unsigned' => true, + ), 'View Version Id') + ->addIndex($installer->getIdxName('mview_state', array('view_id')), + array('view_id')) + ->addIndex($installer->getIdxName('mview_state', array('mode')), + array('mode')) + ->setComment('View State'); +$installer->getConnection()->createTable($table); + +$installer->endSetup(); diff --git a/app/code/Magento/Core/view/frontend/logo_email.gif b/app/code/Magento/Core/view/frontend/logo_email.gif deleted file mode 100644 index a4d941679e111f60e1280207683983e9cd0959d9..0000000000000000000000000000000000000000 Binary files a/app/code/Magento/Core/view/frontend/logo_email.gif and /dev/null differ diff --git a/app/code/Magento/Cron/App/Cron/Plugin/ApplicationInitializer.php b/app/code/Magento/Cron/App/Cron/Plugin/ApplicationInitializer.php index cf657cc16276894de23e55f0af1fd69d9ba4a6be..61a74544e7c0e6a5b58d8ecaccdb540b580c1c00 100644 --- a/app/code/Magento/Cron/App/Cron/Plugin/ApplicationInitializer.php +++ b/app/code/Magento/Cron/App/Cron/Plugin/ApplicationInitializer.php @@ -25,22 +25,30 @@ */ namespace Magento\Cron\App\Cron\Plugin; -use \Magento\Core\Model\AppInterface; +use \Magento\AppInterface; class ApplicationInitializer { /** - * @var \Magento\Core\Model\AppInterface + * @var \Magento\AppInterface */ protected $_application; + /** + * @var \Magento\Session\SidResolverInterface + */ + protected $_sidResolver; + /** * @param AppInterface $application + * @param \Magento\Session\SidResolverInterface $sidResolver */ public function __construct( - AppInterface $application + AppInterface $application, + \Magento\Session\SidResolverInterface $sidResolver ) { $this->_application = $application; + $this->_sidResolver = $sidResolver; } /** @@ -51,7 +59,7 @@ class ApplicationInitializer */ public function beforeExecute(array $methodArguments) { - $this->_application->setUseSessionInUrl(false); + $this->_sidResolver->setUseSessionInUrl(false); $this->_application->requireInstalledInstance(); return $methodArguments; } diff --git a/app/code/Magento/Cron/Model/Config/Backend/Product/Alert.php b/app/code/Magento/Cron/Model/Config/Backend/Product/Alert.php index 49e6c52acb03dec0ed75013738bbb298692c32c2..e8388e13979dc7b3c6c48840082d05447c606831 100644 --- a/app/code/Magento/Cron/Model/Config/Backend/Product/Alert.php +++ b/app/code/Magento/Cron/Model/Config/Backend/Product/Alert.php @@ -59,7 +59,7 @@ class Alert extends \Magento\Core\Model\Config\Value * @param \Magento\Core\Model\Context $context * @param \Magento\Core\Model\Registry $registry * @param \Magento\Core\Model\StoreManagerInterface $storeManager - * @param \Magento\Core\Model\Config $config + * @param \Magento\App\ConfigInterface $config * @param \Magento\Core\Model\Config\ValueFactory $configValueFactory * @param \Magento\Core\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection @@ -70,7 +70,7 @@ class Alert extends \Magento\Core\Model\Config\Value \Magento\Core\Model\Context $context, \Magento\Core\Model\Registry $registry, \Magento\Core\Model\StoreManagerInterface $storeManager, - \Magento\Core\Model\Config $config, + \Magento\App\ConfigInterface $config, \Magento\Core\Model\Config\ValueFactory $configValueFactory, \Magento\Core\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, diff --git a/app/code/Magento/Cron/Model/Config/Backend/Sitemap.php b/app/code/Magento/Cron/Model/Config/Backend/Sitemap.php index 3172c2222e65d209416cc9cfea22af7686ed350f..29b43deeaa64e998fdb95154bb97f39922cc3d04 100644 --- a/app/code/Magento/Cron/Model/Config/Backend/Sitemap.php +++ b/app/code/Magento/Cron/Model/Config/Backend/Sitemap.php @@ -59,7 +59,7 @@ class Sitemap extends \Magento\Core\Model\Config\Value * @param \Magento\Core\Model\Context $context * @param \Magento\Core\Model\Registry $registry * @param \Magento\Core\Model\StoreManagerInterface $storeManager - * @param \Magento\Core\Model\Config $config + * @param \Magento\App\ConfigInterface $config * @param \Magento\Core\Model\Config\ValueFactory $configValueFactory * @param \Magento\Core\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection @@ -70,7 +70,7 @@ class Sitemap extends \Magento\Core\Model\Config\Value \Magento\Core\Model\Context $context, \Magento\Core\Model\Registry $registry, \Magento\Core\Model\StoreManagerInterface $storeManager, - \Magento\Core\Model\Config $config, + \Magento\App\ConfigInterface $config, \Magento\Core\Model\Config\ValueFactory $configValueFactory, \Magento\Core\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, diff --git a/app/code/Magento/Cron/Model/Observer.php b/app/code/Magento/Cron/Model/Observer.php index 1a9d259e1b3558f323fd10fd8b12ac4f5dd78c7f..ba2387890669672eeaa02aeade1bf3518639aa19 100644 --- a/app/code/Magento/Cron/Model/Observer.php +++ b/app/code/Magento/Cron/Model/Observer.php @@ -75,13 +75,13 @@ class Observer * Initialize parameters * * @param \Magento\ObjectManager $objectManager - * @param \Magento\Core\Model\AppInterface $app + * @param \Magento\AppInterface $app * @param \Magento\Cron\Model\ConfigInterface $config * @param \Magento\Core\Model\Store\Config $coreStoreConfig */ public function __construct( \Magento\ObjectManager $objectManager, - \Magento\Core\Model\AppInterface $app, + \Magento\AppInterface $app, \Magento\Cron\Model\ConfigInterface $config, \Magento\Core\Model\Store\Config $coreStoreConfig ) { diff --git a/app/code/Magento/CurrencySymbol/Model/System/Currencysymbol.php b/app/code/Magento/CurrencySymbol/Model/System/Currencysymbol.php index e10414df8559bba757157c0f1b5acb20a4da9de4..b51223d0cf51137aca43386af8f2e913e57fd18c 100644 --- a/app/code/Magento/CurrencySymbol/Model/System/Currencysymbol.php +++ b/app/code/Magento/CurrencySymbol/Model/System/Currencysymbol.php @@ -115,7 +115,7 @@ class Currencysymbol protected $_locale; /** - * @var \Magento\Core\Model\Config + * @var \Magento\App\ReinitableConfigInterface */ protected $_coreConfig; @@ -128,7 +128,7 @@ class Currencysymbol /** * @param \Magento\Core\Model\Store\Config $coreStoreConfig - * @param \Magento\Core\Model\Config $coreConfig + * @param \Magento\App\ReinitableConfigInterface $coreConfig * @param \Magento\Backend\Model\Config\Factory $configFactory * @param \Magento\App\Cache\TypeListInterface $cacheTypeList * @param \Magento\Core\Model\StoreManagerInterface $storeManager @@ -138,7 +138,7 @@ class Currencysymbol */ public function __construct( \Magento\Core\Model\Store\Config $coreStoreConfig, - \Magento\Core\Model\Config $coreConfig, + \Magento\App\ReinitableConfigInterface $coreConfig, \Magento\Backend\Model\Config\Factory $configFactory, \Magento\App\Cache\TypeListInterface $cacheTypeList, \Magento\Core\Model\StoreManagerInterface $storeManager, diff --git a/app/code/Magento/Customer/Block/Account/AuthorizationLink.php b/app/code/Magento/Customer/Block/Account/AuthorizationLink.php index 3e2ea17d6633d2e2f5186668605bcbedf5aa13d2..37c37c3ab83f994860856eae71b26a18b00e4701 100644 --- a/app/code/Magento/Customer/Block/Account/AuthorizationLink.php +++ b/app/code/Magento/Customer/Block/Account/AuthorizationLink.php @@ -41,22 +41,30 @@ class AuthorizationLink extends \Magento\View\Element\Html\Link */ protected $_customerHelper; + /** + * @var \Magento\Core\Helper\PostData + */ + protected $_postDataHelper; + /** * @param \Magento\View\Element\Template\Context $context * @param \Magento\Customer\Model\Session $session * @param \Magento\Customer\Helper\Data $customerHelper + * @param \Magento\Core\Helper\PostData $postDataHelper * @param array $data */ public function __construct( \Magento\View\Element\Template\Context $context, \Magento\Customer\Model\Session $session, \Magento\Customer\Helper\Data $customerHelper, + \Magento\Core\Helper\PostData $postDataHelper, array $data = array() ) { parent::__construct($context, $data); $this->_customerSession = $session; $this->_customerHelper = $customerHelper; $this->_isScopePrivate = true; + $this->_postDataHelper = $postDataHelper; } /** @@ -77,4 +85,24 @@ class AuthorizationLink extends \Magento\View\Element\Html\Link return $this->_customerSession->isLoggedIn() ? __('Log Out') : __('Log In'); } + /** + * Retrieve params for post request + * + * @return string + */ + public function getPostParams() + { + return $this->_postDataHelper->getPostData($this->getHref()); + } + + /** + * Is logged in + * + * @return bool + */ + public function isLoggedIn() + { + return $this->_customerSession->isLoggedIn(); + } + } diff --git a/app/code/Magento/Customer/Block/Address/Edit.php b/app/code/Magento/Customer/Block/Address/Edit.php index ea81b4e0d19633e40ee314a81aea72c99020ae5f..9f3a14cc88ae7f286243318534b242b5ba887309 100644 --- a/app/code/Magento/Customer/Block/Address/Edit.php +++ b/app/code/Magento/Customer/Block/Address/Edit.php @@ -36,7 +36,7 @@ class Edit extends \Magento\Directory\Block\Data protected $_regionCollection; /** - * @var \Magento\Core\Model\Config + * @var \Magento\App\ConfigInterface */ protected $_config; @@ -57,7 +57,7 @@ class Edit extends \Magento\Directory\Block\Data * @param \Magento\App\Cache\Type\Config $configCacheType * @param \Magento\Directory\Model\Resource\Region\CollectionFactory $regionCollectionFactory * @param \Magento\Directory\Model\Resource\Country\CollectionFactory $countryCollectionFactory - * @param \Magento\Core\Model\Config $config + * @param \Magento\App\ConfigInterface $config * @param \Magento\Customer\Model\Session $customerSession * @param \Magento\Customer\Model\AddressFactory $addressFactory * @param array $data @@ -69,7 +69,7 @@ class Edit extends \Magento\Directory\Block\Data \Magento\App\Cache\Type\Config $configCacheType, \Magento\Directory\Model\Resource\Region\CollectionFactory $regionCollectionFactory, \Magento\Directory\Model\Resource\Country\CollectionFactory $countryCollectionFactory, - \Magento\Core\Model\Config $config, + \Magento\App\ConfigInterface $config, \Magento\Customer\Model\Session $customerSession, \Magento\Customer\Model\AddressFactory $addressFactory, array $data = array() diff --git a/app/code/Magento/Customer/Block/Address/Renderer/DefaultRenderer.php b/app/code/Magento/Customer/Block/Address/Renderer/DefaultRenderer.php index 46406a31ba254fdcb4670bb675003b5eca1b3a3b..ddccada0e86f99ac59865c212d8455cde0664bc5 100644 --- a/app/code/Magento/Customer/Block/Address/Renderer/DefaultRenderer.php +++ b/app/code/Magento/Customer/Block/Address/Renderer/DefaultRenderer.php @@ -57,20 +57,43 @@ class DefaultRenderer */ protected $_attrDataFactory; + /** + * @var \Magento\Customer\Model\Metadata\ElementFactory + */ + protected $_attributeMetadataFactory; + + /** + * @var \Magento\Directory\Model\CountryFactory + */ + protected $_countryFactory; + + /** + * @var \Magento\Customer\Service\V1\CustomerMetadataServiceInterface + */ + protected $_customerMetadataService; + /** * @param \Magento\View\Element\Context $context * @param \Magento\Customer\Helper\Address $customerAddress * @param \Magento\Eav\Model\AttributeDataFactory $attrDataFactory + * @param \Magento\Directory\Model\CountryFactory $countryFactory, + * @param \Magento\Customer\Service\V1\CustomerMetadataServiceInterface $customerMetadataService * @param array $data */ public function __construct( \Magento\View\Element\Context $context, \Magento\Customer\Helper\Address $customerAddress, \Magento\Eav\Model\AttributeDataFactory $attrDataFactory, + \Magento\Directory\Model\CountryFactory $countryFactory, + \Magento\Customer\Model\Metadata\ElementFactory $attributeMetadataFactory, + \Magento\Customer\Service\V1\CustomerMetadataServiceInterface $customerMetadataService, array $data = array() ) { $this->_customerAddress = $customerAddress; $this->_attrDataFactory = $attrDataFactory; + $this->_countryFactory = $countryFactory; + $this->_attributeMetadataFactory = $attributeMetadataFactory; + $this->_customerMetadataService = $customerMetadataService; parent::__construct($context, $data); $this->_isScopePrivate = true; } @@ -97,7 +120,12 @@ class DefaultRenderer return $this; } - public function getFormat(\Magento\Customer\Model\Address\AbstractAddress $address=null) + /** + * @deprecated All new code should use renderArray based on Metadata service + * @param \Magento\Customer\Model\Address\AbstractAddress $address + * @return string + */ + public function getFormat(\Magento\Customer\Model\Address\AbstractAddress $address = null) { $countryFormat = is_null($address) ? false @@ -109,10 +137,12 @@ class DefaultRenderer /** * Render address * + * @deprecated All new code should use renderArray based on Metadata service * @param \Magento\Customer\Model\Address\AbstractAddress $address + * @param string|null $format * @return string */ - public function render(\Magento\Customer\Model\Address\AbstractAddress $address, $format=null) + public function render(\Magento\Customer\Model\Address\AbstractAddress $address, $format = null) { switch ($this->getType()->getCode()) { case 'html': @@ -165,4 +195,81 @@ class DefaultRenderer return $this->filterManager->template($format, array('variables' => $data)); } + + /** + * Get a format object for a given address attributes, based on the type set earlier. + * + * @param null|array $addressAttributes + * @return string + */ + public function getFormatArray($addressAttributes = null) + { + $countryFormat = false; + if ($addressAttributes && isset($addressAttributes['country_id'])) { + /** @var \Magento\Directory\Model\Country $country */ + $country = $this->_countryFactory->create()->load($addressAttributes['country_id']); + $countryFormat = $country->getFormat($this->getType()->getCode()); + } + $format = $countryFormat ? $countryFormat->getFormat() : $this->getType()->getDefaultFormat(); + return $format; + } + + /** + * Render address by attribute array + * + * @param array $addressAttributes + * @param \Magento\Directory\Model\Country\Format $format + * @return string + */ + public function renderArray($addressAttributes, $format = null) + { + switch ($this->getType()->getCode()) { + case 'html': + $dataFormat = \Magento\Eav\Model\AttributeDataFactory::OUTPUT_FORMAT_HTML; + break; + case 'pdf': + $dataFormat = \Magento\Eav\Model\AttributeDataFactory::OUTPUT_FORMAT_PDF; + break; + case 'oneline': + $dataFormat = \Magento\Eav\Model\AttributeDataFactory::OUTPUT_FORMAT_ONELINE; + break; + default: + $dataFormat = \Magento\Eav\Model\AttributeDataFactory::OUTPUT_FORMAT_TEXT; + break; + } + + $attributesMetadata = $this->_customerMetadataService->getAllAddressAttributeMetadata(); + $data = array(); + foreach ($attributesMetadata as $attributeMetadata) { + if (!$attributeMetadata->isVisible()) { + continue; + } + $attributeCode = $attributeMetadata->getAttributeCode(); + if ($attributeCode == 'country_id' && isset($addressAttributes['country_id'])) { + $data['country'] = $this->_countryFactory->create(['id' => $addressAttributes['country_id']])->getName(); + } elseif ($attributeCode == 'region' && isset($addressAttributes['region'])) { + $data['region'] = __($addressAttributes['region']['region']); + } elseif (isset($addressAttributes[$attributeCode])) { + $value = $addressAttributes[$attributeCode]; + $dataModel = $this->_attributeMetadataFactory->create($attributeMetadata, $value, 'customer_address'); + $value = $dataModel->outputValue($dataFormat); + if ($attributeMetadata->getFrontendInput() == 'multiline') { + $values = $dataModel->outputValue(\Magento\Eav\Model\AttributeDataFactory::OUTPUT_FORMAT_ARRAY); + // explode lines + foreach ($values as $k => $v) { + $key = sprintf('%s%d', $attributeCode, $k + 1); + $data[$key] = $v; + } + } + $data[$attributeCode] = $value; + } + } + if ($this->getType()->getEscapeHtml()) { + foreach ($data as $key => $value) { + $data[$key] = $this->escapeHtml($value); + } + } + $format = !is_null($format) ? $format : $this->getFormatArray($addressAttributes); + return $this->filterManager->template($format, array('variables' => $data)); + } } diff --git a/app/code/Magento/Customer/Block/Address/Renderer/RendererInterface.php b/app/code/Magento/Customer/Block/Address/Renderer/RendererInterface.php index 3fd65aac38e91a278de40079a3bf2315418a300a..532b0ab8ccd31fd48a6942332c5bccccc9c05eaa 100644 --- a/app/code/Magento/Customer/Block/Address/Renderer/RendererInterface.php +++ b/app/code/Magento/Customer/Block/Address/Renderer/RendererInterface.php @@ -53,8 +53,26 @@ interface RendererInterface /** * Render address * + * @deprecated All new code should use renderArray based on Metadata service * @param \Magento\Customer\Model\Address\AbstractAddress $address * @return mixed */ function render(\Magento\Customer\Model\Address\AbstractAddress $address); + + /** + * Get a format object for a given address attributes, based on the type set earlier. + * + * @param null|array $addressAttributes + * @return \Magento\Directory\Model\Country\Format + */ + public function getFormatArray($addressAttributes = null); + + /** + * Render address by attribute array + * + * @param array $addressAttributes + * @param \Magento\Directory\Model\Country\Format $format + * @return string + */ + public function renderArray($addressAttributes, $format = null); } diff --git a/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/Addresses.php b/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/Addresses.php index 6e743463d4076863b62293c961cdcc28e0a685a9..70e9d59dceacc24f97f7332910eee54b08521b9b 100644 --- a/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/Addresses.php +++ b/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/Addresses.php @@ -72,7 +72,7 @@ class Addresses extends \Magento\Backend\Block\Widget\Form\Generic * @param \Magento\Backend\Helper\Addresses $adminhtmlAddresses * @param \Magento\Customer\Helper\Data $customerHelper * @param array $data - * + * * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ public function __construct( diff --git a/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/Cart.php b/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/Cart.php index c4f95be4bf26908cfdc3056484d82d970aeaf712..41f0bead10dfbda539bcf2f8c7e372ff79803c5d 100644 --- a/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/Cart.php +++ b/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/Cart.php @@ -57,7 +57,6 @@ class Cart extends \Magento\Backend\Block\Widget\Grid\Extended /** * @param \Magento\Backend\Block\Template\Context $context - * @param \Magento\Core\Model\Url $urlModel * @param \Magento\Backend\Helper\Data $backendHelper * @param \Magento\Sales\Model\QuoteFactory $quoteFactory * @param \Magento\Data\CollectionFactory $dataCollectionFactory @@ -66,7 +65,6 @@ class Cart extends \Magento\Backend\Block\Widget\Grid\Extended */ public function __construct( \Magento\Backend\Block\Template\Context $context, - \Magento\Core\Model\Url $urlModel, \Magento\Backend\Helper\Data $backendHelper, \Magento\Sales\Model\QuoteFactory $quoteFactory, \Magento\Data\CollectionFactory $dataCollectionFactory, @@ -76,7 +74,7 @@ class Cart extends \Magento\Backend\Block\Widget\Grid\Extended $this->_dataCollectionFactory = $dataCollectionFactory; $this->_coreRegistry = $coreRegistry; $this->_quoteFactory = $quoteFactory; - parent::__construct($context, $urlModel, $backendHelper, $data); + parent::__construct($context, $backendHelper, $data); } protected function _construct() diff --git a/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/Newsletter/Grid.php b/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/Newsletter/Grid.php index ef91eae724645cfaccccca0bd01e478a603167be..e48a50a07a3618ceae8bf32c59fde33df0b5d1f4 100644 --- a/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/Newsletter/Grid.php +++ b/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/Newsletter/Grid.php @@ -49,7 +49,6 @@ class Grid extends \Magento\Backend\Block\Widget\Grid\Extended /** * @param \Magento\Backend\Block\Template\Context $context - * @param \Magento\Core\Model\Url $urlModel * @param \Magento\Backend\Helper\Data $backendHelper * @param \Magento\Newsletter\Model\Resource\Queue\CollectionFactory $collectionFactory * @param \Magento\Core\Model\Registry $coreRegistry @@ -57,7 +56,6 @@ class Grid extends \Magento\Backend\Block\Widget\Grid\Extended */ public function __construct( \Magento\Backend\Block\Template\Context $context, - \Magento\Core\Model\Url $urlModel, \Magento\Backend\Helper\Data $backendHelper, \Magento\Newsletter\Model\Resource\Queue\CollectionFactory $collectionFactory, \Magento\Core\Model\Registry $coreRegistry, @@ -65,7 +63,7 @@ class Grid extends \Magento\Backend\Block\Widget\Grid\Extended ) { $this->_coreRegistry = $coreRegistry; $this->_collectionFactory = $collectionFactory; - parent::__construct($context, $urlModel, $backendHelper, $data); + parent::__construct($context, $backendHelper, $data); } protected function _construct() diff --git a/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/Orders.php b/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/Orders.php index 8b333e0d829f3e4d24ae8a082e7a9d2a531f0366..366135c44f4c5f98e11909202315057ac8f94077 100644 --- a/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/Orders.php +++ b/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/Orders.php @@ -56,7 +56,6 @@ class Orders extends \Magento\Backend\Block\Widget\Grid\Extended /** * @param \Magento\Backend\Block\Template\Context $context - * @param \Magento\Core\Model\Url $urlModel * @param \Magento\Backend\Helper\Data $backendHelper * @param \Magento\Sales\Model\Resource\Order\Grid\CollectionFactory $collectionFactory * @param \Magento\Sales\Helper\Reorder $salesReorder @@ -65,7 +64,6 @@ class Orders extends \Magento\Backend\Block\Widget\Grid\Extended */ public function __construct( \Magento\Backend\Block\Template\Context $context, - \Magento\Core\Model\Url $urlModel, \Magento\Backend\Helper\Data $backendHelper, \Magento\Sales\Model\Resource\Order\Grid\CollectionFactory $collectionFactory, \Magento\Sales\Helper\Reorder $salesReorder, @@ -75,7 +73,7 @@ class Orders extends \Magento\Backend\Block\Widget\Grid\Extended $this->_coreRegistry = $coreRegistry; $this->_salesReorder = $salesReorder; $this->_collectionFactory = $collectionFactory; - parent::__construct($context, $urlModel, $backendHelper, $data); + parent::__construct($context, $backendHelper, $data); } protected function _construct() diff --git a/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/View/Cart.php b/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/View/Cart.php index 8e11ba911302613d928cf74e8ef5ae573ab575be..13592e72bacbf6829733215071627ccc26a5b0d8 100644 --- a/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/View/Cart.php +++ b/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/View/Cart.php @@ -57,7 +57,6 @@ class Cart extends \Magento\Backend\Block\Widget\Grid\Extended /** * @param \Magento\Backend\Block\Template\Context $context - * @param \Magento\Core\Model\Url $urlModel * @param \Magento\Backend\Helper\Data $backendHelper * @param \Magento\Sales\Model\QuoteFactory $quoteFactory * @param \Magento\Data\CollectionFactory $dataCollectionFactory @@ -66,7 +65,6 @@ class Cart extends \Magento\Backend\Block\Widget\Grid\Extended */ public function __construct( \Magento\Backend\Block\Template\Context $context, - \Magento\Core\Model\Url $urlModel, \Magento\Backend\Helper\Data $backendHelper, \Magento\Sales\Model\QuoteFactory $quoteFactory, \Magento\Data\CollectionFactory $dataCollectionFactory, @@ -76,7 +74,7 @@ class Cart extends \Magento\Backend\Block\Widget\Grid\Extended $this->_dataCollectionFactory = $dataCollectionFactory; $this->_coreRegistry = $coreRegistry; $this->_quoteFactory = $quoteFactory; - parent::__construct($context, $urlModel, $backendHelper, $data); + parent::__construct($context, $backendHelper, $data); } protected function _construct() diff --git a/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/View/Orders.php b/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/View/Orders.php index d2a11e6d7df6123fab536d74b48ae0284ecd1a1b..842c508245385a9fbdb0ff58023e3dbc8beb5b35 100644 --- a/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/View/Orders.php +++ b/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/View/Orders.php @@ -49,7 +49,6 @@ class Orders extends \Magento\Backend\Block\Widget\Grid\Extended /** * @param \Magento\Backend\Block\Template\Context $context - * @param \Magento\Core\Model\Url $urlModel * @param \Magento\Backend\Helper\Data $backendHelper * @param \Magento\Sales\Model\Resource\Order\Grid\CollectionFactory $collectionFactory * @param \Magento\Core\Model\Registry $coreRegistry @@ -57,7 +56,6 @@ class Orders extends \Magento\Backend\Block\Widget\Grid\Extended */ public function __construct( \Magento\Backend\Block\Template\Context $context, - \Magento\Core\Model\Url $urlModel, \Magento\Backend\Helper\Data $backendHelper, \Magento\Sales\Model\Resource\Order\Grid\CollectionFactory $collectionFactory, \Magento\Core\Model\Registry $coreRegistry, @@ -65,7 +63,7 @@ class Orders extends \Magento\Backend\Block\Widget\Grid\Extended ) { $this->_coreRegistry = $coreRegistry; $this->_collectionFactory = $collectionFactory; - parent::__construct($context, $urlModel, $backendHelper, $data); + parent::__construct($context, $backendHelper, $data); } protected function _construct() diff --git a/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/View/Wishlist.php b/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/View/Wishlist.php index 2dcf806fe98216e34a460aa850def2bb3a6c9d3d..c0e0567366c9c5d04de2e3b9200cadea31c30c20 100644 --- a/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/View/Wishlist.php +++ b/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/View/Wishlist.php @@ -49,7 +49,6 @@ class Wishlist extends \Magento\Backend\Block\Widget\Grid\Extended /** * @param \Magento\Backend\Block\Template\Context $context - * @param \Magento\Core\Model\Url $urlModel * @param \Magento\Backend\Helper\Data $backendHelper * @param \Magento\Wishlist\Model\Resource\Item\CollectionFactory $collectionFactory * @param \Magento\Core\Model\Registry $coreRegistry @@ -57,7 +56,6 @@ class Wishlist extends \Magento\Backend\Block\Widget\Grid\Extended */ public function __construct( \Magento\Backend\Block\Template\Context $context, - \Magento\Core\Model\Url $urlModel, \Magento\Backend\Helper\Data $backendHelper, \Magento\Wishlist\Model\Resource\Item\CollectionFactory $collectionFactory, \Magento\Core\Model\Registry $coreRegistry, @@ -65,7 +63,7 @@ class Wishlist extends \Magento\Backend\Block\Widget\Grid\Extended ) { $this->_coreRegistry = $coreRegistry; $this->_collectionFactory = $collectionFactory; - parent::__construct($context, $urlModel, $backendHelper, $data); + parent::__construct($context, $backendHelper, $data); } /** diff --git a/app/code/Magento/Customer/Block/Adminhtml/Grid.php b/app/code/Magento/Customer/Block/Adminhtml/Grid.php index 4c7f3544b2344d16cc176ede9681c59ecc62b316..add8e677851188a3574d847a007b8a220d53b223 100644 --- a/app/code/Magento/Customer/Block/Adminhtml/Grid.php +++ b/app/code/Magento/Customer/Block/Adminhtml/Grid.php @@ -57,7 +57,6 @@ class Grid extends \Magento\Backend\Block\Widget\Grid\Extended /** * @param \Magento\Backend\Block\Template\Context $context - * @param \Magento\Core\Model\Url $urlModel * @param \Magento\Backend\Helper\Data $backendHelper * @param \Magento\Core\Model\System\Store $systemStore * @param \Magento\Customer\Model\Resource\Customer\CollectionFactory $customersFactory @@ -67,7 +66,6 @@ class Grid extends \Magento\Backend\Block\Widget\Grid\Extended */ public function __construct( \Magento\Backend\Block\Template\Context $context, - \Magento\Core\Model\Url $urlModel, \Magento\Backend\Helper\Data $backendHelper, \Magento\Core\Model\System\Store $systemStore, \Magento\Customer\Model\Resource\Customer\CollectionFactory $customersFactory, @@ -79,7 +77,7 @@ class Grid extends \Magento\Backend\Block\Widget\Grid\Extended $this->_systemStore = $systemStore; $this->_customersFactory = $customersFactory; $this->_groupsFactory = $groupsFactory; - parent::__construct($context, $urlModel, $backendHelper, $data); + parent::__construct($context, $backendHelper, $data); } protected function _construct() diff --git a/app/code/Magento/Customer/Controller/Account.php b/app/code/Magento/Customer/Controller/Account.php index 74d3b1129362a274bd92586c3a71eb45eb29d3d7..b8c2ca4a35ac5ebb9550b6cc2eca431f86d3e697 100644 --- a/app/code/Magento/Customer/Controller/Account.php +++ b/app/code/Magento/Customer/Controller/Account.php @@ -65,7 +65,7 @@ class Account extends \Magento\App\Action\Action protected $_customerSession; /** - * @var \Magento\Core\Model\UrlFactory + * @var \Magento\UrlFactory */ protected $_urlFactory; @@ -105,7 +105,7 @@ class Account extends \Magento\App\Action\Action * @param \Magento\App\Action\Context $context * @param \Magento\Core\Model\Registry $coreRegistry * @param \Magento\Customer\Model\Session $customerSession - * @param \Magento\Core\Model\UrlFactory $urlFactory + * @param \Magento\UrlFactory $urlFactory * @param \Magento\Customer\Model\CustomerFactory $customerFactory * @param \Magento\Customer\Model\FormFactory $formFactory * @param \Magento\Customer\Model\AddressFactory $addressFactory @@ -118,7 +118,7 @@ class Account extends \Magento\App\Action\Action \Magento\App\Action\Context $context, \Magento\Core\Model\Registry $coreRegistry, \Magento\Customer\Model\Session $customerSession, - \Magento\Core\Model\UrlFactory $urlFactory, + \Magento\UrlFactory $urlFactory, \Magento\Customer\Model\CustomerFactory $customerFactory, \Magento\Customer\Model\FormFactory $formFactory, \Magento\Customer\Model\AddressFactory $addressFactory, @@ -1015,7 +1015,7 @@ class Account extends \Magento\App\Action\Action } /** - * @return \Magento\Core\Model\Url + * @return \Magento\UrlInterface */ protected function _createUrl() { diff --git a/app/code/Magento/Customer/Controller/Address.php b/app/code/Magento/Customer/Controller/Address.php index d97364fa183490e0e3b41c2dfa1ab2c8f20798c0..3e973df1acb1cc9e8e9cea68d07120d2c33e9167 100644 --- a/app/code/Magento/Customer/Controller/Address.php +++ b/app/code/Magento/Customer/Controller/Address.php @@ -284,8 +284,8 @@ class Address extends \Magento\App\Action\Action */ protected function _buildUrl($route = '', $params = array()) { - /** @var \Magento\Core\Model\Url $urlBuilder */ - $urlBuilder = $this->_objectManager->create('Magento\Core\Model\Url'); + /** @var \Magento\UrlInterface $urlBuilder */ + $urlBuilder = $this->_objectManager->create('Magento\UrlInterface'); return $urlBuilder->getUrl($route, $params); } diff --git a/app/code/Magento/Customer/Controller/Adminhtml/Index.php b/app/code/Magento/Customer/Controller/Adminhtml/Index.php index ef0a546146e8dd0193342d708bc20cf60a62757c..62f59c44d9811bf85033c211dd8a3d94eec6d1dd 100644 --- a/app/code/Magento/Customer/Controller/Adminhtml/Index.php +++ b/app/code/Magento/Customer/Controller/Adminhtml/Index.php @@ -46,18 +46,53 @@ class Index extends \Magento\Backend\App\Action */ protected $_fileFactory; + /** + * @var \Magento\Customer\Model\CustomerFactory + */ + protected $_customerFactory = null; + + /** + * @var \Magento\Customer\Model\AddressFactory + */ + protected $_addressFactory = null; + + /** + * @var \Magento\Customer\Helper\Data + */ + protected $_dataHelper = null; + + /** + * Registry key where current customer DTO stored + * @todo switch to use ID instead and remove after refactoring of all occurrences + */ + const REGISTRY_CURRENT_CUSTOMER = 'current_customer'; + + /** + * Registry key where current customer ID is stored + */ + const REGISTRY_CURRENT_CUSTOMER_ID = 'current_customer_id'; + /** * @param \Magento\Backend\App\Action\Context $context * @param \Magento\Core\Model\Registry $coreRegistry * @param \Magento\App\Response\Http\FileFactory $fileFactory + * @param \Magento\Customer\Model\CustomerFactory $customerFactory + * @param \Magento\Customer\Model\AddressFactory $addressFactory + * @param \Magento\Customer\Helper\Data $helper */ public function __construct( \Magento\Backend\App\Action\Context $context, \Magento\Core\Model\Registry $coreRegistry, - \Magento\App\Response\Http\FileFactory $fileFactory + \Magento\App\Response\Http\FileFactory $fileFactory, + \Magento\Customer\Model\CustomerFactory $customerFactory, + \Magento\Customer\Model\AddressFactory $addressFactory, + \Magento\Customer\Helper\Data $helper ) { $this->_fileFactory = $fileFactory; $this->_coreRegistry = $coreRegistry; + $this->_customerFactory = $customerFactory; + $this->_addressFactory = $addressFactory; + $this->_dataHelper = $helper; parent::__construct($context); } @@ -78,7 +113,7 @@ class Index extends \Magento\Backend\App\Action $customer->load($customerId); } - $this->_coreRegistry->register('current_customer', $customer); + $this->_coreRegistry->register(self::REGISTRY_CURRENT_CUSTOMER, $customer); return $this; } @@ -135,7 +170,7 @@ class Index extends \Magento\Backend\App\Action $this->_setActiveMenu('Magento_Customer::customer_manage'); /* @var $customer \Magento\Customer\Model\Customer */ - $customer = $this->_coreRegistry->registry('current_customer'); + $customer = $this->_coreRegistry->registry(self::REGISTRY_CURRENT_CUSTOMER); // set entered data if was error when we do save $data = $this->_objectManager->get('Magento\Backend\Model\Session')->getCustomerData(true); @@ -212,7 +247,7 @@ class Index extends \Magento\Backend\App\Action public function deleteAction() { $this->_initCustomer(); - $customer = $this->_coreRegistry->registry('current_customer'); + $customer = $this->_coreRegistry->registry(self::REGISTRY_CURRENT_CUSTOMER); if ($customer->getId()) { try { $customer->delete(); @@ -236,39 +271,48 @@ class Index extends \Magento\Backend\App\Action if ($originalRequestData) { try { // optional fields might be set in request for future processing by observers in other modules - $accountData = $this->_extractCustomerData(); + $customerData = $this->_extractCustomerData(); $addressesData = $this->_extractCustomerAddressData(); - $request = $this->getRequest(); + $isExistingCustomer = (bool)$customerId; - $eventManager = $this->_eventManager; - $beforeSaveCallback = function ($customer) use ($request, $eventManager) { - $eventManager->dispatch('adminhtml_customer_prepare_save', array( - 'customer' => $customer, - 'request' => $request - )); - }; - $afterSaveCallback = function ($customer) use ($request, $eventManager) { - $eventManager->dispatch('adminhtml_customer_save_after', array( - 'customer' => $customer, - 'request' => $request - )); - }; - - /** @var \Magento\Customer\Service\Customer $customerService */ - $customerService = $this->_objectManager->get('Magento\Customer\Service\Customer'); - $customerService->setIsAdminStore(true); - $customerService->setBeforeSaveCallback($beforeSaveCallback); - $customerService->setAfterSaveCallback($afterSaveCallback); - if ($customerId) { - /** @var \Magento\Customer\Model\Customer $customer */ - $customer = $customerService->update($customerId, $accountData, $addressesData); + /** @var \Magento\Customer\Model\Customer $customer */ + $customer = null; + if ($isExistingCustomer) { + // load the customer from the db + $customer = $this->_loadCustomerById($customerId); } else { - /** @var \Magento\Customer\Model\Customer $customer */ - $customer = $customerService->create($accountData, $addressesData); + // create a new customer + $customer = $this->_customerFactory->create(); + $this->_preparePasswordForSave($customer, $customerData); + } + + // Before save + foreach ($customerData as $property => $value) { + $customer->setDataUsingMethod($property, $value); + } + $this->_prepareCustomerAddressesForSave($customer, $addressesData); + $this->_eventManager->dispatch('adminhtml_customer_prepare_save', array( + 'customer' => $customer, + 'request' => $request + )); + + // Save customer + $customer->save(); + + // After save + $this->_eventManager->dispatch('adminhtml_customer_save_after', array( + 'customer' => $customer, + 'request' => $request + )); + $this->_sendWelcomeEmail($customer, $customerData); + if ($isExistingCustomer) { + $this->_changePassword($customer, $customerData); } - $this->_objectManager->get('Magento\Core\Model\Registry')->register('current_customer', $customer); + // Done Saving customer, finish save action + $this->_objectManager->get('Magento\Core\Model\Registry') + ->register(self::REGISTRY_CURRENT_CUSTOMER, $customer); $this->messageManager->addSuccess(__('You saved the customer.')); $returnToEdit = (bool)$this->getRequest()->getParam('back', false); @@ -304,6 +348,163 @@ class Index extends \Magento\Backend\App\Action } } + /** + * Load customer by its ID + * + * @param int|string $customerId + * @return \Magento\Customer\Model\Customer + * @throws \Magento\Core\Exception + */ + private function _loadCustomerById($customerId) + { + $customer = $this->_customerFactory->create(); + $customer->load($customerId); + if (!$customer->getId()) { + throw new \Magento\Core\Exception(__("The customer with the specified ID not found.")); + } + + return $customer; + } + + /** + * Save customer addresses. + * + * @param \Magento\Customer\Model\Customer $customer + * @param array $addressesData + * @throws \Magento\Core\Exception + */ + private function _prepareCustomerAddressesForSave($customer, array $addressesData) + { + $hasChanges = $customer->hasDataChanges(); + $actualAddressesIds = array(); + foreach ($addressesData as $addressData) { + $addressId = null; + if (array_key_exists('entity_id', $addressData)) { + $addressId = $addressData['entity_id']; + unset($addressData['entity_id']); + } + + if (null !== $addressId) { + $address = $customer->getAddressItemById($addressId); + if (!$address || !$address->getId()) { + throw new \Magento\Core\Exception( + __('The address with the specified ID not found.') + ); + } + } else { + $address = $this->_addressFactory->create(); + $address->setCustomerId($customer->getId()); + // Add customer address into addresses collection + $customer->addAddress($address); + } + $address->addData($addressData); + $hasChanges = $hasChanges || $address->hasDataChanges(); + + // Set post_index for detect default billing and shipping addresses + $address->setPostIndex($addressId); + + $actualAddressesIds[] = $address->getId(); + } + + /** @var \Magento\Customer\Model\Address $address */ + foreach ($customer->getAddressesCollection() as $address) { + if (!in_array($address->getId(), $actualAddressesIds)) { + $address->setData('_deleted', true); + $hasChanges = true; + } + } + $customer->setDataChanges($hasChanges); + } + + /** + * Send welcome email to customer + * + * @param \Magento\Customer\Model\Customer $customer + * @param array $customerData + */ + private function _sendWelcomeEmail($customer, array $customerData) + { + $isSendEmail = !empty($customerData['sendemail']); + + if ($customer->getWebsiteId() + && ($isSendEmail || $this->_isAutogeneratePassword($customerData)) + ) { + $isNewCustomer = !(bool)$customer->getOrigData($customer->getIdFieldName()); + $storeId = $customer->getSendemailStoreId(); + + if ($isNewCustomer) { + $newLinkToken = $this->_dataHelper->generateResetPasswordLinkToken(); + $customer->changeResetPasswordLinkToken($newLinkToken); + $customer->sendNewAccountEmail('registered', '', $storeId); + } elseif (!$customer->getConfirmation()) { + // Confirm not confirmed customer + $customer->sendNewAccountEmail('confirmed', '', $storeId); + } + } + } + + /** + * Check if password should be generated automatically + * + * @param array $customerData + * @return bool + */ + private function _isAutogeneratePassword(array $customerData) + { + return !empty($customerData['autogenerate_password']); + } + + /** + * Change customer password + * + * @param \Magento\Customer\Model\Customer $customer + * @param array $customerData + */ + private function _changePassword($customer, array $customerData) + { + if (!empty($customerData['password']) || $this->_isAutogeneratePassword($customerData)) { + $newPassword = $this->_getCustomerPassword($customer, $customerData); + $customer->changePassword($newPassword); + $customer->sendPasswordReminderEmail(); + } + } + + /** + * Get customer password + * + * @param \Magento\Customer\Model\Customer $customer + * @param array $customerData + * @return string|null + */ + private function _getCustomerPassword($customer, array $customerData) + { + $password = null; + + if ($this->_isAutogeneratePassword($customerData)) { + $password = $customer->generatePassword(); + } elseif (isset($customerData['password'])) { + $password = $customerData['password']; + } + + return $password; + } + + /** + * Set customer password + * + * @param \Magento\Customer\Model\Customer $customer + * @param array $customerData + */ + private function _preparePasswordForSave($customer, array $customerData) + { + $password = $this->_getCustomerPassword($customer, $customerData); + if (!is_null($password)) { + // 'force_confirmed' should be set in admin area only + $customer->setForceConfirmed(true); + $customer->setPassword($password); + } + } + /** * Reset password handler */ @@ -325,7 +526,7 @@ class Index extends \Magento\Backend\App\Action $newPasswordToken = $this->_objectManager->get('Magento\Customer\Helper\Data') ->generateResetPasswordLinkToken(); $customer->changeResetPasswordLinkToken($newPasswordToken); - $resetUrl = $this->_objectManager->create('Magento\Core\Model\Url') + $resetUrl = $this->_objectManager->create('Magento\UrlInterface') ->getUrl('customer/account/createPassword', array( '_query' => array('id' => $customer->getId(), 'token' => $newPasswordToken), '_store' => $customer->getStoreId() @@ -514,7 +715,7 @@ class Index extends \Magento\Backend\App\Action { $this->_initCustomer(); $subscriber = $this->_objectManager->create('Magento\Newsletter\Model\Subscriber') - ->loadByCustomer($this->_coreRegistry->registry('current_customer')); + ->loadByCustomer($this->_coreRegistry->registry(self::REGISTRY_CURRENT_CUSTOMER)); $this->_coreRegistry->register('subscriber', $subscriber); $this->_view->loadLayout()->renderLayout(); @@ -523,7 +724,7 @@ class Index extends \Magento\Backend\App\Action public function wishlistAction() { $this->_initCustomer(); - $customer = $this->_coreRegistry->registry('current_customer'); + $customer = $this->_coreRegistry->registry(self::REGISTRY_CURRENT_CUSTOMER); $itemId = (int)$this->getRequest()->getParam('delete'); if ($customer->getId() && $itemId) { try { @@ -568,7 +769,7 @@ class Index extends \Magento\Backend\App\Action ->setWebsite( $this->_objectManager->get('Magento\Core\Model\StoreManagerInterface')->getWebsite($websiteId) ) - ->loadByCustomer($this->_coreRegistry->registry('current_customer')); + ->loadByCustomer($this->_coreRegistry->registry(self::REGISTRY_CURRENT_CUSTOMER)); $item = $quote->getItemById($deleteItemId); if ($item && $item->getId()) { $quote->removeItem($deleteItemId); @@ -614,7 +815,7 @@ class Index extends \Magento\Backend\App\Action $this->_initCustomer(); $this->_view->loadLayout(); $this->_view->getLayout()->getBlock('admin.customer.reviews') - ->setCustomerId($this->_coreRegistry->registry('current_customer')->getId()) + ->setCustomerId($this->_coreRegistry->registry(self::REGISTRY_CURRENT_CUSTOMER)->getId()) ->setUseAjax(true); $this->_view->renderLayout(); } diff --git a/app/code/Magento/Customer/Helper/Address.php b/app/code/Magento/Customer/Helper/Address.php index 4cbc155ce08d2685223182e4d1edb131f2fd515e..a445b418744bd00769bacf535842487410efe0cf 100644 --- a/app/code/Magento/Customer/Helper/Address.php +++ b/app/code/Magento/Customer/Helper/Address.php @@ -192,6 +192,21 @@ class Address extends \Magento\App\Helper\AbstractHelper return $format->getRenderer() ? $format->getRenderer()->getFormat() : ''; } + /** + * Retrieve renderer by code + * + * @param string $code + * @return \Magento\Customer\Block\Address\Renderer\RendererInterface + */ + public function getFormatTypeRenderer($code) + { + $formatType = $this->_addressConfig->getFormatByCode($code); + if (!$formatType || !$formatType->getRenderer()) { + return null; + } + return $formatType->getRenderer(); + } + /** * Determine if specified address config value can be shown * diff --git a/app/code/Magento/Customer/Helper/Data.php b/app/code/Magento/Customer/Helper/Data.php index 5e7713db329551240192f0150ffd5e42f392710f..503acd501e82f4e65087a69d4cca06cf9634f543 100644 --- a/app/code/Magento/Customer/Helper/Data.php +++ b/app/code/Magento/Customer/Helper/Data.php @@ -127,7 +127,7 @@ class Data extends \Magento\App\Helper\AbstractHelper protected $_coreStoreConfig; /** - * @var \Magento\Core\Model\Config + * @var \Magento\App\ConfigInterface */ protected $_coreConfig; @@ -161,7 +161,7 @@ class Data extends \Magento\App\Helper\AbstractHelper * @param \Magento\Customer\Helper\Address $customerAddress * @param \Magento\Core\Helper\Data $coreData * @param \Magento\Core\Model\Store\Config $coreStoreConfig - * @param \Magento\Core\Model\Config $coreConfig + * @param \Magento\App\ConfigInterface $coreConfig * @param \Magento\Customer\Model\Session $customerSession * @param \Magento\Customer\Model\GroupFactory $groupFactory * @param \Magento\Customer\Model\FormFactory $formFactory @@ -173,7 +173,7 @@ class Data extends \Magento\App\Helper\AbstractHelper \Magento\Customer\Helper\Address $customerAddress, \Magento\Core\Helper\Data $coreData, \Magento\Core\Model\Store\Config $coreStoreConfig, - \Magento\Core\Model\Config $coreConfig, + \Magento\App\ConfigInterface $coreConfig, \Magento\Customer\Model\Session $customerSession, \Magento\Customer\Model\GroupFactory $groupFactory, \Magento\Customer\Model\FormFactory $formFactory, diff --git a/app/code/Magento/Customer/Helper/View.php b/app/code/Magento/Customer/Helper/View.php new file mode 100644 index 0000000000000000000000000000000000000000..d23870cf7ea373349b3e124a2946a1955e1da05c --- /dev/null +++ b/app/code/Magento/Customer/Helper/View.php @@ -0,0 +1,78 @@ +<?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\Customer\Helper; + +/** + * Customer helper for view. + */ +class View extends \Magento\App\Helper\AbstractHelper +{ + /** @var \Magento\Customer\Service\V1\CustomerMetadataServiceInterface */ + protected $_customerMetadataService; + + /** + * Initialize dependencies. + * + * @param \Magento\App\Helper\Context $context + * @param \Magento\Customer\Service\V1\CustomerMetadataServiceInterface $customerMetadataService + */ + public function __construct( + \Magento\App\Helper\Context $context, + \Magento\Customer\Service\V1\CustomerMetadataServiceInterface $customerMetadataService + ) { + $this->_customerMetadataService = $customerMetadataService; + parent::__construct($context); + } + + /** + * Concatenate all customer name parts into full customer name. + * + * @param \Magento\Customer\Service\V1\Dto\Customer $customerData + * @return string + */ + public function getCustomerName(\Magento\Customer\Service\V1\Dto\Customer $customerData) + { + $name = ''; + $prefixMetadata = $this->_customerMetadataService->getAttributeMetadata('customer', 'prefix'); + if ($prefixMetadata->isVisible() && $customerData->getPrefix()) { + $name .= $customerData->getPrefix() . ' '; + } + + $name .= $customerData->getFirstname(); + + $middleNameMetadata = $this->_customerMetadataService->getAttributeMetadata('customer', 'middlename'); + if ($middleNameMetadata->isVisible() && $customerData->getMiddlename()) { + $name .= ' ' . $customerData->getMiddlename(); + } + + $name .= ' ' . $customerData->getLastname(); + + $suffixMetadata = $this->_customerMetadataService->getAttributeMetadata('customer', 'suffix'); + if ($suffixMetadata->isVisible() && $customerData->getSuffix()) { + $name .= ' ' . $customerData->getSuffix(); + } + return $name; + } +} diff --git a/app/code/Magento/Customer/Model/Attribute.php b/app/code/Magento/Customer/Model/Attribute.php index c04871e089ee46cf2c7ffb62e622de0bc985bf24..55b266a9282bf4910a857238ec2c31578774c5d8 100644 --- a/app/code/Magento/Customer/Model/Attribute.php +++ b/app/code/Magento/Customer/Model/Attribute.php @@ -24,15 +24,13 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Customer\Model; + /** * Customer attribute model * - * @category Magento - * @package Magento_Customer - * @author Magento Core Team <core@magentocommerce.com> + * @method int getSortOrder() */ -namespace Magento\Customer\Model; - class Attribute extends \Magento\Eav\Model\Attribute { /** diff --git a/app/code/Magento/Customer/Model/Config/Backend/Address/Street.php b/app/code/Magento/Customer/Model/Config/Backend/Address/Street.php index 19f66864f82559415cf68f1a2685bd5fbb9d4dd7..cf9ec68684b9bacf88962c8c1573669fa9517b5b 100644 --- a/app/code/Magento/Customer/Model/Config/Backend/Address/Street.php +++ b/app/code/Magento/Customer/Model/Config/Backend/Address/Street.php @@ -25,7 +25,7 @@ */ /** - * Customer Address Street Model + * Line count config model for customer address street attribute * * @method string getWebsiteCode */ @@ -42,7 +42,7 @@ class Street extends \Magento\Core\Model\Config\Value * @param \Magento\Core\Model\Context $context * @param \Magento\Core\Model\Registry $registry * @param \Magento\Core\Model\StoreManagerInterface $storeManager - * @param \Magento\Core\Model\Config $config + * @param \Magento\App\ConfigInterface $config * @param \Magento\Eav\Model\Config $eavConfig * @param \Magento\Core\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection @@ -52,7 +52,7 @@ class Street extends \Magento\Core\Model\Config\Value \Magento\Core\Model\Context $context, \Magento\Core\Model\Registry $registry, \Magento\Core\Model\StoreManagerInterface $storeManager, - \Magento\Core\Model\Config $config, + \Magento\App\ConfigInterface $config, \Magento\Eav\Model\Config $eavConfig, \Magento\Core\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, diff --git a/app/code/Magento/Customer/Model/Config/Backend/Show/Customer.php b/app/code/Magento/Customer/Model/Config/Backend/Show/Customer.php index 336c40dd411391137d8c9b1c20d69ad554baea8d..e4d05453b940efa17ca0128d71905bb4cd389bb1 100644 --- a/app/code/Magento/Customer/Model/Config/Backend/Show/Customer.php +++ b/app/code/Magento/Customer/Model/Config/Backend/Show/Customer.php @@ -44,7 +44,7 @@ class Customer extends \Magento\Core\Model\Config\Value * @param \Magento\Core\Model\Context $context * @param \Magento\Core\Model\Registry $registry * @param \Magento\Core\Model\StoreManagerInterface $storeManager - * @param \Magento\Core\Model\Config $config + * @param \Magento\App\ConfigInterface $config * @param \Magento\Eav\Model\Config $eavConfig * @param \Magento\Core\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection @@ -54,7 +54,7 @@ class Customer extends \Magento\Core\Model\Config\Value \Magento\Core\Model\Context $context, \Magento\Core\Model\Registry $registry, \Magento\Core\Model\StoreManagerInterface $storeManager, - \Magento\Core\Model\Config $config, + \Magento\App\ConfigInterface $config, \Magento\Eav\Model\Config $eavConfig, \Magento\Core\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, diff --git a/app/code/Magento/Customer/Model/Config/Share.php b/app/code/Magento/Customer/Model/Config/Share.php index 26db0e91e442ea36e819efcaad29840bed02742e..c4f768c5e4fdc3df87fefdc632d17f99c247e936 100644 --- a/app/code/Magento/Customer/Model/Config/Share.php +++ b/app/code/Magento/Customer/Model/Config/Share.php @@ -67,7 +67,7 @@ class Share extends \Magento\Core\Model\Config\Value * @param \Magento\Core\Model\Context $context * @param \Magento\Core\Model\Registry $registry * @param \Magento\Core\Model\StoreManagerInterface $storeManager - * @param \Magento\Core\Model\Config $config + * @param \Magento\App\ConfigInterface $config * @param \Magento\Core\Model\Store\Config $coreStoreConfig * @param \Magento\Customer\Model\Resource\Customer $customerResource * @param \Magento\Core\Model\Resource\AbstractResource $resource @@ -78,7 +78,7 @@ class Share extends \Magento\Core\Model\Config\Value \Magento\Core\Model\Context $context, \Magento\Core\Model\Registry $registry, \Magento\Core\Model\StoreManagerInterface $storeManager, - \Magento\Core\Model\Config $config, + \Magento\App\ConfigInterface $config, \Magento\Core\Model\Store\Config $coreStoreConfig, \Magento\Customer\Model\Resource\Customer $customerResource, \Magento\Core\Model\Resource\AbstractResource $resource = null, diff --git a/app/code/Magento/Customer/Model/Metadata/Form.php b/app/code/Magento/Customer/Model/Metadata/Form.php new file mode 100644 index 0000000000000000000000000000000000000000..900372c0191a2f157346dc7b42286e649f4abb33 --- /dev/null +++ b/app/code/Magento/Customer/Model/Metadata/Form.php @@ -0,0 +1,364 @@ +<?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_Customer + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Customer\Model\Metadata; + +class Form +{ + /** + * @var \Magento\Customer\Service\V1\CustomerMetadataServiceInterface + */ + protected $_eavMetadataService; + + /** + * @var ElementFactory + */ + protected $_elementFactory; + + /** + * @var string + */ + protected $_entityType; + + /** + * @var string + */ + protected $_formCode; + + /** + * @var bool + */ + protected $_ignoreInvisible = true; + + /** + * @var array + */ + protected $_filterAttributes = []; + + /** + * @var bool + */ + protected $_isAjax = false; + + /** + * @var array + */ + protected $_attributeValues = []; + + /** + * @var \Magento\App\RequestInterface + */ + protected $_httpRequest; + + /** + * @var \Magento\Module\Dir\Reader + */ + protected $_modulesReader; + + /** + * @var \Magento\Validator\ConfigFactory + */ + protected $_validatorConfigFactory; + + /** + * @var \Magento\Validator + */ + protected $_validator; + + /** + * @var \Magento\Customer\Service\V1\Dto\Eav\AttributeMetadata[] + */ + protected $_attributes; + + /** + * @param \Magento\Customer\Service\V1\CustomerMetadataServiceInterface $eavMetadataService + * @param ElementFactory $elementFactory + * @param \Magento\App\RequestInterface $httpRequest + * @param \Magento\Module\Dir\Reader $modulesReader + * @param \Magento\Validator\ConfigFactory $validatorConfigFactory + * @param string $entityType + * @param string $formCode + * @param array $attributeValues + * @param bool $ignoreInvisible + * @param array $filterAttributes + * @param bool $isAjax + * + * @SuppressWarnings(PHPMD.ExcessiveParameterList) + */ + public function __construct( + \Magento\Customer\Service\V1\CustomerMetadataServiceInterface $eavMetadataService, + ElementFactory $elementFactory, + \Magento\App\RequestInterface $httpRequest, + \Magento\Module\Dir\Reader $modulesReader, + \Magento\Validator\ConfigFactory $validatorConfigFactory, + $entityType, + $formCode, + array $attributeValues = [], + $ignoreInvisible = true, + $filterAttributes = [], + $isAjax = false + ) { + $this->_eavMetadataService = $eavMetadataService; + $this->_elementFactory = $elementFactory; + $this->_attributeValues = $attributeValues; + $this->_entityType = $entityType; + $this->_formCode = $formCode; + $this->_ignoreInvisible = $ignoreInvisible; + $this->_filterAttributes = $filterAttributes; + $this->_isAjax = $isAjax; + $this->_httpRequest = $httpRequest; + $this->_modulesReader = $modulesReader; + $this->_validatorConfigFactory = $validatorConfigFactory; + } + + /** + * Retrieve attributes metadata for the form + * + * @return \Magento\Customer\Service\V1\Dto\Eav\AttributeMetadata[] + */ + public function getAttributes() + { + if (!isset($this->_attributes)) { + $this->_attributes = $this->_eavMetadataService + ->getAttributes($this->_entityType, $this->_formCode); + } + return $this->_attributes; + } + + /** + * Retrieve user defined attributes + * + * @return \Magento\Customer\Service\V1\Dto\Eav\AttributeMetadata[] + */ + public function getUserAttributes() + { + $result = []; + foreach ($this->getAttributes() as $attribute) { + if ($attribute->isUserDefined()) { + $result[$attribute->getAttributeCode()] = $attribute; + } + } + return $result; + } + + /** + * Retrieve system required attributes + * + * @return \Magento\Customer\Service\V1\Dto\Eav\AttributeMetadata[] + */ + public function getSystemAttributes() + { + $result = []; + foreach ($this->getAttributes() as $attribute) { + if (!$attribute->isUserDefined()) { + $result[$attribute->getAttributeCode()] = $attribute; + } + } + return $result; + } + + /** + * Retrieve filtered attributes + * + * @return \Magento\Customer\Service\V1\Dto\Eav\AttributeMetadata[] + */ + public function getAllowedAttributes() + { + $attributes = $this->_eavMetadataService->getAttributes($this->_entityType, $this->_formCode); + foreach ($attributes as $attributeCode => $attribute) { + if ( + $this->_ignoreInvisible && !$attribute->isVisible() + || in_array($attribute->getAttributeCode(), $this->_filterAttributes) + ) { + unset($attributes[$attributeCode]); + } + } + return $attributes; + } + + /** + * Extract data from request and return associative data array + * + * @param \Magento\App\RequestInterface $request + * @param string $scope the request scope + * @param boolean $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) + { + $data = array(); + /** @var $attribute \Magento\Eav\Model\Attribute */ + foreach ($this->getAllowedAttributes() as $attribute) { + $dataModel = $this->_getAttributeDataModel($attribute); + $dataModel->setRequestScope($scope); + $dataModel->setRequestScopeOnly($scopeOnly); + $data[$attribute->getAttributeCode()] = $dataModel->extractValue($request); + } + return $data; + } + + /** + * Compact data array to current entity + * + * @param array $data + * @return array + */ + public function compactData(array $data) + { + foreach ($this->getAllowedAttributes() as $attribute) { + $dataModel = $this->_getAttributeDataModel($attribute); + $dataModel->setExtractedData($data); + if (!isset($data[$attribute->getAttributeCode()])) { + $data[$attribute->getAttributeCode()] = false; + } + } + + return $data; + } + + /** + * Restore data array from SESSION to current entity + * + * @param array $data + * @return array + */ + public function restoreData(array $data) + { + /** @var $attribute \Magento\Eav\Model\Attribute */ + foreach ($this->getAllowedAttributes() as $attribute) { + $dataModel = $this->_getAttributeDataModel($attribute); + $dataModel->setExtractedData($data); + if (!isset($data[$attribute->getAttributeCode()])) { + $data[$attribute->getAttributeCode()] = false; + } + $dataModel->restoreValue($data[$attribute->getAttributeCode()]); + } + return $data; + } + + /** + * Return attribute data model by attribute + * + * @param \Magento\Eav\Model\Entity\Attribute $attribute + * @return \Magento\Eav\Model\Attribute\Data\AbstractData + */ + protected function _getAttributeDataModel($attribute) + { + $dataModel = $this->_elementFactory->create( + $attribute, + isset($this->_attributeValues[$attribute->getAttributeCode()]) + ? $this->_attributeValues[$attribute->getAttributeCode()] : null, + $this->_entityType, + $this->_isAjax + ); + return $dataModel; + } + + + /** + * Prepare request with data and returns it + * + * @param array $data + * @return \Magento\App\RequestInterface + */ + public function prepareRequest(array $data) + { + $request = clone $this->_httpRequest; + $request->setParamSources(); + $request->clearParams(); + $request->setParams($data); + + return $request; + } + + /** + * Get validator + * + * @param array $data + * @return \Magento\Validator + */ + protected function _getValidator(array $data) + { + if ($this->_validator !== null) { + return $this->_validator; + } + + $configFiles = $this->_modulesReader->getConfigurationFiles('validation.xml'); + $validatorFactory = $this->_validatorConfigFactory->create(array('configFiles' => $configFiles)); + $builder = $validatorFactory->createValidatorBuilder('customer', 'form'); + + $builder->addConfiguration('metadata_data_validator', array( + 'method' => 'setAttributes', + 'arguments' => array($this->getAllowedAttributes()) + )); + $builder->addConfiguration('metadata_data_validator', array( + 'method' => 'setData', + 'arguments' => array($data) + )); + $builder->addConfiguration('metadata_data_validator', array( + 'method' => 'setEntityType', + 'arguments' => array($this->_entityType) + )); + $this->_validator = $builder->createValidator(); + + return $this->_validator; + } + + /** + * Validate data array and return true or array of errors + * + * @param array $data + * @return boolean|array + */ + public function validateData(array $data) + { + $validator = $this->_getValidator($data); + if (!$validator->isValid(false)) { + $messages = array(); + foreach ($validator->getMessages() as $errorMessages) { + $messages = array_merge($messages, (array)$errorMessages); + } + return $messages; + } + return true; + } + + /** + * Return array of formatted allowed attributes values. + * + * @param string $format + * @return array + */ + public function outputData($format = \Magento\Eav\Model\AttributeDataFactory::OUTPUT_FORMAT_TEXT) + { + $result = array(); + foreach ($this->getAllowedAttributes() as $attribute) { + $dataModel = $this->_getAttributeDataModel($attribute); + $result[$attribute->getAttributeCode()] = $dataModel->outputValue($format); + } + return $result; + } +} diff --git a/app/code/Magento/GroupedProduct/Model/ProductTypes/Config/Converter/Plugin/Grouped.php b/app/code/Magento/Customer/Model/Metadata/Form/Boolean.php similarity index 62% rename from app/code/Magento/GroupedProduct/Model/ProductTypes/Config/Converter/Plugin/Grouped.php rename to app/code/Magento/Customer/Model/Metadata/Form/Boolean.php index 1869b53a1f320fd014fe03f740c0da00abda0543..0893367eb47d02e2573180ad0cce8625aff6379f 100644 --- a/app/code/Magento/GroupedProduct/Model/ProductTypes/Config/Converter/Plugin/Grouped.php +++ b/app/code/Magento/Customer/Model/Metadata/Form/Boolean.php @@ -1,6 +1,6 @@ <?php /** - * Plugin for product type configuration converter + * Form Element Boolean Data Model * * Magento * @@ -20,25 +20,35 @@ * 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_Eav * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\GroupedProduct\Model\ProductTypes\Config\Converter\Plugin; +namespace Magento\Customer\Model\Metadata\Form; -class Grouped +class Boolean extends Select { /** - * Set value to product type configuration data that grouped product type is a set of products + * Return a text for option value * - * @param array $config - * @return array + * @param int $value + * @return string */ - public function afterConvert(array $config) + protected function _getOptionText($value) { - if (isset($config[\Magento\GroupedProduct\Model\Product\Type\Grouped::TYPE_CODE])) { - $config[\Magento\GroupedProduct\Model\Product\Type\Grouped::TYPE_CODE]['is_product_set'] = true; + switch ($value) { + case '0': + $text = __('No'); + break; + case '1': + $text = __('Yes'); + break; + default: + $text = ''; + break; } - return $config; + return $text; } -} +} diff --git a/app/code/Magento/Customer/Model/Metadata/Form/Date.php b/app/code/Magento/Customer/Model/Metadata/Form/Date.php new file mode 100644 index 0000000000000000000000000000000000000000..071c9d561c1fc2fd6c6ffe9018abab1b310a248a --- /dev/null +++ b/app/code/Magento/Customer/Model/Metadata/Form/Date.php @@ -0,0 +1,150 @@ +<?php +/** + * Form Element Date Data Model + * + * 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_Eav + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Customer\Model\Metadata\Form; + +class Date extends AbstractData +{ + /** + * Extract data from request and return value + * + * @param \Magento\App\RequestInterface $request + * @return array|string + */ + public function extractValue(\Magento\App\RequestInterface $request) + { + $value = $this->_getRequestValue($request); + return $this->_applyInputFilter($value); + } + + /** + * Validate data + * Return true or array of errors + * + * @param array|string $value + * @return boolean|array + */ + public function validateValue($value) + { + $errors = array(); + $attribute = $this->getAttribute(); + $label = $attribute->getStoreLabel(); + + if ($value === false) { + // try to load original value and validate it + $value = $this->_value; + } + + if ($attribute->isRequired() && empty($value)) { + $errors[] = __('"%1" is a required value.', $label); + } + + if (!$errors && !$attribute->isRequired() && empty($value)) { + return true; + } + + $result = $this->_validateInputRule($value); + if ($result !== true) { + $errors = array_merge($errors, $result); + } + + //range validation + $validateRules = $attribute->getValidationRules(); + if ((!empty($validateRules['date_range_min']) && (strtotime($value) < $validateRules['date_range_min'])) + || (!empty($validateRules['date_range_max']) && (strtotime($value) > $validateRules['date_range_max'])) + ) { + if (!empty($validateRules['date_range_min']) && !empty($validateRules['date_range_max'])) { + $errors[] = __('Please enter a valid date between %1 and %2 at %3.', date('d/m/Y', $validateRules['date_range_min']), date('d/m/Y', $validateRules['date_range_max']), $label); + } elseif (!empty($validateRules['date_range_min'])) { + $errors[] = __('Please enter a valid date equal to or greater than %1 at %2.', date('d/m/Y', $validateRules['date_range_min']), $label); + } elseif (!empty($validateRules['date_range_max'])) { + $errors[] = __('Please enter a valid date less than or equal to %1 at %2.', date('d/m/Y', $validateRules['date_range_max']), $label); + } + } + + if (count($errors) == 0) { + return true; + } + + return $errors; + } + + /** + * Export attribute value to entity model + * + * @param array|string $value + * @return string + */ + public function compactValue($value) + { + if ($value !== false) { + if (empty($value)) { + $value = null; + } + return $value; + } + return false; + } + + + /** + * Restore attribute value from SESSION to entity model + * + * @param array|string $value + * @return \Magento\Eav\Model\Attribute\Data\Date + */ + public function restoreValue($value) + { + return $this->compactValue($value); + } + + /** + * Return formated attribute value from entity model + * + * @param string $format + * @return string|array + */ + public function outputValue($format = \Magento\Eav\Model\AttributeDataFactory::OUTPUT_FORMAT_TEXT) + { + $value = $this->_value; + if ($value) { + switch ($format) { + case \Magento\Eav\Model\AttributeDataFactory::OUTPUT_FORMAT_TEXT: + case \Magento\Eav\Model\AttributeDataFactory::OUTPUT_FORMAT_HTML: + case \Magento\Eav\Model\AttributeDataFactory::OUTPUT_FORMAT_PDF: + $this->_dateFilterFormat(\Magento\Core\Model\LocaleInterface::FORMAT_TYPE_MEDIUM); + break; + } + $value = $this->_applyOutputFilter($value); + } + + $this->_dateFilterFormat(\Magento\Core\Model\LocaleInterface::FORMAT_TYPE_SHORT); + + return $value; + } +} diff --git a/app/code/Magento/Customer/Model/Metadata/Form/File.php b/app/code/Magento/Customer/Model/Metadata/Form/File.php new file mode 100644 index 0000000000000000000000000000000000000000..a3ee74acedb38c1045cbf1c7bcea3de62ad59b66 --- /dev/null +++ b/app/code/Magento/Customer/Model/Metadata/Form/File.php @@ -0,0 +1,320 @@ +<?php +/** + * Form Element File Data Model + * + * 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_Eav + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Customer\Model\Metadata\Form; + +class File extends AbstractData +{ + /** + * Validator for check not protected extensions + * + * @var \Magento\Core\Model\File\Validator\NotProtectedExtension + */ + protected $_validatorNotProtectedExtensions; + + /** + * Core data + * + * @var \Magento\Core\Helper\Data + */ + protected $_coreData = null; + + /** + * @var \Magento\Core\Model\File\Validator\NotProtectedExtension + */ + protected $_fileValidator; + + /** + * @var \Magento\App\Filesystem + */ + protected $_fileSystem; + + /** + * @param \Magento\Core\Model\LocaleInterface $locale + * @param \Magento\Logger $logger + * @param \Magento\Customer\Service\V1\Dto\Eav\AttributeMetadata $attribute + * @param null $value + * @param $entityTypeCode + * @param bool $isAjax + * @param \Magento\Core\Helper\Data $coreData + * @param \Magento\Core\Model\File\Validator\NotProtectedExtension $fileValidator + * @param \Magento\App\Filesystem $fileSystem + */ + public function __construct( + \Magento\Core\Model\LocaleInterface $locale, + \Magento\Logger $logger, + \Magento\Customer\Service\V1\Dto\Eav\AttributeMetadata $attribute, + $value = null, + $entityTypeCode, + $isAjax = false, + \Magento\Core\Helper\Data $coreData, + \Magento\Core\Model\File\Validator\NotProtectedExtension $fileValidator, + \Magento\App\Filesystem $fileSystem + ) { + parent::__construct($locale, $logger, $attribute, $value, $entityTypeCode, $isAjax); + $this->_coreData = $coreData; + $this->_fileValidator = $fileValidator; + $this->_fileSystem = $fileSystem; + } + + /** + * Extract data from request and return value + * + * @param \Magento\App\RequestInterface $request + * @return array|string + */ + public function extractValue(\Magento\App\RequestInterface $request) + { + if ($this->getIsAjaxRequest()) { + return false; + } + + $extend = $this->_getRequestValue($request); + + $attrCode = $this->getAttribute()->getAttributeCode(); + if ($this->_requestScope) { + $value = array(); + if (strpos($this->_requestScope, '/') !== false) { + $scopes = explode('/', $this->_requestScope); + $mainScope = array_shift($scopes); + } else { + $mainScope = $this->_requestScope; + $scopes = array(); + } + + if (!empty($_FILES[$mainScope])) { + foreach ($_FILES[$mainScope] as $fileKey => $scopeData) { + foreach ($scopes as $scopeName) { + if (isset($scopeData[$scopeName])) { + $scopeData = $scopeData[$scopeName]; + } else { + $scopeData[$scopeName] = array(); + } + } + + if (isset($scopeData[$attrCode])) { + $value[$fileKey] = $scopeData[$attrCode]; + } + } + } else { + $value = array(); + } + } else { + if (isset($_FILES[$attrCode])) { + $value = $_FILES[$attrCode]; + } else { + $value = array(); + } + } + + if (!empty($extend['delete'])) { + $value['delete'] = true; + } + + return $value; + } + + /** + * Validate file by attribute validate rules + * Return array of errors + * + * @param array $value + * @return array + */ + protected function _validateByRules($value) + { + $label = $this->getAttribute()->getStoreLabel(); + $rules = $this->getAttribute()->getValidationRules(); + $extension = pathinfo($value['name'], PATHINFO_EXTENSION); + + if (!empty($rules['file_extensions'])) { + $extensions = explode(',', $rules['file_extensions']); + $extensions = array_map('trim', $extensions); + if (!in_array($extension, $extensions)) { + return array( + __('"%1" is not a valid file extension.', $label) + ); + } + } + + /** + * Check protected file extension + */ + if (!$this->_fileValidator->isValid($extension)) { + return $this->_fileValidator->getMessages(); + } + + if (!is_uploaded_file($value['tmp_name'])) { + return array( + __('"%1" is not a valid file.', $label) + ); + } + + if (!empty($rules['max_file_size'])) { + $size = $value['size']; + if ($rules['max_file_size'] < $size) { + return array( + __('"%1" exceeds the allowed file size.', $label) + ); + }; + } + + return array(); + } + + /** + * Validate data + * + * @param array|string $value + * @throws \Magento\Core\Exception + * @return boolean + */ + public function validateValue($value) + { + if ($this->getIsAjaxRequest()) { + return true; + } + + $errors = array(); + $attribute = $this->getAttribute(); + $label = $attribute->getStoreLabel(); + + $toDelete = !empty($value['delete']) ? true : false; + $toUpload = !empty($value['tmp_name']) ? true : false; + + if (!$toUpload && !$toDelete && $this->_value) { + return true; + } + + if (!$attribute->isRequired() && !$toUpload) { + return true; + } + + if ($attribute->isRequired() && !$toUpload) { + $errors[] = __('"%1" is a required value.', $label); + } + + if ($toUpload) { + $errors = array_merge($errors, $this->_validateByRules($value)); + } + + if (count($errors) == 0) { + return true; + } + + return $errors; + } + + /** + * Export attribute value to entity model + * + * @param \Magento\Core\Model\AbstractModel $entity + * @param array|string $value + * @return string + */ + public function compactValue($value) + { + if ($this->getIsAjaxRequest()) { + return $this; + } + + $attribute = $this->getAttribute(); + $original = $this->_value; + $toDelete = false; + if ($original) { + if (!$attribute->isRequired() && !empty($value['delete'])) { + $toDelete = true; + } + if (!empty($value['tmp_name'])) { + $toDelete = true; + } + } + + $path = $this->_fileSystem->getPath(\Magento\App\Filesystem::MEDIA_DIR) . '/' . $this->_entityTypeCode; + + $result = $original; + // unlink entity file + if ($toDelete) { + $result = ''; + $file = $path . $original; + $ioFile = new \Magento\Io\File(); + if ($ioFile->fileExists($file)) { + $ioFile->rm($file); + } + } + + if (!empty($value['tmp_name'])) { + try { + $uploader = new \Magento\File\Uploader($value); + $uploader->setFilesDispersion(true); + $uploader->setFilenamesCaseSensitivity(false); + $uploader->setAllowRenameFiles(true); + $uploader->save($path, $value['name']); + $fileName = $uploader->getUploadedFileName(); + $result = $fileName; + } catch (\Exception $e) { + $this->_logger->logException($e); + } + } + + return $result; + } + + /** + * Restore attribute value from SESSION to entity model + * + * @param array|string $value + * @return \Magento\Customer\Model\Metadata\Form\File + */ + public function restoreValue($value) + { + return $this; + } + + /** + * Return formated attribute value from entity model + * + * @return string|array + */ + public function outputValue($format = \Magento\Eav\Model\AttributeDataFactory::OUTPUT_FORMAT_TEXT) + { + $output = ''; + if ($this->_value) { + switch ($format) { + case \Magento\Eav\Model\AttributeDataFactory::OUTPUT_FORMAT_JSON: + $output = array( + 'value' => $this->_value, + 'url_key' => $this->_coreData->urlEncode($this->_value) + ); + break; + } + } + + return $output; + } +} diff --git a/app/code/Magento/PaypalUk/Helper/Data.php b/app/code/Magento/Customer/Model/Metadata/Form/Hidden.php similarity index 85% rename from app/code/Magento/PaypalUk/Helper/Data.php rename to app/code/Magento/Customer/Model/Metadata/Form/Hidden.php index d0febfab84883963958c9da5df8bbb0dbae039d3..381f35bef4edcd36393c0ff5a2948450b12ce892 100644 --- a/app/code/Magento/PaypalUk/Helper/Data.php +++ b/app/code/Magento/Customer/Model/Metadata/Form/Hidden.php @@ -1,5 +1,7 @@ <?php /** + * Form Element Hidden Data Model + * * Magento * * NOTICE OF LICENSE @@ -19,17 +21,13 @@ * needs please refer to http://www.magentocommerce.com for more information. * * @category Magento - * @package Magento_PaypalUk + * @package Magento_Customer * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -/** - * PaypalUk data helper - */ -namespace Magento\PaypalUk\Helper; +namespace Magento\Customer\Model\Metadata\Form; -class Data extends \Magento\App\Helper\AbstractHelper +class Hidden extends Text { - } diff --git a/app/code/Magento/Customer/Model/Metadata/Form/Image.php b/app/code/Magento/Customer/Model/Metadata/Form/Image.php new file mode 100644 index 0000000000000000000000000000000000000000..f467a81220fbe93ce3ce640c7dc2edfb6fc03a7e --- /dev/null +++ b/app/code/Magento/Customer/Model/Metadata/Form/Image.php @@ -0,0 +1,94 @@ +<?php +/** + * Form Element Image Data Model + * + * 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_Customer + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Customer\Model\Metadata\Form; + +class Image extends File +{ + /** + * Validate file by attribute validate rules + * Return array of errors + * + * @param array $value + * @return array + */ + protected function _validateByRules($value) + { + $label = __($this->getAttribute()->getStoreLabel()); + $rules = $this->getAttribute()->getValidationRules(); + + $imageProp = @getimagesize($value['tmp_name']); + + if (!is_uploaded_file($value['tmp_name']) || !$imageProp) { + return array( + __('"%1" is not a valid file', $label) + ); + } + + $allowImageTypes = array( + 1 => 'gif', + 2 => 'jpg', + 3 => 'png', + ); + + if (!isset($allowImageTypes[$imageProp[2]])) { + return array( + __('"%1" is not a valid image format', $label) + ); + } + + // modify image name + $extension = pathinfo($value['name'], PATHINFO_EXTENSION); + if ($extension != $allowImageTypes[$imageProp[2]]) { + $value['name'] = pathinfo($value['name'], PATHINFO_FILENAME) . '.' . $allowImageTypes[$imageProp[2]]; + } + + $errors = array(); + if (!empty($rules['max_file_size'])) { + $size = $value['size']; + if ($rules['max_file_size'] < $size) { + $errors[] = __('"%1" exceeds the allowed file size.', $label); + }; + } + + if (!empty($rules['max_image_width'])) { + if ($rules['max_image_width'] < $imageProp[0]) { + $r = $rules['max_image_width']; + $errors[] = __('"%1" width exceeds allowed value of %2 px.', $label, $r); + }; + } + if (!empty($rules['max_image_heght'])) { + if ($rules['max_image_heght'] < $imageProp[1]) { + $r = $rules['max_image_heght']; + $errors[] = __('"%1" height exceeds allowed value of %2 px.', $label, $r); + }; + } + + return $errors; + } +} diff --git a/app/code/Magento/Customer/Model/Metadata/Form/Multiline.php b/app/code/Magento/Customer/Model/Metadata/Form/Multiline.php new file mode 100644 index 0000000000000000000000000000000000000000..035b9d6a106dde1bc853d43f0c150342016b2220 --- /dev/null +++ b/app/code/Magento/Customer/Model/Metadata/Form/Multiline.php @@ -0,0 +1,153 @@ +<?php +/** + * Form Element Multiline Data Model + * + * 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_Customer + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Customer\Model\Metadata\Form; + +class Multiline extends Text +{ + /** + * Extract data from request and return value + * + * @param \Magento\App\RequestInterface $request + * @return array|string + */ + public function extractValue(\Magento\App\RequestInterface $request) + { + $value = $this->_getRequestValue($request); + if (!is_array($value)) { + $value = false; + } else { + $value = array_map(array($this, '_applyInputFilter'), $value); + } + return $value; + } + + /** + * Validate data + * Return true or array of errors + * + * @param array|string $value + * @return boolean|array + */ + public function validateValue($value) + { + $errors = array(); + $attribute = $this->getAttribute(); + + if ($value === false) { + // try to load original value and validate it + $value = $this->_value; + if (!is_array($value)) { + $value = explode("\n", $value); + } + } + + if (!is_array($value)) { + $value = array($value); + } + for ($i = 0; $i < $attribute->getMultilineCount(); $i ++) { + if (!isset($value[$i])) { + $value[$i] = null; + } + // validate first line + if ($i == 0) { + $result = parent::validateValue($value[$i]); + if ($result !== true) { + $errors = $result; + } + } else { + if (!empty($value[$i])) { + $result = parent::validateValue($value[$i]); + if ($result !== true) { + $errors = array_merge($errors, $result); + } + } + } + } + + if (count($errors) == 0) { + return true; + } + return $errors; + } + + /** + * Export attribute value to entity model + * + * @param array|string $value + * @return \Magento\Customer\Model\Metadata\Form\Multiline + */ + public function compactValue($value) + { + if (is_array($value)) { + $value = trim(implode("\n", $value)); + } + return parent::compactValue($value); + } + + /** + * Restore attribute value from SESSION to entity model + * + * @param array|string $value + * @return \Magento\Customer\Model\Metadata\Form\Multiline + */ + public function restoreValue($value) + { + return $this->compactValue($value); + } + + /** + * Return formated attribute value from entity model + * + * @param string $format + * @return array|string + */ + public function outputValue($format = \Magento\Eav\Model\AttributeDataFactory::OUTPUT_FORMAT_TEXT) + { + $values = $this->_value; + if (!is_array($values)) { + $values = explode("\n", $values); + } + $values = array_map(array($this, '_applyOutputFilter'), $values); + switch ($format) { + case \Magento\Eav\Model\AttributeDataFactory::OUTPUT_FORMAT_ARRAY: + $output = $values; + break; + case \Magento\Eav\Model\AttributeDataFactory::OUTPUT_FORMAT_HTML: + $output = implode("<br />", $values); + break; + case \Magento\Eav\Model\AttributeDataFactory::OUTPUT_FORMAT_ONELINE: + $output = implode(" ", $values); + break; + default: + $output = implode("\n", $values); + break; + } + return $output; + } +} diff --git a/app/code/Magento/Customer/Model/Metadata/Form/Multiselect.php b/app/code/Magento/Customer/Model/Metadata/Form/Multiselect.php new file mode 100644 index 0000000000000000000000000000000000000000..586bedfbd7f111cce490332f00c8a9a7a90086da --- /dev/null +++ b/app/code/Magento/Customer/Model/Metadata/Form/Multiselect.php @@ -0,0 +1,99 @@ +<?php +/** + * Form Element Multiselect Data Model + * + * 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_Customer + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Customer\Model\Metadata\Form; + +class Multiselect extends Select +{ + /** + * Extract data from request and return value + * + * @param \Magento\App\RequestInterface $request + * @return array|string + */ + public function extractValue(\Magento\App\RequestInterface $request) + { + $values = $this->_getRequestValue($request); + if ($values !== false && !is_array($values)) { + $values = array($values); + } + return $values; + } + + /** + * Export attribute value to entity model + * + * @param array|string $value + * @return \Magento\Customer\Model\Metadata\Form\Multiselect + */ + public function compactValue($value) + { + if (is_array($value)) { + $value = implode(',', $value); + } + return parent::compactValue($value); + } + + /** + * Return formated attribute value from entity model + * + * @param string $format + * @return array|string + */ + public function outputValue($format = \Magento\Eav\Model\AttributeDataFactory::OUTPUT_FORMAT_TEXT) + { + $values = $this->_value; + if (!is_array($values)) { + $values = explode(',', $values); + } + + switch ($format) { + case \Magento\Eav\Model\AttributeDataFactory::OUTPUT_FORMAT_JSON: + case \Magento\Eav\Model\AttributeDataFactory::OUTPUT_FORMAT_ARRAY: + $output = $values; + default: + $output = array(); + foreach ($values as $value) { + if (!$value) { + continue; + } + $optionText = false; + foreach ($this->getAttribute()->getOptions() as $optionKey => $optionValue) { + if ($optionValue == $value) { + $optionText = $optionKey; + } + } + $output[] = $optionText; + } + $output = implode(', ', $output); + break; + } + + return $output; + } +} diff --git a/app/code/Magento/Customer/Model/Metadata/Form/Select.php b/app/code/Magento/Customer/Model/Metadata/Form/Select.php new file mode 100644 index 0000000000000000000000000000000000000000..8ee81142130d23d07b745c18d10713ac745f103e --- /dev/null +++ b/app/code/Magento/Customer/Model/Metadata/Form/Select.php @@ -0,0 +1,142 @@ +<?php +/** + * Form Element Select Data Model + * + * 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_Eav + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Customer\Model\Metadata\Form; + +class Select extends AbstractData +{ + /** + * Extract data from request and return value + * + * @param \Magento\App\RequestInterface $request + * @return array|string + */ + public function extractValue(\Magento\App\RequestInterface $request) + { + return $this->_getRequestValue($request); + } + + /** + * Validate data + * Return true or array of errors + * + * @param array|string $value + * @return boolean|array + */ + public function validateValue($value) + { + $errors = array(); + $attribute = $this->getAttribute(); + $label = __($attribute->getStoreLabel()); + + if ($value === false) { + // try to load original value and validate it + $value = $this->_value; + } + + if ($attribute->isRequired() && empty($value) && $value != '0') { + $errors[] = __('"%1" is a required value.', $label); + } + + if (!$errors && !$attribute->isRequired() && empty($value)) { + return true; + } + + if (count($errors) == 0) { + return true; + } + + return $errors; + } + + /** + * Export attribute value to entity model + * + * @param array|string $value + * @return string + */ + public function compactValue($value) + { + if ($value !== false) { + $value; + } + return false; + } + + /** + * Restore attribute value from SESSION to entity model + * + * @param array|string $value + * @return string + */ + public function restoreValue($value) + { + return $this->compactValue($value); + } + + /** + * Return a text for option value + * + * @param int $value + * @return string + */ + protected function _getOptionText($value) + { + $optionText = false; + foreach ($this->getAttribute()->getOptions() as $optionKey => $optionValue) { + if ($optionValue == $value) { + $optionText = $optionKey; + } + } + $output[] = $optionText; + } + + /** + * Return formated attribute value from entity model + * + * @return string|array + */ + public function outputValue($format = \Magento\Eav\Model\AttributeDataFactory::OUTPUT_FORMAT_TEXT) + { + $value = $this->_value; + switch ($format) { + case \Magento\Eav\Model\AttributeDataFactory::OUTPUT_FORMAT_JSON: + $output = $value; + break; + default: + if ($value != '') { + $output = $this->_getOptionText($value); + } else { + $output = ''; + } + break; + } + + return $output; + } +} diff --git a/app/code/Magento/Customer/Model/Metadata/Form/Text.php b/app/code/Magento/Customer/Model/Metadata/Form/Text.php new file mode 100644 index 0000000000000000000000000000000000000000..59bc406fce49103e08ed0d223b386d33693548f4 --- /dev/null +++ b/app/code/Magento/Customer/Model/Metadata/Form/Text.php @@ -0,0 +1,168 @@ +<?php +/** + * Form Element Text Data Model + * + * 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_Eav + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + + +/** + * EAV Entity Attribute Text Data Model + * + * @category Magento + * @package Magento_Eav + * @author Magento Core Team <core@magentocommerce.com> + */ +namespace Magento\Customer\Model\Metadata\Form; + +class Text extends AbstractData +{ + /** + * @var \Magento\Core\Helper\String + */ + protected $_string; + + /** + * @param \Magento\Core\Model\LocaleInterface $locale + * @param \Magento\Logger $logger + * @param \Magento\Customer\Service\V1\Dto\Eav\AttributeMetadata $attribute + * @param null $value + * @param $entityTypeCode + * @param bool $isAjax + * @param \Magento\Stdlib\String $stringHelper + */ + public function __construct( + \Magento\Core\Model\LocaleInterface $locale, + \Magento\Logger $logger, + \Magento\Customer\Service\V1\Dto\Eav\AttributeMetadata $attribute, + $value = null, + $entityTypeCode, + $isAjax = false, + \Magento\Stdlib\String $stringHelper + ) { + parent::__construct($locale, $logger, $attribute, $value, $entityTypeCode, $isAjax); + $this->_string = $stringHelper; + } + + /** + * Extract data from request and return value + * + * @param \Magento\App\RequestInterface $request + * @return array|string + */ + public function extractValue(\Magento\App\RequestInterface $request) + { + $value = $this->_getRequestValue($request); + return $this->_applyInputFilter($value); + } + + /** + * Validate data + * Return true or array of errors + * + * @param array|string $value + * @return boolean|array + */ + public function validateValue($value) + { + $errors = array(); + $attribute = $this->getAttribute(); + $label = __($attribute->getStoreLabel()); + + if ($value === false) { + // try to load original value and validate it + $value = $this->_value; + } + + if ($attribute->isRequired() && empty($value) && $value !== '0') { + $errors[] = __('"%1" is a required value.', $label); + } + + if (!$errors && !$attribute->isRequired() && empty($value)) { + return true; + } + + // validate length + $length = $this->_string->strlen(trim($value)); + + $validateRules = $attribute->getValidationRules(); + if (!empty($validateRules['min_text_length']) && $length < $validateRules['min_text_length']) { + $v = $validateRules['min_text_length']; + $errors[] = __('"%1" length must be equal or greater than %2 characters.', $label, $v); + } + if (!empty($validateRules['max_text_length']) && $length > $validateRules['max_text_length']) { + $v = $validateRules['max_text_length']; + $errors[] = __('"%1" length must be equal or less than %2 characters.', $label, $v); + } + + $result = $this->_validateInputRule($value); + if ($result !== true) { + $errors = array_merge($errors, $result); + } + if (count($errors) == 0) { + return true; + } + + return $errors; + } + + /** + * Export attribute value to entity model + * + * @param array|string $value + * @return string|value + */ + public function compactValue($value) + { + if ($value !== false) { + $value; + } + return false; + } + + /** + * Restore attribute value from SESSION to entity model + * + * @param array|string $value + * @return string|value + */ + public function restoreValue($value) + { + return $this->compactValue($value); + } + + /** + * Return formated attribute value from entity model + * + * @param string $format + * @return string|array + */ + public function outputValue($format = \Magento\Eav\Model\AttributeDataFactory::OUTPUT_FORMAT_TEXT) + { + $value = $this->_value; + $value = $this->_applyOutputFilter($value); + + return $value; + } +} diff --git a/app/code/Magento/ImportExport/Model/Export/Entity/Product/Type/Grouped.php b/app/code/Magento/Customer/Model/Metadata/Form/Textarea.php similarity index 71% rename from app/code/Magento/ImportExport/Model/Export/Entity/Product/Type/Grouped.php rename to app/code/Magento/Customer/Model/Metadata/Form/Textarea.php index 0f1b4a5d3f7647c9934f4f82e6e4b11af4207961..eeb7bec0d8366e7a313bf4e1b53861612c177bf9 100644 --- a/app/code/Magento/ImportExport/Model/Export/Entity/Product/Type/Grouped.php +++ b/app/code/Magento/Customer/Model/Metadata/Form/Textarea.php @@ -1,5 +1,7 @@ <?php /** + * Form Element Textarea Data Model + * * Magento * * NOTICE OF LICENSE @@ -19,21 +21,13 @@ * needs please refer to http://www.magentocommerce.com for more information. * * @category Magento - * @package Magento_ImportExport + * @package Magento_Eav * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -/** - * Export entity product type grouped model - * - * @category Magento - * @package Magento_ImportExport - * @author Magento Core Team <core@magentocommerce.com> - */ -namespace Magento\ImportExport\Model\Export\Entity\Product\Type; +namespace Magento\Customer\Model\Metadata\Form; -class Grouped - extends \Magento\ImportExport\Model\Export\Entity\Product\Type\AbstractType +class Textarea extends \Magento\Eav\Model\Attribute\Data\Text { } diff --git a/app/code/Magento/Customer/Model/Metadata/FormFactory.php b/app/code/Magento/Customer/Model/Metadata/FormFactory.php new file mode 100644 index 0000000000000000000000000000000000000000..7a4984c1cbfb8f1ebe7f517e77e6ba29819598cf --- /dev/null +++ b/app/code/Magento/Customer/Model/Metadata/FormFactory.php @@ -0,0 +1,70 @@ +<?php +/** + * Customer Form Element Factory + * + * 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_Customer + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Customer\Model\Metadata; + +class FormFactory +{ + /** + * @var \Magento\ObjectManager + */ + protected $_objectManager; + + /** + * @param \Magento\ObjectManager $objectManager + */ + public function __construct(\Magento\ObjectManager $objectManager) + { + $this->_objectManager = $objectManager; + } + + + /** + * Create Form + * + * @param string $entityType + * @param string $formCode + * @param array $attributeValues + * @param bool $isAjax + * @return \Magento\Customer\Model\Metadata\Form + */ + public function create( + $entityType, + $formCode, + $attributeValues = [], + $isAjax = false + ) { + $params = [ + 'entityType' => $entityType, + 'formCode' => $formCode, + 'attributeValues' => $attributeValues, + 'isAjax' => $isAjax, + ]; + return $this->_objectManager->create('Magento\Customer\Model\Metadata\Form', $params); + } +} \ No newline at end of file diff --git a/app/code/Magento/Customer/Model/Resource/Form/Attribute/CollectionFactory.php b/app/code/Magento/Customer/Model/Resource/Form/Attribute/CollectionFactory.php new file mode 100644 index 0000000000000000000000000000000000000000..410a6ff9d0005cd76ef76896b56460a652d6eb2d --- /dev/null +++ b/app/code/Magento/Customer/Model/Resource/Form/Attribute/CollectionFactory.php @@ -0,0 +1,54 @@ +<?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_Customer + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\Customer\Model\Resource\Form\Attribute; + +class CollectionFactory +{ + /** + * @var \Magento\ObjectManager + */ + protected $_objectManager; + + /** + * @param \Magento\ObjectManager $objectManager + */ + public function __construct(\Magento\ObjectManager $objectManager) + { + $this->_objectManager = $objectManager; + } + + + /** + * Create Collection + * + * @return \Magento\Customer\Model\Resource\Form\Attribute\Collection + */ + public function create() + { + return $this->_objectManager->create('Magento\Customer\Model\Resource\Form\Attribute\Collection'); + } +} \ No newline at end of file diff --git a/app/code/Magento/Customer/Model/Session.php b/app/code/Magento/Customer/Model/Session.php index 6c971a51859f434f6ac0997efafae69401398d49..133fa1f2b1fd6535f151010c0628e43e0499c967 100644 --- a/app/code/Magento/Customer/Model/Session.php +++ b/app/code/Magento/Customer/Model/Session.php @@ -80,7 +80,7 @@ class Session extends \Magento\Session\SessionManager protected $_customerFactory; /** - * @var \Magento\Core\Model\UrlFactory + * @var \Magento\UrlFactory */ protected $_urlFactory; @@ -106,7 +106,7 @@ class Session extends \Magento\Session\SessionManager * @param \Magento\Customer\Helper\Data $customerData * @param Resource\Customer $customerResource * @param CustomerFactory $customerFactory - * @param \Magento\Core\Model\UrlFactory $urlFactory + * @param \Magento\UrlFactory $urlFactory * @param \Magento\Core\Model\Session $session * @param \Magento\Event\ManagerInterface $eventManager * @param \Magento\Core\Model\StoreManagerInterface $storeManager @@ -125,7 +125,7 @@ class Session extends \Magento\Session\SessionManager \Magento\Customer\Helper\Data $customerData, \Magento\Customer\Model\Resource\Customer $customerResource, \Magento\Customer\Model\CustomerFactory $customerFactory, - \Magento\Core\Model\UrlFactory $urlFactory, + \Magento\UrlFactory $urlFactory, \Magento\Core\Model\Session $session, \Magento\Event\ManagerInterface $eventManager, \Magento\Core\Model\StoreManagerInterface $storeManager, @@ -441,7 +441,7 @@ class Session extends \Magento\Session\SessionManager } /** - * @return \Magento\Core\Model\Url + * @return \Magento\UrlInterface */ protected function _createUrl() { diff --git a/app/code/Magento/Customer/Service/Customer.php b/app/code/Magento/Customer/Service/Customer.php deleted file mode 100644 index ff922d06d93cdda283771f37933eb227a658b8f8..0000000000000000000000000000000000000000 --- a/app/code/Magento/Customer/Service/Customer.php +++ /dev/null @@ -1,416 +0,0 @@ -<?php -/** - * Customer service is responsible for customer business workflow encapsulation - * - * 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\Customer\Service; - -class Customer -{ - /** - * @var callable - */ - protected $_beforeSaveCallback = null; - - /** - * @var callable - */ - protected $_afterSaveCallback = null; - - /** - * @var \Magento\Customer\Helper\Data - */ - protected $_dataHelper = null; - - /** - * @var \Magento\Customer\Model\CustomerFactory - */ - protected $_customerFactory = null; - - /** - * @var \Magento\Customer\Model\AddressFactory - */ - protected $_addressFactory = null; - - /** - * @var bool - */ - protected $_isAdminStore = true; - - /** - * @var bool - */ - protected $_sendRemainderEmail = true; - // todo: drop the parameter as soon as front controller of webapi will be able to return routers - - /** - * Constructor - * - * @param \Magento\Customer\Helper\Data $helper - * @param \Magento\Customer\Model\CustomerFactory $customerFactory - * @param \Magento\Customer\Model\AddressFactory $addressFactory - * @param bool $isAdminStore - */ - public function __construct( - \Magento\Customer\Helper\Data $helper, - \Magento\Customer\Model\CustomerFactory $customerFactory, - \Magento\Customer\Model\AddressFactory $addressFactory, - $isAdminStore = true - ) { - $this->_dataHelper = $helper; - $this->_customerFactory = $customerFactory; - $this->_addressFactory = $addressFactory; - $this->_isAdminStore = $isAdminStore; - } - - /** - * Set is admin store flag. - * - * @param bool $isAdminStore - * @return \Magento\Customer\Service\Customer - */ - public function setIsAdminStore($isAdminStore) - { - $this->_isAdminStore = $isAdminStore; - return $this; - } - - /** - * Set flag if send remainder email - * - * @param bool $flag - * @return \Magento\Customer\Service\Customer - */ - public function setSendRemainderEmail($flag) - { - // todo: drop next string as soon as front controller of webapi will be able to return routers - $this->_sendRemainderEmail = (bool)$flag; - return $this; - } - - /** - * Set before save callback. - * - * @param callable $callback - * @return \Magento\Customer\Service\Customer - */ - public function setBeforeSaveCallback($callback) - { - $this->_beforeSaveCallback = $callback; - return $this; - } - - /** - * Set after save callback. - * - * @param callable $callback - * @return \Magento\Customer\Service\Customer - */ - public function setAfterSaveCallback($callback) - { - $this->_afterSaveCallback = $callback; - return $this; - } - - /** - * Create customer with optional ability of adding addresses. - * - * @param array $customerData - * @param array|null $addressesData array of addresses - * @return \Magento\Customer\Model\Customer - */ - public function create(array $customerData, array $addressesData = null) - { - $customer = $this->_customerFactory->create(); - $this->_preparePasswordForSave($customer, $customerData); - $this->_save($customer, $customerData, $addressesData); - - return $customer; - } - - /** - * Update customer entity. - * - * Update customer with optional ability to update customer addresses. - * Addresses that are not in $addressesData array but present in customer addresses collection will be removed. - * New address is created in case when no entity_id is present, otherwise corresponding address will be updated - * with data provided. - * - * @param string|int $customerId - * @param array $customerData - * @param array|null $addressesData array of addresses - * @return \Magento\Customer\Model\Customer - */ - public function update($customerId, array $customerData, array $addressesData = null) - { - /** @var \Magento\Customer\Model\Customer $customer */ - $customer = $this->_loadCustomerById($customerId); - - $this->_save($customer, $customerData, $addressesData); - if ($customerData) { - $this->_changePassword($customer, $customerData); - } - - return $customer; - } - - /** - * Save customer entity. Perform supplementary business workflow actions - * - * @param \Magento\Customer\Model\Customer $customer - * @param array $customerData - * @param array|null $addressesData - * @return \Magento\Customer\Service\Customer - */ - protected function _save($customer, array $customerData, array $addressesData = null) - { - if ($customerData) { - $this->_setDataUsingMethods($customer, $customerData); - } - $this->_beforeSave($customer, $customerData, $addressesData); - $customer->save(); - $this->_afterSave($customer, $customerData, $addressesData); - - return $this; - } - - /** - * Sets each value from data to entity \Magento\Object using setter method. - * - * @param \Magento\Object $entity - * @param array $data - */ - protected function _setDataUsingMethods($entity, array $data) - { - foreach ($data as $property => $value) { - $entity->setDataUsingMethod($property, $value); - } - } - - /** - * Trigger before save logic - * - * @param \Magento\Customer\Model\Customer $customer - * @param array $customerData - * @param array $addressesData - */ - protected function _beforeSave($customer, array $customerData, array $addressesData = null) - { - if (!is_null($addressesData)) { - $this->_prepareCustomerAddressesForSave($customer, $addressesData); - } - if (is_callable($this->_beforeSaveCallback)) { - call_user_func_array($this->_beforeSaveCallback, array($customer, $customerData, $addressesData)); - } - } - - /** - * Trigger before save logic - * - * @param \Magento\Customer\Model\Customer $customer - * @param array $customerData - * @param array $addressesData - */ - protected function _afterSave($customer, array $customerData, array $addressesData = null) - { - if (is_callable($this->_afterSaveCallback)) { - call_user_func_array($this->_afterSaveCallback, array($customer, $customerData, $addressesData)); - } - $this->_sendWelcomeEmail($customer, $customerData); - } - - /** - * Set customer password - * - * @param \Magento\Customer\Model\Customer $customer - * @param array $customerData - */ - protected function _preparePasswordForSave($customer, array $customerData) - { - $password = $this->_getCustomerPassword($customer, $customerData); - if (!is_null($password)) { - // 'force_confirmed' should be set in admin area only - if ($this->_isAdminStore) { - $customer->setForceConfirmed(true); - } - $customer->setPassword($password); - } - } - - /** - * Get customer password - * - * @param \Magento\Customer\Model\Customer $customer - * @param array $customerData - * @return string|null - */ - protected function _getCustomerPassword($customer, array $customerData) - { - $password = null; - - if ($this->_isAutogeneratePassword($customerData)) { - $password = $customer->generatePassword(); - } elseif (isset($customerData['password'])) { - $password = $customerData['password']; - } - - return $password; - } - - /** - * Change customer password - * - * @param \Magento\Customer\Model\Customer $customer - * @param array $customerData - * @return \Magento\Customer\Service\Customer - */ - protected function _changePassword($customer, array $customerData) - { - if (!empty($customerData['password']) || $this->_isAutogeneratePassword($customerData)) { - $newPassword = $this->_getCustomerPassword($customer, $customerData); - $customer->changePassword($newPassword); - if ($this->_sendRemainderEmail) { - $customer->sendPasswordReminderEmail(); - } - } - - return $this; - } - - /** - * Check if password should be generated automatically - * - * @param array $customerData - * @return bool - */ - protected function _isAutogeneratePassword(array $customerData) - { - return isset($customerData['autogenerate_password']) && $customerData['autogenerate_password']; - } - - /** - * Retrieve send email flag - * - * @param array $customerData - * @return bool - */ - protected function _isSendEmail(array $customerData) - { - return isset($customerData['sendemail']) && $customerData['sendemail']; - } - - /** - * Send welcome email to customer - * - * @param \Magento\Customer\Model\Customer $customer - * @param array $customerData - * @return \Magento\Customer\Service\Customer - */ - protected function _sendWelcomeEmail($customer, array $customerData) - { - if ($customer->getWebsiteId() - && ($this->_isSendEmail($customerData) || $this->_isAutogeneratePassword($customerData)) - ) { - $isNewCustomer = !(bool)$customer->getOrigData($customer->getIdFieldName()); - $storeId = $customer->getSendemailStoreId(); - - if ($isNewCustomer) { - $newLinkToken = $this->_dataHelper->generateResetPasswordLinkToken(); - $customer->changeResetPasswordLinkToken($newLinkToken); - $customer->sendNewAccountEmail('registered', '', $storeId); - } elseif (!$customer->getConfirmation()) { - // Confirm not confirmed customer - $customer->sendNewAccountEmail('confirmed', '', $storeId); - } - } - return $this; - } - - /** - * Load customer by its ID - * - * @param int|string $customerId - * @return \Magento\Customer\Model\Customer - * @throws \Magento\Core\Exception - */ - protected function _loadCustomerById($customerId) - { - $customer = $this->_customerFactory->create(); - $customer->load($customerId); - if (!$customer->getId()) { - throw new \Magento\Core\Exception(__("The customer with the specified ID not found.")); - } - - return $customer; - } - - /** - * Save customer addresses. - * - * @param \Magento\Customer\Model\Customer $customer - * @param array $addressesData - * @throws \Magento\Core\Exception - */ - protected function _prepareCustomerAddressesForSave($customer, array $addressesData) - { - $hasChanges = $customer->hasDataChanges(); - $actualAddressesIds = array(); - foreach ($addressesData as $addressData) { - $addressId = null; - if (array_key_exists('entity_id', $addressData)) { - $addressId = $addressData['entity_id']; - unset($addressData['entity_id']); - } - - if (null !== $addressId) { - $address = $customer->getAddressItemById($addressId); - if (!$address || !$address->getId()) { - throw new \Magento\Core\Exception( - __('The address with the specified ID not found.') - ); - } - } else { - $address = $this->_addressFactory->create(); - $address->setCustomerId($customer->getId()); - // Add customer address into addresses collection - $customer->addAddress($address); - } - $address->addData($addressData); - $hasChanges = $hasChanges || $address->hasDataChanges(); - - // Set post_index for detect default billing and shipping addresses - $address->setPostIndex($addressId); - - $actualAddressesIds[] = $address->getId(); - } - - /** @var \Magento\Customer\Model\Address $address */ - foreach ($customer->getAddressesCollection() as $address) { - if (!in_array($address->getId(), $actualAddressesIds)) { - $address->setData('_deleted', true); - $hasChanges = true; - } - } - $customer->setDataChanges($hasChanges); - } -} diff --git a/app/code/Magento/Customer/Service/V1/CustomerMetadataService.php b/app/code/Magento/Customer/Service/V1/CustomerMetadataService.php index 695b5cf701b62039e3d719ea7b6260774402ede2..a9e9cd5d702dc4c4ab561e4c0f4da1700573bf2d 100644 --- a/app/code/Magento/Customer/Service/V1/CustomerMetadataService.php +++ b/app/code/Magento/Customer/Service/V1/CustomerMetadataService.php @@ -25,9 +25,7 @@ */ namespace Magento\Customer\Service\V1; -use Magento\Customer\Service\V1\CustomerMetadataServiceInterface; use Magento\Customer\Service\V1\Dto\Eav\AttributeMetadata; -use Magento\Customer\Service\V1\Dto\Eav\OptionBuilder; class CustomerMetadataService implements CustomerMetadataServiceInterface { @@ -40,9 +38,9 @@ class CustomerMetadataService implements CustomerMetadataServiceInterface private $_cache; /** - * @var \Magento\Customer\Model\Resource\Form\Attribute\Collection + * @var \Magento\Customer\Model\Resource\Form\Attribute\CollectionFactory */ - private $_attrFormCollection; + private $_attrFormCollectionFactory; /** * @var \Magento\Core\Model\StoreManager @@ -61,21 +59,21 @@ class CustomerMetadataService implements CustomerMetadataServiceInterface /** * @param \Magento\Eav\Model\Config $eavConfig - * @param \Magento\Customer\Model\Resource\Form\Attribute\Collection $attrFormCollection + * @param \Magento\Customer\Model\Resource\Form\Attribute\CollectionFactory $attrFormCollectionFactory * @param \Magento\Core\Model\StoreManager $storeManager * @param \Magento\Customer\Service\V1\Dto\Eav\OptionBuilder $optionBuilder * @param \Magento\Customer\Service\V1\Dto\Eav\AttributeMetadataBuilder $attributeMetadataBuilder */ public function __construct( \Magento\Eav\Model\Config $eavConfig, - \Magento\Customer\Model\Resource\Form\Attribute\Collection $attrFormCollection, + \Magento\Customer\Model\Resource\Form\Attribute\CollectionFactory $attrFormCollectionFactory, \Magento\Core\Model\StoreManager $storeManager, \Magento\Customer\Service\V1\Dto\Eav\OptionBuilder $optionBuilder, \Magento\Customer\Service\V1\Dto\Eav\AttributeMetadataBuilder $attributeMetadataBuilder ) { $this->_eavConfig = $eavConfig; $this->_cache = []; - $this->_attrFormCollection = $attrFormCollection; + $this->_attrFormCollectionFactory = $attrFormCollectionFactory; $this->_storeManager = $storeManager; $this->_optionBuilder = $optionBuilder; $this->_attributeMetadataBuilder = $attributeMetadataBuilder; @@ -138,8 +136,8 @@ class CustomerMetadataService implements CustomerMetadataServiceInterface public function getAttributes($entityType, $formCode) { $attributes = []; - $this->_loadAttributesCollection($entityType, $formCode); - foreach ($this->_attrFormCollection as $attribute) { + $attributesFormCollection = $this->_loadAttributesCollection($entityType, $formCode); + foreach ($attributesFormCollection as $attribute) { $attributes[$attribute->getAttributeCode()] = $this->_createMetadataAttribute($attribute); } return $attributes; @@ -150,34 +148,34 @@ class CustomerMetadataService implements CustomerMetadataServiceInterface * * @param $entityType * @param $formCode - * @return null + * @return \Magento\Customer\Model\Resource\Form\Attribute\Collection */ private function _loadAttributesCollection($entityType, $formCode) { - $this->_attrFormCollection - ->setStore($this->_storeManager->getStore()) + $attributesFormCollection = $this->_attrFormCollectionFactory->create(); + $attributesFormCollection->setStore($this->_storeManager->getStore()) ->setEntityType($entityType) ->addFormCodeFilter($formCode) - ->setSortOrder() - ->load(); + ->setSortOrder(); + + return $attributesFormCollection; } /** - * @param \Magento\Eav\Model\Entity\Attribute\AbstractAttribute $attribute + * @param \Magento\Customer\Model\Attribute $attribute * @return AttributeMetadata */ private function _createMetadataAttribute($attribute) { $options = []; - try { + if ($attribute->usesSource()) { foreach ($attribute->getSource()->getAllOptions() as $option) { $options[$option['label']] = $this->_optionBuilder->setLabel($option['label']) ->setValue($option['value']) ->create(); } - } catch (\Exception $e) { - // There is no source for this attribute } + $this->_attributeMetadataBuilder->setAttributeCode($attribute->getAttributeCode()) ->setFrontendInput($attribute->getFrontendInput()) ->setInputFilter($attribute->getInputFilter()) @@ -187,7 +185,12 @@ class CustomerMetadataService implements CustomerMetadataServiceInterface ->setIsRequired($attribute->getIsRequired()) ->setMultilineCount($attribute->getMultilineCount()) ->setDataModel($attribute->getDataModel()) - ->setOptions($options); + ->setOptions($options) + ->setFrontendClass($attribute->getFrontend()->getClass()) + ->setFrontendLabel($attribute->getFrontendLabel()) + ->setIsSystem($attribute->getIsSystem()) + ->setIsUserDefined($attribute->getIsUserDefined()) + ->setSortOrder($attribute->getSortOrder()); return $this->_attributeMetadataBuilder->create(); } diff --git a/app/code/Magento/Customer/Service/V1/Dto/Address.php b/app/code/Magento/Customer/Service/V1/Dto/Address.php index 771209452dc0c729dd6141757e364e2f47f77c3b..9c0905ef8bf7593290ec1a130ade937b8e473b72 100644 --- a/app/code/Magento/Customer/Service/V1/Dto/Address.php +++ b/app/code/Magento/Customer/Service/V1/Dto/Address.php @@ -29,6 +29,9 @@ use Magento\Customer\Service\V1\Dto\Region; class Address extends \Magento\Service\Entity\AbstractDto implements Eav\EntityInterface { + + const KEY_COUNTRY_ID = 'country_id'; + /** * @var array */ @@ -105,7 +108,7 @@ class Address extends \Magento\Service\Entity\AbstractDto implements Eav\EntityI */ public function getCountryId() { - return $this->_get('country_id'); + return $this->_get(self::KEY_COUNTRY_ID); } /** diff --git a/app/code/Magento/Customer/Service/V1/Dto/Eav/AttributeMetadata.php b/app/code/Magento/Customer/Service/V1/Dto/Eav/AttributeMetadata.php index 7c1c05328af526ff1d8414a84f51aa932bbac97d..eeb75e9466a5edcb7f48769bc5b3d0eece10c17d 100644 --- a/app/code/Magento/Customer/Service/V1/Dto/Eav/AttributeMetadata.php +++ b/app/code/Magento/Customer/Service/V1/Dto/Eav/AttributeMetadata.php @@ -25,11 +25,9 @@ */ namespace Magento\Customer\Service\V1\Dto\Eav; -use Magento\Customer\Service\V1\Dto\Eav\Option; - class AttributeMetadata extends \Magento\Service\Entity\AbstractDto { - /** + /**#@+ * Constants used as keys into $_data */ const ATTRIBUTE_CODE = 'attribute_code'; @@ -42,8 +40,16 @@ class AttributeMetadata extends \Magento\Service\Entity\AbstractDto const REQUIRED = 'is_required'; const MULTILINE_COUNT = 'multiline_count'; const DATA_MODEL = 'data_model'; + const IS_USER_DEFINED = 'is_user_defined'; + const FRONTEND_CLASS = 'front_end_class'; + const SORT_ORDER = 'sort_order'; + const FRONTEND_LABEL = 'frontend_label'; + const IS_SYSTEM = 'is_system'; + /**#@-*/ /** + * Retrieve code of the attribute. + * * @return string */ public function getAttributeCode() @@ -52,6 +58,8 @@ class AttributeMetadata extends \Magento\Service\Entity\AbstractDto } /** + * Frontend HTML for input element. + * * @return string */ public function getFrontendInput() @@ -60,6 +68,8 @@ class AttributeMetadata extends \Magento\Service\Entity\AbstractDto } /** + * Get template used for input (e.g. "date") + * * @return string */ public function getInputFilter() @@ -68,6 +78,8 @@ class AttributeMetadata extends \Magento\Service\Entity\AbstractDto } /** + * Get label of the store. + * * @return string */ public function getStoreLabel() @@ -76,6 +88,8 @@ class AttributeMetadata extends \Magento\Service\Entity\AbstractDto } /** + * Retrieve validation rules. + * * @return string */ public function getValidationRules() @@ -84,6 +98,8 @@ class AttributeMetadata extends \Magento\Service\Entity\AbstractDto } /** + * Number of lines of the attribute value. + * * @return int */ public function getMultilineCount() @@ -92,22 +108,28 @@ class AttributeMetadata extends \Magento\Service\Entity\AbstractDto } /** + * Whether attribute is visible on frontend. + * * @return boolean */ - public function getIsVisible() + public function isVisible() { return $this->_get(self::VISIBLE); } /** + * Whether attribute is required. + * * @return boolean */ - public function getIsRequired() + public function isRequired() { return $this->_get(self::REQUIRED); } /** + * Get data model for attribute. + * * @return string */ public function getDataModel() @@ -116,10 +138,62 @@ class AttributeMetadata extends \Magento\Service\Entity\AbstractDto } /** + * Return options of the attribute (key => value pairs for select) + * * @return Option[] */ public function getOptions() { return $this->_get(self::OPTIONS); } + + /** + * Get class which is used to display the attribute on frontend. + * + * @return string + */ + public function getFrontendClass() + { + return $this->_get(self::FRONTEND_CLASS); + } + + /** + * Whether current attribute has been defined by a user. + * + * @return bool + */ + public function isUserDefined() + { + return $this->_get(self::IS_USER_DEFINED); + } + + /** + * Get attributes sort order. + * + * @return int + */ + public function getSortOrder() + { + return $this->_get(self::SORT_ORDER); + } + + /** + * Get label which supposed to be displayed on frontend. + * + * @return string + */ + public function getFrontendLabel() + { + return $this->_get(self::FRONTEND_LABEL); + } + + /** + * Whether this is a system attribute. + * + * @return bool + */ + public function isSystem() + { + return $this->_get(self::IS_SYSTEM); + } } diff --git a/app/code/Magento/Customer/Service/V1/Dto/Eav/AttributeMetadataBuilder.php b/app/code/Magento/Customer/Service/V1/Dto/Eav/AttributeMetadataBuilder.php index 72792c4292fd73664acbce60e0844fe5f15f37bd..acbf32174ccdbbd6d6cf695e196752536652adbf 100644 --- a/app/code/Magento/Customer/Service/V1/Dto/Eav/AttributeMetadataBuilder.php +++ b/app/code/Magento/Customer/Service/V1/Dto/Eav/AttributeMetadataBuilder.php @@ -25,8 +25,6 @@ */ namespace Magento\Customer\Service\V1\Dto\Eav; -use Magento\Customer\Service\V1\Dto\Eav\AttributeMetadata; - class AttributeMetadataBuilder extends \Magento\Service\Entity\AbstractDtoBuilder { /** @@ -89,7 +87,7 @@ class AttributeMetadataBuilder extends \Magento\Service\Entity\AbstractDtoBuilde */ public function setOptions($options) { - $this->_set(AttributeMetadata::OPTIONS, $options); + return $this->_set(AttributeMetadata::OPTIONS, $options); } /** @@ -121,11 +119,56 @@ class AttributeMetadataBuilder extends \Magento\Service\Entity\AbstractDtoBuilde } /** - * @param string + * @param string $dataModel * @return AttributeMetadataBuilder */ public function setDataModel($dataModel) { return $this->_set(AttributeMetadata::DATA_MODEL, $dataModel); } + + /** + * @param $frontendClass + * @return AttributeMetadataBuilder + */ + public function setFrontendClass($frontendClass) + { + return $this->_set(AttributeMetadata::FRONTEND_CLASS, $frontendClass); + } + + /** + * @param bool $isUserDefined + * @return AttributeMetadataBuilder + */ + public function setIsUserDefined($isUserDefined) + { + return $this->_set(AttributeMetadata::IS_USER_DEFINED, $isUserDefined); + } + + /** + * @param int $sortOrder + * @return AttributeMetadataBuilder + */ + public function setSortOrder($sortOrder) + { + return $this->_set(AttributeMetadata::SORT_ORDER, $sortOrder); + } + + /** + * @param string $frontendLabel + * @return AttributeMetadataBuilder + */ + public function setFrontendLabel($frontendLabel) + { + return $this->_set(AttributeMetadata::FRONTEND_LABEL, $frontendLabel); + } + + /** + * @param bool $isSystem + * @return AttributeMetadataBuilder + */ + public function setIsSystem($isSystem) + { + return $this->_set(AttributeMetadata::IS_SYSTEM, $isSystem); + } } diff --git a/app/code/Magento/Customer/etc/di.xml b/app/code/Magento/Customer/etc/di.xml index dfb7026534a0e9f723c0b35307557e52d4ba9366..486515cdbc3f2cb62d66fd33f84f28982df51ec2 100644 --- a/app/code/Magento/Customer/etc/di.xml +++ b/app/code/Magento/Customer/etc/di.xml @@ -50,9 +50,9 @@ </type> <type name="Magento\Module\Updater\SetupFactory"> <param name="resourceTypes"> - <value> - <customer_setup>Magento\Customer\Model\Resource\Setup</customer_setup> - </value> + <array> + <item key="customer_setup"><value>Magento\Customer\Model\Resource\Setup</value></item> + </array> </param> </type> <type name="Magento\Customer\Helper\Address"> diff --git a/app/code/Magento/Customer/etc/frontend/di.xml b/app/code/Magento/Customer/etc/frontend/di.xml index bb634792fbef00f7764b736432a06490b248cabe..c74382804f4233e4cfdfaf0c78526fa7b99100ce 100644 --- a/app/code/Magento/Customer/etc/frontend/di.xml +++ b/app/code/Magento/Customer/etc/frontend/di.xml @@ -31,17 +31,17 @@ </type> <type name="Magento\Core\Model\Url\SecurityInfo"> <param name="secureUrlList"> - <value> - <customer>/customer/</customer> - </value> + <array> + <item key="customer"><value>/customer/</value></item> + </array> </param> </type> <virtualType name="customerAccountInitSession" type="Magento\Core\App\Action\Plugin\Session"> <param name="cookieCheckActions"> - <value> - <customerLogin>loginPost</customerLogin> - <customerCreate>createpost</customerCreate> - </value> + <array> + <item key="customerLogin"><value>loginPost</value></item> + <item key="customerCreate"><value>createpost</value></item> + </array> </param> </virtualType> <type name="Magento\Customer\Controller\Account"> diff --git a/app/code/Magento/Customer/sql/customer_setup/upgrade-1.6.1.0-1.6.2.0.php b/app/code/Magento/Customer/sql/customer_setup/upgrade-1.6.1.0-1.6.2.0.php index 7eef3c482d1b51f1a4755421ccd922d1af56e2a6..041acc582af2ce3dcccff16e7d4db9657ce5f90a 100644 --- a/app/code/Magento/Customer/sql/customer_setup/upgrade-1.6.1.0-1.6.2.0.php +++ b/app/code/Magento/Customer/sql/customer_setup/upgrade-1.6.1.0-1.6.2.0.php @@ -24,7 +24,7 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -/* @var $installer \Magento\Customer\Model\Entity\Setup */ +/* @var $installer \Magento\Customer\Model\Resource\Setup */ $installer = $this; $disableAGCAttributeCode = 'disable_auto_group_change'; diff --git a/app/code/Magento/Customer/view/frontend/account/link/authorization.phtml b/app/code/Magento/Customer/view/frontend/account/link/authorization.phtml new file mode 100644 index 0000000000000000000000000000000000000000..b40d300c45abbd45c11f7c908179178a763ae659 --- /dev/null +++ b/app/code/Magento/Customer/view/frontend/account/link/authorization.phtml @@ -0,0 +1,31 @@ +<?php +/** + * 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. + * + * @category design + * @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) + */ +?> +<li> + <?php /** @var $this \Magento\Customer\Block\Account\AuthorizationLink */?> + <a <?php if ($this->isLoggedIn()) {echo "data-post='" . $this->getPostParams(); } ?>' <?php echo $this->getLinkAttributes(); ?> > + <?php echo $this->escapeHtml($this->getLabel()); ?> + </a> +</li> diff --git a/app/code/Magento/Customer/view/frontend/layout/default.xml b/app/code/Magento/Customer/view/frontend/layout/default.xml index c0cf556c60480c5636521132dc8bbe3dcef68738..0154cacb206deb311bb6a8d0175d3bc9ef5b9356 100644 --- a/app/code/Magento/Customer/view/frontend/layout/default.xml +++ b/app/code/Magento/Customer/view/frontend/layout/default.xml @@ -35,6 +35,6 @@ <argument name="label" xsi:type="string">Register</argument> </arguments> </block> - <block class="Magento\Customer\Block\Account\AuthorizationLink" name="authorization-link" after="onepage-checkout-link" cacheable="false"/> + <block class="Magento\Customer\Block\Account\AuthorizationLink" name="authorization-link" template="account/link/authorization.phtml" after="onepage-checkout-link" cacheable="false"/> </referenceBlock> </layout> 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 df1e847f9b2be83070b25a0d0690737ee19bfabb..e65165e2770ff075477e22156e9a1a34ab895115 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 @@ -429,12 +429,12 @@ class Tools extends \Magento\Backend\App\Action /** * Re-init system configuration * - * @return \Magento\Core\Model\Config + * @return \Magento\App\ReinitableConfigInterface */ protected function _reinitSystemConfiguration() { - /** @var $configModel \Magento\Core\Model\Config */ - $configModel = $this->_objectManager->get('Magento\Core\Model\Config'); + /** @var $configModel \Magento\App\ReinitableConfigInterface */ + $configModel = $this->_objectManager->get('Magento\App\ReinitableConfigInterface'); return $configModel->reinit(); } } diff --git a/app/code/Magento/DesignEditor/Controller/Varien/Router/Standard.php b/app/code/Magento/DesignEditor/Controller/Varien/Router/Standard.php index 10b2dc97b880846bd5a8fe6fc9462199fcb26d75..26901fcc4720297f5426340c7a5560e8393f97dc 100644 --- a/app/code/Magento/DesignEditor/Controller/Varien/Router/Standard.php +++ b/app/code/Magento/DesignEditor/Controller/Varien/Router/Standard.php @@ -62,7 +62,7 @@ class Standard extends \Magento\Core\App\Router\Base * @param \Magento\UrlInterface $url * @param \Magento\Core\Model\StoreManagerInterface $storeManager * @param \Magento\Core\Model\Store\Config $storeConfig - * @param \Magento\Core\Model\Url\SecurityInfoInterface $urlSecurityInfo + * @param \Magento\Url\SecurityInfoInterface $urlSecurityInfo * @param string $routerId * @param \Magento\App\RouterListInterface $routerList * @param \Magento\ObjectManager $objectManager @@ -79,7 +79,7 @@ class Standard extends \Magento\Core\App\Router\Base \Magento\UrlInterface $url, \Magento\Core\Model\StoreManagerInterface $storeManager, \Magento\Core\Model\Store\Config $storeConfig, - \Magento\Core\Model\Url\SecurityInfoInterface $urlSecurityInfo, + \Magento\Url\SecurityInfoInterface $urlSecurityInfo, $routerId, \Magento\App\RouterListInterface $routerList, \Magento\ObjectManager $objectManager, diff --git a/app/code/Magento/DesignEditor/Model/State.php b/app/code/Magento/DesignEditor/Model/State.php index a6d883b93c71fb953452e200ac518e9d19d68027..99c1e2d0a5eb608e69518fa08d22fd04b620a788 100644 --- a/app/code/Magento/DesignEditor/Model/State.php +++ b/app/code/Magento/DesignEditor/Model/State.php @@ -37,7 +37,7 @@ class State const LAYOUT_NAVIGATION_CLASS_NAME = 'Magento\Core\Model\Layout'; /** - * Url model classes that will be used instead of \Magento\Core\Model\Url in navigation vde modes + * Url model classes that will be used instead of \Magento\UrlInterface in navigation vde modes */ const URL_MODEL_NAVIGATION_MODE_CLASS_NAME = 'Magento\DesignEditor\Model\Url\NavigationMode'; @@ -90,6 +90,13 @@ class State */ protected $_application; + /** + * Store list manager + * + * @var \Magento\Core\Model\StoreManagerInterface + */ + protected $_storeManager; + /** * @param \Magento\Backend\Model\Session $backendSession * @param \Magento\Core\Model\Layout\Factory $layoutFactory @@ -99,6 +106,7 @@ class State * @param \Magento\ObjectManager $objectManager * @param \Magento\Core\Model\App $application * @param \Magento\DesignEditor\Model\Theme\Context $themeContext + * @param \Magento\Core\Model\StoreManagerInterface $storeManager */ public function __construct( \Magento\Backend\Model\Session $backendSession, @@ -108,7 +116,8 @@ class State \Magento\DesignEditor\Helper\Data $dataHelper, \Magento\ObjectManager $objectManager, \Magento\Core\Model\App $application, - \Magento\DesignEditor\Model\Theme\Context $themeContext + \Magento\DesignEditor\Model\Theme\Context $themeContext, + \Magento\Core\Model\StoreManagerInterface $storeManager ) { $this->_backendSession = $backendSession; $this->_layoutFactory = $layoutFactory; @@ -118,6 +127,7 @@ class State $this->_objectManager = $objectManager; $this->_application = $application; $this->_themeContext = $themeContext; + $this->_storeManager = $storeManager; } /** @@ -171,7 +181,7 @@ class State } /** - * Create url model instance that will be used instead of \Magento\Core\Model\Url in navigation mode + * Create url model instance that will be used instead of \Magento\UrlInterface in navigation mode */ protected function _injectUrlModel($mode) { @@ -190,7 +200,7 @@ class State { if ($this->_themeContext->getEditableTheme()) { $themeId = $this->_themeContext->getVisibleTheme()->getId(); - $this->_application->getStore()->setConfig( + $this->_storeManager->getStore()->setConfig( \Magento\View\DesignInterface::XML_PATH_THEME_ID, $themeId ); diff --git a/app/code/Magento/DesignEditor/Model/Translate/InlineVde.php b/app/code/Magento/DesignEditor/Model/Translate/InlineVde.php index c88c00de8e781b5e0c6606b068fb1b37e9cbf7aa..d6c6a07108939516980ba8129e752aa700e081d7 100644 --- a/app/code/Magento/DesignEditor/Model/Translate/InlineVde.php +++ b/app/code/Magento/DesignEditor/Model/Translate/InlineVde.php @@ -71,7 +71,7 @@ class InlineVde implements \Magento\Core\Model\Translate\InlineInterface protected $_parser; /** - * @var \Magento\Core\Model\Url + * @var \Magento\UrlInterface */ protected $_url; @@ -92,13 +92,13 @@ class InlineVde implements \Magento\Core\Model\Translate\InlineInterface * * @param \Magento\Core\Model\Translate\InlineParser $parser * @param \Magento\DesignEditor\Helper\Data $helper - * @param \Magento\Core\Model\Url $url + * @param \Magento\UrlInterface $url * @param \Magento\ObjectManager $objectManager */ public function __construct( \Magento\Core\Model\Translate\InlineParser $parser, \Magento\DesignEditor\Helper\Data $helper, - \Magento\Core\Model\Url $url, + \Magento\UrlInterface $url, \Magento\ObjectManager $objectManager ) { $this->_parser = $parser; diff --git a/app/code/Magento/DesignEditor/Model/Url/Factory.php b/app/code/Magento/DesignEditor/Model/Url/Factory.php index f84c98d5723d7bfa544fdab81a370eca5fca605a..8fcfd89fe4428434d8a3bbc2f70a670645b529dc 100644 --- a/app/code/Magento/DesignEditor/Model/Url/Factory.php +++ b/app/code/Magento/DesignEditor/Model/Url/Factory.php @@ -31,7 +31,7 @@ class Factory /** * Default url model class name */ - const CLASS_NAME = 'Magento\Core\Model\Url'; + const CLASS_NAME = 'Magento\UrlInterface'; /** * @var \Magento\ObjectManager @@ -63,7 +63,7 @@ class Factory * Create url model new instance * * @param array $arguments - * @return \Magento\Core\Model\Url + * @return \Magento\UrlInterface */ public function create(array $arguments = array()) { diff --git a/app/code/Magento/DesignEditor/Model/Url/NavigationMode.php b/app/code/Magento/DesignEditor/Model/Url/NavigationMode.php index c6859d0ffe8719c80b071787137d0b6108c4958d..13840b5d30335fac3b3d57f69ca03f149eeaf434 100644 --- a/app/code/Magento/DesignEditor/Model/Url/NavigationMode.php +++ b/app/code/Magento/DesignEditor/Model/Url/NavigationMode.php @@ -29,7 +29,7 @@ */ namespace Magento\DesignEditor\Model\Url; -class NavigationMode extends \Magento\Core\Model\Url +class NavigationMode extends \Magento\Url { /** * VDE helper @@ -55,29 +55,25 @@ class NavigationMode extends \Magento\Core\Model\Url /** * @param \Magento\App\Route\ConfigInterface $routeConfig * @param \Magento\App\RequestInterface $request - * @param \Magento\Core\Model\Url\SecurityInfoInterface $urlSecurityInfo - * @param \Magento\Core\Model\Store\Config $coreStoreConfig - * @param \Magento\Core\Model\App $app - * @param \Magento\Core\Model\StoreManagerInterface $storeManager + * @param \Magento\Url\SecurityInfoInterface $urlSecurityInfo + * @param \Magento\Url\ScopeResolverInterface $scopeResolver * @param \Magento\Core\Model\Session $session * @param \Magento\Session\SidResolverInterface $sidResolver + * @param \Magento\Url\RouteParamsResolverFactory $routeParamsResolver + * @param \Magento\Url\QueryParamsResolverInterface $queryParamsResolver * @param \Magento\DesignEditor\Helper\Data $helper - * @param string $areaCode * @param array $data - * - * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ public function __construct( \Magento\App\Route\ConfigInterface $routeConfig, \Magento\App\RequestInterface $request, - \Magento\Core\Model\Url\SecurityInfoInterface $urlSecurityInfo, - \Magento\Core\Model\Store\Config $coreStoreConfig, - \Magento\Core\Model\App $app, - \Magento\Core\Model\StoreManagerInterface $storeManager, + \Magento\Url\SecurityInfoInterface $urlSecurityInfo, + \Magento\Url\ScopeResolverInterface $scopeResolver, \Magento\Core\Model\Session $session, \Magento\Session\SidResolverInterface $sidResolver, + \Magento\Url\RouteParamsResolverFactory $routeParamsResolver, + \Magento\Url\QueryParamsResolverInterface $queryParamsResolver, \Magento\DesignEditor\Helper\Data $helper, - $areaCode, array $data = array() ) { $this->_helper = $helper; @@ -92,12 +88,11 @@ class NavigationMode extends \Magento\Core\Model\Url $routeConfig, $request, $urlSecurityInfo, - $coreStoreConfig, - $app, - $storeManager, + $scopeResolver, $session, $sidResolver, - $areaCode, + $routeParamsResolver, + $queryParamsResolver, $data ); } @@ -133,11 +128,11 @@ class NavigationMode extends \Magento\Core\Model\Url protected function _hasThemeAndMode() { if (!$this->_mode) { - $this->_mode = $this->getRequest()->getAlias('editorMode'); + $this->_mode = $this->_getRequest()->getAlias('editorMode'); } if (!$this->_themeId) { - $this->_themeId = $this->getRequest()->getAlias('themeId'); + $this->_themeId = $this->_getRequest()->getAlias('themeId'); } return $this; } diff --git a/app/code/Magento/DesignEditor/etc/di.xml b/app/code/Magento/DesignEditor/etc/di.xml index beffc0dab77300273b036d50ee27dc309d2250f0..b60f4b20bdd75784abbe5af544499c4851d2816a 100644 --- a/app/code/Magento/DesignEditor/etc/di.xml +++ b/app/code/Magento/DesignEditor/etc/di.xml @@ -37,10 +37,10 @@ <value>vde</value> </param> <param name="disabledCacheTypes"> - <value> - <block_html>block_html</block_html> - <configType>config</configType> - </value> + <array> + <item key="block_html"><value>block_html</value></item> + <item key="configType"><value>config</value></item> + </array> </param> </type> </config> diff --git a/app/code/Magento/DesignEditor/etc/frontend/di.xml b/app/code/Magento/DesignEditor/etc/frontend/di.xml index 641cb3e08599a5aeec0c32adac6dea9b16427d26..fe9b602f0935ea2a4fc2ab205646d5e4f480bdaf 100644 --- a/app/code/Magento/DesignEditor/etc/frontend/di.xml +++ b/app/code/Magento/DesignEditor/etc/frontend/di.xml @@ -26,13 +26,15 @@ <config> <type name="Magento\App\RouterList"> <param name="routerList"> - <value> - <vde> - <instance>Magento\DesignEditor\Controller\Varien\Router\Standard</instance> - <disable type="bool">false</disable> - <sortOrder>40</sortOrder> - </vde> - </value> + <array> + <item key="vde"> + <array> + <item key="instance"><value>Magento\DesignEditor\Controller\Varien\Router\Standard</value></item> + <item key="disable"><value type="bool">false</value></item> + <item key="sortOrder"><value>40</value></item> + </array> + </item> + </array> </param> </type> </config> diff --git a/app/code/Magento/Directory/Helper/Data.php b/app/code/Magento/Directory/Helper/Data.php index 6ed3b6ffec17a491baeaa6cd9a6236e6adf07ec9..042485121aa8df66754cb8c7783379f653491027 100644 --- a/app/code/Magento/Directory/Helper/Data.php +++ b/app/code/Magento/Directory/Helper/Data.php @@ -107,7 +107,7 @@ class Data extends \Magento\App\Helper\AbstractHelper protected $_currencyFactory; /** - * @var \Magento\Core\Model\Config + * @var \Magento\App\ConfigInterface */ protected $_config; @@ -119,7 +119,7 @@ class Data extends \Magento\App\Helper\AbstractHelper * @param \Magento\Core\Helper\Data $coreHelper * @param \Magento\Core\Model\StoreManagerInterface $storeManager * @param \Magento\Directory\Model\CurrencyFactory $currencyFactory - * @param \Magento\Core\Model\Config $config + * @param \Magento\App\ConfigInterface $config */ public function __construct( \Magento\App\Helper\Context $context, @@ -129,7 +129,7 @@ class Data extends \Magento\App\Helper\AbstractHelper \Magento\Core\Helper\Data $coreHelper, \Magento\Core\Model\StoreManagerInterface $storeManager, \Magento\Directory\Model\CurrencyFactory $currencyFactory, - \Magento\Core\Model\Config $config + \Magento\App\ConfigInterface $config ) { parent::__construct($context); $this->_configCacheType = $configCacheType; diff --git a/app/code/Magento/Directory/Model/Currency/DefaultLocator.php b/app/code/Magento/Directory/Model/Currency/DefaultLocator.php index c7293304413c9292871255c75fb190713b597137..761a1b00866272bacde5fd16674af67b010349b3 100644 --- a/app/code/Magento/Directory/Model/Currency/DefaultLocator.php +++ b/app/code/Magento/Directory/Model/Currency/DefaultLocator.php @@ -35,14 +35,25 @@ class DefaultLocator */ protected $_app; + /** + * Store manager + * + * @var \Magento\Core\Model\StoreManagerInterface + */ + protected $_storeManager; + /** * Constructor * * @param \Magento\Core\Model\App $app + * @param \Magento\Core\Model\StoreManagerInterface $storeManager */ - public function __construct(\Magento\Core\Model\App $app) - { + public function __construct( + \Magento\Core\Model\App $app, + \Magento\Core\Model\StoreManagerInterface $storeManager + ) { $this->_app = $app; + $this->_storeManager = $storeManager; } /** @@ -55,13 +66,13 @@ class DefaultLocator { if ($request->getParam('store')) { $store = $request->getParam('store'); - $currencyCode = $this->_app->getStore($store)->getBaseCurrencyCode(); + $currencyCode = $this->_storeManager->getStore($store)->getBaseCurrencyCode(); } else if ($request->getParam('website')) { $website = $request->getParam('website'); - $currencyCode = $this->_app->getWebsite($website)->getBaseCurrencyCode(); + $currencyCode = $this->_storeManager->getWebsite($website)->getBaseCurrencyCode(); } else if ($request->getParam('group')) { $group = $request->getParam('group'); - $currencyCode = $this->_app->getGroup($group)->getWebsite()->getBaseCurrencyCode(); + $currencyCode = $this->_storeManager->getGroup($group)->getWebsite()->getBaseCurrencyCode(); } else { $currencyCode = $this->_app->getBaseCurrencyCode(); } diff --git a/app/code/Magento/Directory/Model/Currency/Import/Source/Service.php b/app/code/Magento/Directory/Model/Currency/Import/Source/Service.php index daf3e01e6d1f7a42bb0004b95691dd005ec630c5..b7a08d86ec459b3cd424cfbd8837038642bf0983 100644 --- a/app/code/Magento/Directory/Model/Currency/Import/Source/Service.php +++ b/app/code/Magento/Directory/Model/Currency/Import/Source/Service.php @@ -26,7 +26,7 @@ namespace Magento\Directory\Model\Currency\Import\Source; class Service implements \Magento\Core\Model\Option\ArrayInterface { /** - * @var \Magento\Core\Model\Config + * @var \Magento\Directory\Model\Currency\Import\Config */ private $_importConfig; diff --git a/app/code/Magento/Directory/etc/di.xml b/app/code/Magento/Directory/etc/di.xml index 9831615741a8836e1880cfcb47f45b2ede73a8cc..dd708713e14ee3201c76f92ac7fcdad9d15f7f63 100644 --- a/app/code/Magento/Directory/etc/di.xml +++ b/app/code/Magento/Directory/etc/di.xml @@ -27,19 +27,21 @@ <type name="Magento\Directory\Model\Resource\Country\Collection" shared="false" /> <type name="Magento\Directory\Model\Currency\Import\Config"> <param name="servicesConfig"> - <value> - <webservicex> - <label>Webservicex</label> - <class>Magento\Directory\Model\Currency\Import\Webservicex</class> - </webservicex> - </value> + <array> + <item key="webservicex"> + <array> + <item key="label"><value>Webservicex</value></item> + <item key="class"><value>Magento\Directory\Model\Currency\Import\Webservicex</value></item> + </array> + </item> + </array> </param> </type> <type name="Magento\Module\Updater\SetupFactory"> <param name="resourceTypes"> - <value> - <directory_setup>Magento\Directory\Model\Resource\Setup</directory_setup> - </value> + <array> + <item key="directory_setup"><value>Magento\Directory\Model\Resource\Setup</value></item> + </array> </param> </type> </config> diff --git a/app/code/Magento/Downloadable/Block/Sales/Order/Email/Items/Downloadable.php b/app/code/Magento/Downloadable/Block/Sales/Order/Email/Items/Downloadable.php index 9fe0b479947cbf31671e571d55de30b8deaf1ee0..aa114f820f9b5013d65407c33d64f306e8ed2f4e 100644 --- a/app/code/Magento/Downloadable/Block/Sales/Order/Email/Items/Downloadable.php +++ b/app/code/Magento/Downloadable/Block/Sales/Order/Email/Items/Downloadable.php @@ -52,7 +52,7 @@ class Downloadable extends \Magento\Sales\Block\Order\Email\Items\DefaultItems protected $_itemsFactory; /** - * @var \Magento\Core\Model\Url + * @var \Magento\UrlInterface */ protected $urlGenerator; @@ -60,19 +60,16 @@ class Downloadable extends \Magento\Sales\Block\Order\Email\Items\DefaultItems * @param \Magento\View\Element\Template\Context $context * @param \Magento\Downloadable\Model\Link\PurchasedFactory $purchasedFactory * @param \Magento\Downloadable\Model\Resource\Link\Purchased\Item\CollectionFactory $itemsFactory - * @param \Magento\Core\Model\Url $urlGenerator * @param array $data */ public function __construct( \Magento\View\Element\Template\Context $context, \Magento\Downloadable\Model\Link\PurchasedFactory $purchasedFactory, \Magento\Downloadable\Model\Resource\Link\Purchased\Item\CollectionFactory $itemsFactory, - \Magento\Core\Model\Url $urlGenerator, array $data = array() ) { $this->_purchasedFactory = $purchasedFactory; $this->_itemsFactory = $itemsFactory; - $this->urlGenerator = $urlGenerator; parent::__construct($context, $data); } @@ -102,9 +99,9 @@ class Downloadable extends \Magento\Sales\Block\Order\Email\Items\DefaultItems public function getPurchasedLinkUrl($item) { - return $this->urlGenerator->getUrl('downloadable/download/link', array( + return $this->_urlBuilder->getUrl('downloadable/download/link', array( 'id' => $item->getLinkHash(), - '_store' => $this->getOrder()->getStore(), + '_scope' => $this->getOrder()->getStore(), '_secure' => true, '_nosid' => true )); diff --git a/app/code/Magento/Downloadable/Block/Sales/Order/Email/Items/Order/Downloadable.php b/app/code/Magento/Downloadable/Block/Sales/Order/Email/Items/Order/Downloadable.php index 74f543e17185b01658294105de9b40c242a6a598..6b5b3eecbbd649a8357fbda652d0240448e78af4 100644 --- a/app/code/Magento/Downloadable/Block/Sales/Order/Email/Items/Order/Downloadable.php +++ b/app/code/Magento/Downloadable/Block/Sales/Order/Email/Items/Order/Downloadable.php @@ -94,7 +94,7 @@ class Downloadable extends \Magento\Sales\Block\Order\Email\Items\Order\DefaultO { return $this->getUrl('downloadable/download/link', array( 'id' => $item->getLinkHash(), - '_store' => $this->getOrder()->getStore(), + '_scope' => $this->getOrder()->getStore(), '_secure' => true, '_nosid' => true )); diff --git a/app/code/Magento/Downloadable/Controller/Download.php b/app/code/Magento/Downloadable/Controller/Download.php index f70274b57be2a3f01460c671e73fb309cfe760bd..0ba410eac4f60ef9706db8096035c887b377ccd1 100644 --- a/app/code/Magento/Downloadable/Controller/Download.php +++ b/app/code/Magento/Downloadable/Controller/Download.php @@ -196,7 +196,7 @@ class Download extends \Magento\App\Action\Action $this->messageManager->addNotice($notice); $session->authenticate($this); $session->setBeforeAuthUrl( - $this->_objectManager->create('Magento\Core\Model\Url')->getUrl( + $this->_objectManager->create('Magento\UrlInterface')->getUrl( 'downloadable/customer/products/', array('_secure' => true) ) diff --git a/app/code/Magento/Webapi/Model/Soap/Wsdl/ComplexTypeStrategy/AnyComplexType.php b/app/code/Magento/Downloadable/Model/Product/CartConfiguration/Plugin/Downloadable.php similarity index 55% rename from app/code/Magento/Webapi/Model/Soap/Wsdl/ComplexTypeStrategy/AnyComplexType.php rename to app/code/Magento/Downloadable/Model/Product/CartConfiguration/Plugin/Downloadable.php index 4a0bf93ec52c8bf1a0585dd7b15bfb5ab86d49c6..adf2ca713e1cf6fc65b32c80bc026b6abc28f815 100644 --- a/app/code/Magento/Webapi/Model/Soap/Wsdl/ComplexTypeStrategy/AnyComplexType.php +++ b/app/code/Magento/Downloadable/Model/Product/CartConfiguration/Plugin/Downloadable.php @@ -1,6 +1,6 @@ <?php /** - * Magento-specific Complex type strategy for WSDL auto discovery. + * Plugin for cart product configuration * * Magento * @@ -23,22 +23,27 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Webapi\Model\Soap\Wsdl\ComplexTypeStrategy; -use Zend\Soap\Wsdl\ComplexTypeStrategy\AbstractComplexTypeStrategy, - Zend\Soap\Wsdl; -class AnyComplexType extends AbstractComplexTypeStrategy +namespace Magento\Downloadable\Model\Product\CartConfiguration\Plugin; + +class Downloadable { /** - * Inject XSD describing service method input/output directly into WSDL. + * Decide whether product has been configured for cart or not * - * @param \DOMNode $complexTypeNode \DOMNode to be added to the WSDL - * @return string|null + * @param array $arguments + * @param \Magento\Code\Plugin\InvocationChain $invocationChain + * @return bool */ - public function addComplexType($complexTypeNode) + public function aroundIsProductConfigured(array $arguments, \Magento\Code\Plugin\InvocationChain $invocationChain) { - $complexType = $this->getContext()->toDomDocument()->importNode($complexTypeNode, true); - $this->getContext()->getSchema()->appendChild($complexType); - return $this->scanRegisteredTypes($complexTypeNode->nodeName); + /** @var $product \Magento\Catalog\Model\Product */ + list($product, $config) = $arguments; + + if ($product->getTypeId() == \Magento\Downloadable\Model\Product\Type::TYPE_DOWNLOADABLE) { + return isset($config['links']); + } + + return $invocationChain->proceed($arguments); } -} +} diff --git a/app/code/Magento/Downloadable/Model/Sales/Order/Pdf/Items/AbstractItems.php b/app/code/Magento/Downloadable/Model/Sales/Order/Pdf/Items/AbstractItems.php index 026763a80bce5cdf239ecca6a02d48e99c004563..45722f1720bb833b597801af422670127b18b66d 100644 --- a/app/code/Magento/Downloadable/Model/Sales/Order/Pdf/Items/AbstractItems.php +++ b/app/code/Magento/Downloadable/Model/Sales/Order/Pdf/Items/AbstractItems.php @@ -24,11 +24,11 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Downloadable\Model\Sales\Order\Pdf\Items; + /** * Order Downloadable Pdf Items renderer */ -namespace Magento\Downloadable\Model\Sales\Order\Pdf\Items; - abstract class AbstractItems extends \Magento\Sales\Model\Order\Pdf\Items\AbstractItems { /** @@ -60,6 +60,7 @@ abstract class AbstractItems extends \Magento\Sales\Model\Order\Pdf\Items\Abstra * @param \Magento\Core\Model\Registry $registry * @param \Magento\Tax\Helper\Data $taxData * @param \Magento\App\Filesystem $filesystem + * @param \Magento\Filter\FilterManager $filterManager * @param \Magento\Core\Model\Store\Config $coreStoreConfig * @param \Magento\Downloadable\Model\Link\PurchasedFactory $purchasedFactory * @param \Magento\Downloadable\Model\Resource\Link\Purchased\Item\CollectionFactory $itemsFactory @@ -72,6 +73,7 @@ abstract class AbstractItems extends \Magento\Sales\Model\Order\Pdf\Items\Abstra \Magento\Core\Model\Registry $registry, \Magento\Tax\Helper\Data $taxData, \Magento\App\Filesystem $filesystem, + \Magento\Filter\FilterManager $filterManager, \Magento\Core\Model\Store\Config $coreStoreConfig, \Magento\Downloadable\Model\Link\PurchasedFactory $purchasedFactory, \Magento\Downloadable\Model\Resource\Link\Purchased\Item\CollectionFactory $itemsFactory, @@ -82,7 +84,16 @@ abstract class AbstractItems extends \Magento\Sales\Model\Order\Pdf\Items\Abstra $this->_coreStoreConfig = $coreStoreConfig; $this->_purchasedFactory = $purchasedFactory; $this->_itemsFactory = $itemsFactory; - parent::__construct($context, $registry, $taxData, $filesystem, $resource, $resourceCollection, $data); + parent::__construct( + $context, + $registry, + $taxData, + $filesystem, + $filterManager, + $resource, + $resourceCollection, + $data + ); } /** diff --git a/app/code/Magento/Downloadable/Model/Sales/Order/Pdf/Items/Creditmemo.php b/app/code/Magento/Downloadable/Model/Sales/Order/Pdf/Items/Creditmemo.php index 9247d08ef732436a283f7f9e9911e6daea86d9e0..10e3a85e91fe54cf101f2b9f2ac2fefba62ee83c 100644 --- a/app/code/Magento/Downloadable/Model/Sales/Order/Pdf/Items/Creditmemo.php +++ b/app/code/Magento/Downloadable/Model/Sales/Order/Pdf/Items/Creditmemo.php @@ -24,13 +24,12 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Downloadable\Model\Sales\Order\Pdf\Items; + /** * Order Creditmemo Downloadable Pdf Items renderer */ -namespace Magento\Downloadable\Model\Sales\Order\Pdf\Items; - -class Creditmemo - extends \Magento\Downloadable\Model\Sales\Order\Pdf\Items\AbstractItems +class Creditmemo extends \Magento\Downloadable\Model\Sales\Order\Pdf\Items\AbstractItems { /** * @var \Magento\Stdlib\String @@ -42,6 +41,7 @@ class Creditmemo * @param \Magento\Core\Model\Registry $registry * @param \Magento\Tax\Helper\Data $taxData * @param \Magento\App\Filesystem $filesystem + * @param \Magento\Filter\FilterManager $filterManager * @param \Magento\Core\Model\Store\Config $coreStoreConfig * @param \Magento\Downloadable\Model\Link\PurchasedFactory $purchasedFactory * @param \Magento\Downloadable\Model\Resource\Link\Purchased\Item\CollectionFactory $itemsFactory @@ -55,6 +55,7 @@ class Creditmemo \Magento\Core\Model\Registry $registry, \Magento\Tax\Helper\Data $taxData, \Magento\App\Filesystem $filesystem, + \Magento\Filter\FilterManager $filterManager, \Magento\Core\Model\Store\Config $coreStoreConfig, \Magento\Downloadable\Model\Link\PurchasedFactory $purchasedFactory, \Magento\Downloadable\Model\Resource\Link\Purchased\Item\CollectionFactory $itemsFactory, @@ -69,6 +70,7 @@ class Creditmemo $registry, $taxData, $filesystem, + $filterManager, $coreStoreConfig, $purchasedFactory, $itemsFactory, @@ -80,7 +82,6 @@ class Creditmemo /** * Draw item line - * */ public function draw() { @@ -151,22 +152,24 @@ class Creditmemo foreach ($options as $option) { // draw options label $lines[][] = array( - 'text' => $this->string->split(strip_tags($option['label']), 40, true, true), + 'text' => $this->string->split($this->filterManager->stripTags($option['label']), 40, true, true), 'font' => 'italic', 'feed' => 35 ); // draw options value - $_printValue = isset($option['print_value']) ? $option['print_value'] : strip_tags($option['value']); + $printValue = isset($option['print_value']) + ? $option['print_value'] + : $this->filterManager->stripTags($option['value']); $lines[][] = array( - 'text' => $this->string->split($_printValue, 30, true, true), + 'text' => $this->string->split($printValue, 30, true, true), 'feed' => 40 ); } } // downloadable Items - $_purchasedItems = $this->getLinks()->getPurchasedItems(); + $purchasedItems = $this->getLinks()->getPurchasedItems(); // draw Links title $lines[][] = array( @@ -176,9 +179,9 @@ class Creditmemo ); // draw Links - foreach ($_purchasedItems as $_link) { + foreach ($purchasedItems as $link) { $lines[][] = array( - 'text' => $this->string->split($_link->getLinkTitle(), 50, true, true), + 'text' => $this->string->split($link->getLinkTitle(), 50, true, true), 'feed' => 40 ); } diff --git a/app/code/Magento/Downloadable/Model/Sales/Order/Pdf/Items/Invoice.php b/app/code/Magento/Downloadable/Model/Sales/Order/Pdf/Items/Invoice.php index 0b515c173fa991117f8a364e129476901194b18b..72c4f8b1172ac8060e5817f40b905889e87abcae 100644 --- a/app/code/Magento/Downloadable/Model/Sales/Order/Pdf/Items/Invoice.php +++ b/app/code/Magento/Downloadable/Model/Sales/Order/Pdf/Items/Invoice.php @@ -24,18 +24,12 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Downloadable\Model\Sales\Order\Pdf\Items; /** * Order Invoice Downloadable Pdf Items renderer - * - * @category Magento - * @package Magento_Downloadable - * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\Downloadable\Model\Sales\Order\Pdf\Items; - -class Invoice - extends \Magento\Downloadable\Model\Sales\Order\Pdf\Items\AbstractItems +class Invoice extends \Magento\Downloadable\Model\Sales\Order\Pdf\Items\AbstractItems { /** * @var \Magento\Stdlib\String @@ -47,6 +41,7 @@ class Invoice * @param \Magento\Core\Model\Registry $registry * @param \Magento\Tax\Helper\Data $taxData * @param \Magento\App\Filesystem $filesystem + * @param \Magento\Filter\FilterManager $filterManager * @param \Magento\Core\Model\Store\Config $coreStoreConfig * @param \Magento\Downloadable\Model\Link\PurchasedFactory $purchasedFactory * @param \Magento\Downloadable\Model\Resource\Link\Purchased\Item\CollectionFactory $itemsFactory @@ -60,6 +55,7 @@ class Invoice \Magento\Core\Model\Registry $registry, \Magento\Tax\Helper\Data $taxData, \Magento\App\Filesystem $filesystem, + \Magento\Filter\FilterManager $filterManager, \Magento\Core\Model\Store\Config $coreStoreConfig, \Magento\Downloadable\Model\Link\PurchasedFactory $purchasedFactory, \Magento\Downloadable\Model\Resource\Link\Purchased\Item\CollectionFactory $itemsFactory, @@ -74,6 +70,7 @@ class Invoice $registry, $taxData, $filesystem, + $filterManager, $coreStoreConfig, $purchasedFactory, $itemsFactory, @@ -85,7 +82,6 @@ class Invoice /** * Draw item line - * */ public function draw() { @@ -167,18 +163,18 @@ class Invoice foreach ($options as $option) { // draw options label $lines[][] = array( - 'text' => $this->string->split(strip_tags($option['label']), 40, true, true), + 'text' => $this->string->split($this->filterManager->stripTags($option['label']), 40, true, true), 'font' => 'italic', 'feed' => 35 ); if ($option['value']) { if (isset($option['print_value'])) { - $_printValue = $option['print_value']; + $printValue = $option['print_value']; } else { - $_printValue = strip_tags($option['value']); + $printValue = $this->filterManager->stripTags($option['value']); } - $values = explode(', ', $_printValue); + $values = explode(', ', $printValue); foreach ($values as $value) { $lines[][] = array( 'text' => $this->string->split($value, 30, true, true), @@ -190,7 +186,7 @@ class Invoice } // downloadable Items - $_purchasedItems = $this->getLinks()->getPurchasedItems(); + $purchasedItems = $this->getLinks()->getPurchasedItems(); // draw Links title $lines[][] = array( @@ -200,9 +196,9 @@ class Invoice ); // draw Links - foreach ($_purchasedItems as $_link) { + foreach ($purchasedItems as $link) { $lines[][] = array( - 'text' => $this->string->split($_link->getLinkTitle(), 50, true, true), + 'text' => $this->string->split($link->getLinkTitle(), 50, true, true), 'feed' => 40 ); } diff --git a/app/code/Magento/Downloadable/etc/adminhtml/di.xml b/app/code/Magento/Downloadable/etc/adminhtml/di.xml index 8e4ced5f6abcf486b05ba958464f1750c04757ed..9b7e3391548d6bcee36cdfc45c18f3b323dbbc7d 100644 --- a/app/code/Magento/Downloadable/etc/adminhtml/di.xml +++ b/app/code/Magento/Downloadable/etc/adminhtml/di.xml @@ -29,9 +29,9 @@ </type> <type name="Magento\Catalog\Model\Product\CopyConstructor\Composite"> <param name="constructors"> - <value> - <downloadable>Magento\Downloadable\Model\Product\CopyConstructor\Downloadable</downloadable> - </value> + <array> + <item key="downloadable"><value>Magento\Downloadable\Model\Product\CopyConstructor\Downloadable</value></item> + </array> </param> </type> </config> diff --git a/app/code/Magento/Downloadable/etc/di.xml b/app/code/Magento/Downloadable/etc/di.xml index 22cfc4027596e7b6da622766e02ab0df3f0eaf83..51067a60ba89c16fb705544e6a5d97f40e6a6fd2 100644 --- a/app/code/Magento/Downloadable/etc/di.xml +++ b/app/code/Magento/Downloadable/etc/di.xml @@ -36,14 +36,12 @@ </type> <type name="Magento\Module\Updater\SetupFactory"> <param name="resourceTypes"> - <value> - <downloadable_setup>Magento\Catalog\Model\Resource\Setup</downloadable_setup> - </value> + <array> + <item key="downloadable_setup"><value>Magento\Catalog\Model\Resource\Setup</value></item> + </array> </param> </type> - <type name="Magento\Downloadable\Block\Sales\Order\Email\Items\Downloadable"> - <param name="urlGenerator"> - <instance type="Magento\Core\Model\Url\Proxy"/> - </param> + <type name="Magento\Catalog\Model\Product\CartConfiguration"> + <plugin name="Downloadable" type="Magento\Downloadable\Model\Product\CartConfiguration\Plugin\Downloadable" /> </type> </config> diff --git a/app/code/Magento/Downloadable/etc/frontend/di.xml b/app/code/Magento/Downloadable/etc/frontend/di.xml index 24702d4b66d92e1d1a7595edc04afbc60a23dd28..5bfe97b5686855b7d8d434bcbfdf0208fe32978b 100644 --- a/app/code/Magento/Downloadable/etc/frontend/di.xml +++ b/app/code/Magento/Downloadable/etc/frontend/di.xml @@ -26,10 +26,10 @@ <config> <type name="Magento\Core\Model\Url\SecurityInfo"> <param name="secureUrlList"> - <value> - <downloadable>/downloadable/customer/</downloadable> - <downloadable_download>/downloadable/download/</downloadable_download> - </value> + <array> + <item key="downloadable"><value>/downloadable/customer/</value></item> + <item key="downloadable_download"><value>/downloadable/download/</value></item> + </array> </param> </type> </config> diff --git a/app/code/Magento/Downloadable/etc/module.xml b/app/code/Magento/Downloadable/etc/module.xml index 617c9b1f864f8d97186975d58fd0e63b4860cd93..1de608ef7d90c1ca72ca122a3eeea2156a828891 100755 --- a/app/code/Magento/Downloadable/etc/module.xml +++ b/app/code/Magento/Downloadable/etc/module.xml @@ -27,7 +27,6 @@ <module name="Magento_Downloadable" version="1.6.0.0.3" active="true"> <sequence> <module name="Magento_Catalog"/> - <module name="Magento_GroupedProduct" /> </sequence> <depends> <module name="Magento_Catalog"/> diff --git a/app/code/Magento/Downloadable/etc/product_types.xml b/app/code/Magento/Downloadable/etc/product_types.xml index 784ab05ff90c082127a8901b2b4812666be87979..20ae539e98a3a8fc5ce68d3260a9ad669935511c 100644 --- a/app/code/Magento/Downloadable/etc/product_types.xml +++ b/app/code/Magento/Downloadable/etc/product_types.xml @@ -27,15 +27,12 @@ <type name="downloadable" label="Downloadable Product" modelInstance="Magento\Downloadable\Model\Product\Type" composite="false" isQty="true" canUseQtyDecimals="false"> <priceModel instance="Magento\Downloadable\Model\Product\Price" /> <indexerModel instance="Magento\Downloadable\Model\Resource\Indexer\Price" /> + <customAttributes> + <attribute name="refundable" value="false"/> + <attribute name="is_real_product" value="false"/> + </customAttributes> </type> - <type name="configurable"> - <allowProductTypes> - <type name="downloadable" /> - </allowProductTypes> - </type> - <type name="grouped"> - <allowProductTypes> - <type name="downloadable" /> - </allowProductTypes> - </type> + <composableTypes> + <type name="downloadable" /> + </composableTypes> </config> diff --git a/app/code/Magento/Downloadable/view/frontend/checkout/cart/item/default.phtml b/app/code/Magento/Downloadable/view/frontend/checkout/cart/item/default.phtml index ce8deef606a3534a8102bfb1e26120fb5ab3bcd0..28bbf52834180d8ab3c87098fc22e1d591acb7fc 100644 --- a/app/code/Magento/Downloadable/view/frontend/checkout/cart/item/default.phtml +++ b/app/code/Magento/Downloadable/view/frontend/checkout/cart/item/default.phtml @@ -64,17 +64,6 @@ $canApplyMsrp = $this->helper('Magento\Catalog\Helper\Data')->canApplyMsrp($_ite <?php endforeach; ?> </dl> <?php endif;?> - <?php /* downloadable */ ?> - <?php if ($links = $this->getLinks()): ?> - <dl class="cart item options"> - <dt><?php echo $this->getLinksTitle() ?></dt> - <?php foreach ($links as $link): ?> - <dd><?php echo $this->escapeHtml($link->getTitle()) ?></dd> - <?php endforeach; ?> - </dl> - <?php endif; ?> - <?php echo $this->getChildHtml('item_extra'); ?> - <?php /* EOF downloadable */ ?> <?php if ($messages = $this->getMessages()): ?> <?php foreach ($messages as $message): ?> <p class="cart item message <?php echo $message['type'] ?>">* <?php echo $this->escapeHtml($message['text']) ?></p> diff --git a/app/code/Magento/Downloadable/view/frontend/checkout/links.phtml b/app/code/Magento/Downloadable/view/frontend/checkout/links.phtml new file mode 100644 index 0000000000000000000000000000000000000000..58eabed22d447a23375f4c0a8871dc4a7e013c2d --- /dev/null +++ b/app/code/Magento/Downloadable/view/frontend/checkout/links.phtml @@ -0,0 +1,32 @@ +<?php +/** + * 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) + */ +?> +<?php if ($links = $this->getLinks()): ?> + <dl class="cart item options"> + <dt><?php echo $this->getLinksTitle() ?></dt> + <?php foreach ($links as $link): ?> + <dd><?php echo $this->escapeHtml($link->getTitle()) ?></dd> + <?php endforeach; ?> + </dl> +<?php endif; ?> diff --git a/app/code/Magento/Downloadable/view/frontend/checkout/multishipping/item/downloadable.phtml b/app/code/Magento/Downloadable/view/frontend/checkout/multishipping/item/downloadable.phtml deleted file mode 100644 index 11eb12f78bbad78894a0fffb3a9d67d557de1123..0000000000000000000000000000000000000000 --- a/app/code/Magento/Downloadable/view/frontend/checkout/multishipping/item/downloadable.phtml +++ /dev/null @@ -1,56 +0,0 @@ -<?php -/** - * 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) - */ -?> -<div class="product details"> - <strong class="product name"><a href="<?php echo $this->getProductUrl() ?>"><?php echo $this->escapeHtml($this->getProductName()) ?></a></strong> - <?php if ($_options = $this->getOptionList()): ?> - <dl class="item options"> - <?php foreach ($_options as $_option) : ?> - <?php $_formatedOptionValue = $this->getFormatedOptionValue($_option) ?> - <dt><?php echo $this->escapeHtml($_option['label']) ?></dt> - <dd<?php if (isset($_formatedOptionValue['full_view'])): ?> class="truncated" data-mage-init="{truncateOptions:[]}"<?php endif; ?>><?php echo $_formatedOptionValue['value'] ?> - <?php if (isset($_formatedOptionValue['full_view'])): ?> - <dl class="item options"> - <dt><?php echo $this->escapeHtml($_option['label']) ?></dt> - <dd><?php echo $_formatedOptionValue['full_view'] ?></dd> - </dl> - <?php endif; ?> - </dd> - <?php endforeach; ?> - </dl> - <?php endif; ?> - <?php /* downloadable */ ?> - <?php if ($links = $this->getLinks()): ?> - <dl class="item options"> - <dt><?php echo $this->getLinksTitle() ?></dt> - <?php foreach ($links as $link): ?> - <dd><?php echo $this->escapeHtml($link->getTitle()); ?></dd> - <?php endforeach; ?> - </dl> - <?php endif; ?> - <?php /* EOF downloadable */ ?> - <?php if ($addtInfoBlock = $this->getProductAdditionalInformationBlock()): ?> - <?php echo $addtInfoBlock->setItem($this->getItem())->toHtml() ?> - <?php endif; ?> -</div> diff --git a/app/code/Magento/Downloadable/view/frontend/checkout/onepage/review/item.phtml b/app/code/Magento/Downloadable/view/frontend/checkout/onepage/review/item.phtml deleted file mode 100644 index 4815d67044af581ce9103e6a93d7eaeb979e0277..0000000000000000000000000000000000000000 --- a/app/code/Magento/Downloadable/view/frontend/checkout/onepage/review/item.phtml +++ /dev/null @@ -1,243 +0,0 @@ -<?php -/** - * 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) - */ -?> -<?php $_item = $this->getItem()?> -<tr> - <td class="col item"><strong class="product name"><?php echo $this->escapeHtml($this->getProductName()) ?></strong> - <?php if ($_options = $this->getOptionList()):?> - <dl class="review item options"> - <?php foreach ($_options as $_option) : ?> - <?php $_formatedOptionValue = $this->getFormatedOptionValue($_option) ?> - <dt><?php echo $this->escapeHtml($_option['label']) ?></dt> - <dd<?php if (isset($_formatedOptionValue['full_view'])): ?> class="truncated" data-mage-init="{truncateOptions:[]}"<?php endif; ?>><?php echo $_formatedOptionValue['value'] ?> - <?php if (isset($_formatedOptionValue['full_view'])): ?> - <div class="truncated_full_value"> - <dl class="item options"> - <dt><?php echo $this->escapeHtml($_option['label']) ?></dt> - <dd><?php echo $_formatedOptionValue['full_view'] ?></dd> - </dl> - </div> - <?php endif; ?> - </dd> - <?php endforeach; ?> - </dl> - <?php endif;?> - <?php if ($links = $this->getLinks()): ?> - <dl class="review item options"> - <dt><?php echo $this->getLinksTitle() ?></dt> - <?php foreach ($links as $link): ?> - <dd><?php echo $this->escapeHtml($link->getTitle()) ?></dd> - <?php endforeach; ?> - </dl> - <?php endif; ?> - <?php /* EOF downloadable */ ?> - <?php if ($addtInfoBlock = $this->getProductAdditionalInformationBlock()):?> - <?php echo $addtInfoBlock->setItem($_item)->toHtml() ?> - <?php endif;?> - </td> -<?php if ($this->helper('Magento\Tax\Helper\Data')->displayCartPriceExclTax() || $this->helper('Magento\Tax\Helper\Data')->displayCartBothPrices()): ?> - <td class="col price excl tax"> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay($_item, array(1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?> - <span class="cart tax total" - data-tax-toggle='{"itemTaxId" : "#eunit-item-tax-details<?php echo $_item->getId(); ?>"}'> - <?php else: ?> - <span class="cart price"> - <?php endif; ?> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay($_item, array(0, 1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?> - <?php echo $this->helper('Magento\Checkout\Helper\Data')->formatPrice($_item->getCalculationPrice()+$_item->getWeeeTaxAppliedAmount()+$_item->getWeeeTaxDisposition()); ?> - <?php else: ?> - <?php echo $this->helper('Magento\Checkout\Helper\Data')->formatPrice($_item->getCalculationPrice()) ?> - <?php endif; ?> - </span> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item)): ?> - <div class="cart tax info" id="eunit-item-tax-details<?php echo $_item->getId(); ?>" style="display:none;"> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay($_item, 1, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?> - <small> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <?php echo $tax['title']; ?>: <?php echo $this->helper('Magento\Checkout\Helper\Data')->formatPrice($tax['amount'],true,true); ?><br /> - <?php endforeach; ?> - </small> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay($_item, 2, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <small><?php echo $tax['title']; ?>: <?php echo $this->helper('Magento\Checkout\Helper\Data')->formatPrice($tax['amount_incl_tax'],true,true); ?></small><br /> - <?php endforeach; ?> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay($_item, 4, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?> - <small> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <?php echo $tax['title']; ?>: <?php echo $this->helper('Magento\Checkout\Helper\Data')->formatPrice($tax['amount_incl_tax'],true,true); ?><br /> - <?php endforeach; ?> - </small> - <?php endif; ?> - </div> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay($_item, 2, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?> - <div class="cart tax total" - data-tax-toggle='{"itemTaxId" : "#eunit-item-tax-details<?php echo $_item->getId(); ?>"}'> - <?php echo __('Total'); ?>:<br /> <?php echo $this->helper('Magento\Checkout\Helper\Data')->formatPrice($_item->getCalculationPrice()+$_item->getWeeeTaxAppliedAmount()+$_item->getWeeeTaxDisposition()); ?> - </div> - <?php endif; ?> - <?php endif; ?> - </td> -<?php endif; ?> -<?php if ($this->helper('Magento\Tax\Helper\Data')->displayCartPriceInclTax() || $this->helper('Magento\Tax\Helper\Data')->displayCartBothPrices()): ?> - <td class="col price incl tax"> - <?php $_incl = $this->helper('Magento\Checkout\Helper\Data')->getPriceInclTax($_item); ?> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay($_item, array(1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?> - <span class="cart tax total" - data-tax-toggle='{"itemTaxId" : "#unit-item-tax-details<?php echo $_item->getId(); ?>"}'> - <?php else: ?> - <span class="cart price"> - <?php endif; ?> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay($_item, array(0, 1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?> - <?php echo $this->helper('Magento\Checkout\Helper\Data')->formatPrice($_incl+$_item->getWeeeTaxAppliedAmount()); ?> - <?php else: ?> - <?php echo $this->helper('Magento\Checkout\Helper\Data')->formatPrice($_incl-$_item->getWeeeTaxDisposition()) ?> - <?php endif; ?> - - </span> - <?php if ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item)): ?> - <div class="cart tax info" id="unit-item-tax-details<?php echo $_item->getId(); ?>" style="display:none;"> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay($_item, 1, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?> - <small> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <?php echo $tax['title']; ?>: <?php echo $this->helper('Magento\Checkout\Helper\Data')->formatPrice($tax['amount'],true,true); ?><br /> - <?php endforeach; ?> - </small> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay($_item, 2, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <small><?php echo $tax['title']; ?>: <?php echo $this->helper('Magento\Checkout\Helper\Data')->formatPrice($tax['amount_incl_tax'],true,true); ?></small><br /> - <?php endforeach; ?> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay($_item, 4, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?> - <small> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <?php echo $tax['title']; ?>: <?php echo $this->helper('Magento\Checkout\Helper\Data')->formatPrice($tax['amount_incl_tax'],true,true); ?><br /> - <?php endforeach; ?> - </small> - <?php endif; ?> - </div> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay($_item, 2, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?> - <div class="cart tax total" - data-tax-toggle='{"itemTaxId" : "#unit-item-tax-details<?php echo $_item->getId(); ?>"}'> - <?php echo __('Total incl. tax'); ?>:<br /> <?php echo $this->helper('Magento\Checkout\Helper\Data')->formatPrice($_incl+$_item->getWeeeTaxAppliedAmount()); ?> - </div> - <?php endif; ?> - <?php endif; ?> - </td> -<?php endif; ?> - <td class="col qty"><span class="qty"><?php echo $_item->getQty() ?></span></td> -<?php if ($this->helper('Magento\Tax\Helper\Data')->displayCartPriceExclTax() || $this->helper('Magento\Tax\Helper\Data')->displayCartBothPrices()): ?> - <td class="col subtotal excl tax"> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay($_item, array(1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?> - <span class="cart tax total" - data-tax-toggle='{"itemTaxId" : "#esubtotal-item-tax-details<?php echo $_item->getId(); ?>"}'> - <?php else: ?> - <span class="cart price"> - <?php endif; ?> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay($_item, array(0, 1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?> - <?php echo $this->helper('Magento\Checkout\Helper\Data')->formatPrice($_item->getRowTotal()+$_item->getWeeeTaxAppliedRowAmount()+$_item->getWeeeTaxRowDisposition()); ?> - <?php else: ?> - <?php echo $this->helper('Magento\Checkout\Helper\Data')->formatPrice($_item->getRowTotal()) ?> - <?php endif; ?> - </span> - <?php if ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item)): ?> - <div class="cart tax info" id="esubtotal-item-tax-details<?php echo $_item->getId(); ?>" style="display:none;"> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay($_item, 1, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?> - <small> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <?php echo $tax['title']; ?>: <?php echo $this->helper('Magento\Checkout\Helper\Data')->formatPrice($tax['row_amount'],true,true); ?><br /> - <?php endforeach; ?> - </small> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay($_item, 2, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <small><?php echo $tax['title']; ?>: <?php echo $this->helper('Magento\Checkout\Helper\Data')->formatPrice($tax['row_amount_incl_tax'],true,true); ?></small><br /> - <?php endforeach; ?> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay($_item, 4, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?> - <small> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <?php echo $tax['title']; ?>: <?php echo $this->helper('Magento\Checkout\Helper\Data')->formatPrice($tax['row_amount_incl_tax'],true,true); ?><br /> - <?php endforeach; ?> - </small> - <?php endif; ?> - </div> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay($_item, 2, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?> - <div class="cart tax total" - data-tax-toggle='{"itemTaxId" : "#esubtotal-item-tax-details<?php echo $_item->getId(); ?>"}'> - <?php echo __('Total'); ?>:<br /> <?php echo $this->helper('Magento\Checkout\Helper\Data')->formatPrice($_item->getRowTotal()+$_item->getWeeeTaxAppliedRowAmount()+$_item->getWeeeTaxRowDisposition()); ?> - </div> - <?php endif; ?> - <?php endif; ?> - </td> -<?php endif; ?> -<?php if ($this->helper('Magento\Tax\Helper\Data')->displayCartPriceInclTax() || $this->helper('Magento\Tax\Helper\Data')->displayCartBothPrices()): ?> - <td class="col subtotal incl tax"> - <?php $_incl = $this->helper('Magento\Checkout\Helper\Data')->getSubtotalInclTax($_item); ?> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay($_item, array(1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?> - <span class="cart tax total" - data-tax-toggle='{"itemTaxId" : "#subtotal-item-tax-details<?php echo $_item->getId(); ?>"}'> - <?php else: ?> - <span class="cart price"> - <?php endif; ?> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay($_item, array(0, 1, 4), 'sales') && $_item->getWeeeTaxAppliedAmount()): ?> - <?php echo $this->helper('Magento\Checkout\Helper\Data')->formatPrice($_incl+$_item->getWeeeTaxAppliedRowAmount()); ?> - <?php else: ?> - <?php echo $this->helper('Magento\Checkout\Helper\Data')->formatPrice($_incl-$_item->getWeeeTaxRowDisposition()) ?> - <?php endif; ?> - </span> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item)): ?> - <div class="cart tax info" id="subtotal-item-tax-details<?php echo $_item->getId(); ?>" style="display:none;"> - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay($_item, 1, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?> - <small> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <?php echo $tax['title']; ?>: <?php echo $this->helper('Magento\Checkout\Helper\Data')->formatPrice($tax['row_amount'],true,true); ?><br /> - <?php endforeach; ?> - </small> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay($_item, 2, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <small><?php echo $tax['title']; ?>: <?php echo $this->helper('Magento\Checkout\Helper\Data')->formatPrice($tax['row_amount_incl_tax'],true,true); ?></small><br /> - <?php endforeach; ?> - <?php elseif ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay($_item, 4, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?> - <small> - <?php foreach ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item) as $tax): ?> - <?php echo $tax['title']; ?>: <?php echo $this->helper('Magento\Checkout\Helper\Data')->formatPrice($tax['row_amount_incl_tax'],true,true); ?><br /> - <?php endforeach; ?> - </small> - <?php endif; ?> - </div> - - <?php if ($this->helper('Magento\Weee\Helper\Data')->typeOfDisplay($_item, 2, 'sales') && $_item->getWeeeTaxAppliedAmount()): ?> - <div class="cart tax total" - data-tax-toggle='{"itemTaxId" : "#subtotal-item-tax-details<?php echo $_item->getId(); ?>"}'> - <?php echo __('Total incl. tax'); ?>:<br /> <?php echo $this->helper('Magento\Checkout\Helper\Data')->formatPrice($_incl+$_item->getWeeeTaxAppliedRowAmount()); ?> - </div> - <?php endif; ?> - <?php endif; ?> - </td> -<?php endif; ?> -</tr> diff --git a/app/code/Magento/Downloadable/view/frontend/layout/checkout_onepage_review.xml b/app/code/Magento/Downloadable/view/frontend/layout/checkout_cart_item_renderers.xml similarity index 77% rename from app/code/Magento/Downloadable/view/frontend/layout/checkout_onepage_review.xml rename to app/code/Magento/Downloadable/view/frontend/layout/checkout_cart_item_renderers.xml index ab6538942c70dc7c1177be4cbdef4202392da834..b26ad99378e8dec214973ffeb280d72714b6ce15 100644 --- a/app/code/Magento/Downloadable/view/frontend/layout/checkout_onepage_review.xml +++ b/app/code/Magento/Downloadable/view/frontend/layout/checkout_cart_item_renderers.xml @@ -24,7 +24,10 @@ */ --> <layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> - <referenceBlock name="order_review"> - <block class="Magento\Downloadable\Block\Checkout\Cart\Item\Renderer" as="downloadable" template="checkout/onepage/review/item.phtml"/> + <referenceBlock name="checkout.cart.item.renderers"> + <block class="Magento\Downloadable\Block\Checkout\Cart\Item\Renderer" as="downloadable" template="checkout/cart/item/default.phtml"/> + </referenceBlock> + <referenceBlock name="additional.product.info"> + <block class="Magento\View\Element\Template" name="downloadable.product.links" template="checkout/links.phtml"/> </referenceBlock> </layout> diff --git a/app/code/Magento/Downloadable/view/frontend/layout/default.xml b/app/code/Magento/Downloadable/view/frontend/layout/checkout_cart_sidebar_item_renderers.xml similarity index 94% rename from app/code/Magento/Downloadable/view/frontend/layout/default.xml rename to app/code/Magento/Downloadable/view/frontend/layout/checkout_cart_sidebar_item_renderers.xml index 15f0dc4dc845c501c9cd42a0cd80f8040179c766..ccb0d1216faf2103716829de71d0932573daf3c7 100644 --- a/app/code/Magento/Downloadable/view/frontend/layout/default.xml +++ b/app/code/Magento/Downloadable/view/frontend/layout/checkout_cart_sidebar_item_renderers.xml @@ -24,7 +24,7 @@ */ --> <layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> - <referenceBlock name="minicart"> + <referenceBlock name="checkout.cart.sidebar.item.renderers"> <block class="Magento\Downloadable\Block\Checkout\Cart\Item\Renderer" as="downloadable" template="Magento_Checkout::cart/sidebar/default.phtml"/> </referenceBlock> </layout> diff --git a/app/code/Magento/Downloadable/view/frontend/layout/checkout_cart_index.xml b/app/code/Magento/Downloadable/view/frontend/layout/checkout_onepage_review_item_renderers.xml similarity index 87% rename from app/code/Magento/Downloadable/view/frontend/layout/checkout_cart_index.xml rename to app/code/Magento/Downloadable/view/frontend/layout/checkout_onepage_review_item_renderers.xml index f267c7de20a4e85b9d9d69a3ee097d6713ac7c56..8fecfaf5e1362d2f22ede45cbb9013d0e06299f4 100644 --- a/app/code/Magento/Downloadable/view/frontend/layout/checkout_cart_index.xml +++ b/app/code/Magento/Downloadable/view/frontend/layout/checkout_onepage_review_item_renderers.xml @@ -24,7 +24,7 @@ */ --> <layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> - <referenceBlock name="checkout.cart.form"> - <block class="Magento\Downloadable\Block\Checkout\Cart\Item\Renderer" as="downloadable" template="checkout/cart/item/default.phtml"/> + <referenceBlock name="checkout.onepage.review.item.renderers"> + <block class="Magento\Downloadable\Block\Checkout\Cart\Item\Renderer" as="downloadable" template="Magento_Checkout::onepage/review/item.phtml"/> </referenceBlock> </layout> diff --git a/app/code/Magento/Downloadable/view/frontend/layout/multishipping_checkout_addresses.xml b/app/code/Magento/Downloadable/view/frontend/layout/multishipping_checkout_addresses.xml deleted file mode 100644 index e401e426a733a6150668e6be6c2631320a52ecc7..0000000000000000000000000000000000000000 --- a/app/code/Magento/Downloadable/view/frontend/layout/multishipping_checkout_addresses.xml +++ /dev/null @@ -1,30 +0,0 @@ -<?xml version="1.0"?> -<!-- -/** - * 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) - */ ---> -<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> - <referenceBlock name="checkout_addresses"> - <block class="Magento\Downloadable\Block\Checkout\Cart\Item\Renderer" as="downloadable" template="checkout/multishipping/item/downloadable.phtml"/> - </referenceBlock> -</layout> diff --git a/app/code/Magento/Downloadable/view/frontend/layout/multishipping_checkout_overview.xml b/app/code/Magento/Downloadable/view/frontend/layout/multishipping_checkout_overview.xml deleted file mode 100644 index 7b08b20a92395e11cb9a0e42c24c733daacfc918..0000000000000000000000000000000000000000 --- a/app/code/Magento/Downloadable/view/frontend/layout/multishipping_checkout_overview.xml +++ /dev/null @@ -1,30 +0,0 @@ -<?xml version="1.0"?> -<!-- -/** - * 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) - */ ---> -<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> - <referenceBlock name="checkout_overview"> - <block class="Magento\Downloadable\Block\Checkout\Cart\Item\Renderer" as="downloadable" template="checkout/multishipping/item/downloadable.phtml"/> - </referenceBlock> -</layout> diff --git a/app/code/Magento/Downloadable/view/frontend/layout/multishipping_checkout_shipping.xml b/app/code/Magento/Downloadable/view/frontend/layout/multishipping_checkout_shipping.xml deleted file mode 100644 index e8e2dc9a759e385a409180afc758edf12474cfce..0000000000000000000000000000000000000000 --- a/app/code/Magento/Downloadable/view/frontend/layout/multishipping_checkout_shipping.xml +++ /dev/null @@ -1,30 +0,0 @@ -<?xml version="1.0"?> -<!-- -/** - * 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) - */ ---> -<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> - <referenceBlock name="checkout_billing_items"> - <block class="Magento\Downloadable\Block\Checkout\Cart\Item\Renderer" as="downloadable" template="checkout/multishipping/item/downloadable.phtml"/> - </referenceBlock> -</layout> diff --git a/app/code/Magento/Downloadable/view/frontend/layout/paypal_express_review.xml b/app/code/Magento/Downloadable/view/frontend/layout/paypal_express_review.xml deleted file mode 100644 index d3599c1181fb18a69f41145471a47d5164a9de8c..0000000000000000000000000000000000000000 --- a/app/code/Magento/Downloadable/view/frontend/layout/paypal_express_review.xml +++ /dev/null @@ -1,30 +0,0 @@ -<?xml version="1.0"?> -<!-- -/** - * 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) - */ ---> -<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> - <referenceBlock name="paypal.express.review.details"> - <block class="Magento\Downloadable\Block\Checkout\Cart\Item\Renderer" as="downloadable" template="checkout/onepage/review/item.phtml"/> - </referenceBlock> -</layout> diff --git a/app/code/Magento/Downloadable/view/frontend/layout/paypal_express_review_details.xml b/app/code/Magento/Downloadable/view/frontend/layout/paypal_express_review_details.xml deleted file mode 100644 index d3599c1181fb18a69f41145471a47d5164a9de8c..0000000000000000000000000000000000000000 --- a/app/code/Magento/Downloadable/view/frontend/layout/paypal_express_review_details.xml +++ /dev/null @@ -1,30 +0,0 @@ -<?xml version="1.0"?> -<!-- -/** - * 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) - */ ---> -<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> - <referenceBlock name="paypal.express.review.details"> - <block class="Magento\Downloadable\Block\Checkout\Cart\Item\Renderer" as="downloadable" template="checkout/onepage/review/item.phtml"/> - </referenceBlock> -</layout> diff --git a/app/code/Magento/Downloadable/view/frontend/layout/paypaluk_express_review.xml b/app/code/Magento/Downloadable/view/frontend/layout/paypaluk_express_review.xml deleted file mode 100644 index d3599c1181fb18a69f41145471a47d5164a9de8c..0000000000000000000000000000000000000000 --- a/app/code/Magento/Downloadable/view/frontend/layout/paypaluk_express_review.xml +++ /dev/null @@ -1,30 +0,0 @@ -<?xml version="1.0"?> -<!-- -/** - * 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) - */ ---> -<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> - <referenceBlock name="paypal.express.review.details"> - <block class="Magento\Downloadable\Block\Checkout\Cart\Item\Renderer" as="downloadable" template="checkout/onepage/review/item.phtml"/> - </referenceBlock> -</layout> diff --git a/app/code/Magento/Downloadable/view/frontend/layout/paypaluk_express_review_details.xml b/app/code/Magento/Downloadable/view/frontend/layout/paypaluk_express_review_details.xml deleted file mode 100644 index ab6538942c70dc7c1177be4cbdef4202392da834..0000000000000000000000000000000000000000 --- a/app/code/Magento/Downloadable/view/frontend/layout/paypaluk_express_review_details.xml +++ /dev/null @@ -1,30 +0,0 @@ -<?xml version="1.0"?> -<!-- -/** - * 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) - */ ---> -<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> - <referenceBlock name="order_review"> - <block class="Magento\Downloadable\Block\Checkout\Cart\Item\Renderer" as="downloadable" template="checkout/onepage/review/item.phtml"/> - </referenceBlock> -</layout> diff --git a/app/code/Magento/Downloadable/view/frontend/layout/sales_email_order_creditmemo_items.xml b/app/code/Magento/Downloadable/view/frontend/layout/sales_email_order_creditmemo_renderers.xml similarity index 94% rename from app/code/Magento/Downloadable/view/frontend/layout/sales_email_order_creditmemo_items.xml rename to app/code/Magento/Downloadable/view/frontend/layout/sales_email_order_creditmemo_renderers.xml index dc32941feb8e2d197898eae16dfe2c0ac8f03e1b..038cf80bec80efa92e41dc7350fe6b9d1dc51a0c 100644 --- a/app/code/Magento/Downloadable/view/frontend/layout/sales_email_order_creditmemo_items.xml +++ b/app/code/Magento/Downloadable/view/frontend/layout/sales_email_order_creditmemo_renderers.xml @@ -24,7 +24,7 @@ */ --> <layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> - <referenceBlock name="items"> + <referenceBlock name="sales.email.order.creditmemo.renderers"> <block class="Magento\Downloadable\Block\Sales\Order\Email\Items\Downloadable" as="downloadable" template="email/order/items/creditmemo/downloadable.phtml"/> </referenceBlock> </layout> diff --git a/app/code/Magento/Downloadable/view/frontend/layout/sales_email_order_invoice_items.xml b/app/code/Magento/Downloadable/view/frontend/layout/sales_email_order_invoice_renderers.xml similarity index 94% rename from app/code/Magento/Downloadable/view/frontend/layout/sales_email_order_invoice_items.xml rename to app/code/Magento/Downloadable/view/frontend/layout/sales_email_order_invoice_renderers.xml index d51f31dfccd3845a23c61efc665f613a3e614bce..9fabb69a64c76cc5ecb444108fb5f075bdcf05ca 100644 --- a/app/code/Magento/Downloadable/view/frontend/layout/sales_email_order_invoice_items.xml +++ b/app/code/Magento/Downloadable/view/frontend/layout/sales_email_order_invoice_renderers.xml @@ -24,7 +24,7 @@ */ --> <layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> - <referenceBlock name="items"> + <referenceBlock name="sales.email.order.invoice.renderers"> <block class="Magento\Downloadable\Block\Sales\Order\Email\Items\Downloadable" as="downloadable" template="email/order/items/invoice/downloadable.phtml"/> </referenceBlock> </layout> diff --git a/app/code/Magento/Downloadable/view/frontend/layout/sales_email_order_items.xml b/app/code/Magento/Downloadable/view/frontend/layout/sales_email_order_renderers.xml similarity index 95% rename from app/code/Magento/Downloadable/view/frontend/layout/sales_email_order_items.xml rename to app/code/Magento/Downloadable/view/frontend/layout/sales_email_order_renderers.xml index 21d4f882cb09b888c72ac2e71cf883c8d7b1e2db..dc0773310b03b173ff45bed758d51acb34625951 100644 --- a/app/code/Magento/Downloadable/view/frontend/layout/sales_email_order_items.xml +++ b/app/code/Magento/Downloadable/view/frontend/layout/sales_email_order_renderers.xml @@ -24,7 +24,7 @@ */ --> <layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> - <referenceBlock name="items"> + <referenceBlock name="sales.email.order.renderers"> <block class="Magento\Downloadable\Block\Sales\Order\Email\Items\Order\Downloadable" as="downloadable" template="email/order/items/order/downloadable.phtml"/> </referenceBlock> </layout> diff --git a/app/code/Magento/Downloadable/view/frontend/layout/sales_guest_printorder.xml b/app/code/Magento/Downloadable/view/frontend/layout/sales_guest_printorder.xml deleted file mode 100644 index 50a54a51237478421b0baa9e39b36a0a5f95f409..0000000000000000000000000000000000000000 --- a/app/code/Magento/Downloadable/view/frontend/layout/sales_guest_printorder.xml +++ /dev/null @@ -1,30 +0,0 @@ -<?xml version="1.0"?> -<!-- -/** - * 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) - */ ---> -<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> - <referenceBlock name="sales.order.print"> - <block class="Magento\Downloadable\Block\Sales\Order\Item\Renderer\Downloadable" as="downloadable" template="sales/order/items/renderer/downloadable.phtml"/> - </referenceBlock> -</layout> diff --git a/app/code/Magento/Downloadable/view/frontend/layout/sales_guest_printordercreditmemo.xml b/app/code/Magento/Downloadable/view/frontend/layout/sales_guest_printordercreditmemo.xml deleted file mode 100644 index 054e60b11581aa0fb5359ca885e623a429775a6f..0000000000000000000000000000000000000000 --- a/app/code/Magento/Downloadable/view/frontend/layout/sales_guest_printordercreditmemo.xml +++ /dev/null @@ -1,30 +0,0 @@ -<?xml version="1.0"?> -<!-- -/** - * 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) - */ ---> -<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> - <referenceBlock name="sales.order.print.creditmemo"> - <block class="Magento\Downloadable\Block\Sales\Order\Item\Renderer\Downloadable" as="downloadable" template="sales/order/creditmemo/items/renderer/downloadable.phtml"/> - </referenceBlock> -</layout> diff --git a/app/code/Magento/Downloadable/view/frontend/layout/sales_guest_creditmemo.xml b/app/code/Magento/Downloadable/view/frontend/layout/sales_order_creditmemo_renderers.xml similarity index 95% rename from app/code/Magento/Downloadable/view/frontend/layout/sales_guest_creditmemo.xml rename to app/code/Magento/Downloadable/view/frontend/layout/sales_order_creditmemo_renderers.xml index ea2e341ef98819fe383de108b2a9814dbc582bd6..56943f3f0aba728f28893ff3309afc3dfddff10c 100644 --- a/app/code/Magento/Downloadable/view/frontend/layout/sales_guest_creditmemo.xml +++ b/app/code/Magento/Downloadable/view/frontend/layout/sales_order_creditmemo_renderers.xml @@ -24,7 +24,7 @@ */ --> <layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> - <referenceBlock name="creditmemo_items"> + <referenceBlock name="sales.order.creditmemo.renderers"> <block class="Magento\Downloadable\Block\Sales\Order\Item\Renderer\Downloadable" as="downloadable" template="sales/order/creditmemo/items/renderer/downloadable.phtml"/> </referenceBlock> </layout> diff --git a/app/code/Magento/Downloadable/view/frontend/layout/sales_order_invoice.xml b/app/code/Magento/Downloadable/view/frontend/layout/sales_order_invoice_renderers.xml similarity index 95% rename from app/code/Magento/Downloadable/view/frontend/layout/sales_order_invoice.xml rename to app/code/Magento/Downloadable/view/frontend/layout/sales_order_invoice_renderers.xml index e5bee2ceebf058a7002ee269c3b809dfa2f26915..e435688621ba8468fe3f3e0103dd6507ff56876f 100644 --- a/app/code/Magento/Downloadable/view/frontend/layout/sales_order_invoice.xml +++ b/app/code/Magento/Downloadable/view/frontend/layout/sales_order_invoice_renderers.xml @@ -24,7 +24,7 @@ */ --> <layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> - <referenceBlock name="invoice_items"> + <referenceBlock name="sales.order.invoice.renderers"> <block class="Magento\Downloadable\Block\Sales\Order\Item\Renderer\Downloadable" as="downloadable" template="sales/order/invoice/items/renderer/downloadable.phtml"/> </referenceBlock> </layout> diff --git a/app/code/Magento/Downloadable/view/frontend/layout/sales_order_printorder.xml b/app/code/Magento/Downloadable/view/frontend/layout/sales_order_item_renderers.xml similarity index 95% rename from app/code/Magento/Downloadable/view/frontend/layout/sales_order_printorder.xml rename to app/code/Magento/Downloadable/view/frontend/layout/sales_order_item_renderers.xml index 50a54a51237478421b0baa9e39b36a0a5f95f409..02b665bca1fc8a453b0b1d5644ba8b5e80489af8 100644 --- a/app/code/Magento/Downloadable/view/frontend/layout/sales_order_printorder.xml +++ b/app/code/Magento/Downloadable/view/frontend/layout/sales_order_item_renderers.xml @@ -24,7 +24,7 @@ */ --> <layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> - <referenceBlock name="sales.order.print"> + <referenceBlock name="sales.order.items.renderers"> <block class="Magento\Downloadable\Block\Sales\Order\Item\Renderer\Downloadable" as="downloadable" template="sales/order/items/renderer/downloadable.phtml"/> </referenceBlock> </layout> diff --git a/app/code/Magento/Downloadable/view/frontend/layout/sales_order_creditmemo.xml b/app/code/Magento/Downloadable/view/frontend/layout/sales_order_print_creditmemo_renderers.xml similarity index 94% rename from app/code/Magento/Downloadable/view/frontend/layout/sales_order_creditmemo.xml rename to app/code/Magento/Downloadable/view/frontend/layout/sales_order_print_creditmemo_renderers.xml index ea2e341ef98819fe383de108b2a9814dbc582bd6..1509b5bf43438746a205bf477973d9d9d4cc5ad6 100644 --- a/app/code/Magento/Downloadable/view/frontend/layout/sales_order_creditmemo.xml +++ b/app/code/Magento/Downloadable/view/frontend/layout/sales_order_print_creditmemo_renderers.xml @@ -24,7 +24,7 @@ */ --> <layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> - <referenceBlock name="creditmemo_items"> + <referenceBlock name="sales.order.print.creditmemo.renderers"> <block class="Magento\Downloadable\Block\Sales\Order\Item\Renderer\Downloadable" as="downloadable" template="sales/order/creditmemo/items/renderer/downloadable.phtml"/> </referenceBlock> </layout> diff --git a/app/code/Magento/Downloadable/view/frontend/layout/sales_guest_printorderinvoice.xml b/app/code/Magento/Downloadable/view/frontend/layout/sales_order_print_invoice_renderers.xml similarity index 94% rename from app/code/Magento/Downloadable/view/frontend/layout/sales_guest_printorderinvoice.xml rename to app/code/Magento/Downloadable/view/frontend/layout/sales_order_print_invoice_renderers.xml index 7f017145d1ee29401a7e6c9cc65f8cbc22f4e4a6..8f9b77ec9002f68d5c8993b53a0693b90b59643b 100644 --- a/app/code/Magento/Downloadable/view/frontend/layout/sales_guest_printorderinvoice.xml +++ b/app/code/Magento/Downloadable/view/frontend/layout/sales_order_print_invoice_renderers.xml @@ -24,7 +24,7 @@ */ --> <layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> - <referenceBlock name="sales.order.print.invoice"> + <referenceBlock name="sales.order.print.invoice.renderers"> <block class="Magento\Downloadable\Block\Sales\Order\Item\Renderer\Downloadable" as="downloadable" template="sales/order/invoice/items/renderer/downloadable.phtml"/> </referenceBlock> </layout> diff --git a/app/code/Magento/Downloadable/view/frontend/layout/sales_order_view.xml b/app/code/Magento/Downloadable/view/frontend/layout/sales_order_print_renderers.xml similarity index 95% rename from app/code/Magento/Downloadable/view/frontend/layout/sales_order_view.xml rename to app/code/Magento/Downloadable/view/frontend/layout/sales_order_print_renderers.xml index f0dff79e197637fd3505a821954d8e66a78e9df9..6d0f8ae6eeccde38f7915c77c9c525c86606a09c 100644 --- a/app/code/Magento/Downloadable/view/frontend/layout/sales_order_view.xml +++ b/app/code/Magento/Downloadable/view/frontend/layout/sales_order_print_renderers.xml @@ -24,7 +24,7 @@ */ --> <layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> - <referenceBlock name="order_items"> + <referenceBlock name="sales.order.print.renderers"> <block class="Magento\Downloadable\Block\Sales\Order\Item\Renderer\Downloadable" as="downloadable" template="sales/order/items/renderer/downloadable.phtml"/> </referenceBlock> </layout> diff --git a/app/code/Magento/Downloadable/view/frontend/layout/sales_order_printordercreditmemo.xml b/app/code/Magento/Downloadable/view/frontend/layout/sales_order_printordercreditmemo.xml deleted file mode 100644 index 054e60b11581aa0fb5359ca885e623a429775a6f..0000000000000000000000000000000000000000 --- a/app/code/Magento/Downloadable/view/frontend/layout/sales_order_printordercreditmemo.xml +++ /dev/null @@ -1,30 +0,0 @@ -<?xml version="1.0"?> -<!-- -/** - * 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) - */ ---> -<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> - <referenceBlock name="sales.order.print.creditmemo"> - <block class="Magento\Downloadable\Block\Sales\Order\Item\Renderer\Downloadable" as="downloadable" template="sales/order/creditmemo/items/renderer/downloadable.phtml"/> - </referenceBlock> -</layout> diff --git a/app/code/Magento/Downloadable/view/frontend/layout/sales_order_printorderinvoice.xml b/app/code/Magento/Downloadable/view/frontend/layout/sales_order_printorderinvoice.xml deleted file mode 100644 index 7f017145d1ee29401a7e6c9cc65f8cbc22f4e4a6..0000000000000000000000000000000000000000 --- a/app/code/Magento/Downloadable/view/frontend/layout/sales_order_printorderinvoice.xml +++ /dev/null @@ -1,30 +0,0 @@ -<?xml version="1.0"?> -<!-- -/** - * 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) - */ ---> -<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> - <referenceBlock name="sales.order.print.invoice"> - <block class="Magento\Downloadable\Block\Sales\Order\Item\Renderer\Downloadable" as="downloadable" template="sales/order/invoice/items/renderer/downloadable.phtml"/> - </referenceBlock> -</layout> diff --git a/app/code/Magento/Eav/Model/Attribute/Data/AbstractData.php b/app/code/Magento/Eav/Model/Attribute/Data/AbstractData.php index ebe588fdf4018d7ade3616ffe519e0f7ba0b4d98..b4ea1b770a64195bae6e7dc97f274da0df600aa1 100644 --- a/app/code/Magento/Eav/Model/Attribute/Data/AbstractData.php +++ b/app/code/Magento/Eav/Model/Attribute/Data/AbstractData.php @@ -101,7 +101,7 @@ abstract class AbstractData * * @param \Magento\Core\Model\LocaleInterface $locale * @param \Magento\Logger $logger - */ + */ public function __construct( \Magento\Core\Model\LocaleInterface $locale, \Magento\Logger $logger @@ -583,7 +583,7 @@ abstract class AbstractData abstract public function restoreValue($value); /** - * Return formated attribute value from entity model + * Return formatted attribute value from entity model * * @param string $format * @return string|array diff --git a/app/code/Magento/Eav/Model/Entity/Setup.php b/app/code/Magento/Eav/Model/Entity/Setup.php index be3acbc6c250915bbe272a56f58932b1a108a07b..d9dff25f0579ceb8eb086159f2e2aa2c4b563385 100644 --- a/app/code/Magento/Eav/Model/Entity/Setup.php +++ b/app/code/Magento/Eav/Model/Entity/Setup.php @@ -1267,184 +1267,6 @@ class Setup extends \Magento\Core\Model\Resource\Setup return $this; } - -/****************************** CREATE ENTITY TABLES ***********************************/ - - /** - * Create entity tables - * - * @param string $baseName - * @param array $options - * - no-main - * - no-default-types - * - types - * @return unknown - */ - public function createEntityTables($baseTableName, array $options = array()) - { - $isNoCreateMainTable = $this->_getValue($options, 'no-main', false); - $isNoDefaultTypes = $this->_getValue($options, 'no-default-types', false); - $customTypes = $this->_getValue($options, 'types', array()); - $tables = array(); - - if (!$isNoCreateMainTable) { - /** - * Create table main eav table - */ - $connection = $this->getConnection(); - $mainTable = $connection - ->newTable($this->getTable($baseTableName)) - ->addColumn('entity_id', \Magento\DB\Ddl\Table::TYPE_INTEGER, null, array( - 'identity' => true, - 'nullable' => false, - 'primary' => true, - ), 'Entity Id') - ->addColumn('entity_type_id', \Magento\DB\Ddl\Table::TYPE_SMALLINT, null, array( - 'unsigned' => true, - 'nullable' => false, - 'default' => '0', - ), 'Entity Type Id') - ->addColumn('attribute_set_id', \Magento\DB\Ddl\Table::TYPE_SMALLINT, null, array( - 'unsigned' => true, - 'nullable' => false, - 'default' => '0', - ), 'Attribute Set Id') - ->addColumn('increment_id', \Magento\DB\Ddl\Table::TYPE_TEXT, 50, array( - 'nullable' => false, - 'default' => '', - ), 'Increment Id') - ->addColumn('store_id', \Magento\DB\Ddl\Table::TYPE_SMALLINT, null, array( - 'unsigned' => true, - 'nullable' => false, - 'default' => '0', - ), 'Store Id') - ->addColumn('created_at', \Magento\DB\Ddl\Table::TYPE_TIMESTAMP, null, array( - 'nullable' => false, - ), 'Created At') - ->addColumn('updated_at', \Magento\DB\Ddl\Table::TYPE_TIMESTAMP, null, array( - 'nullable' => false, - ), 'Updated At') - ->addColumn('is_active', \Magento\DB\Ddl\Table::TYPE_SMALLINT, null, array( - 'unsigned' => true, - 'nullable' => false, - 'default' => '1', - ), 'Defines Is Entity Active') - ->addIndex($this->getIdxName($baseTableName, array('entity_type_id')), - array('entity_type_id')) - ->addIndex($this->getIdxName($baseTableName, array('store_id')), - array('store_id')) - ->addForeignKey($this->getFkName($baseTableName, 'entity_type_id', 'eav_entity_type', 'entity_type_id'), - 'entity_type_id', $this->getTable('eav_entity_type'), 'entity_type_id', - \Magento\DB\Ddl\Table::ACTION_CASCADE, \Magento\DB\Ddl\Table::ACTION_CASCADE) - ->addForeignKey($this->getFkName($baseTableName, 'store_id', 'core_store', 'store_id'), - 'store_id', $this->getTable('core_store'), 'store_id', - \Magento\DB\Ddl\Table::ACTION_CASCADE, \Magento\DB\Ddl\Table::ACTION_CASCADE) - ->setComment('Eav Entity Main Table'); - - $tables[$this->getTable($baseTableName)] = $mainTable; - } - - $types = array(); - if (!$isNoDefaultTypes) { - $types = array( - 'datetime' => array(\Magento\DB\Ddl\Table::TYPE_DATETIME, null), - 'decimal' => array(\Magento\DB\Ddl\Table::TYPE_DECIMAL, '12,4'), - 'int' => array(\Magento\DB\Ddl\Table::TYPE_INTEGER, null), - 'text' => array(\Magento\DB\Ddl\Table::TYPE_TEXT, '64k'), - 'varchar' => array(\Magento\DB\Ddl\Table::TYPE_TEXT, '255'), - 'char' => array(\Magento\DB\Ddl\Table::TYPE_TEXT, '255') - ); - } - - if (!empty($customTypes)) { - foreach ($customTypes as $type => $fieldType) { - if (count($fieldType) != 2) { - throw new \Magento\Eav\Exception(__('Wrong type definition for %1', $type)); - } - $types[$type] = $fieldType; - } - } - - /** - * Create table array($baseTableName, $type) - */ - foreach ($types as $type => $fieldType) { - $eavTableName = array($baseTableName, $type); - - $eavTable = $connection->newTable($this->getTable($eavTableName)); - $eavTable - ->addColumn('value_id', \Magento\DB\Ddl\Table::TYPE_INTEGER, null, array( - 'identity' => true, - 'nullable' => false, - 'primary' => true, - ), 'Value Id') - ->addColumn('entity_type_id', \Magento\DB\Ddl\Table::TYPE_SMALLINT, null, array( - 'unsigned' => true, - 'nullable' => false, - 'default' => '0', - ), 'Entity Type Id') - ->addColumn('attribute_id', \Magento\DB\Ddl\Table::TYPE_SMALLINT, null, array( - 'unsigned' => true, - 'nullable' => false, - 'default' => '0', - ), 'Attribute Id') - ->addColumn('store_id', \Magento\DB\Ddl\Table::TYPE_SMALLINT, null, array( - 'unsigned' => true, - 'nullable' => false, - 'default' => '0', - ), 'Store Id') - ->addColumn('entity_id', \Magento\DB\Ddl\Table::TYPE_INTEGER, null, array( - 'unsigned' => true, - 'nullable' => false, - 'default' => '0', - ), 'Entity Id') - ->addColumn('value', $fieldType[0], $fieldType[1], array( - 'nullable' => false, - ), 'Attribute Value') - ->addIndex($this->getIdxName($eavTableName, array('entity_type_id')), - array('entity_type_id')) - ->addIndex($this->getIdxName($eavTableName, array('attribute_id')), - array('attribute_id')) - ->addIndex($this->getIdxName($eavTableName, array('store_id')), - array('store_id')) - ->addIndex($this->getIdxName($eavTableName, array('entity_id')), - array('entity_id')); - if ($type !== 'text') { - $eavTable->addIndex($this->getIdxName($eavTableName, array('attribute_id', 'value')), - array('attribute_id', 'value')); - $eavTable->addIndex($this->getIdxName($eavTableName, array('entity_type_id', 'value')), - array('entity_type_id', 'value')); - } - - $eavTable - ->addForeignKey($this->getFkName($eavTableName, 'entity_id', $baseTableName, 'entity_id'), - 'entity_id', $this->getTable($baseTableName), 'entity_id', - \Magento\DB\Ddl\Table::ACTION_CASCADE, \Magento\DB\Ddl\Table::ACTION_CASCADE) - ->addForeignKey($this->getFkName($eavTableName, 'entity_type_id', 'eav_entity_type', 'entity_type_id'), - 'entity_type_id', $this->getTable('eav_entity_type'), 'entity_type_id', - \Magento\DB\Ddl\Table::ACTION_CASCADE, \Magento\DB\Ddl\Table::ACTION_CASCADE) - ->addForeignKey($this->getFkName($eavTableName, 'store_id', 'core_store', 'store_id'), - 'store_id', $this->getTable('core_store'), 'store_id', - \Magento\DB\Ddl\Table::ACTION_CASCADE, \Magento\DB\Ddl\Table::ACTION_CASCADE) - ->setComment('Eav Entity Value Table'); - - $tables[$this->getTable($eavTableName)] = $eavTable; - } - - $connection->beginTransaction(); - try { - foreach ($tables as $tableName => $table) { - $connection->createTable($table); - } - $connection->commit(); - } catch (\Exception $e) { - $connection->rollBack(); - throw new \Magento\Eav\Exception(__('Can\'t create table: %1', $tableName)); - } - - return $this; - } - /** * Retrieve attribute table fields * diff --git a/app/code/Magento/Eav/Model/Resource/Entity/Attribute.php b/app/code/Magento/Eav/Model/Resource/Entity/Attribute.php index cfce611d86e38bd25e37ebed6ce9782a087cec7b..f9dc99292734c3bd498715fe650534e113d639f2 100644 --- a/app/code/Magento/Eav/Model/Resource/Entity/Attribute.php +++ b/app/code/Magento/Eav/Model/Resource/Entity/Attribute.php @@ -51,9 +51,9 @@ class Attribute extends \Magento\Core\Model\Resource\Db\AbstractDb protected $_application; /** - * @var \Magento\Core\Model\App + * @var \Magento\Core\Model\StoreManagerInterface */ - protected $_app; + protected $_storeManager; /** * @var \Magento\Eav\Model\Resource\Entity\Type @@ -64,21 +64,15 @@ class Attribute extends \Magento\Core\Model\Resource\Db\AbstractDb * Class constructor * * @param \Magento\App\Resource $resource - * @param \Magento\Core\Model\App $app + * @param \Magento\Core\Model\StoreManagerInterface $storeManager * @param \Magento\Eav\Model\Resource\Entity\Type $eavEntityType - * @param array $arguments */ public function __construct( \Magento\App\Resource $resource, - \Magento\Core\Model\App $app, - \Magento\Eav\Model\Resource\Entity\Type $eavEntityType, - array $arguments = array() + \Magento\Core\Model\StoreManagerInterface $storeManager, + \Magento\Eav\Model\Resource\Entity\Type $eavEntityType ) { - if (isset($arguments['application']) && $arguments['application'] instanceof \Magento\Core\Model\App) { - $this->_application = $arguments['application']; - unset($arguments['application']); - } - $this->_app = $app; + $this->_storeManager = $storeManager; $this->_eavEntityType = $eavEntityType; parent::__construct($resource); } @@ -92,16 +86,6 @@ class Attribute extends \Magento\Core\Model\Resource\Db\AbstractDb $this->_init('eav_attribute', 'attribute_id'); } - /** - * Retrieve application instance - * - * @return \Magento\Core\Model\App - */ - protected function _getApplication() - { - return $this->_application ?: $this->_app; - } - /** * Initialize unique fields * @@ -493,7 +477,7 @@ class Attribute extends \Magento\Core\Model\Resource\Db\AbstractDb $adapter->delete($table, array('option_id = ?' => $optionId)); - $stores = $this->_getApplication()->getStores(true); + $stores = $this->_storeManager->getStores(true); foreach ($stores as $store) { $storeId = $store->getId(); if (!empty($values[$storeId]) || isset($values[$storeId]) && $values[$storeId] == '0') { diff --git a/app/code/Magento/Eav/etc/di.xml b/app/code/Magento/Eav/etc/di.xml index 09580286d8239c6b89b9daea5ce7b91d734849b2..8bc8259daaac25f76cc1d670a500f0cb3d1c1ce3 100644 --- a/app/code/Magento/Eav/etc/di.xml +++ b/app/code/Magento/Eav/etc/di.xml @@ -31,9 +31,9 @@ </type> <type name="Magento\Module\Updater\SetupFactory"> <param name="resourceTypes"> - <value> - <eav_setup>Magento\Eav\Model\Entity\Setup</eav_setup> - </value> + <array> + <item key="eav_setup"><value>Magento\Eav\Model\Entity\Setup</value></item> + </array> </param> </type> </config> diff --git a/app/code/Magento/Email/Model/BackendTemplate.php b/app/code/Magento/Email/Model/BackendTemplate.php index e5bb5f40689f9cfde37d216053f1a9168d7607a7..a1252d2520a9209e13e3bc66e3157ee36a6fe356 100644 --- a/app/code/Magento/Email/Model/BackendTemplate.php +++ b/app/code/Magento/Email/Model/BackendTemplate.php @@ -32,7 +32,7 @@ namespace Magento\Email\Model; class BackendTemplate extends Template { /** - * @var \Magento\Core\Model\Config + * @var \Magento\App\ConfigInterface */ protected $_coreConfig; @@ -51,7 +51,7 @@ class BackendTemplate extends Template * @param \Magento\View\Url $viewUrl * @param \Magento\View\FileSystem $viewFileSystem * @param \Magento\Core\Model\Store\Config $coreStoreConfig - * @param \Magento\Core\Model\Config $coreConfig + * @param \Magento\App\ConfigInterface $coreConfig * @param \Magento\Email\Model\Template\FilterFactory $emailFilterFactory * @param \Magento\Email\Model\Template\Config $emailConfig * @param \Magento\Backend\Model\Config\Structure $structure @@ -69,7 +69,7 @@ class BackendTemplate extends Template \Magento\View\Url $viewUrl, \Magento\View\FileSystem $viewFileSystem, \Magento\Core\Model\Store\Config $coreStoreConfig, - \Magento\Core\Model\Config $coreConfig, + \Magento\App\ConfigInterface $coreConfig, \Magento\Email\Model\Template\FilterFactory $emailFilterFactory, \Magento\Email\Model\Template\Config $emailConfig, \Magento\Backend\Model\Config\Structure $structure, diff --git a/app/code/Magento/Email/Model/Source/Variables.php b/app/code/Magento/Email/Model/Source/Variables.php index 1b5db5fc64d45d44714b4103bab0ea1d0d94863a..7883218e43b4cf12dafc858028745e1e00214973 100644 --- a/app/code/Magento/Email/Model/Source/Variables.php +++ b/app/code/Magento/Email/Model/Source/Variables.php @@ -51,11 +51,11 @@ class Variables implements \Magento\Core\Model\Option\ArrayInterface { $this->_configVariables = array( array( - 'value' => \Magento\Core\Model\Url::XML_PATH_UNSECURE_URL, + 'value' => \Magento\Core\Model\Store::XML_PATH_UNSECURE_BASE_URL, 'label' => __('Base Unsecure URL') ), array( - 'value' => \Magento\Core\Model\Url::XML_PATH_SECURE_URL, + 'value' => \Magento\Core\Model\Store::XML_PATH_SECURE_BASE_URL, 'label' => __('Base Secure URL') ), array( diff --git a/app/code/Magento/Email/Model/Template.php b/app/code/Magento/Email/Model/Template.php index 21138b2d6e48f687b94572c2c818d218ae8a9d32..253424a039b08e6b91721c4c73e43d92b1727e13 100644 --- a/app/code/Magento/Email/Model/Template.php +++ b/app/code/Magento/Email/Model/Template.php @@ -145,7 +145,7 @@ class Template extends \Magento\Core\Model\Template * @param \Magento\View\Url $viewUrl * @param \Magento\View\FileSystem $viewFileSystem * @param \Magento\Core\Model\Store\ConfigInterface $coreStoreConfig - * @param \Magento\Core\Model\ConfigInterface $coreConfig + * @param \Magento\App\ConfigInterface $coreConfig * @param \Magento\Email\Model\Template\FilterFactory $emailFilterFactory * @param \Magento\Email\Model\Template\Config $emailConfig * @param array $data @@ -162,7 +162,7 @@ class Template extends \Magento\Core\Model\Template \Magento\View\Url $viewUrl, \Magento\View\FileSystem $viewFileSystem, \Magento\Core\Model\Store\ConfigInterface $coreStoreConfig, - \Magento\Core\Model\ConfigInterface $coreConfig, + \Magento\App\ConfigInterface $coreConfig, \Magento\Email\Model\Template\FilterFactory $emailFilterFactory, \Magento\Email\Model\Template\Config $emailConfig, array $data = array() @@ -200,10 +200,24 @@ class Template extends \Magento\Core\Model\Template $uploadDir = \Magento\Backend\Model\Config\Backend\Email\Logo::UPLOAD_DIR; $mediaDirectory = $this->_filesystem->getDirectoryRead(\Magento\App\Filesystem::MEDIA_DIR); if ($mediaDirectory->isFile($uploadDir . '/' . $fileName)) { - return $this->_storeManager->getStore()->getBaseUrl('media') . $uploadDir . '/' . $fileName; + return $this->_storeManager->getStore() + ->getBaseUrl(\Magento\UrlInterface::URL_TYPE_MEDIA) . $uploadDir . '/' . $fileName; } } - return $this->_viewUrl->getViewFileUrl('Magento_Core::logo_email.gif'); + return $this->getDefaultEmailLogo(); + } + + /** + * Get default email logo image + * + * @return string + */ + public function getDefaultEmailLogo() + { + return $this->_viewUrl->getViewFileUrl( + 'Magento_Email::logo_email.gif', + array('area' => \Magento\Core\Model\App\Area::AREA_FRONTEND) + ); } /** diff --git a/app/code/Magento/Email/Model/Template/Filter.php b/app/code/Magento/Email/Model/Template/Filter.php index ebb04b0d5ae7752a07cc941f12ae7a73afe32b5c..8e98c28d013a7b9f401878f26b3ddbba463b3479 100644 --- a/app/code/Magento/Email/Model/Template/Filter.php +++ b/app/code/Magento/Email/Model/Template/Filter.php @@ -370,7 +370,8 @@ class Filter extends \Magento\Filter\Template public function mediaDirective($construction) { $params = $this->_getIncludeParameters($construction[2]); - return $this->_storeManager->getStore()->getBaseUrl('media') . $params['url']; + return $this->_storeManager->getStore() + ->getBaseUrl(\Magento\UrlInterface::URL_TYPE_MEDIA) . $params['url']; } /** diff --git a/app/code/Magento/Core/view/adminhtml/logo_email.gif b/app/code/Magento/Email/view/frontend/logo_email.gif similarity index 100% rename from app/code/Magento/Core/view/adminhtml/logo_email.gif rename to app/code/Magento/Email/view/frontend/logo_email.gif diff --git a/app/code/Magento/GiftMessage/Model/Resource/Setup.php b/app/code/Magento/GiftMessage/Model/Resource/Setup.php index 7257cdae6937ebb8cfb6de18a5b8b3c1d633ff3d..9f320c800a02ff4626813ed9a2720d679dd0e028 100644 --- a/app/code/Magento/GiftMessage/Model/Resource/Setup.php +++ b/app/code/Magento/GiftMessage/Model/Resource/Setup.php @@ -41,7 +41,7 @@ class Setup extends \Magento\Sales\Model\Resource\Setup * @param string $resourceName * @param \Magento\App\CacheInterface $cache * @param \Magento\Eav\Model\Resource\Entity\Attribute\Group\CollectionFactory $attrGroupCollectionFactory - * @param \Magento\Core\Model\Config $config + * @param \Magento\App\ConfigInterface $config * @param \Magento\Catalog\Model\Resource\SetupFactory $catalogSetupFactory * @param string $moduleName * @param string $connectionName @@ -51,7 +51,7 @@ class Setup extends \Magento\Sales\Model\Resource\Setup $resourceName, \Magento\App\CacheInterface $cache, \Magento\Eav\Model\Resource\Entity\Attribute\Group\CollectionFactory $attrGroupCollectionFactory, - \Magento\Core\Model\Config $config, + \Magento\App\ConfigInterface $config, \Magento\Catalog\Model\Resource\SetupFactory $catalogSetupFactory, $moduleName = 'Magento_GiftMessage', $connectionName = '' diff --git a/app/code/Magento/GiftMessage/etc/di.xml b/app/code/Magento/GiftMessage/etc/di.xml index 7b1bdd30e3fcd3207806153e75d52e8eaf72d957..a8f808469b9aa9dcd6f44c7d5f3587e6560c16c9 100644 --- a/app/code/Magento/GiftMessage/etc/di.xml +++ b/app/code/Magento/GiftMessage/etc/di.xml @@ -26,9 +26,9 @@ <config> <type name="Magento\Module\Updater\SetupFactory"> <param name="resourceTypes"> - <value> - <giftmessage_setup>Magento\GiftMessage\Model\Resource\Setup</giftmessage_setup> - </value> + <array> + <item key="giftmessage_setup"><value>Magento\GiftMessage\Model\Resource\Setup</value></item> + </array> </param> </type> </config> diff --git a/app/code/Magento/GoogleAdwords/Helper/Data.php b/app/code/Magento/GoogleAdwords/Helper/Data.php index 78fcf8b38e5a9f38d33b45d14b5a30c4653a9d88..1e591c6df9521a49f5d7115e734a506abd2445e0 100644 --- a/app/code/Magento/GoogleAdwords/Helper/Data.php +++ b/app/code/Magento/GoogleAdwords/Helper/Data.php @@ -72,7 +72,7 @@ class Data extends \Magento\App\Helper\AbstractHelper /**#@-*/ /** - * @var \Magento\Core\Model\Config + * @var \Magento\App\ConfigInterface */ protected $_config; @@ -88,13 +88,13 @@ class Data extends \Magento\App\Helper\AbstractHelper /** * @param \Magento\App\Helper\Context $context - * @param \Magento\Core\Model\Config $config + * @param \Magento\App\ConfigInterface $config * @param \Magento\Core\Model\Store\ConfigInterface $storeConfig * @param \Magento\Core\Model\Registry $registry */ public function __construct( \Magento\App\Helper\Context $context, - \Magento\Core\Model\Config $config, + \Magento\App\ConfigInterface $config, \Magento\Core\Model\Store\ConfigInterface $storeConfig, \Magento\Core\Model\Registry $registry ) { diff --git a/app/code/Magento/GoogleAdwords/Model/Config/Backend/AbstractConversion.php b/app/code/Magento/GoogleAdwords/Model/Config/Backend/AbstractConversion.php index 26fe4614f296eef3e4d9b83acaec6d279c539169..b2c1fca711dcfdbc9190378ccd1bb6b5f22a57db 100644 --- a/app/code/Magento/GoogleAdwords/Model/Config/Backend/AbstractConversion.php +++ b/app/code/Magento/GoogleAdwords/Model/Config/Backend/AbstractConversion.php @@ -44,7 +44,7 @@ abstract class AbstractConversion extends \Magento\Core\Model\Config\Value * @param \Magento\Core\Model\Context $context * @param \Magento\Core\Model\Registry $registry * @param \Magento\Core\Model\StoreManagerInterface $storeManager - * @param \Magento\Core\Model\Config $config + * @param \Magento\App\ConfigInterface $config * @param \Magento\Validator\Composite\VarienObjectFactory $validatorCompositeFactory * @param \Magento\GoogleAdwords\Model\Validator\Factory $validatorFactory * @param \Magento\Core\Model\Resource\AbstractResource $resource @@ -55,7 +55,7 @@ abstract class AbstractConversion extends \Magento\Core\Model\Config\Value \Magento\Core\Model\Context $context, \Magento\Core\Model\Registry $registry, \Magento\Core\Model\StoreManagerInterface $storeManager, - \Magento\Core\Model\Config $config, + \Magento\App\ConfigInterface $config, \Magento\Validator\Composite\VarienObjectFactory $validatorCompositeFactory, \Magento\GoogleAdwords\Model\Validator\Factory $validatorFactory, \Magento\Core\Model\Resource\AbstractResource $resource = null, diff --git a/app/code/Magento/GoogleCheckout/Controller/Redirect.php b/app/code/Magento/GoogleCheckout/Controller/Redirect.php index c84cbaaa5133fb54c63e337e3e8d47d018eaa5c7..bd89956fd35eab2925605707a675ffb2ca0eefe3 100644 --- a/app/code/Magento/GoogleCheckout/Controller/Redirect.php +++ b/app/code/Magento/GoogleCheckout/Controller/Redirect.php @@ -47,7 +47,7 @@ class Redirect extends \Magento\App\Action\Action if (!$quote->hasItems()) { $this->getResponse()->setRedirect( - $this->_objectManager->create('Magento\Core\Model\Url')->getUrl('checkout/cart') + $this->_objectManager->create('Magento\UrlInterface')->getUrl('checkout/cart') ); $api->setError(true); } @@ -103,7 +103,7 @@ class Redirect extends \Magento\App\Action\Action $api = $this->_getApi(); if ($api->getError()) { - $url = $this->_objectManager->create('Magento\Core\Model\Url')->getUrl('checkout/cart'); + $url = $this->_objectManager->create('Magento\UrlInterface')->getUrl('checkout/cart'); } else { $url = $api->getRedirectUrl(); } @@ -120,7 +120,7 @@ class Redirect extends \Magento\App\Action\Action if ($api->getError()) { $this->getResponse()->setRedirect( - $this->_objectManager->create('Magento\Core\Model\Url')->getUrl('checkout/cart') + $this->_objectManager->create('Magento\UrlInterface')->getUrl('checkout/cart') ); return; } else { diff --git a/app/code/Magento/GoogleCheckout/Model/Api/Xml/AbstractXml.php b/app/code/Magento/GoogleCheckout/Model/Api/Xml/AbstractXml.php index db17bf393c6daac45dbf44d17798ad7bd1d00047..47e7542bcca6158fe0608b773116edd19de3c2c9 100644 --- a/app/code/Magento/GoogleCheckout/Model/Api/Xml/AbstractXml.php +++ b/app/code/Magento/GoogleCheckout/Model/Api/Xml/AbstractXml.php @@ -240,7 +240,7 @@ abstract class AbstractXml extends \Magento\Object protected function _getCallbackUrl() { - return $this->objectManager->create('Magento\Core\Model\Url')->getUrl( + return $this->objectManager->create('Magento\UrlInterface')->getUrl( 'googlecheckout/api', array('_forced_secure'=>$this->_coreStoreConfig->getConfig('google/checkout/use_secure_callback_url',$this->getStoreId())) ); diff --git a/app/code/Magento/GoogleCheckout/Model/Api/Xml/Checkout.php b/app/code/Magento/GoogleCheckout/Model/Api/Xml/Checkout.php index c3fd8c39b3ec763b9c1b919ed0a162b6db69221d..645726b737d0baf0c31264bd1cb2e6d4ad54d343 100644 --- a/app/code/Magento/GoogleCheckout/Model/Api/Xml/Checkout.php +++ b/app/code/Magento/GoogleCheckout/Model/Api/Xml/Checkout.php @@ -1135,7 +1135,7 @@ EOT; */ protected function _getEditCartUrl() { - return $this->objectManager->create('Magento\Core\Model\Url')->getUrl('googlecheckout/redirect/cart'); + return $this->objectManager->create('Magento\UrlInterface')->getUrl('googlecheckout/redirect/cart'); } /** @@ -1145,7 +1145,7 @@ EOT; */ protected function _getContinueShoppingUrl() { - return $this->objectManager->create('Magento\Core\Model\Url')->getUrl('googlecheckout/redirect/continue'); + return $this->objectManager->create('Magento\UrlInterface')->getUrl('googlecheckout/redirect/continue'); } /** @@ -1175,7 +1175,7 @@ EOT; */ protected function _getParameterizedUrl() { - return $this->objectManager->create('Magento\Core\Model\Url')->getUrl('googlecheckout/api/beacon'); + return $this->objectManager->create('Magento\UrlInterface')->getUrl('googlecheckout/api/beacon'); } /** diff --git a/app/code/Magento/GoogleCheckout/Model/Payment.php b/app/code/Magento/GoogleCheckout/Model/Payment.php index f98d64eb1aa1f24e34f34971c873fb1c5b1e2d47..399b2899581518cd929e321b7ec1905bc9e046d3 100644 --- a/app/code/Magento/GoogleCheckout/Model/Payment.php +++ b/app/code/Magento/GoogleCheckout/Model/Payment.php @@ -54,7 +54,7 @@ class Payment extends \Magento\Payment\Model\Method\AbstractMethod protected $apiFactory; /** - * @var \Magento\Core\Model\UrlFactory + * @var \Magento\UrlFactory */ protected $urlFactory; @@ -69,7 +69,7 @@ class Payment extends \Magento\Payment\Model\Method\AbstractMethod \Magento\Core\Model\Store\ConfigInterface $coreStoreConfig, \Magento\Core\Model\Log\AdapterFactory $logAdapterFactory, \Magento\Core\Model\DateFactory $dateFactory, - \Magento\Core\Model\UrlFactory $urlFactory, + \Magento\UrlFactory $urlFactory, \Magento\GoogleCheckout\Model\ApiFactory $apiFactory, array $data = array() ) { diff --git a/app/code/Magento/GoogleCheckout/etc/di.xml b/app/code/Magento/GoogleCheckout/etc/di.xml index cfafe870a6bbd883aac86fb759e64c09579f6106..c88a94d607bcc768fca014029757cda0cd694344 100644 --- a/app/code/Magento/GoogleCheckout/etc/di.xml +++ b/app/code/Magento/GoogleCheckout/etc/di.xml @@ -26,9 +26,9 @@ <config> <type name="Magento\Module\Updater\SetupFactory"> <param name="resourceTypes"> - <value> - <googlecheckout_setup>Magento\Catalog\Model\Resource\Setup</googlecheckout_setup> - </value> + <array> + <item key="googlecheckout_setup"><value>Magento\Catalog\Model\Resource\Setup</value></item> + </array> </param> </type> </config> diff --git a/app/code/Magento/GoogleCheckout/etc/frontend/di.xml b/app/code/Magento/GoogleCheckout/etc/frontend/di.xml index 1b6cdc0479f4d70fe381ba2b7838f067f42be926..2f41f0a33190eacb5d2c83d296ecb05836805249 100644 --- a/app/code/Magento/GoogleCheckout/etc/frontend/di.xml +++ b/app/code/Magento/GoogleCheckout/etc/frontend/di.xml @@ -26,11 +26,11 @@ <config> <type name="Magento\Core\Model\Url\SecurityInfo"> <param name="secureUrlList"> - <value> - <googlecheckout_redirect>/googlecheckout/redirect/</googlecheckout_redirect> - <googlecheckout_beacon>/googlecheckout/api/beacon/</googlecheckout_beacon> - <googlecheckout_api>/googlecheckout/api/</googlecheckout_api> - </value> + <array> + <item key="googlecheckout_redirect"><value>/googlecheckout/redirect/</value></item> + <item key="googlecheckout_beacon"><value>/googlecheckout/api/beacon/</value></item> + <item key="googlecheckout_api"><value>/googlecheckout/api/</value></item> + </array> </param> </type> </config> diff --git a/app/code/Magento/GoogleShopping/Block/Adminhtml/Items/Item.php b/app/code/Magento/GoogleShopping/Block/Adminhtml/Items/Item.php index b6fb85e0401e5ac8bfb07fbffc8177ccec415751..c8f0cf7b9441e888e6405c119eef741470a23f3f 100644 --- a/app/code/Magento/GoogleShopping/Block/Adminhtml/Items/Item.php +++ b/app/code/Magento/GoogleShopping/Block/Adminhtml/Items/Item.php @@ -44,20 +44,18 @@ class Item extends \Magento\Backend\Block\Widget\Grid\Extended /** * @param \Magento\Backend\Block\Template\Context $context - * @param \Magento\Core\Model\Url $urlModel * @param \Magento\Backend\Helper\Data $backendHelper * @param \Magento\GoogleShopping\Model\Resource\Item\CollectionFactory $collectionFactory * @param array $data */ public function __construct( \Magento\Backend\Block\Template\Context $context, - \Magento\Core\Model\Url $urlModel, \Magento\Backend\Helper\Data $backendHelper, \Magento\GoogleShopping\Model\Resource\Item\CollectionFactory $collectionFactory, array $data = array() ) { $this->_collectionFactory = $collectionFactory; - parent::__construct($context, $urlModel, $backendHelper, $data); + parent::__construct($context, $backendHelper, $data); } protected function _construct() diff --git a/app/code/Magento/GoogleShopping/Block/Adminhtml/Items/Product.php b/app/code/Magento/GoogleShopping/Block/Adminhtml/Items/Product.php index 79db04cd402b0517babb74303bdcac382c171733..f181435a6486ce98226ad30d5bc64ddf70a6d3cf 100644 --- a/app/code/Magento/GoogleShopping/Block/Adminhtml/Items/Product.php +++ b/app/code/Magento/GoogleShopping/Block/Adminhtml/Items/Product.php @@ -65,7 +65,6 @@ class Product extends \Magento\Backend\Block\Widget\Grid\Extended /** * @param \Magento\Backend\Block\Template\Context $context - * @param \Magento\Core\Model\Url $urlModel * @param \Magento\Backend\Helper\Data $backendHelper * @param \Magento\GoogleShopping\Model\Resource\Item\CollectionFactory $itemCollectionFactory * @param \Magento\Eav\Model\Resource\Entity\Attribute\Set\CollectionFactory $eavCollectionFactory @@ -75,7 +74,6 @@ class Product extends \Magento\Backend\Block\Widget\Grid\Extended */ public function __construct( \Magento\Backend\Block\Template\Context $context, - \Magento\Core\Model\Url $urlModel, \Magento\Backend\Helper\Data $backendHelper, \Magento\GoogleShopping\Model\Resource\Item\CollectionFactory $itemCollectionFactory, \Magento\Eav\Model\Resource\Entity\Attribute\Set\CollectionFactory $eavCollectionFactory, @@ -87,7 +85,7 @@ class Product extends \Magento\Backend\Block\Widget\Grid\Extended $this->_eavCollectionFactory = $eavCollectionFactory; $this->_productType = $productType; $this->_productFactory = $productFactory; - parent::__construct($context, $urlModel, $backendHelper, $data); + parent::__construct($context, $backendHelper, $data); } protected function _construct() diff --git a/app/code/Magento/GoogleShopping/Helper/Price.php b/app/code/Magento/GoogleShopping/Helper/Price.php deleted file mode 100644 index 9796713956bcb76ec3cb2d18a4bfc6c6b37dce53..0000000000000000000000000000000000000000 --- a/app/code/Magento/GoogleShopping/Helper/Price.php +++ /dev/null @@ -1,148 +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. - * - * @category Magento - * @package Magento_GoogleShopping - * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) - */ - -/** - * Price helper - * This class is workaround for problem of getting appropriate price for - * some types of products: bundle, grouped, gift cards; abstract price model - * doesn't give access to such information - * - * @category Magento - * @package Magento_GoogleShopping - * @author Magento Core Team <core@magentocommerce.com> - */ -namespace Magento\GoogleShopping\Helper; - -class Price -{ - /** - * Core registry - * - * @var \Magento\Core\Model\Registry - */ - protected $_coreRegistry = null; - - /** - * Store manager - * - * @var \Magento\Core\Model\StoreManagerInterface - */ - protected $_storeManager; - - /** - * @param \Magento\Core\Model\Registry $coreRegistry - * @param \Magento\Core\Model\StoreManagerInterface $storeManager - */ - public function __construct( - \Magento\Core\Model\Registry $coreRegistry, - \Magento\Core\Model\StoreManagerInterface $storeManager - ) { - $this->_coreRegistry = $coreRegistry; - $this->_storeManager = $storeManager; - } - - /** - * Tries to return price that looks like price in catalog - * - * @param \Magento\Catalog\Model\Product $product - * @param null|\Magento\Core\Model\Store $store Store view - * @return null|float Price - */ - public function getCatalogPrice(\Magento\Catalog\Model\Product $product, $store = null, $inclTax = null) - { - switch ($product->getTypeId()) { - case \Magento\GroupedProduct\Model\Product\Type\Grouped::TYPE_CODE: - // Workaround to avoid loading stock status by admin's website - if ($store instanceof \Magento\Core\Model\Store) { - $oldStore = $this->_storeManager->getStore(); - $this->_storeManager->setCurrentStore($store); - } - $subProducts = $product->getTypeInstance()->getAssociatedProducts($product); - if ($store instanceof \Magento\Core\Model\Store) { - $this->_storeManager->setCurrentStore($oldStore); - } - if (!count($subProducts)) { - return null; - } - $minPrice = null; - foreach ($subProducts as $subProduct) { - $subProduct->setWebsiteId($product->getWebsiteId()) - ->setCustomerGroupId($product->getCustomerGroupId()); - if ($subProduct->isSalable()) { - if ($this->getCatalogPrice($subProduct) < $minPrice || $minPrice === null) { - $minPrice = $this->getCatalogPrice($subProduct); - $product->setTaxClassId($subProduct->getTaxClassId()); - } - } - } - return $minPrice; - - case \Magento\Catalog\Model\Product\Type::TYPE_BUNDLE: - if ($store instanceof \Magento\Core\Model\Store) { - $oldStore = $this->_storeManager->getStore(); - $this->_storeManager->setCurrentStore($store); - } - - $this->_coreRegistry->unregister('rule_data'); - $this->_coreRegistry->register('rule_data', new \Magento\Object(array( - 'store_id' => $product->getStoreId(), - 'website_id' => $product->getWebsiteId(), - 'customer_group_id' => $product->getCustomerGroupId()))); - - $minPrice = $product->getPriceModel()->getTotalPrices($product, 'min', $inclTax); - - if ($store instanceof \Magento\Core\Model\Store) { - $this->_storeManager->setCurrentStore($oldStore); - } - return $minPrice; - - case 'giftcard': - return $product->getPriceModel()->getMinAmount($product); - - default: - return $product->getFinalPrice(); - } - } - - /** - * Tries calculate price without discount; if can't returns nul - * - * @param \Magento\Catalog\Model\Product $product - * @param mixed $store - */ - public function getCatalogRegularPrice(\Magento\Catalog\Model\Product $product, $store = null) - { - switch ($product->getTypeId()) { - case \Magento\GroupedProduct\Model\Product\Type\Grouped::TYPE_CODE: - case \Magento\Catalog\Model\Product\Type::TYPE_BUNDLE: - case 'giftcard': - return null; - - default: - return $product->getPrice(); - } - } -} diff --git a/app/code/Magento/GoogleShopping/Model/Attribute.php b/app/code/Magento/GoogleShopping/Model/Attribute.php index bd2f27df0ee12ad80379f64f8be83fcf6a74b038..76f050ff02523c9447a188f7479fc8f9967f5e85 100644 --- a/app/code/Magento/GoogleShopping/Model/Attribute.php +++ b/app/code/Magento/GoogleShopping/Model/Attribute.php @@ -80,9 +80,9 @@ class Attribute extends \Magento\Core\Model\AbstractModel protected $_gsProduct = null; /** - * @var \Magento\GoogleShopping\Helper\Price|null + * @var \Magento\Catalog\Model\Product\CatalogPrice */ - protected $_gsPrice = null; + protected $catalogPrice; /** * Product factory @@ -97,7 +97,7 @@ class Attribute extends \Magento\Core\Model\AbstractModel * @param \Magento\Catalog\Model\ProductFactory $productFactory * @param \Magento\GoogleShopping\Helper\Data $gsData * @param \Magento\GoogleShopping\Helper\Product $gsProduct - * @param \Magento\GoogleShopping\Helper\Price $gsPrice + * @param \Magento\Catalog\Model\Product\CatalogPrice $catalogPrice * @param \Magento\GoogleShopping\Model\Resource\Attribute $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data @@ -108,7 +108,7 @@ class Attribute extends \Magento\Core\Model\AbstractModel \Magento\Catalog\Model\ProductFactory $productFactory, \Magento\GoogleShopping\Helper\Data $gsData, \Magento\GoogleShopping\Helper\Product $gsProduct, - \Magento\GoogleShopping\Helper\Price $gsPrice, + \Magento\Catalog\Model\Product\CatalogPrice $catalogPrice, \Magento\GoogleShopping\Model\Resource\Attribute $resource, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() @@ -116,7 +116,7 @@ class Attribute extends \Magento\Core\Model\AbstractModel $this->_productFactory = $productFactory; $this->_gsData = $gsData; $this->_gsProduct = $gsProduct; - $this->_gsPrice = $gsPrice; + $this->catalogPrice = $catalogPrice; parent::__construct($context, $registry, $resource, $resourceCollection, $data); } diff --git a/app/code/Magento/GoogleShopping/Model/Attribute/ContentLanguage.php b/app/code/Magento/GoogleShopping/Model/Attribute/ContentLanguage.php index b173c64d81c78c6fcbd25b932a1f03cb37a29968..79f0efcaab0f2c38a8d709e3443a5d16421acde8 100644 --- a/app/code/Magento/GoogleShopping/Model/Attribute/ContentLanguage.php +++ b/app/code/Magento/GoogleShopping/Model/Attribute/ContentLanguage.php @@ -48,7 +48,7 @@ class ContentLanguage extends \Magento\GoogleShopping\Model\Attribute\DefaultAtt * @param \Magento\Catalog\Model\ProductFactory $productFactory * @param \Magento\GoogleShopping\Helper\Data $gsData * @param \Magento\GoogleShopping\Helper\Product $gsProduct - * @param \Magento\GoogleShopping\Helper\Price $gsPrice + * @param \Magento\Catalog\Model\Product\CatalogPrice $catalogPrice * @param \Magento\GoogleShopping\Model\Resource\Attribute $resource * @param \Magento\GoogleShopping\Model\Config $config * @param \Magento\Data\Collection\Db $resourceCollection @@ -60,7 +60,7 @@ class ContentLanguage extends \Magento\GoogleShopping\Model\Attribute\DefaultAtt \Magento\Catalog\Model\ProductFactory $productFactory, \Magento\GoogleShopping\Helper\Data $gsData, \Magento\GoogleShopping\Helper\Product $gsProduct, - \Magento\GoogleShopping\Helper\Price $gsPrice, + \Magento\Catalog\Model\Product\CatalogPrice $catalogPrice, \Magento\GoogleShopping\Model\Resource\Attribute $resource, \Magento\GoogleShopping\Model\Config $config, \Magento\Data\Collection\Db $resourceCollection = null, @@ -73,7 +73,7 @@ class ContentLanguage extends \Magento\GoogleShopping\Model\Attribute\DefaultAtt $productFactory, $gsData, $gsProduct, - $gsPrice, + $catalogPrice, $resource, $resourceCollection, $data diff --git a/app/code/Magento/GoogleShopping/Model/Attribute/Destinations.php b/app/code/Magento/GoogleShopping/Model/Attribute/Destinations.php index 4f43b61d6a003657a662a50306224f00a4f5f89b..3e6b35ced1e167e97d1f505e09c424eb9bb44297 100644 --- a/app/code/Magento/GoogleShopping/Model/Attribute/Destinations.php +++ b/app/code/Magento/GoogleShopping/Model/Attribute/Destinations.php @@ -48,7 +48,7 @@ class Destinations extends \Magento\GoogleShopping\Model\Attribute\DefaultAttrib * @param \Magento\Catalog\Model\ProductFactory $productFactory * @param \Magento\GoogleShopping\Helper\Data $gsData * @param \Magento\GoogleShopping\Helper\Product $gsProduct - * @param \Magento\GoogleShopping\Helper\Price $gsPrice + * @param \Magento\Catalog\Model\Product\CatalogPrice $catalogPrice * @param \Magento\GoogleShopping\Model\Resource\Attribute $resource * @param \Magento\GoogleShopping\Model\Config $config * @param \Magento\Data\Collection\Db $resourceCollection @@ -60,7 +60,7 @@ class Destinations extends \Magento\GoogleShopping\Model\Attribute\DefaultAttrib \Magento\Catalog\Model\ProductFactory $productFactory, \Magento\GoogleShopping\Helper\Data $gsData, \Magento\GoogleShopping\Helper\Product $gsProduct, - \Magento\GoogleShopping\Helper\Price $gsPrice, + \Magento\Catalog\Model\Product\CatalogPrice $catalogPrice, \Magento\GoogleShopping\Model\Resource\Attribute $resource, \Magento\GoogleShopping\Model\Config $config, \Magento\Data\Collection\Db $resourceCollection = null, @@ -73,7 +73,7 @@ class Destinations extends \Magento\GoogleShopping\Model\Attribute\DefaultAttrib $productFactory, $gsData, $gsProduct, - $gsPrice, + $catalogPrice, $resource, $resourceCollection, $data diff --git a/app/code/Magento/GoogleShopping/Model/Attribute/GoogleProductCategory.php b/app/code/Magento/GoogleShopping/Model/Attribute/GoogleProductCategory.php index 861338af62d017c441c000c8bf7588f5270d8977..0150b87380a6bba4260e4cb21bb89bd80d72ef8e 100644 --- a/app/code/Magento/GoogleShopping/Model/Attribute/GoogleProductCategory.php +++ b/app/code/Magento/GoogleShopping/Model/Attribute/GoogleProductCategory.php @@ -55,7 +55,7 @@ class GoogleProductCategory extends \Magento\GoogleShopping\Model\Attribute\Defa * @param \Magento\Catalog\Model\ProductFactory $productFactory * @param \Magento\GoogleShopping\Helper\Data $gsData * @param \Magento\GoogleShopping\Helper\Product $gsProduct - * @param \Magento\GoogleShopping\Helper\Price $gsPrice + * @param \Magento\Catalog\Model\Product\CatalogPrice $catalogPrice * @param \Magento\GoogleShopping\Model\Resource\Attribute $resource * @param \Magento\GoogleShopping\Model\TypeFactory $typeFactory * @param \Magento\GoogleShopping\Model\Config $config @@ -68,7 +68,7 @@ class GoogleProductCategory extends \Magento\GoogleShopping\Model\Attribute\Defa \Magento\Catalog\Model\ProductFactory $productFactory, \Magento\GoogleShopping\Helper\Data $gsData, \Magento\GoogleShopping\Helper\Product $gsProduct, - \Magento\GoogleShopping\Helper\Price $gsPrice, + \Magento\Catalog\Model\Product\CatalogPrice $catalogPrice, \Magento\GoogleShopping\Model\Resource\Attribute $resource, \Magento\GoogleShopping\Model\TypeFactory $typeFactory, \Magento\GoogleShopping\Model\Config $config, @@ -83,7 +83,7 @@ class GoogleProductCategory extends \Magento\GoogleShopping\Model\Attribute\Defa $productFactory, $gsData, $gsProduct, - $gsPrice, + $catalogPrice, $resource, $resourceCollection, $data diff --git a/app/code/Magento/GoogleShopping/Model/Attribute/ImageLink.php b/app/code/Magento/GoogleShopping/Model/Attribute/ImageLink.php index 1df531adb83e5f57d7ff70734314ba0ae9e4ae21..317b7152f714add0f7e05b032112e115bbca1ee2 100644 --- a/app/code/Magento/GoogleShopping/Model/Attribute/ImageLink.php +++ b/app/code/Magento/GoogleShopping/Model/Attribute/ImageLink.php @@ -46,7 +46,7 @@ class ImageLink extends \Magento\GoogleShopping\Model\Attribute\DefaultAttribute * @param \Magento\Catalog\Model\ProductFactory $productFactory * @param \Magento\GoogleShopping\Helper\Data $gsData * @param \Magento\GoogleShopping\Helper\Product $gsProduct - * @param \Magento\GoogleShopping\Helper\Price $gsPrice + * @param \Magento\Catalog\Model\Product\CatalogPrice $catalogPrice * @param \Magento\GoogleShopping\Model\Resource\Attribute $resource * @param \Magento\Catalog\Helper\Product $catalogProduct * @param \Magento\Data\Collection\Db $resourceCollection @@ -58,7 +58,7 @@ class ImageLink extends \Magento\GoogleShopping\Model\Attribute\DefaultAttribute \Magento\Catalog\Model\ProductFactory $productFactory, \Magento\GoogleShopping\Helper\Data $gsData, \Magento\GoogleShopping\Helper\Product $gsProduct, - \Magento\GoogleShopping\Helper\Price $gsPrice, + \Magento\Catalog\Model\Product\CatalogPrice $catalogPrice, \Magento\GoogleShopping\Model\Resource\Attribute $resource, \Magento\Catalog\Helper\Product $catalogProduct, \Magento\Data\Collection\Db $resourceCollection = null, @@ -71,7 +71,7 @@ class ImageLink extends \Magento\GoogleShopping\Model\Attribute\DefaultAttribute $productFactory, $gsData, $gsProduct, - $gsPrice, + $catalogPrice, $resource, $resourceCollection, $data diff --git a/app/code/Magento/GoogleShopping/Model/Attribute/Link.php b/app/code/Magento/GoogleShopping/Model/Attribute/Link.php index 88e1331748d4d700228055c0292a94a6dddd459b..397ab5fb10f00480c909aeb428f49fca795ef495 100644 --- a/app/code/Magento/GoogleShopping/Model/Attribute/Link.php +++ b/app/code/Magento/GoogleShopping/Model/Attribute/Link.php @@ -48,7 +48,7 @@ class Link extends \Magento\GoogleShopping\Model\Attribute\DefaultAttribute * @param \Magento\Catalog\Model\ProductFactory $productFactory * @param \Magento\GoogleShopping\Helper\Data $gsData * @param \Magento\GoogleShopping\Helper\Product $gsProduct - * @param \Magento\GoogleShopping\Helper\Price $gsPrice + * @param \Magento\Catalog\Model\Product\CatalogPrice $catalogPrice * @param \Magento\GoogleShopping\Model\Resource\Attribute $resource * @param \Magento\Core\Model\Store\Config $coreStoreConfig * @param \Magento\Data\Collection\Db $resourceCollection @@ -60,7 +60,7 @@ class Link extends \Magento\GoogleShopping\Model\Attribute\DefaultAttribute \Magento\Catalog\Model\ProductFactory $productFactory, \Magento\GoogleShopping\Helper\Data $gsData, \Magento\GoogleShopping\Helper\Product $gsProduct, - \Magento\GoogleShopping\Helper\Price $gsPrice, + \Magento\Catalog\Model\Product\CatalogPrice $catalogPrice, \Magento\GoogleShopping\Model\Resource\Attribute $resource, \Magento\Core\Model\Store\Config $coreStoreConfig, \Magento\Data\Collection\Db $resourceCollection = null, @@ -73,7 +73,7 @@ class Link extends \Magento\GoogleShopping\Model\Attribute\DefaultAttribute $productFactory, $gsData, $gsProduct, - $gsPrice, + $catalogPrice, $resource, $resourceCollection, $data diff --git a/app/code/Magento/GoogleShopping/Model/Attribute/Price.php b/app/code/Magento/GoogleShopping/Model/Attribute/Price.php index 31b166c47dffe2fb6aee5416395bb83420709e2c..6c698d44e61f9729b130115dc4d36430040e6c4a 100644 --- a/app/code/Magento/GoogleShopping/Model/Attribute/Price.php +++ b/app/code/Magento/GoogleShopping/Model/Attribute/Price.php @@ -61,18 +61,24 @@ class Price extends \Magento\GoogleShopping\Model\Attribute\DefaultAttribute */ protected $_storeManager; + /** + * @var \Magento\Catalog\Model\Product\CatalogPrice + */ + protected $catalogPrice; + /** * @param \Magento\Core\Model\Context $context * @param \Magento\Core\Model\Registry $registry * @param \Magento\Catalog\Model\ProductFactory $productFactory * @param \Magento\GoogleShopping\Helper\Data $gsData * @param \Magento\GoogleShopping\Helper\Product $gsProduct - * @param \Magento\GoogleShopping\Helper\Price $gsPrice + * @param \Magento\Catalog\Model\Product\CatalogPrice $catalogPrice * @param \Magento\GoogleShopping\Model\Resource\Attribute $resource * @param \Magento\Core\Model\StoreManagerInterface $storeManager * @param \Magento\Tax\Helper\Data $taxData * @param \Magento\Core\Model\Store\Config $coreStoreConfig * @param \Magento\GoogleShopping\Model\Config $config + * @param \Magento\Catalog\Model\Product\CatalogPrice $catalogPrice * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data */ @@ -82,7 +88,7 @@ class Price extends \Magento\GoogleShopping\Model\Attribute\DefaultAttribute \Magento\Catalog\Model\ProductFactory $productFactory, \Magento\GoogleShopping\Helper\Data $gsData, \Magento\GoogleShopping\Helper\Product $gsProduct, - \Magento\GoogleShopping\Helper\Price $gsPrice, + \Magento\Catalog\Model\Product\CatalogPrice $catalogPrice, \Magento\GoogleShopping\Model\Resource\Attribute $resource, \Magento\Core\Model\StoreManagerInterface $storeManager, \Magento\Tax\Helper\Data $taxData, @@ -95,13 +101,14 @@ class Price extends \Magento\GoogleShopping\Model\Attribute\DefaultAttribute $this->_config = $config; $this->_taxData = $taxData; $this->_coreStoreConfig = $coreStoreConfig; + $this->catalogPrice = $catalogPrice; parent::__construct( $context, $registry, $productFactory, $gsData, $gsProduct, - $gsPrice, + $catalogPrice, $resource, $resourceCollection, $data @@ -141,7 +148,7 @@ class Price extends \Magento\GoogleShopping\Model\Attribute\DefaultAttribute if (!is_null($salePriceMapValue) && floatval($salePriceMapValue) > .0001) { $finalPrice = $salePriceMapValue; } else if ($isSalePriceAllowed) { - $finalPrice = $this->_gsPrice->getCatalogPrice($product, $store, $inclTax); + $finalPrice = $this->catalogPrice->getCatalogPrice($product, $store, $inclTax); } if ($product->getTypeId() != \Magento\Catalog\Model\Product\Type::TYPE_BUNDLE) { $finalPrice = $taxHelp->getPrice($product, $finalPrice, $inclTax, null, null, null, $product->getStoreId()); @@ -153,10 +160,10 @@ class Price extends \Magento\GoogleShopping\Model\Attribute\DefaultAttribute if (!is_null($priceMapValue) && floatval($priceMapValue) > .0001) { $price = $priceMapValue; } else if ($isSalePriceAllowed) { - $price = $this->_gsPrice->getCatalogRegularPrice($product, $store); + $price = $this->catalogPrice->getCatalogRegularPrice($product, $store); } else { $inclTax = ($priceDisplayType != \Magento\Tax\Model\Config::DISPLAY_TYPE_EXCLUDING_TAX); - $price = $this->_gsPrice->getCatalogPrice($product, $store, $inclTax); + $price = $this->catalogPrice->getCatalogPrice($product, $store, $inclTax); } if ($product->getTypeId() != \Magento\Catalog\Model\Product\Type::TYPE_BUNDLE) { $price = $taxHelp->getPrice($product, $price, $inclTax, null, null, null, $product->getStoreId()); diff --git a/app/code/Magento/GoogleShopping/Model/Attribute/ProductType.php b/app/code/Magento/GoogleShopping/Model/Attribute/ProductType.php index b692a7094ed8021556314ffe56134e9aa2460a92..ce24e44f5c5cc1ff4409f5d398715ec75ee56d7e 100644 --- a/app/code/Magento/GoogleShopping/Model/Attribute/ProductType.php +++ b/app/code/Magento/GoogleShopping/Model/Attribute/ProductType.php @@ -48,7 +48,7 @@ class ProductType extends \Magento\GoogleShopping\Model\Attribute\DefaultAttribu * @param \Magento\Catalog\Model\ProductFactory $productFactory * @param \Magento\GoogleShopping\Helper\Data $gsData * @param \Magento\GoogleShopping\Helper\Product $gsProduct - * @param \Magento\GoogleShopping\Helper\Price $gsPrice + * @param \Magento\Catalog\Model\Product\CatalogPrice $catalogPrice * @param \Magento\GoogleShopping\Model\Resource\Attribute $resource * @param \Magento\Catalog\Model\CategoryFactory $categoryFactory * @param \Magento\Data\Collection\Db $resourceCollection @@ -60,7 +60,7 @@ class ProductType extends \Magento\GoogleShopping\Model\Attribute\DefaultAttribu \Magento\Catalog\Model\ProductFactory $productFactory, \Magento\GoogleShopping\Helper\Data $gsData, \Magento\GoogleShopping\Helper\Product $gsProduct, - \Magento\GoogleShopping\Helper\Price $gsPrice, + \Magento\Catalog\Model\Product\CatalogPrice $catalogPrice, \Magento\GoogleShopping\Model\Resource\Attribute $resource, \Magento\Catalog\Model\CategoryFactory $categoryFactory, \Magento\Data\Collection\Db $resourceCollection = null, @@ -73,7 +73,7 @@ class ProductType extends \Magento\GoogleShopping\Model\Attribute\DefaultAttribu $productFactory, $gsData, $gsProduct, - $gsPrice, + $catalogPrice, $resource, $resourceCollection, $data diff --git a/app/code/Magento/GoogleShopping/Model/Attribute/TargetCountry.php b/app/code/Magento/GoogleShopping/Model/Attribute/TargetCountry.php index b9900cb7d3288c69de23234a4bb1fe43b04c8e66..d013b8bafa41da9b3c7124545ec42682feb8302f 100644 --- a/app/code/Magento/GoogleShopping/Model/Attribute/TargetCountry.php +++ b/app/code/Magento/GoogleShopping/Model/Attribute/TargetCountry.php @@ -48,7 +48,7 @@ class TargetCountry extends \Magento\GoogleShopping\Model\Attribute\DefaultAttri * @param \Magento\Catalog\Model\ProductFactory $productFactory * @param \Magento\GoogleShopping\Helper\Data $gsData * @param \Magento\GoogleShopping\Helper\Product $gsProduct - * @param \Magento\GoogleShopping\Helper\Price $gsPrice + * @param \Magento\Catalog\Model\Product\CatalogPrice $catalogPrice * @param \Magento\GoogleShopping\Model\Resource\Attribute $resource * @param \Magento\GoogleShopping\Model\Config $config * @param \Magento\Data\Collection\Db $resourceCollection @@ -60,7 +60,7 @@ class TargetCountry extends \Magento\GoogleShopping\Model\Attribute\DefaultAttri \Magento\Catalog\Model\ProductFactory $productFactory, \Magento\GoogleShopping\Helper\Data $gsData, \Magento\GoogleShopping\Helper\Product $gsProduct, - \Magento\GoogleShopping\Helper\Price $gsPrice, + \Magento\Catalog\Model\Product\CatalogPrice $catalogPrice, \Magento\GoogleShopping\Model\Resource\Attribute $resource, \Magento\GoogleShopping\Model\Config $config, \Magento\Data\Collection\Db $resourceCollection = null, @@ -73,7 +73,7 @@ class TargetCountry extends \Magento\GoogleShopping\Model\Attribute\DefaultAttri $productFactory, $gsData, $gsProduct, - $gsPrice, + $catalogPrice, $resource, $resourceCollection, $data diff --git a/app/code/Magento/GoogleShopping/Model/Attribute/Tax.php b/app/code/Magento/GoogleShopping/Model/Attribute/Tax.php index 8ac8325d4b6feb7e8ad484e81f711776319fceb1..9d35aa31adcb48823741f3ff655ab4a0930675ef 100644 --- a/app/code/Magento/GoogleShopping/Model/Attribute/Tax.php +++ b/app/code/Magento/GoogleShopping/Model/Attribute/Tax.php @@ -61,7 +61,7 @@ class Tax extends \Magento\GoogleShopping\Model\Attribute\DefaultAttribute * @param \Magento\Catalog\Model\ProductFactory $productFactory * @param \Magento\GoogleShopping\Helper\Data $gsData * @param \Magento\GoogleShopping\Helper\Product $gsProduct - * @param \Magento\GoogleShopping\Helper\Price $gsPrice + * @param \Magento\Catalog\Model\Product\CatalogPrice $catalogPrice * @param \Magento\GoogleShopping\Model\Resource\Attribute $resource * @param \Magento\GoogleCheckout\Helper\Data $checkoutDataHelper * @param \Magento\GoogleShopping\Model\Config $config @@ -75,7 +75,7 @@ class Tax extends \Magento\GoogleShopping\Model\Attribute\DefaultAttribute \Magento\Catalog\Model\ProductFactory $productFactory, \Magento\GoogleShopping\Helper\Data $gsData, \Magento\GoogleShopping\Helper\Product $gsProduct, - \Magento\GoogleShopping\Helper\Price $gsPrice, + \Magento\Catalog\Model\Product\CatalogPrice $catalogPrice, \Magento\GoogleShopping\Model\Resource\Attribute $resource, \Magento\GoogleCheckout\Helper\Data $checkoutDataHelper, \Magento\GoogleShopping\Model\Config $config, @@ -92,7 +92,7 @@ class Tax extends \Magento\GoogleShopping\Model\Attribute\DefaultAttribute $productFactory, $gsData, $gsProduct, - $gsPrice, + $catalogPrice, $resource, $resourceCollection, $data diff --git a/app/code/Magento/GoogleShopping/etc/di.xml b/app/code/Magento/GoogleShopping/etc/di.xml index fd192922525939f49a249a91904b356268e1558a..89f94b870f94ef2b2fe7e33cd99b627690792bef 100644 --- a/app/code/Magento/GoogleShopping/etc/di.xml +++ b/app/code/Magento/GoogleShopping/etc/di.xml @@ -36,9 +36,9 @@ </type> <type name="Magento\Module\Updater\SetupFactory"> <param name="resourceTypes"> - <value> - <googleshopping_setup>Magento\GoogleShopping\Model\Resource\Setup</googleshopping_setup> - </value> + <array> + <item key="googleshopping_setup"><value>Magento\GoogleShopping\Model\Resource\Setup</value></item> + </array> </param> </type> </config> diff --git a/app/code/Magento/GoogleShopping/etc/module.xml b/app/code/Magento/GoogleShopping/etc/module.xml index 397874cb81e1628ed4077f7833aae45ac57195d9..9916215e0d0416cc0bbd8368de4603fe70ccb369 100755 --- a/app/code/Magento/GoogleShopping/etc/module.xml +++ b/app/code/Magento/GoogleShopping/etc/module.xml @@ -38,7 +38,6 @@ <module name="Magento_Tax"/> <module name="Magento_Theme"/> <module name="Magento_GoogleCheckout"/> - <module name="Magento_GroupedProduct"/> </depends> </module> </config> diff --git a/app/code/Magento/Sales/Block/Adminhtml/Items/Column/Name/Grouped.php b/app/code/Magento/GroupedProduct/Block/Adminhtml/Items/Column/Name/Grouped.php similarity index 87% rename from app/code/Magento/Sales/Block/Adminhtml/Items/Column/Name/Grouped.php rename to app/code/Magento/GroupedProduct/Block/Adminhtml/Items/Column/Name/Grouped.php index a36ab9d639cee31343f07907d66767077ad1ff6c..dcd3c260879112491480aceac9f64784824272ba 100644 --- a/app/code/Magento/Sales/Block/Adminhtml/Items/Column/Name/Grouped.php +++ b/app/code/Magento/GroupedProduct/Block/Adminhtml/Items/Column/Name/Grouped.php @@ -1,5 +1,7 @@ <?php /** + * Sales Order items name column renderer + * * Magento * * NOTICE OF LICENSE @@ -18,21 +20,11 @@ * 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_Sales * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ - -/** - * Sales Order items name column renderer - * - * @category Magento - * @package Magento_Sales - * @author Magento Core Team <core@magentocommerce.com> - */ -namespace Magento\Sales\Block\Adminhtml\Items\Column\Name; +namespace Magento\GroupedProduct\Block\Adminhtml\Items\Column\Name; class Grouped extends \Magento\Sales\Block\Adminhtml\Items\Column\Name { @@ -57,4 +49,3 @@ class Grouped extends \Magento\Sales\Block\Adminhtml\Items\Column\Name return parent::_toHtml(); } } -?> diff --git a/app/code/Magento/GroupedProduct/Block/Adminhtml/Order/Create/Sidebar.php b/app/code/Magento/GroupedProduct/Block/Adminhtml/Order/Create/Sidebar.php new file mode 100644 index 0000000000000000000000000000000000000000..ab3b73c2896f8f55c41945fe8f5d372cd3df2b61 --- /dev/null +++ b/app/code/Magento/GroupedProduct/Block/Adminhtml/Order/Create/Sidebar.php @@ -0,0 +1,63 @@ +<?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\GroupedProduct\Block\Adminhtml\Order\Create; + +class Sidebar +{ + /** + * Get item qty + * + * @param array $arguments + * @param \Magento\Code\Plugin\InvocationChain $invocationChain + * @return mixed|string + */ + public function aroundGetItemQty(array $arguments, \Magento\Code\Plugin\InvocationChain $invocationChain) + { + /** @var \Magento\Catalog\Model\Product\Configuration\Item\ItemInterface $item */ + $item = $arguments[0]; + if ($item->getProduct()->getTypeId() == \Magento\GroupedProduct\Model\Product\Type\Grouped::TYPE_CODE) { + return ''; + } + return $invocationChain->proceed($arguments); + } + + /** + * Check whether product configuration is required before adding to order + * + * @param array $arguments + * @param \Magento\Code\Plugin\InvocationChain $invocationChain + * @return bool|mixed + */ + public function aroundIsConfigurationRequired( + array $arguments, + \Magento\Code\Plugin\InvocationChain $invocationChain + ) { + $typeId = $arguments[0]; + if ($typeId == \Magento\GroupedProduct\Model\Product\Type\Grouped::TYPE_CODE) { + return true; + } + return $invocationChain->proceed($arguments); + } +} diff --git a/app/code/Magento/Checkout/Block/Cart/Item/Renderer/Grouped.php b/app/code/Magento/GroupedProduct/Block/Cart/Item/Renderer/Grouped.php similarity index 98% rename from app/code/Magento/Checkout/Block/Cart/Item/Renderer/Grouped.php rename to app/code/Magento/GroupedProduct/Block/Cart/Item/Renderer/Grouped.php index 4e012a9426fee6956aef1398179498700cfb36ca..023ff092d1ccac7196f489c2a76ba756afbb7237 100644 --- a/app/code/Magento/Checkout/Block/Cart/Item/Renderer/Grouped.php +++ b/app/code/Magento/GroupedProduct/Block/Cart/Item/Renderer/Grouped.php @@ -22,7 +22,7 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Checkout\Block\Cart\Item\Renderer; +namespace Magento\GroupedProduct\Block\Cart\Item\Renderer; use Magento\Catalog\Model\Config\Source\Product\Thumbnail as ThumbnailSource; diff --git a/app/code/Magento/Sales/Block/Order/Email/Items/Order/Grouped.php b/app/code/Magento/GroupedProduct/Block/Order/Email/Items/Order/Grouped.php similarity index 82% rename from app/code/Magento/Sales/Block/Order/Email/Items/Order/Grouped.php rename to app/code/Magento/GroupedProduct/Block/Order/Email/Items/Order/Grouped.php index fc3dff0a0aee76bf20de9e8467dc22f0e129481b..cf3482e6e03e5587a95b4a641898f4340d6d22a2 100644 --- a/app/code/Magento/Sales/Block/Order/Email/Items/Order/Grouped.php +++ b/app/code/Magento/GroupedProduct/Block/Order/Email/Items/Order/Grouped.php @@ -1,5 +1,7 @@ <?php /** + * Order Email items grouped renderer + * * Magento * * NOTICE OF LICENSE @@ -18,21 +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_Sales * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ - - -/** - * Sales Order Email items grouped renderer - * - * @category Magento - * @package Magento_Sales - * @author Magento Core Team <core@magentocommerce.com> - */ -namespace Magento\Sales\Block\Order\Email\Items\Order; +namespace Magento\GroupedProduct\Block\Order\Email\Items\Order; class Grouped extends \Magento\Sales\Block\Order\Email\Items\Order\DefaultOrder { @@ -44,7 +35,8 @@ class Grouped extends \Magento\Sales\Block\Order\Email\Items\Order\DefaultOrder * @return string */ protected function _toHtml() - { if ($this->getItem()->getOrderItem()) { + { + if ($this->getItem()->getOrderItem()) { $item = $this->getItem()->getOrderItem(); } else { $item = $this->getItem(); diff --git a/app/code/Magento/Sales/Block/Order/Item/Renderer/Grouped.php b/app/code/Magento/GroupedProduct/Block/Order/Item/Renderer/Grouped.php similarity index 83% rename from app/code/Magento/Sales/Block/Order/Item/Renderer/Grouped.php rename to app/code/Magento/GroupedProduct/Block/Order/Item/Renderer/Grouped.php index 0ef0af88f8e71aa4320653f361dc806b94792572..3454290f2afa1e1e169f57cba21472a33c51d891 100644 --- a/app/code/Magento/Sales/Block/Order/Item/Renderer/Grouped.php +++ b/app/code/Magento/GroupedProduct/Block/Order/Item/Renderer/Grouped.php @@ -1,5 +1,7 @@ <?php /** + * Order item render block for grouped product type + * * Magento * * NOTICE OF LICENSE @@ -18,22 +20,14 @@ * 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_Sales * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\GroupedProduct\Block\Order\Item\Renderer; -/** - * Order item render block for grouped product type - * - * @category Magento - * @package Magento_Sales - * @author Magento Core Team <core@magentocommerce.com> - */ -namespace Magento\Sales\Block\Order\Item\Renderer; +use Magento\Sales\Block\Order\Item\Renderer\DefaultRenderer; -class Grouped extends \Magento\Sales\Block\Order\Item\Renderer\DefaultRenderer +class Grouped extends DefaultRenderer { /** * Prepare item html diff --git a/app/code/Magento/CatalogInventory/Block/Stockqty/Type/Grouped.php b/app/code/Magento/GroupedProduct/Block/Stockqty/Type/Grouped.php similarity index 76% rename from app/code/Magento/CatalogInventory/Block/Stockqty/Type/Grouped.php rename to app/code/Magento/GroupedProduct/Block/Stockqty/Type/Grouped.php index dbb689dfed09f093b06726d3f1a6a2f80e2c5267..1c66ad885e688fb5a48bad79913c77640c0e7358 100644 --- a/app/code/Magento/CatalogInventory/Block/Stockqty/Type/Grouped.php +++ b/app/code/Magento/GroupedProduct/Block/Stockqty/Type/Grouped.php @@ -1,5 +1,7 @@ <?php /** + * Product stock qty block for grouped product type + * * Magento * * NOTICE OF LICENSE @@ -18,21 +20,11 @@ * 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; +namespace Magento\GroupedProduct\Block\Stockqty\Type; class Grouped extends \Magento\CatalogInventory\Block\Stockqty\Composite { @@ -43,7 +35,6 @@ class Grouped extends \Magento\CatalogInventory\Block\Stockqty\Composite */ protected function _getChildProducts() { - return $this->getProduct()->getTypeInstance() - ->getAssociatedProducts($this->getProduct()); + return $this->getProduct()->getTypeInstance()->getAssociatedProducts($this->getProduct()); } } diff --git a/app/code/Magento/GroupedProduct/Model/Export/Entity/Product/Type/Grouped.php b/app/code/Magento/GroupedProduct/Model/Export/Entity/Product/Type/Grouped.php new file mode 100644 index 0000000000000000000000000000000000000000..9da90ae4a80dc508994ee8bc7155ca2b10f416f4 --- /dev/null +++ b/app/code/Magento/GroupedProduct/Model/Export/Entity/Product/Type/Grouped.php @@ -0,0 +1,33 @@ +<?php +/** + * Export entity of grouped product type + * + * 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\GroupedProduct\Model\Export\Entity\Product\Type; + +use Magento\ImportExport\Model\Export\Entity\Product\Type\AbstractType; + +class Grouped extends AbstractType +{ +} diff --git a/app/code/Magento/ImportExport/Model/Import/Entity/Product/Type/Grouped.php b/app/code/Magento/GroupedProduct/Model/Import/Entity/Product/Type/Grouped.php similarity index 94% rename from app/code/Magento/ImportExport/Model/Import/Entity/Product/Type/Grouped.php rename to app/code/Magento/GroupedProduct/Model/Import/Entity/Product/Type/Grouped.php index 4ddcf479a9f0ed649a158320328c159c2d97456e..ee676c7a8bb01c87aaa3017e29944b52469326e8 100644 --- a/app/code/Magento/ImportExport/Model/Import/Entity/Product/Type/Grouped.php +++ b/app/code/Magento/GroupedProduct/Model/Import/Entity/Product/Type/Grouped.php @@ -1,5 +1,7 @@ <?php /** + * Import entity of grouped product type + * * Magento * * NOTICE OF LICENSE @@ -18,23 +20,15 @@ * 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_ImportExport * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -/** - * Import entity grouped product type model - * - * @category Magento - * @package Magento_ImportExport - * @author Magento Core Team <core@magentocommerce.com> - */ -namespace Magento\ImportExport\Model\Import\Entity\Product\Type; +namespace Magento\GroupedProduct\Model\Import\Entity\Product\Type; + +use Magento\ImportExport\Model\Import\Entity\Product\Type\AbstractType; -class Grouped - extends \Magento\ImportExport\Model\Import\Entity\Product\Type\AbstractType +class Grouped extends AbstractType { /** * Column names that holds values with particular meaning. @@ -106,6 +100,10 @@ class Grouped * Save product type specific data. * * @return \Magento\ImportExport\Model\Import\Entity\Product\Type\AbstractType + * + * @SuppressWarnings(PHPMD.CyclomaticComplexity) + * @SuppressWarnings(PHPMD.NPathComplexity) + * @SuppressWarnings(PHPMD.ExcessiveMethodLength) */ public function saveData() { @@ -189,7 +187,8 @@ class Grouped } } // save links and relations - if ($linksData['product_ids'] && $this->getBehavior() != \Magento\ImportExport\Model\Import::BEHAVIOR_APPEND) { + if ($linksData['product_ids'] && + $this->getBehavior() != \Magento\ImportExport\Model\Import::BEHAVIOR_APPEND) { $connection->delete( $mainTable, $connection->quoteInto( diff --git a/app/code/Magento/Sales/Model/Order/Pdf/Items/Creditmemo/Grouped.php b/app/code/Magento/GroupedProduct/Model/Order/Pdf/Items/Creditmemo/Grouped.php similarity index 86% rename from app/code/Magento/Sales/Model/Order/Pdf/Items/Creditmemo/Grouped.php rename to app/code/Magento/GroupedProduct/Model/Order/Pdf/Items/Creditmemo/Grouped.php index 18c27f968d3ff67a5747783bd167c576a648bee6..eb56a7c110a7b562a3b3575ed58481a9b1336b93 100644 --- a/app/code/Magento/Sales/Model/Order/Pdf/Items/Creditmemo/Grouped.php +++ b/app/code/Magento/GroupedProduct/Model/Order/Pdf/Items/Creditmemo/Grouped.php @@ -1,5 +1,7 @@ <?php /** + * Sales Order Creditmemo Pdf grouped items renderer + * * Magento * * NOTICE OF LICENSE @@ -18,20 +20,11 @@ * 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_Sales * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -/** - * Sales Order Creditmemo Pdf grouped items renderer - * - * @category Magento - * @package Magento_Sales - * @author Magento Core Team <core@magentocommerce.com> - */ -namespace Magento\Sales\Model\Order\Pdf\Items\Creditmemo; +namespace Magento\GroupedProduct\Model\Order\Pdf\Items\Creditmemo; class Grouped extends \Magento\Sales\Model\Order\Pdf\Items\Creditmemo\DefaultCreditmemo { diff --git a/app/code/Magento/Sales/Model/Order/Pdf/Items/Invoice/Grouped.php b/app/code/Magento/GroupedProduct/Model/Order/Pdf/Items/Invoice/Grouped.php similarity index 86% rename from app/code/Magento/Sales/Model/Order/Pdf/Items/Invoice/Grouped.php rename to app/code/Magento/GroupedProduct/Model/Order/Pdf/Items/Invoice/Grouped.php index c2cfef9ce0f364b1029169246d5b4713a4af554f..d866b65f2da2848a457be16019e43a1e85649dbb 100644 --- a/app/code/Magento/Sales/Model/Order/Pdf/Items/Invoice/Grouped.php +++ b/app/code/Magento/GroupedProduct/Model/Order/Pdf/Items/Invoice/Grouped.php @@ -1,5 +1,7 @@ <?php /** + * Sales Order Invoice Pdf grouped items renderer + * * Magento * * NOTICE OF LICENSE @@ -18,20 +20,11 @@ * 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_Sales * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -/** - * Sales Order Invoice Pdf grouped items renderer - * - * @category Magento - * @package Magento_Sales - * @author Magento Core Team <core@magentocommerce.com> - */ -namespace Magento\Sales\Model\Order\Pdf\Items\Invoice; +namespace Magento\GroupedProduct\Model\Order\Pdf\Items\Invoice; class Grouped extends \Magento\Sales\Model\Order\Pdf\Items\Invoice\DefaultInvoice { diff --git a/app/code/Magento/GroupedProduct/Model/Product/Cart/Configuration/Plugin/Grouped.php b/app/code/Magento/GroupedProduct/Model/Product/Cart/Configuration/Plugin/Grouped.php new file mode 100644 index 0000000000000000000000000000000000000000..986a14ac09ac65cfab6a9abbe8b2dd6a8871d156 --- /dev/null +++ b/app/code/Magento/GroupedProduct/Model/Product/Cart/Configuration/Plugin/Grouped.php @@ -0,0 +1,48 @@ +<?php +/** + * Plugin for cart product configuration + * + * 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\GroupedProduct\Model\Product\Cart\Configuration\Plugin; + +class Grouped +{ + /** + * Decide whether product has been configured for cart or not + * + * @param array $arguments + * @param \Magento\Code\Plugin\InvocationChain $invocationChain + * @return bool + */ + public function aroundIsProductConfigured(array $arguments, \Magento\Code\Plugin\InvocationChain $invocationChain) + { + list($product, $config) = $arguments; + + if ($product->getTypeId() == \Magento\GroupedProduct\Model\Product\Type\Grouped::TYPE_CODE) { + return isset($config['super_group']); + } + + return $invocationChain->proceed($arguments); + } +} diff --git a/app/code/Magento/GroupedProduct/Model/Product/CatalogPrice.php b/app/code/Magento/GroupedProduct/Model/Product/CatalogPrice.php new file mode 100644 index 0000000000000000000000000000000000000000..506f2c7275f18f746be5f126beafa6ea43a3bf44 --- /dev/null +++ b/app/code/Magento/GroupedProduct/Model/Product/CatalogPrice.php @@ -0,0 +1,102 @@ +<?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\GroupedProduct\Model\Product; + +/** + * Price model for external catalogs + */ +class CatalogPrice implements \Magento\Catalog\Model\Product\CatalogPriceInterface +{ + /** + * @var \Magento\Core\Model\StoreManagerInterface + */ + protected $storeManager; + + /** + * @var \Magento\Catalog\Model\Product\CatalogPrice + */ + protected $commonPriceModel; + + /** + * @param \Magento\Core\Model\StoreManagerInterface $storeManager + * @param \Magento\Catalog\Model\Product\CatalogPrice $commonPriceModel + */ + public function __construct( + \Magento\Core\Model\StoreManagerInterface $storeManager, + \Magento\Catalog\Model\Product\CatalogPrice $commonPriceModel + ) { + $this->storeManager = $storeManager; + $this->commonPriceModel = $commonPriceModel; + } + + /** + * Minimal price for "regular" user + * + * @param \Magento\Catalog\Model\Product $product + * @param null|\Magento\Core\Model\Store $store Store view + * @param bool $inclTax + * @return null|float + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + */ + public function getCatalogPrice(\Magento\Catalog\Model\Product $product, $store = null, $inclTax = false) + { + // Workaround to avoid loading stock status by admin's website + if ($store instanceof \Magento\Core\Model\Store) { + $oldStore = $this->storeManager->getStore(); + $this->storeManager->setCurrentStore($store); + } + $subProducts = $product->getTypeInstance()->getAssociatedProducts($product); + if ($store instanceof \Magento\Core\Model\Store) { + $this->storeManager->setCurrentStore($oldStore); + } + if (!count($subProducts)) { + return null; + } + $minPrice = null; + foreach ($subProducts as $subProduct) { + $subProduct->setWebsiteId($product->getWebsiteId()) + ->setCustomerGroupId($product->getCustomerGroupId()); + if ($subProduct->isSalable()) { + if ($this->commonPriceModel->getCatalogPrice($subProduct) < $minPrice || $minPrice === null) { + $minPrice = $this->commonPriceModel->getCatalogPrice($subProduct); + $product->setTaxClassId($subProduct->getTaxClassId()); + } + } + } + return $minPrice; + } + + /** + * Regular catalog price not applicable for grouped product + * + * @param \Magento\Catalog\Model\Product $product + * @return null + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + */ + public function getCatalogRegularPrice(\Magento\Catalog\Model\Product $product) + { + return null; + } +} \ No newline at end of file diff --git a/app/code/Magento/GroupedProduct/Model/Product/Type/Plugin.php b/app/code/Magento/GroupedProduct/Model/Product/Type/Plugin.php new file mode 100644 index 0000000000000000000000000000000000000000..6809c5fc3ec4a1afda8f1712b1d25b3f33931e1f --- /dev/null +++ b/app/code/Magento/GroupedProduct/Model/Product/Type/Plugin.php @@ -0,0 +1,58 @@ +<?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\GroupedProduct\Model\Product\Type; + +use Magento\Module\Manager; + +class Plugin +{ + /** + * @var \Magento\Module\Manager + */ + protected $moduleManager; + + /** + * @param Manager $moduleManager + */ + public function __construct(Manager $moduleManager) + { + $this->moduleManager = $moduleManager; + } + + /** + * Remove grouped product from list of visible product types + * + * @param string $result + * @return mixed + */ + public function afterGetOptionArray($result) + { + if (!$this->moduleManager->isOutputEnabled('Magento_GroupedProduct')) { + unset($result[\Magento\GroupedProduct\Model\Product\Type\Grouped::TYPE_CODE]); + } + return $result; + } +} diff --git a/app/code/Magento/CatalogInventory/Model/Resource/Indexer/Stock/Grouped.php b/app/code/Magento/GroupedProduct/Model/Resource/Indexer/Stock/Grouped.php similarity index 93% rename from app/code/Magento/CatalogInventory/Model/Resource/Indexer/Stock/Grouped.php rename to app/code/Magento/GroupedProduct/Model/Resource/Indexer/Stock/Grouped.php index a34dad9095d2040d96d59a919b001a998750cd58..3b6586d84a043034d34fcb8ad067b485e2ea231d 100644 --- a/app/code/Magento/CatalogInventory/Model/Resource/Indexer/Stock/Grouped.php +++ b/app/code/Magento/GroupedProduct/Model/Resource/Indexer/Stock/Grouped.php @@ -19,20 +19,20 @@ * needs please refer to http://www.magentocommerce.com for more information. * * @category Magento - * @package Magento_CatalogInventory + * @package Magento_GroupedProduct * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ /** - * CatalogInventory Grouped Products Stock Status Indexer Resource Model + * Grouped Products Stock Status Indexer Resource Model * * @category Magento - * @package Magento_CatalogInventory + * @package Magento_GroupedProduct * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\CatalogInventory\Model\Resource\Indexer\Stock; +namespace Magento\GroupedProduct\Model\Resource\Indexer\Stock; class Grouped extends \Magento\CatalogInventory\Model\Resource\Indexer\Stock\DefaultStock @@ -41,7 +41,7 @@ class Grouped * Reindex stock data for defined configurable product ids * * @param int|array $entityIds - * @return \Magento\CatalogInventory\Model\Resource\Indexer\Stock\Grouped + * @return \Magento\GroupedProduct\Model\Resource\Indexer\Stock\Grouped */ public function reindexEntity($entityIds) { diff --git a/app/code/Magento/GroupedProduct/Model/Resource/Product/Type/Grouped/AssociatedProductsCollection.php b/app/code/Magento/GroupedProduct/Model/Resource/Product/Type/Grouped/AssociatedProductsCollection.php index e6a4f07bba84abd35187ccfb840da3c214874669..e9a0ceaa3497b32562526e8543fbea8a918aa570 100644 --- a/app/code/Magento/GroupedProduct/Model/Resource/Product/Type/Grouped/AssociatedProductsCollection.php +++ b/app/code/Magento/GroupedProduct/Model/Resource/Product/Type/Grouped/AssociatedProductsCollection.php @@ -137,15 +137,12 @@ class AssociatedProductsCollection public function _initSelect() { parent::_initSelect(); - - $configData = $this->_config->getType('grouped'); - $allowProductTypes = isset($configData['allow_product_types']) ? $configData['allow_product_types'] : array(); $this->setProduct($this->_getProduct()) ->addAttributeToSelect('name') ->addAttributeToSelect('price') ->addAttributeToSelect('sku') ->addFilterByRequiredOptions() - ->addAttributeToFilter('type_id', $allowProductTypes); + ->addAttributeToFilter('type_id', $this->_config->getComposableTypes()); return $this; } diff --git a/app/code/Magento/GroupedProduct/Model/Sales/AdminOrder/Product/Quote/Plugin/Initializer.php b/app/code/Magento/GroupedProduct/Model/Sales/AdminOrder/Product/Quote/Plugin/Initializer.php new file mode 100644 index 0000000000000000000000000000000000000000..1b1138dc5027b2e1c013abd8204a25c39ccdc0cf --- /dev/null +++ b/app/code/Magento/GroupedProduct/Model/Sales/AdminOrder/Product/Quote/Plugin/Initializer.php @@ -0,0 +1,63 @@ +<?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) + */ + +/** + * Product quote initializer plugin + * + * @author Magento Core Team <core@magentocommerce.com> + * + */ +namespace Magento\GroupedProduct\Model\Sales\AdminOrder\Product\Quote\Plugin; + + +use Magento\GroupedProduct\Model\Product\Type\Grouped; + +class Initializer +{ + /** + * @param array $arguments + * @param \Magento\Code\Plugin\InvocationChain $invocationChain + * @return \Magento\Sales\Model\Quote\Item|string + */ + public function aroundInit(array $arguments, \Magento\Code\Plugin\InvocationChain $invocationChain) + { + /** @var \Magento\Sales\Model\Quote $quote */ + $quote = $arguments[0]; + /** @var \Magento\Catalog\Model\Product $product */ + $product = $arguments[1]; + /** @var \Magento\Object $config */ + $config = $arguments[2]; + + $item = $invocationChain->proceed($arguments); + + if (is_string($item) && $product->getTypeId() != Grouped::TYPE_CODE) { + $item = $quote->addProductAdvanced( + $product, + $config, + \Magento\Catalog\Model\Product\Type\AbstractType::PROCESS_MODE_LITE + ); + } + return $item; + } +} diff --git a/app/code/Magento/GroupedProduct/etc/adminhtml/di.xml b/app/code/Magento/GroupedProduct/etc/adminhtml/di.xml index 5ee459ff6b1fa778b1474279f7c08850075b2c58..c55b86bc6d9cfa7e60f21c5c719ad30eabb1f35e 100644 --- a/app/code/Magento/GroupedProduct/etc/adminhtml/di.xml +++ b/app/code/Magento/GroupedProduct/etc/adminhtml/di.xml @@ -28,11 +28,24 @@ <type name="Magento\Catalog\Controller\Adminhtml\Product\Initialization\Helper\ProductLinks"> <plugin name="GroupedProduct" type="Magento\GroupedProduct\Controller\Adminhtml\Product\Initialization\Helper\ProductLinks\Plugin\Grouped" /> </type> + <type name="Magento\Sales\Block\Adminhtml\Order\Create\Sidebar\AbstractSidebar"> + <plugin name="GroupedProduct" type="Magento\GroupedProduct\Block\Adminhtml\Order\Create\Sidebar" sortOrder="100"/> + </type> <type name="Magento\Catalog\Model\Product\CopyConstructor\Composite"> <param name="constructors"> - <value> - <grouped>Magento\GroupedProduct\Model\Product\CopyConstructor\Grouped</grouped> - </value> + <array> + <item key="grouped"><value>Magento\GroupedProduct\Model\Product\CopyConstructor\Grouped</value></item> + </array> + </param> + </type> + <type name="Magento\Sales\Model\AdminOrder\Product\Quote\Initializer"> + <plugin name="sales_adminorder_quote_initializer_plugin" type="Magento\GroupedProduct\Model\Sales\AdminOrder\Product\Quote\Plugin\Initializer" sortOrder="100"/> + </type> + <type name="Magento\CatalogInventory\Block\Adminhtml\Form\Field\Stock"> + <param name="complexProductTypes"> + <array> + <item key="grouped"><value type="const">Magento\GroupedProduct\Model\Product\Type\Grouped::TYPE_CODE</value></item> + </array> </param> </type> </config> diff --git a/app/code/Magento/GroupedProduct/etc/adminhtml/system.xml b/app/code/Magento/GroupedProduct/etc/adminhtml/system.xml new file mode 100644 index 0000000000000000000000000000000000000000..566fbee4857788419b9dead61eb8f980dbb503e3 --- /dev/null +++ b/app/code/Magento/GroupedProduct/etc/adminhtml/system.xml @@ -0,0 +1,37 @@ +<?xml version="1.0"?> +<!-- +/** + * 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) + */ +--> +<config> + <system> + <section id="checkout" translate="label" type="text" sortOrder="305" showInDefault="1" showInWebsite="1" showInStore="1"> + <group id="cart" translate="label" sortOrder="2" showInDefault="1" showInWebsite="1" showInStore="1"> + <field id="grouped_product_image" translate="label" type="select" sortOrder="3" showInDefault="1" showInWebsite="1" showInStore="1"> + <label>Grouped Product Image</label> + <source_model>Magento\Catalog\Model\Config\Source\Product\Thumbnail</source_model> + </field> + </group> + </section> + </system> +</config> diff --git a/app/code/Magento/GroupedProduct/etc/config.xml b/app/code/Magento/GroupedProduct/etc/config.xml new file mode 100644 index 0000000000000000000000000000000000000000..c63e0dfc55c5bdf1ce49f134332114c20ff898ca --- /dev/null +++ b/app/code/Magento/GroupedProduct/etc/config.xml @@ -0,0 +1,34 @@ +<?xml version="1.0"?> +<!-- +/** + * 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) + */ +--> +<config> + <default> + <checkout> + <cart> + <grouped_product_image>itself</grouped_product_image> + </cart> + </checkout> + </default> +</config> diff --git a/app/code/Magento/GroupedProduct/etc/di.xml b/app/code/Magento/GroupedProduct/etc/di.xml index 87eca94a6e5e37d3e445fd3f03bc3048e92880af..9d1b6014d6132ebd965f3f1bfcd9b7661f16b985 100644 --- a/app/code/Magento/GroupedProduct/etc/di.xml +++ b/app/code/Magento/GroupedProduct/etc/di.xml @@ -24,16 +24,47 @@ */ --> <config> - <type name="Magento\Catalog\Model\ProductTypes\Config\Converter"> - <plugin name="groupedProductType" type="Magento\GroupedProduct\Model\ProductTypes\Config\Converter\Plugin\Grouped" /> - </type> <type name="Magento\Module\Updater\SetupFactory"> <param name="resourceTypes"> - <value> - <groupedproduct_setup>Magento\Catalog\Model\Resource\Setup</groupedproduct_setup> - </value> + <array> + <item key="groupedproduct_setup"><value>Magento\Catalog\Model\Resource\Setup</value></item> + </array> + </param> + </type> + <type name="Magento\Sales\Model\Quote\Item\RelatedProducts"> + <param name="relatedProductTypes"> + <array> + <item key="grouped"><value type="const">\Magento\GroupedProduct\Model\Product\Type\Grouped::TYPE_CODE</value></item> + </array> </param> </type> + <type name="Magento\Catalog\Model\Product\LinkTypeProvider"> + <param name="linkTypes"> + <array> + <item key="associated"><value type="const">Magento\GroupedProduct\Model\Resource\Product\Link::LINK_TYPE_GROUPED</value></item> + </array> + </param> + </type> + <type name="Magento\Sales\Model\Resource\Report\Bestsellers"> + <param name="ignoredProductTypes"> + <array> + <item key="grouped"><value type="const">\Magento\GroupedProduct\Model\Product\Type\Grouped::TYPE_CODE</value></item> + </array> + </param> + </type> + <type name="Magento\Catalog\Model\Product\CatalogPrice"> + <param name="priceModelPool"> + <array> + <item key="grouped"><value>Magento\GroupedProduct\Model\Product\CatalogPrice</value></item> + </array> + </param> + </type> + <type name="Magento\Catalog\Model\Product\Type"> + <plugin name="grouped_output" type="Magento\GroupedProduct\Model\Product\Type\Plugin" /> + </type> + <type name="Magento\Catalog\Model\Product\CartConfiguration"> + <plugin name="isProductConfigured" type="Magento\GroupedProduct\Model\Product\Cart\Configuration\Plugin\Grouped" /> + </type> </config> diff --git a/app/code/Magento/PaypalUk/view/frontend/layout/catalog_product_compare_index.xml b/app/code/Magento/GroupedProduct/etc/export.xml similarity index 88% rename from app/code/Magento/PaypalUk/view/frontend/layout/catalog_product_compare_index.xml rename to app/code/Magento/GroupedProduct/etc/export.xml index 40668f6fc4bdb5a327cbd5c2ec348b2ef6af9d60..d1108514b25f494d0880268352d44a8988bd0356 100644 --- a/app/code/Magento/PaypalUk/view/frontend/layout/catalog_product_compare_index.xml +++ b/app/code/Magento/GroupedProduct/etc/export.xml @@ -23,6 +23,6 @@ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */ --> -<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> - <update handle="SHORTCUT_uk_popup"/> -</layout> +<config> + <productType name="grouped" model="Magento\GroupedProduct\Model\Export\Entity\Product\Type\Grouped" /> +</config> diff --git a/app/code/Magento/GroupedProduct/etc/frontend/di.xml b/app/code/Magento/GroupedProduct/etc/frontend/di.xml index 4e79f98ef09f7e027d4714c2c2fa50c71604b014..ff50a6003c66201840a8b800aa005b6c76738018 100644 --- a/app/code/Magento/GroupedProduct/etc/frontend/di.xml +++ b/app/code/Magento/GroupedProduct/etc/frontend/di.xml @@ -26,22 +26,26 @@ <config> <type name="Magento\Catalog\Block\Product\AbstractProduct"> <param name="priceBlockTypes"> - <value> - <grouped> - <block>Magento\Catalog\Block\Product\Price</block> - <template>Magento_GroupedProduct::product/price.phtml</template> - </grouped> - </value> + <array> + <item key="grouped"> + <array> + <item key="block"><value>Magento\Catalog\Block\Product\Price</value></item> + <item key="template"><value>Magento_GroupedProduct::product/price.phtml</value></item> + </array> + </item> + </array> </param> </type> <type name="Magento\Catalog\Block\Product\Price\Template"> <param name="priceBlockTypes"> - <value> - <grouped> - <block>Magento\Catalog\Block\Product\Price</block> - <template>Magento_GroupedProduct::product/price.phtml</template> - </grouped> - </value> + <array> + <item key="grouped"> + <array> + <item key="block"><value>Magento\Catalog\Block\Product\Price</value></item> + <item key="template"><value>Magento_GroupedProduct::product/price.phtml</value></item> + </array> + </item> + </array> </param> </type> </config> diff --git a/app/code/Magento/PaypalUk/view/frontend/layout/catalog_category_view.xml b/app/code/Magento/GroupedProduct/etc/import.xml similarity index 88% rename from app/code/Magento/PaypalUk/view/frontend/layout/catalog_category_view.xml rename to app/code/Magento/GroupedProduct/etc/import.xml index 40668f6fc4bdb5a327cbd5c2ec348b2ef6af9d60..b2b2ee88928c3e38c080cea09dfa680b4f554d40 100644 --- a/app/code/Magento/PaypalUk/view/frontend/layout/catalog_category_view.xml +++ b/app/code/Magento/GroupedProduct/etc/import.xml @@ -23,6 +23,6 @@ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */ --> -<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> - <update handle="SHORTCUT_uk_popup"/> -</layout> +<config> + <productType name="grouped" model="Magento\GroupedProduct\Model\Import\Entity\Product\Type\Grouped" /> +</config> diff --git a/app/code/Magento/GroupedProduct/etc/module.xml b/app/code/Magento/GroupedProduct/etc/module.xml index dc97cb059543f4a121cec6acfdbe69c9287840d6..a3f1b5f00c9d6108df75b745e44dee7374704dcd 100644 --- a/app/code/Magento/GroupedProduct/etc/module.xml +++ b/app/code/Magento/GroupedProduct/etc/module.xml @@ -28,9 +28,12 @@ <sequence> <module name="Magento_Catalog" /> <module name="Magento_CatalogInventory" /> + <module name="Magento_Sales" /> </sequence> <depends> <module name="Magento_Catalog" /> + <module name="Magento_CatalogInventory" /> + <module name="Magento_Sales" /> <module name="Magento_Core" /> <module name="Magento_Tax" /> <module name="Magento_Checkout" /> @@ -39,6 +42,7 @@ <module name="Magento_Eav" /> <module name="Magento_Customer" /> <module name="Magento_Theme" /> + <module name="Magento_ImportExport" /> </depends> </module> </config> diff --git a/app/code/Magento/PaypalUk/etc/config.xml b/app/code/Magento/GroupedProduct/etc/pdf.xml similarity index 72% rename from app/code/Magento/PaypalUk/etc/config.xml rename to app/code/Magento/GroupedProduct/etc/pdf.xml index bbccb18be2111964e69a91c1cd6ecaa9c6cf2f2a..9cea4c73c6985079cabdac16a3064772d9cc42e2 100644 --- a/app/code/Magento/PaypalUk/etc/config.xml +++ b/app/code/Magento/GroupedProduct/etc/pdf.xml @@ -19,21 +19,17 @@ * 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_PaypalUk * @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) */ --> <config> - <default> - <payment> - <paypaluk_express> - <model>Magento\PaypalUk\Model\Express</model> - </paypaluk_express> - <paypaluk_direct> - <model>Magento\PaypalUk\Model\Direct</model> - </paypaluk_direct> - </payment> - </default> + <renderers> + <page type="invoice"> + <renderer product_type="grouped">Magento\GroupedProduct\Model\Order\Pdf\Items\Invoice\Grouped</renderer> + </page> + <page type="creditmemo"> + <renderer product_type="grouped">Magento\GroupedProduct\Model\Order\Pdf\Items\Creditmemo\Grouped</renderer> + </page> + </renderers> </config> diff --git a/app/code/Magento/GroupedProduct/etc/product_types.xml b/app/code/Magento/GroupedProduct/etc/product_types.xml index b5620233e5c9bf0253016369e3df6dd370914ee8..997fd427cfc3b1cdbfc2a1c30499424b3f694fc1 100644 --- a/app/code/Magento/GroupedProduct/etc/product_types.xml +++ b/app/code/Magento/GroupedProduct/etc/product_types.xml @@ -27,10 +27,11 @@ <type name="grouped" label="Grouped Product" modelInstance="Magento\GroupedProduct\Model\Product\Type\Grouped" composite='true' indexPriority="50"> <priceModel instance="Magento\GroupedProduct\Model\Product\Type\Grouped\Price" /> <indexerModel instance="Magento\GroupedProduct\Model\Resource\Product\Indexer\Price\Grouped" /> - <stockIndexerModel instance="Magento\CatalogInventory\Model\Resource\Indexer\Stock\Grouped" /> - <allowProductTypes> - <type name="simple" /> - <type name="virtual" /> - </allowProductTypes> + <stockIndexerModel instance="Magento\GroupedProduct\Model\Resource\Indexer\Stock\Grouped" /> + <customAttributes> + <attribute name="is_real_product" value="false"/> + <attribute name="refundable" value="true"/> + <attribute name="is_product_set" value="true"/> + </customAttributes> </type> </config> diff --git a/app/code/Magento/PaypalUk/etc/frontend/page_types.xml b/app/code/Magento/GroupedProduct/etc/sales.xml similarity index 89% rename from app/code/Magento/PaypalUk/etc/frontend/page_types.xml rename to app/code/Magento/GroupedProduct/etc/sales.xml index cf479fa3f74fb0375db13d62785eb6003c277922..ee061e2962f1a27952a98b1f3da88ef908064803 100644 --- a/app/code/Magento/PaypalUk/etc/frontend/page_types.xml +++ b/app/code/Magento/GroupedProduct/etc/sales.xml @@ -23,6 +23,8 @@ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */ --> -<page_types> - <type id="paypaluk_express_review" label="PayPal Express Order Review Form"/> -</page_types> +<config> + <order> + <available_product_type name="grouped"/> + </order> +</config> diff --git a/app/code/Magento/GroupedProduct/i18n/de_DE.csv b/app/code/Magento/GroupedProduct/i18n/de_DE.csv index c7768a0a21dcb3b33de348a5ac5770c47dcdde57..42bd011f7b37606d0a63f836cf7340f2bbeb52a8 100644 --- a/app/code/Magento/GroupedProduct/i18n/de_DE.csv +++ b/app/code/Magento/GroupedProduct/i18n/de_DE.csv @@ -1,2 +1,4 @@ "Catalog Product View (Grouped)","Produktansicht des Katalogs (in Gruppen)" "Grouped Product","Gruppiertes Produkt" +"Grouped Product Image","Gruppiertes Produktbild" + diff --git a/app/code/Magento/GroupedProduct/i18n/en_US.csv b/app/code/Magento/GroupedProduct/i18n/en_US.csv index f0c636a3c8e7e71bba8b0692d9e8bcc2b934b048..f2f1873e0abd88cccbbe1d00264ca0e0ed58f825 100644 --- a/app/code/Magento/GroupedProduct/i18n/en_US.csv +++ b/app/code/Magento/GroupedProduct/i18n/en_US.csv @@ -1,2 +1,4 @@ "Catalog Product View (Grouped)","Catalog Product View (Grouped)" "Grouped Product","Grouped Product" +"Grouped Product Image","Grouped Product Image" + diff --git a/app/code/Magento/GroupedProduct/i18n/es_ES.csv b/app/code/Magento/GroupedProduct/i18n/es_ES.csv index 3ee3ba2a1f54cf3fb8842121d1da8c4f074016fe..7ca2042a10d79180899389664dbf85ae210890e1 100644 --- a/app/code/Magento/GroupedProduct/i18n/es_ES.csv +++ b/app/code/Magento/GroupedProduct/i18n/es_ES.csv @@ -1,2 +1,3 @@ "Catalog Product View (Grouped)","Vista del Catálogo de Producto (Agrupada)" "Grouped Product","Producto agrupado" +"Grouped Product Image","Imagen de productos agrupados" diff --git a/app/code/Magento/GroupedProduct/i18n/fr_FR.csv b/app/code/Magento/GroupedProduct/i18n/fr_FR.csv index b0d1941b9785fba6285845bc0b973f74e620fb2f..32a3ed558155cc5d651b2485a661a878490e1295 100644 --- a/app/code/Magento/GroupedProduct/i18n/fr_FR.csv +++ b/app/code/Magento/GroupedProduct/i18n/fr_FR.csv @@ -1,2 +1,4 @@ "Catalog Product View (Grouped)","Affichage du Produit Catalogue (Groupé)" "Grouped Product","Produits groupés" +"Grouped Product Image","Image groupée du produit" + diff --git a/app/code/Magento/GroupedProduct/i18n/nl_NL.csv b/app/code/Magento/GroupedProduct/i18n/nl_NL.csv index 410a26f0142121221217f58a5cfbdd1f4f360c0e..ddd7672f35d961b01316164f05dcce130205b8e2 100644 --- a/app/code/Magento/GroupedProduct/i18n/nl_NL.csv +++ b/app/code/Magento/GroupedProduct/i18n/nl_NL.csv @@ -1,2 +1,3 @@ "Catalog Product View (Grouped)","Catalogus Product Bezichtiging (Gegroepeerd)" "Grouped Product","Gegroepeerd Product" +"Grouped Product Image","Gegroepeerde productafbeelding" diff --git a/app/code/Magento/GroupedProduct/i18n/pt_BR.csv b/app/code/Magento/GroupedProduct/i18n/pt_BR.csv index d4585d81ed46dc07d8bed454462ea52aba050cc6..ff5786c4444b9373c99efbf63651bdaca834558f 100644 --- a/app/code/Magento/GroupedProduct/i18n/pt_BR.csv +++ b/app/code/Magento/GroupedProduct/i18n/pt_BR.csv @@ -1,2 +1,3 @@ "Catalog Product View (Grouped)","Visualizar Produto de Catálogo (Agrupado)" "Grouped Product","Produto Agrupado" +"Grouped Product Image","Imagem de Produto Agrupado" diff --git a/app/code/Magento/GroupedProduct/i18n/zh_CN.csv b/app/code/Magento/GroupedProduct/i18n/zh_CN.csv index 416c91d0186203eea2439a12708abcb26552e4c0..2c3135bb038d0dcafcf5c6a44a2d43043657e016 100644 --- a/app/code/Magento/GroupedProduct/i18n/zh_CN.csv +++ b/app/code/Magento/GroupedProduct/i18n/zh_CN.csv @@ -1,2 +1,4 @@ "Catalog Product View (Grouped)","分类产å“视图(分组)" "Grouped Product","分组产å“" +"Grouped Product Image","已分组的产å“图片" + diff --git a/app/code/Magento/GroupedProduct/view/adminhtml/layout/catalog_product_grouped.xml b/app/code/Magento/GroupedProduct/view/adminhtml/layout/catalog_product_grouped.xml index c3a2e591ba8291aacc1835ab9ad9a1ad1632962d..0d05a628194fc64f79e96fa403c91874101c21ad 100644 --- a/app/code/Magento/GroupedProduct/view/adminhtml/layout/catalog_product_grouped.xml +++ b/app/code/Magento/GroupedProduct/view/adminhtml/layout/catalog_product_grouped.xml @@ -35,8 +35,7 @@ <referenceBlock name="product_tabs"> <block class="Magento\GroupedProduct\Block\Product\Grouped\AssociatedProducts" name="catalog.product.edit.grouped.container" template="product/grouped/container.phtml"> <block class="Magento\View\Element\Template" name="catalog.product.edit.tab.super.container" template="Magento_GroupedProduct::product/grouped/grouped.phtml"> - <block class="Magento\GroupedProduct\Block\Product\Grouped\AssociatedProducts\ListAssociatedProducts" name="catalog.product.edit.tab.super.list" as="list" template="product/grouped/list.phtml"> - </block> + <block class="Magento\GroupedProduct\Block\Product\Grouped\AssociatedProducts\ListAssociatedProducts" name="catalog.product.edit.tab.super.list" as="list" template="product/grouped/list.phtml" /> <block class="Magento\View\Element\Template" name="catalog.product.edit.tab.super.grid.popup.container" as="catalog.product.group.grid.popup.container"/> </block> </block> diff --git a/app/code/Magento/Downloadable/view/frontend/layout/sales_guest_view.xml b/app/code/Magento/GroupedProduct/view/adminhtml/layout/sales_order_creditmemo_new.xml similarity index 85% rename from app/code/Magento/Downloadable/view/frontend/layout/sales_guest_view.xml rename to app/code/Magento/GroupedProduct/view/adminhtml/layout/sales_order_creditmemo_new.xml index f0dff79e197637fd3505a821954d8e66a78e9df9..c575d01b1d7de18d0fecc7f96fae2d253ef7f986 100644 --- a/app/code/Magento/Downloadable/view/frontend/layout/sales_guest_view.xml +++ b/app/code/Magento/GroupedProduct/view/adminhtml/layout/sales_order_creditmemo_new.xml @@ -25,6 +25,6 @@ --> <layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <referenceBlock name="order_items"> - <block class="Magento\Downloadable\Block\Sales\Order\Item\Renderer\Downloadable" as="downloadable" template="sales/order/items/renderer/downloadable.phtml"/> + <block class="Magento\GroupedProduct\Block\Adminhtml\Items\Column\Name\Grouped" name="column_name_grouped" template="Magento_Sales::items/column/name.phtml" group="column"/> </referenceBlock> </layout> diff --git a/app/code/Magento/GroupedProduct/view/adminhtml/layout/sales_order_creditmemo_updateqty.xml b/app/code/Magento/GroupedProduct/view/adminhtml/layout/sales_order_creditmemo_updateqty.xml new file mode 100644 index 0000000000000000000000000000000000000000..c575d01b1d7de18d0fecc7f96fae2d253ef7f986 --- /dev/null +++ b/app/code/Magento/GroupedProduct/view/adminhtml/layout/sales_order_creditmemo_updateqty.xml @@ -0,0 +1,30 @@ +<?xml version="1.0"?> +<!-- +/** + * 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) + */ +--> +<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <referenceBlock name="order_items"> + <block class="Magento\GroupedProduct\Block\Adminhtml\Items\Column\Name\Grouped" name="column_name_grouped" template="Magento_Sales::items/column/name.phtml" group="column"/> + </referenceBlock> +</layout> diff --git a/app/code/Magento/Bundle/view/frontend/layout/sales_order_creditmemo.xml b/app/code/Magento/GroupedProduct/view/adminhtml/layout/sales_order_creditmemo_view.xml similarity index 85% rename from app/code/Magento/Bundle/view/frontend/layout/sales_order_creditmemo.xml rename to app/code/Magento/GroupedProduct/view/adminhtml/layout/sales_order_creditmemo_view.xml index 0de2252d1d8d4f4f2dce88fb6faa775b3b2f8e99..4d96222ba99eccc2a625cf8ead07f854c4495397 100644 --- a/app/code/Magento/Bundle/view/frontend/layout/sales_order_creditmemo.xml +++ b/app/code/Magento/GroupedProduct/view/adminhtml/layout/sales_order_creditmemo_view.xml @@ -25,6 +25,6 @@ --> <layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <referenceBlock name="creditmemo_items"> - <block class="Magento\Bundle\Block\Sales\Order\Items\Renderer" as="bundle" template="sales/order/creditmemo/items/renderer.phtml"/> + <block class="Magento\GroupedProduct\Block\Adminhtml\Items\Column\Name\Grouped" name="column_name_grouped" template="Magento_Sales::items/column/name.phtml" group="column"/> </referenceBlock> </layout> diff --git a/app/code/Magento/GroupedProduct/view/adminhtml/layout/sales_order_invoice_new.xml b/app/code/Magento/GroupedProduct/view/adminhtml/layout/sales_order_invoice_new.xml new file mode 100644 index 0000000000000000000000000000000000000000..c575d01b1d7de18d0fecc7f96fae2d253ef7f986 --- /dev/null +++ b/app/code/Magento/GroupedProduct/view/adminhtml/layout/sales_order_invoice_new.xml @@ -0,0 +1,30 @@ +<?xml version="1.0"?> +<!-- +/** + * 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) + */ +--> +<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <referenceBlock name="order_items"> + <block class="Magento\GroupedProduct\Block\Adminhtml\Items\Column\Name\Grouped" name="column_name_grouped" template="Magento_Sales::items/column/name.phtml" group="column"/> + </referenceBlock> +</layout> diff --git a/app/code/Magento/GroupedProduct/view/adminhtml/layout/sales_order_invoice_updateqty.xml b/app/code/Magento/GroupedProduct/view/adminhtml/layout/sales_order_invoice_updateqty.xml new file mode 100644 index 0000000000000000000000000000000000000000..c575d01b1d7de18d0fecc7f96fae2d253ef7f986 --- /dev/null +++ b/app/code/Magento/GroupedProduct/view/adminhtml/layout/sales_order_invoice_updateqty.xml @@ -0,0 +1,30 @@ +<?xml version="1.0"?> +<!-- +/** + * 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) + */ +--> +<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <referenceBlock name="order_items"> + <block class="Magento\GroupedProduct\Block\Adminhtml\Items\Column\Name\Grouped" name="column_name_grouped" template="Magento_Sales::items/column/name.phtml" group="column"/> + </referenceBlock> +</layout> diff --git a/app/code/Magento/GroupedProduct/view/adminhtml/layout/sales_order_invoice_view.xml b/app/code/Magento/GroupedProduct/view/adminhtml/layout/sales_order_invoice_view.xml new file mode 100644 index 0000000000000000000000000000000000000000..14a9dc3e2f73eec97ec6ac4ce4222729fe623820 --- /dev/null +++ b/app/code/Magento/GroupedProduct/view/adminhtml/layout/sales_order_invoice_view.xml @@ -0,0 +1,30 @@ +<?xml version="1.0"?> +<!-- +/** + * 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) + */ +--> +<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> +<referenceBlock name="invoice_items"> + <block class="Magento\GroupedProduct\Block\Adminhtml\Items\Column\Name\Grouped" name="column_name_grouped" template="Magento_Sales::items/column/name.phtml" group="column"/> +</referenceBlock> +</layout> diff --git a/app/code/Magento/Bundle/view/frontend/layout/sales_order_view.xml b/app/code/Magento/GroupedProduct/view/adminhtml/layout/sales_order_view.xml similarity index 85% rename from app/code/Magento/Bundle/view/frontend/layout/sales_order_view.xml rename to app/code/Magento/GroupedProduct/view/adminhtml/layout/sales_order_view.xml index 22abd2c96402d60708556d98b67914009d476d7d..c575d01b1d7de18d0fecc7f96fae2d253ef7f986 100644 --- a/app/code/Magento/Bundle/view/frontend/layout/sales_order_view.xml +++ b/app/code/Magento/GroupedProduct/view/adminhtml/layout/sales_order_view.xml @@ -25,6 +25,6 @@ --> <layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <referenceBlock name="order_items"> - <block class="Magento\Bundle\Block\Sales\Order\Items\Renderer" as="bundle" template="sales/order/items/renderer.phtml"/> + <block class="Magento\GroupedProduct\Block\Adminhtml\Items\Column\Name\Grouped" name="column_name_grouped" template="Magento_Sales::items/column/name.phtml" group="column"/> </referenceBlock> </layout> diff --git a/app/code/Magento/Bundle/view/frontend/layout/paypaluk_express_review_details.xml b/app/code/Magento/GroupedProduct/view/frontend/layout/catalog_product_rss_feed_renderer_list.xml similarity index 83% rename from app/code/Magento/Bundle/view/frontend/layout/paypaluk_express_review_details.xml rename to app/code/Magento/GroupedProduct/view/frontend/layout/catalog_product_rss_feed_renderer_list.xml index 10b6e9f7103f56afa41ab9e3eac1085a74237514..1bd021a1f6cb9075db6f131c1295feb52e7f0deb 100644 --- a/app/code/Magento/Bundle/view/frontend/layout/paypaluk_express_review_details.xml +++ b/app/code/Magento/GroupedProduct/view/frontend/layout/catalog_product_rss_feed_renderer_list.xml @@ -24,7 +24,7 @@ */ --> <layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> - <referenceBlock name="order_review"> - <block class="Magento\Bundle\Block\Checkout\Cart\Item\Renderer" as="bundle" template="Magento_Checkout::onepage/review/item.phtml" cacheable="false"/> + <referenceBlock name="catalog.product.rss.feed.renderer.list"> + <block class="Magento\Catalog\Block\Product\Price" as="grouped" template="Magento_GroupedProduct::rss/product/price.phtml" /> </referenceBlock> </layout> diff --git a/app/code/Magento/GroupedProduct/view/frontend/layout/catalog_product_view_type_grouped.xml b/app/code/Magento/GroupedProduct/view/frontend/layout/catalog_product_view_type_grouped.xml index 1b3d0eb71b27788b8e0cb5e0a180db68aa9d8cdc..ad6d1683b7ec0ff6464fa0ff1ada68f0e97b1c2e 100644 --- a/app/code/Magento/GroupedProduct/view/frontend/layout/catalog_product_view_type_grouped.xml +++ b/app/code/Magento/GroupedProduct/view/frontend/layout/catalog_product_view_type_grouped.xml @@ -28,4 +28,7 @@ <block class="Magento\GroupedProduct\Block\Product\View\Type\Grouped" name="product.info.grouped" before="product.info.addtocart" template="product/view/type/grouped.phtml"/> <container name="product.info.grouped.extra" after="product.info.grouped" before="product.info.grouped" as="product_type_data_extra" label="Product Extra Info"/> </referenceContainer> + <referenceContainer name="product.info.grouped.extra"> + <block class="Magento\GroupedProduct\Block\Stockqty\Type\Grouped" template="Magento_CatalogInventory::stockqty/composite.phtml"/> + </referenceContainer> </layout> diff --git a/app/code/Magento/GroupedProduct/view/frontend/layout/checkout_cart_item_renderers.xml b/app/code/Magento/GroupedProduct/view/frontend/layout/checkout_cart_item_renderers.xml new file mode 100644 index 0000000000000000000000000000000000000000..f65500e24889d210ee08dd2f85c2ab0677d2cd2b --- /dev/null +++ b/app/code/Magento/GroupedProduct/view/frontend/layout/checkout_cart_item_renderers.xml @@ -0,0 +1,30 @@ +<?xml version="1.0"?> +<!-- +/** + * 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) + */ +--> +<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <referenceBlock name="checkout.cart.item.renderers"> + <block class="Magento\GroupedProduct\Block\Cart\Item\Renderer\Grouped" as="grouped" template="Magento_Checkout::cart/item/default.phtml" cacheable="false"/> + </referenceBlock> +</layout> diff --git a/app/code/Magento/GroupedProduct/view/frontend/layout/checkout_cart_sidebar_item_renderers.xml b/app/code/Magento/GroupedProduct/view/frontend/layout/checkout_cart_sidebar_item_renderers.xml new file mode 100644 index 0000000000000000000000000000000000000000..db5296ad4dbf89d0460cb9b326801577dee0e006 --- /dev/null +++ b/app/code/Magento/GroupedProduct/view/frontend/layout/checkout_cart_sidebar_item_renderers.xml @@ -0,0 +1,30 @@ +<?xml version="1.0"?> +<!-- +/** + * 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) + */ +--> +<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <referenceBlock name="checkout.cart.sidebar.item.renderers"> + <block class="Magento\GroupedProduct\Block\Cart\Item\Renderer\Grouped" as="grouped" template="Magento_Checkout::cart/sidebar/default.phtml" cacheable="false"/> + </referenceBlock> +</layout> diff --git a/app/code/Magento/GroupedProduct/view/frontend/layout/checkout_onepage_review_item_renderers.xml b/app/code/Magento/GroupedProduct/view/frontend/layout/checkout_onepage_review_item_renderers.xml new file mode 100644 index 0000000000000000000000000000000000000000..9a0eac833d50403a073c546f65a70a74c89669ae --- /dev/null +++ b/app/code/Magento/GroupedProduct/view/frontend/layout/checkout_onepage_review_item_renderers.xml @@ -0,0 +1,30 @@ +<?xml version="1.0"?> +<!-- +/** + * 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) + */ +--> +<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <referenceBlock name="checkout.onepage.review.item.renderers"> + <block class="Magento\GroupedProduct\Block\Cart\Item\Renderer\Grouped" as="grouped" template="Magento_Checkout::onepage/review/item.phtml" cacheable="false"/> + </referenceBlock> +</layout> diff --git a/app/code/Magento/GroupedProduct/view/frontend/layout/rss_catalog_category.xml b/app/code/Magento/GroupedProduct/view/frontend/layout/rss_catalog_category.xml deleted file mode 100644 index efd78c1b381cc4675e890ba5a95ef50e0f60f4d7..0000000000000000000000000000000000000000 --- a/app/code/Magento/GroupedProduct/view/frontend/layout/rss_catalog_category.xml +++ /dev/null @@ -1,34 +0,0 @@ -<?xml version="1.0"?> -<!-- -/** - * 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) - */ ---> -<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> - <referenceBlock name="rss.catalog.category"> - <action method="addPriceBlockType"> - <argument name="type" xsi:type="string">grouped</argument> - <argument name="block" xsi:type="string">Magento\Catalog\Block\Product\Price</argument> - <argument name="template" xsi:type="string">Magento_GroupedProduct::rss/product/price.phtml</argument> - </action> - </referenceBlock> -</layout> diff --git a/app/code/Magento/GroupedProduct/view/frontend/layout/rss_catalog_new.xml b/app/code/Magento/GroupedProduct/view/frontend/layout/rss_catalog_new.xml deleted file mode 100644 index 974fd752c71ab820091e19280fe057fbfe41a8c6..0000000000000000000000000000000000000000 --- a/app/code/Magento/GroupedProduct/view/frontend/layout/rss_catalog_new.xml +++ /dev/null @@ -1,34 +0,0 @@ -<?xml version="1.0"?> -<!-- -/** - * 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) - */ ---> -<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> - <referenceBlock name="rss.catalog.new"> - <action method="addPriceBlockType"> - <argument name="type" xsi:type="string">grouped</argument> - <argument name="block" xsi:type="string">Magento\Catalog\Block\Product\Price</argument> - <argument name="template" xsi:type="string">Magento_GroupedProduct::rss/product/price.phtml</argument> - </action> - </referenceBlock> -</layout> diff --git a/app/code/Magento/GroupedProduct/view/frontend/layout/sales_email_order_creditmemo_renderers.xml b/app/code/Magento/GroupedProduct/view/frontend/layout/sales_email_order_creditmemo_renderers.xml new file mode 100644 index 0000000000000000000000000000000000000000..449b29d3cf1bb7d9decfb6017686dbe6acd7b3a9 --- /dev/null +++ b/app/code/Magento/GroupedProduct/view/frontend/layout/sales_email_order_creditmemo_renderers.xml @@ -0,0 +1,30 @@ +<?xml version="1.0"?> +<!-- +/** + * 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) + */ +--> +<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" label="Email Creditmemo Items List" design_abstraction="custom"> + <referenceBlock name="sales.email.order.creditmemo.renderers"> + <block class="Magento\GroupedProduct\Block\Order\Email\Items\Order\Grouped" as="grouped" template="Magento_Sales::email/items/creditmemo/default.phtml"/> + </referenceBlock> +</layout> diff --git a/app/code/Magento/GroupedProduct/view/frontend/layout/sales_email_order_invoice_renderers.xml b/app/code/Magento/GroupedProduct/view/frontend/layout/sales_email_order_invoice_renderers.xml new file mode 100644 index 0000000000000000000000000000000000000000..0a47a69e55a1bde17f1078ba3e626136dcc7d58b --- /dev/null +++ b/app/code/Magento/GroupedProduct/view/frontend/layout/sales_email_order_invoice_renderers.xml @@ -0,0 +1,30 @@ +<?xml version="1.0"?> +<!-- +/** + * 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) + */ +--> +<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" label="Email Invoice Items List" design_abstraction="custom"> + <referenceBlock name="sales.email.order.invoice.renderers"> + <block class="Magento\GroupedProduct\Block\Order\Email\Items\Order\Grouped" as="grouped" template="Magento_Sales::email/items/invoice/default.phtml"/> + </referenceBlock> +</layout> diff --git a/app/code/Magento/GroupedProduct/view/frontend/layout/sales_email_order_renderers.xml b/app/code/Magento/GroupedProduct/view/frontend/layout/sales_email_order_renderers.xml new file mode 100644 index 0000000000000000000000000000000000000000..b11706f13972b7448ca87e32fe76bb0d4da31040 --- /dev/null +++ b/app/code/Magento/GroupedProduct/view/frontend/layout/sales_email_order_renderers.xml @@ -0,0 +1,30 @@ +<?xml version="1.0"?> +<!-- +/** + * 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) + */ +--> +<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" label="Email Order Items List" design_abstraction="custom"> + <block name="sales.email.order.renderers"> + <block class="Magento\GroupedProduct\Block\Order\Email\Items\Order\Grouped" as="grouped" template="Magento_Sales::email/items/order/default.phtml"/> + </block> +</layout> diff --git a/app/code/Magento/Downloadable/view/frontend/layout/sales_guest_invoice.xml b/app/code/Magento/GroupedProduct/view/frontend/layout/sales_guest_invoice.xml similarity index 82% rename from app/code/Magento/Downloadable/view/frontend/layout/sales_guest_invoice.xml rename to app/code/Magento/GroupedProduct/view/frontend/layout/sales_guest_invoice.xml index e5bee2ceebf058a7002ee269c3b809dfa2f26915..ad2791ef86dde61804f5008ab660bcba67c327bb 100644 --- a/app/code/Magento/Downloadable/view/frontend/layout/sales_guest_invoice.xml +++ b/app/code/Magento/GroupedProduct/view/frontend/layout/sales_guest_invoice.xml @@ -24,7 +24,7 @@ */ --> <layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> - <referenceBlock name="invoice_items"> - <block class="Magento\Downloadable\Block\Sales\Order\Item\Renderer\Downloadable" as="downloadable" template="sales/order/invoice/items/renderer/downloadable.phtml"/> + <referenceBlock name="sales.order.invoice.renderers"> + <block class="Magento\GroupedProduct\Block\Order\Item\Renderer\Grouped" as="grouped" template="Magento_Sales::order/invoice/items/renderer/default.phtml"/> </referenceBlock> </layout> diff --git a/app/code/Magento/CatalogInventory/view/frontend/layout/catalog_product_view_type_grouped.xml b/app/code/Magento/GroupedProduct/view/frontend/layout/sales_order_creditmemo_renderers.xml similarity index 84% rename from app/code/Magento/CatalogInventory/view/frontend/layout/catalog_product_view_type_grouped.xml rename to app/code/Magento/GroupedProduct/view/frontend/layout/sales_order_creditmemo_renderers.xml index 7466e2e754d793a9b489d733427aac99dd535509..aaabc0c6c863ce3567cafdef84cc988fd8bb7659 100644 --- a/app/code/Magento/CatalogInventory/view/frontend/layout/catalog_product_view_type_grouped.xml +++ b/app/code/Magento/GroupedProduct/view/frontend/layout/sales_order_creditmemo_renderers.xml @@ -24,7 +24,7 @@ */ --> <layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> - <referenceContainer name="product.info.grouped.extra"> - <block class="Magento\CatalogInventory\Block\Stockqty\Type\Grouped" template="stockqty/composite.phtml"/> - </referenceContainer> + <referenceBlock name="sales.order.creditmemo.renderers"> + <block class="Magento\GroupedProduct\Block\Order\Item\Renderer\Grouped" as="grouped" template="Magento_Sales::order/creditmemo/items/renderer/default.phtml"/> + </referenceBlock> </layout> diff --git a/app/code/Magento/GroupedProduct/view/frontend/layout/sales_order_invoice_renderers.xml b/app/code/Magento/GroupedProduct/view/frontend/layout/sales_order_invoice_renderers.xml new file mode 100644 index 0000000000000000000000000000000000000000..ad2791ef86dde61804f5008ab660bcba67c327bb --- /dev/null +++ b/app/code/Magento/GroupedProduct/view/frontend/layout/sales_order_invoice_renderers.xml @@ -0,0 +1,30 @@ +<?xml version="1.0"?> +<!-- +/** + * 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) + */ +--> +<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <referenceBlock name="sales.order.invoice.renderers"> + <block class="Magento\GroupedProduct\Block\Order\Item\Renderer\Grouped" as="grouped" template="Magento_Sales::order/invoice/items/renderer/default.phtml"/> + </referenceBlock> +</layout> diff --git a/app/code/Magento/GroupedProduct/view/frontend/layout/sales_order_item_renderers.xml b/app/code/Magento/GroupedProduct/view/frontend/layout/sales_order_item_renderers.xml new file mode 100644 index 0000000000000000000000000000000000000000..999c5574e19e6b7d35be20bcfb2da9fae794f36b --- /dev/null +++ b/app/code/Magento/GroupedProduct/view/frontend/layout/sales_order_item_renderers.xml @@ -0,0 +1,30 @@ +<?xml version="1.0"?> +<!-- +/** + * 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) + */ +--> +<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <referenceBlock name="sales.order.items.renderers"> + <block class="Magento\GroupedProduct\Block\Order\Item\Renderer\Grouped" as="grouped" template="Magento_Sales::order/items/renderer/default.phtml"/> + </referenceBlock> +</layout> diff --git a/app/code/Magento/GroupedProduct/view/frontend/layout/sales_order_print_creditmemo_renderers.xml b/app/code/Magento/GroupedProduct/view/frontend/layout/sales_order_print_creditmemo_renderers.xml new file mode 100644 index 0000000000000000000000000000000000000000..23da873001dbae5c505d59902011f1665facee89 --- /dev/null +++ b/app/code/Magento/GroupedProduct/view/frontend/layout/sales_order_print_creditmemo_renderers.xml @@ -0,0 +1,30 @@ +<?xml version="1.0"?> +<!-- +/** + * 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) + */ +--> +<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <referenceBlock name="sales.order.print.creditmemo.renderers"> + <block class="Magento\GroupedProduct\Block\Order\Item\Renderer\Grouped" as="grouped" template="Magento_Sales::order/creditmemo/items/renderer/default.phtml"/> + </referenceBlock> +</layout> diff --git a/app/code/Magento/GroupedProduct/view/frontend/layout/sales_order_print_invoice_renderers.xml b/app/code/Magento/GroupedProduct/view/frontend/layout/sales_order_print_invoice_renderers.xml new file mode 100644 index 0000000000000000000000000000000000000000..91c4de2cb88f8306246652004544731284494e03 --- /dev/null +++ b/app/code/Magento/GroupedProduct/view/frontend/layout/sales_order_print_invoice_renderers.xml @@ -0,0 +1,30 @@ +<?xml version="1.0"?> +<!-- +/** + * 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) + */ +--> +<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <referenceBlock name="checkout.order.print.invoice.renderers"> + <block class="Magento\GroupedProduct\Block\Order\Item\Renderer\Grouped" as="grouped" template="Magento_Sales::order/invoice/items/renderer/default.phtml"/> + </referenceBlock> +</layout> diff --git a/app/code/Magento/GroupedProduct/view/frontend/layout/sales_order_print_renderers.xml b/app/code/Magento/GroupedProduct/view/frontend/layout/sales_order_print_renderers.xml new file mode 100644 index 0000000000000000000000000000000000000000..bb89dbbf4dbf5b6f21a02ff17db4d09b044c99bf --- /dev/null +++ b/app/code/Magento/GroupedProduct/view/frontend/layout/sales_order_print_renderers.xml @@ -0,0 +1,30 @@ +<?xml version="1.0"?> +<!-- +/** + * 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) + */ +--> +<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <referenceBlock name="sales.order.print.renderers"> + <block class="Magento\GroupedProduct\Block\Order\Item\Renderer\Grouped" as="grouped" template="Magento_Sales::order/items/renderer/default.phtml"/> + </referenceBlock> +</layout> diff --git a/app/code/Magento/ImportExport/Block/Adminhtml/Export/Filter.php b/app/code/Magento/ImportExport/Block/Adminhtml/Export/Filter.php index 99b0080fb956d20e32f5f339792e29e83b9fbae7..45c3c075d5e827114e829c77b581ed81d7b49c0e 100644 --- a/app/code/Magento/ImportExport/Block/Adminhtml/Export/Filter.php +++ b/app/code/Magento/ImportExport/Block/Adminhtml/Export/Filter.php @@ -51,20 +51,18 @@ class Filter extends \Magento\Backend\Block\Widget\Grid\Extended /** * @param \Magento\Backend\Block\Template\Context $context - * @param \Magento\Core\Model\Url $urlModel * @param \Magento\Backend\Helper\Data $backendHelper * @param \Magento\ImportExport\Helper\Data $importExportData * @param array $data */ public function __construct( \Magento\Backend\Block\Template\Context $context, - \Magento\Core\Model\Url $urlModel, \Magento\Backend\Helper\Data $backendHelper, \Magento\ImportExport\Helper\Data $importExportData, array $data = array() ) { $this->_importExportData = $importExportData; - parent::__construct($context, $urlModel, $backendHelper, $data); + parent::__construct($context, $backendHelper, $data); } /** diff --git a/app/code/Magento/ImportExport/Model/Export/AbstractEntity.php b/app/code/Magento/ImportExport/Model/Export/AbstractEntity.php index 1f7cbf7cb180de74379cae2b31d095c093491a60..1df32a9cb7b62363c55098008f64da0700498094 100644 --- a/app/code/Magento/ImportExport/Model/Export/AbstractEntity.php +++ b/app/code/Magento/ImportExport/Model/Export/AbstractEntity.php @@ -48,16 +48,9 @@ abstract class AbstractEntity /**#@-*/ /** - * Website manager (currently \Magento\Core\Model\App works as website manager) + * Store manager * - * @var \Magento\Core\Model\App - */ - protected $_websiteManager; - - /** - * Store manager (currently \Magento\Core\Model\App works as store manager) - * - * @var \Magento\Core\Model\App + * @var \Magento\Core\Model\StoreManagerInterface */ protected $_storeManager; @@ -182,21 +175,20 @@ abstract class AbstractEntity /** * @param \Magento\Core\Model\Store\Config $coreStoreConfig - * @param \Magento\Core\Model\App $app + * @param \Magento\Core\Model\StoreManagerInterface $storeManager * @param \Magento\ImportExport\Model\Export\Factory $collectionFactory * @param \Magento\ImportExport\Model\Resource\CollectionByPagesIteratorFactory $resourceColFactory * @param array $data */ public function __construct( \Magento\Core\Model\Store\Config $coreStoreConfig, - \Magento\Core\Model\App $app, + \Magento\Core\Model\StoreManagerInterface $storeManager, \Magento\ImportExport\Model\Export\Factory $collectionFactory, \Magento\ImportExport\Model\Resource\CollectionByPagesIteratorFactory $resourceColFactory, array $data = array() ) { $this->_coreStoreConfig = $coreStoreConfig; - $this->_websiteManager = isset($data['website_manager']) ? $data['website_manager'] : $app; - $this->_storeManager = isset($data['store_manager']) ? $data['store_manager'] : $app; + $this->_storeManager = $storeManager; $this->_attributeCollection = isset($data['attribute_collection']) ? $data['attribute_collection'] : $collectionFactory->create(static::ATTRIBUTE_COLLECTION_NAME); $this->_pageSize = isset($data['page_size']) ? $data['page_size'] @@ -230,7 +222,7 @@ abstract class AbstractEntity protected function _initWebsites($withDefault = false) { /** @var $website \Magento\Core\Model\Website */ - foreach ($this->_websiteManager->getWebsites($withDefault) as $website) { + foreach ($this->_storeManager->getWebsites($withDefault) as $website) { $this->_websiteIdToCode[$website->getId()] = $website->getCode(); } return $this; diff --git a/app/code/Magento/ImportExport/Model/Export/Entity/AbstractEav.php b/app/code/Magento/ImportExport/Model/Export/Entity/AbstractEav.php index 766a5aabb8e770028e1d197b8f0f71532be69493..503a148518ea24a1aa556fd16193f722e5b4b41a 100644 --- a/app/code/Magento/ImportExport/Model/Export/Entity/AbstractEav.php +++ b/app/code/Magento/ImportExport/Model/Export/Entity/AbstractEav.php @@ -78,7 +78,7 @@ abstract class AbstractEav /** * @param \Magento\Core\Model\Store\Config $coreStoreConfig - * @param \Magento\Core\Model\App $app + * @param \Magento\Core\Model\StoreManagerInterface $storeManager * @param \Magento\ImportExport\Model\Export\Factory $collectionFactory * @param \Magento\ImportExport\Model\Resource\CollectionByPagesIteratorFactory $resourceColFactory * @param \Magento\Core\Model\LocaleInterface $locale @@ -87,7 +87,7 @@ abstract class AbstractEav */ public function __construct( \Magento\Core\Model\Store\Config $coreStoreConfig, - \Magento\Core\Model\App $app, + \Magento\Core\Model\StoreManagerInterface $storeManager, \Magento\ImportExport\Model\Export\Factory $collectionFactory, \Magento\ImportExport\Model\Resource\CollectionByPagesIteratorFactory $resourceColFactory, \Magento\Core\Model\LocaleInterface $locale, @@ -95,7 +95,7 @@ abstract class AbstractEav array $data = array() ) { $this->_locale = $locale; - parent::__construct($coreStoreConfig, $app, $collectionFactory, $resourceColFactory, $data); + parent::__construct($coreStoreConfig, $storeManager, $collectionFactory, $resourceColFactory, $data); if (isset($data['entity_type_id'])) { $this->_entityTypeId = $data['entity_type_id']; diff --git a/app/code/Magento/ImportExport/Model/Export/Entity/Eav/Customer.php b/app/code/Magento/ImportExport/Model/Export/Entity/Eav/Customer.php index eb81286855fe37fa682d79bf501f9f09f998080c..3741754b580371f76fecb22e1f892fc1f4ed8a6b 100644 --- a/app/code/Magento/ImportExport/Model/Export/Entity/Eav/Customer.php +++ b/app/code/Magento/ImportExport/Model/Export/Entity/Eav/Customer.php @@ -102,7 +102,7 @@ class Customer /** * @param \Magento\Core\Model\Store\Config $coreStoreConfig - * @param \Magento\Core\Model\App $app + * @param \Magento\Core\Model\StoreManagerInterface $storeManager * @param \Magento\ImportExport\Model\Export\Factory $collectionFactory * @param \Magento\ImportExport\Model\Resource\CollectionByPagesIteratorFactory $resourceColFactory * @param \Magento\Core\Model\LocaleInterface $locale @@ -112,7 +112,7 @@ class Customer */ public function __construct( \Magento\Core\Model\Store\Config $coreStoreConfig, - \Magento\Core\Model\App $app, + \Magento\Core\Model\StoreManagerInterface $storeManager, \Magento\ImportExport\Model\Export\Factory $collectionFactory, \Magento\ImportExport\Model\Resource\CollectionByPagesIteratorFactory $resourceColFactory, \Magento\Core\Model\LocaleInterface $locale, @@ -121,7 +121,7 @@ class Customer array $data = array() ) { parent::__construct( - $coreStoreConfig, $app, $collectionFactory, $resourceColFactory, $locale, $eavConfig, $data + $coreStoreConfig, $storeManager, $collectionFactory, $resourceColFactory, $locale, $eavConfig, $data ); $this->_customerCollection = isset($data['customer_collection']) ? $data['customer_collection'] diff --git a/app/code/Magento/ImportExport/Model/Export/Entity/Eav/Customer/Address.php b/app/code/Magento/ImportExport/Model/Export/Entity/Eav/Customer/Address.php index b33bf17c27e6c4ab2aa31124ce56f9476345b0d9..4123d5bdc3c737d4d0672b75b4f48b0084453328 100644 --- a/app/code/Magento/ImportExport/Model/Export/Entity/Eav/Customer/Address.php +++ b/app/code/Magento/ImportExport/Model/Export/Entity/Eav/Customer/Address.php @@ -123,7 +123,7 @@ class Address /** * @param \Magento\Core\Model\Store\Config $coreStoreConfig - * @param \Magento\Core\Model\App $app + * @param \Magento\Core\Model\StoreManagerInterface $storeManager * @param \Magento\ImportExport\Model\Export\Factory $collectionFactory * @param \Magento\ImportExport\Model\Resource\CollectionByPagesIteratorFactory $resourceColFactory * @param \Magento\Core\Model\LocaleInterface $locale @@ -135,7 +135,7 @@ class Address */ public function __construct( \Magento\Core\Model\Store\Config $coreStoreConfig, - \Magento\Core\Model\App $app, + \Magento\Core\Model\StoreManagerInterface $storeManager, \Magento\ImportExport\Model\Export\Factory $collectionFactory, \Magento\ImportExport\Model\Resource\CollectionByPagesIteratorFactory $resourceColFactory, \Magento\Core\Model\LocaleInterface $locale, @@ -145,8 +145,15 @@ class Address \Magento\Customer\Model\Resource\Address\CollectionFactory $addressColFactory, array $data = array() ) { - parent::__construct($coreStoreConfig, $app, $collectionFactory, $resourceColFactory, $locale, $eavConfig, - $data); + parent::__construct( + $coreStoreConfig, + $storeManager, + $collectionFactory, + $resourceColFactory, + $locale, + $eavConfig, + $data + ); $this->_customerCollection = isset($data['customer_collection']) ? $data['customer_collection'] : $customerColFactory->create(); diff --git a/app/code/Magento/ImportExport/Model/Export/Entity/Product.php b/app/code/Magento/ImportExport/Model/Export/Entity/Product.php index af6a748089c29aa25e9ec2ac26e51b24c16c84d5..faa47c20c42fd3973ba5013b0325e41a2b363d23 100644 --- a/app/code/Magento/ImportExport/Model/Export/Entity/Product.php +++ b/app/code/Magento/ImportExport/Model/Export/Entity/Product.php @@ -196,6 +196,13 @@ class Product extends \Magento\ImportExport\Model\Export\Entity\AbstractEntity */ protected $_typeFactory; + /** + * Provider of product link types + * + * @var \Magento\Catalog\Model\Product\LinkTypeProvider + */ + protected $_linkTypeProvider; + /** * @param \Magento\Core\Model\LocaleInterface $locale * @param \Magento\Eav\Model\Config $config @@ -211,6 +218,7 @@ class Product extends \Magento\ImportExport\Model\Export\Entity\AbstractEntity * @param \Magento\Catalog\Model\Resource\Product\Option\CollectionFactory $optionColFactory * @param \Magento\Catalog\Model\Resource\Product\Attribute\CollectionFactory $attributeColFactory * @param \Magento\ImportExport\Model\Export\Entity\Product\Type\Factory $_typeFactory + * @param \Magento\Catalog\Model\Product\LinkTypeProvider $linkTypeProvider */ public function __construct( \Magento\Core\Model\LocaleInterface $locale, @@ -226,7 +234,8 @@ class Product extends \Magento\ImportExport\Model\Export\Entity\AbstractEntity \Magento\CatalogInventory\Model\Resource\Stock\ItemFactory $itemFactory, \Magento\Catalog\Model\Resource\Product\Option\CollectionFactory $optionColFactory, \Magento\Catalog\Model\Resource\Product\Attribute\CollectionFactory $attributeColFactory, - \Magento\ImportExport\Model\Export\Entity\Product\Type\Factory $_typeFactory + \Magento\ImportExport\Model\Export\Entity\Product\Type\Factory $_typeFactory, + \Magento\Catalog\Model\Product\LinkTypeProvider $linkTypeProvider ) { $this->_entityCollection = $collection; $this->_exportConfig = $exportConfig; @@ -239,6 +248,8 @@ class Product extends \Magento\ImportExport\Model\Export\Entity\AbstractEntity $this->_optionColFactory = $optionColFactory; $this->_attributeColFactory = $attributeColFactory; $this->_typeFactory = $_typeFactory; + $this->_linkTypeProvider = $linkTypeProvider; + parent::__construct($locale, $config, $resource, $storeManager); @@ -523,12 +534,7 @@ class Product extends \Magento\ImportExport\Model\Export\Entity\AbstractEntity '(cplad.link_id = cpl.link_id AND cplad.product_link_attribute_id = cplaq.product_link_attribute_id)', array() ) - ->where('cpl.link_type_id IN (?)', array( - \Magento\Catalog\Model\Product\Link::LINK_TYPE_RELATED, - \Magento\Catalog\Model\Product\Link::LINK_TYPE_UPSELL, - \Magento\Catalog\Model\Product\Link::LINK_TYPE_CROSSSELL, - \Magento\GroupedProduct\Model\Resource\Product\Link::LINK_TYPE_GROUPED, - )) + ->where('cpl.link_type_id IN (?)', array_values($this->_linkTypeProvider->getLinkTypes())) ->where('cpl.product_id IN (?)', $productIds); $stmt = $adapter->query($select); @@ -821,12 +827,11 @@ class Product extends \Magento\ImportExport\Model\Export\Entity\AbstractEntity // prepare links information $linksRows = $this->_prepareLinks($productIds); - $linkIdColPrefix = array( - \Magento\Catalog\Model\Product\Link::LINK_TYPE_RELATED => '_links_related_', - \Magento\Catalog\Model\Product\Link::LINK_TYPE_UPSELL => '_links_upsell_', - \Magento\Catalog\Model\Product\Link::LINK_TYPE_CROSSSELL => '_links_crosssell_', - \Magento\GroupedProduct\Model\Resource\Product\Link::LINK_TYPE_GROUPED => '_associated_' - ); + $linkIdColPrefix = array(); + foreach ($this->_linkTypeProvider->getLinkTypes() as $linkTypeName => $linkTypeId) { + $linkIdColPrefix[$linkTypeId] = '_' . $linkTypeName . '_'; + } + $configurableProductsCollection = $this->_entityCollection; $configurableProductsCollection->addAttributeToFilter( 'entity_id', diff --git a/app/code/Magento/ImportExport/Model/Import.php b/app/code/Magento/ImportExport/Model/Import.php index 0d8dd9299f059932fe137f1fb327d7ae7f85f328..b021dade7e615cad91615dbe2ba9835335aae11d 100644 --- a/app/code/Magento/ImportExport/Model/Import.php +++ b/app/code/Magento/ImportExport/Model/Import.php @@ -142,7 +142,7 @@ class Import extends \Magento\ImportExport\Model\AbstractModel * @param \Magento\App\Filesystem $filesystem * @param \Magento\Core\Model\Log\AdapterFactory $adapterFactory * @param \Magento\ImportExport\Helper\Data $importExportData - * @param \Magento\Core\Model\Config $coreConfig + * @param \Magento\App\ConfigInterface $coreConfig * @param Import\ConfigInterface $importConfig * @param Import\Entity\Factory $entityFactory * @param Resource\Import\Data $importData @@ -158,7 +158,7 @@ class Import extends \Magento\ImportExport\Model\AbstractModel \Magento\App\Filesystem $filesystem, \Magento\Core\Model\Log\AdapterFactory $adapterFactory, \Magento\ImportExport\Helper\Data $importExportData, - \Magento\Core\Model\Config $coreConfig, + \Magento\App\ConfigInterface $coreConfig, \Magento\ImportExport\Model\Import\ConfigInterface $importConfig, \Magento\ImportExport\Model\Import\Entity\Factory $entityFactory, \Magento\ImportExport\Model\Resource\Import\Data $importData, diff --git a/app/code/Magento/ImportExport/Model/Import/Entity/AbstractEav.php b/app/code/Magento/ImportExport/Model/Import/Entity/AbstractEav.php index 03f70693467f62497df6434010b794447606b63f..5aa348c3386c93aa4e509a025645f0131faec630 100644 --- a/app/code/Magento/ImportExport/Model/Import/Entity/AbstractEav.php +++ b/app/code/Magento/ImportExport/Model/Import/Entity/AbstractEav.php @@ -38,16 +38,9 @@ abstract class AbstractEav const ATTRIBUTE_COLLECTION_NAME = 'Magento\Data\Collection'; /** - * Website manager (currently \Magento\Core\Model\App works as website manager) + * Store manager * - * @var \Magento\Core\Model\App - */ - protected $_websiteManager; - - /** - * Store manager (currently \Magento\Core\Model\App works as store manager) - * - * @var \Magento\Core\Model\App + * @var \Magento\Core\Model\StoreManagerInterface */ protected $_storeManager; @@ -107,7 +100,7 @@ abstract class AbstractEav * @param \Magento\ImportExport\Model\ImportFactory $importFactory * @param \Magento\ImportExport\Model\Resource\Helper $resourceHelper * @param \Magento\App\Resource $resource - * @param \Magento\Core\Model\App $app + * @param \Magento\Core\Model\StoreManagerInterface $storeManager * @param \Magento\ImportExport\Model\Export\Factory $collectionFactory * @param \Magento\Eav\Model\Config $eavConfig * @param array $data @@ -119,7 +112,7 @@ abstract class AbstractEav \Magento\ImportExport\Model\ImportFactory $importFactory, \Magento\ImportExport\Model\Resource\Helper $resourceHelper, \Magento\App\Resource $resource, - \Magento\Core\Model\App $app, + \Magento\Core\Model\StoreManagerInterface $storeManager, \Magento\ImportExport\Model\Export\Factory $collectionFactory, \Magento\Eav\Model\Config $eavConfig, array $data = array() @@ -128,8 +121,7 @@ abstract class AbstractEav $coreData, $string, $coreStoreConfig, $importFactory, $resourceHelper, $resource, $data ); - $this->_websiteManager = isset($data['website_manager']) ? $data['website_manager'] : $app; - $this->_storeManager = isset($data['store_manager']) ? $data['store_manager'] : $app; + $this->_storeManager = $storeManager; $this->_attributeCollection = isset($data['attribute_collection']) ? $data['attribute_collection'] : $collectionFactory->create(static::ATTRIBUTE_COLLECTION_NAME); @@ -164,7 +156,7 @@ abstract class AbstractEav protected function _initWebsites($withDefault = false) { /** @var $website \Magento\Core\Model\Website */ - foreach ($this->_websiteManager->getWebsites($withDefault) as $website) { + foreach ($this->_storeManager->getWebsites($withDefault) as $website) { $this->_websiteCodeToId[$website->getCode()] = $website->getId(); } return $this; diff --git a/app/code/Magento/ImportExport/Model/Import/Entity/Eav/AbstractCustomer.php b/app/code/Magento/ImportExport/Model/Import/Entity/Eav/AbstractCustomer.php index f9eeb40bd8c75cba56f9418859a450b67a8739fa..dd1a0524a87d2849d9eb97436311c69dde189b2f 100644 --- a/app/code/Magento/ImportExport/Model/Import/Entity/Eav/AbstractCustomer.php +++ b/app/code/Magento/ImportExport/Model/Import/Entity/Eav/AbstractCustomer.php @@ -80,7 +80,7 @@ abstract class AbstractCustomer extends \Magento\ImportExport\Model\Import\Entit * @param \Magento\ImportExport\Model\ImportFactory $importFactory * @param \Magento\ImportExport\Model\Resource\Helper $resourceHelper * @param \Magento\App\Resource $resource - * @param \Magento\Core\Model\App $app + * @param \Magento\Core\Model\StoreManagerInterface $storeManager * @param \Magento\ImportExport\Model\Export\Factory $collectionFactory * @param \Magento\Eav\Model\Config $eavConfig * @param \Magento\ImportExport\Model\Resource\Customer\StorageFactory $storageFactory @@ -93,7 +93,7 @@ abstract class AbstractCustomer extends \Magento\ImportExport\Model\Import\Entit \Magento\ImportExport\Model\ImportFactory $importFactory, \Magento\ImportExport\Model\Resource\Helper $resourceHelper, \Magento\App\Resource $resource, - \Magento\Core\Model\App $app, + \Magento\Core\Model\StoreManagerInterface $storeManager, \Magento\ImportExport\Model\Export\Factory $collectionFactory, \Magento\Eav\Model\Config $eavConfig, \Magento\ImportExport\Model\Resource\Customer\StorageFactory $storageFactory, @@ -101,7 +101,7 @@ abstract class AbstractCustomer extends \Magento\ImportExport\Model\Import\Entit ) { $this->_storageFactory = $storageFactory; parent::__construct( - $coreData, $string, $coreStoreConfig, $importFactory, $resourceHelper, $resource, $app, + $coreData, $string, $coreStoreConfig, $importFactory, $resourceHelper, $resource, $storeManager, $collectionFactory, $eavConfig, $data ); diff --git a/app/code/Magento/ImportExport/Model/Import/Entity/Eav/Customer.php b/app/code/Magento/ImportExport/Model/Import/Entity/Eav/Customer.php index 3f92f1f14fb7543e2e3962416dafcee59b621122..be33c954734743d40a1505d2163ed58d9bc86f8d 100644 --- a/app/code/Magento/ImportExport/Model/Import/Entity/Eav/Customer.php +++ b/app/code/Magento/ImportExport/Model/Import/Entity/Eav/Customer.php @@ -138,7 +138,7 @@ class Customer * @param \Magento\ImportExport\Model\ImportFactory $importFactory * @param \Magento\ImportExport\Model\Resource\Helper $resourceHelper * @param \Magento\App\Resource $resource - * @param \Magento\Core\Model\App $app + * @param \Magento\Core\Model\StoreManagerInterface $storeManager * @param \Magento\ImportExport\Model\Export\Factory $collectionFactory * @param \Magento\Eav\Model\Config $eavConfig * @param \Magento\ImportExport\Model\Resource\Customer\StorageFactory $storageFactory @@ -153,7 +153,7 @@ class Customer \Magento\ImportExport\Model\ImportFactory $importFactory, \Magento\ImportExport\Model\Resource\Helper $resourceHelper, \Magento\App\Resource $resource, - \Magento\Core\Model\App $app, + \Magento\Core\Model\StoreManagerInterface $storeManager, \Magento\ImportExport\Model\Export\Factory $collectionFactory, \Magento\Eav\Model\Config $eavConfig, \Magento\ImportExport\Model\Resource\Customer\StorageFactory $storageFactory, @@ -173,7 +173,7 @@ class Customer } parent::__construct($coreData, $string, $coreStoreConfig, $importFactory, $resourceHelper, $resource, - $app, $collectionFactory, $eavConfig, $storageFactory, $data); + $storeManager, $collectionFactory, $eavConfig, $storageFactory, $data); $this->_specialAttributes[] = self::COLUMN_WEBSITE; $this->_specialAttributes[] = self::COLUMN_STORE; diff --git a/app/code/Magento/ImportExport/Model/Import/Entity/Eav/Customer/Address.php b/app/code/Magento/ImportExport/Model/Import/Entity/Eav/Customer/Address.php index 4793c20d5360483a2504befdc35bf2b6c8d97a52..b454acc2ff43c1381e644ef0b7cd714b2222e46f 100644 --- a/app/code/Magento/ImportExport/Model/Import/Entity/Eav/Customer/Address.php +++ b/app/code/Magento/ImportExport/Model/Import/Entity/Eav/Customer/Address.php @@ -232,7 +232,7 @@ class Address * @param \Magento\ImportExport\Model\ImportFactory $importFactory * @param \Magento\ImportExport\Model\Resource\Helper $resourceHelper * @param \Magento\App\Resource $resource - * @param \Magento\Core\Model\App $app + * @param \Magento\Core\Model\StoreManagerInterface $storeManager * @param \Magento\ImportExport\Model\Export\Factory $collectionFactory * @param \Magento\Eav\Model\Config $eavConfig * @param \Magento\ImportExport\Model\Resource\Customer\StorageFactory $storageFactory @@ -251,7 +251,7 @@ class Address \Magento\ImportExport\Model\ImportFactory $importFactory, \Magento\ImportExport\Model\Resource\Helper $resourceHelper, \Magento\App\Resource $resource, - \Magento\Core\Model\App $app, + \Magento\Core\Model\StoreManagerInterface $storeManager, \Magento\ImportExport\Model\Export\Factory $collectionFactory, \Magento\Eav\Model\Config $eavConfig, \Magento\ImportExport\Model\Resource\Customer\StorageFactory $storageFactory, @@ -277,7 +277,7 @@ class Address $data['attribute_collection'] = $attributeCollection; } parent::__construct( - $coreData, $string, $coreStoreConfig, $importFactory, $resourceHelper, $resource, $app, + $coreData, $string, $coreStoreConfig, $importFactory, $resourceHelper, $resource, $storeManager, $collectionFactory, $eavConfig, $storageFactory, $data ); diff --git a/app/code/Magento/ImportExport/Model/Import/Entity/Product/Type/Configurable.php b/app/code/Magento/ImportExport/Model/Import/Entity/Product/Type/Configurable.php index 0c1f3f54c676cb8d1a17f0febeab0dd0f3740834..bb35aec1770e9e8e487ed5a0dca2782a08a4b1d4 100644 --- a/app/code/Magento/ImportExport/Model/Import/Entity/Product/Type/Configurable.php +++ b/app/code/Magento/ImportExport/Model/Import/Entity/Product/Type/Configurable.php @@ -271,11 +271,8 @@ class Configurable { if ($this->_superAttributes) { $attrSetIdToName = $this->_entityModel->getAttrSetIdToName(); - - $configData = $this->_productTypesConfig->getType('configurable'); - $allowProductTypes = isset($configData['allow_product_types']) ? $configData['allow_product_types'] : array(); foreach ($this->_productColFac->create() - ->addFieldToFilter('type_id', $allowProductTypes) + ->addFieldToFilter('type_id', $this->_productTypesConfig->getComposableTypes()) ->addAttributeToSelect(array_keys($this->_superAttributes)) as $product) { $attrSetName = $attrSetIdToName[$product->getAttributeSetId()]; diff --git a/app/code/Magento/ImportExport/etc/export.xml b/app/code/Magento/ImportExport/etc/export.xml index 4aea7426c9381e92aec112e970e44be5d0dd026e..e00dbe365669f852ca826f0f0c6d744da2101f0c 100644 --- a/app/code/Magento/ImportExport/etc/export.xml +++ b/app/code/Magento/ImportExport/etc/export.xml @@ -30,6 +30,5 @@ <productType name="simple" model="Magento\ImportExport\Model\Export\Entity\Product\Type\Simple" /> <productType name="configurable" model="Magento\ImportExport\Model\Export\Entity\Product\Type\Configurable" /> <productType name="virtual" model="Magento\ImportExport\Model\Export\Entity\Product\Type\Simple" /> - <productType name="grouped" model="Magento\ImportExport\Model\Export\Entity\Product\Type\Grouped" /> <fileFormat name="csv" label="CSV" model="Magento\ImportExport\Model\Export\Adapter\Csv" /> </config> diff --git a/app/code/Magento/ImportExport/etc/import.xml b/app/code/Magento/ImportExport/etc/import.xml index dfb3115da2825b8cd1774289a9d162bb49f2d0b2..5442215c39051fd0b7c201615f0a2b9a0d5f01b0 100644 --- a/app/code/Magento/ImportExport/etc/import.xml +++ b/app/code/Magento/ImportExport/etc/import.xml @@ -31,5 +31,4 @@ <productType name="simple" model="Magento\ImportExport\Model\Import\Entity\Product\Type\Simple" /> <productType name="configurable" model="Magento\ImportExport\Model\Import\Entity\Product\Type\Configurable" /> <productType name="virtual" model="Magento\ImportExport\Model\Import\Entity\Product\Type\Simple" /> - <productType name="grouped" model="Magento\ImportExport\Model\Import\Entity\Product\Type\Grouped" /> </config> diff --git a/app/code/Magento/ImportExport/etc/module.xml b/app/code/Magento/ImportExport/etc/module.xml index c5b14149ce874670c31de32e3e4b9e7b96e10b0e..b5bfb7199eb12ec517b7c6889f64dadd3c19fe4e 100755 --- a/app/code/Magento/ImportExport/etc/module.xml +++ b/app/code/Magento/ImportExport/etc/module.xml @@ -37,7 +37,6 @@ <module name="Magento_CatalogInventory"/> <module name="Magento_Customer"/> <module name="Magento_Directory"/> - <module name="Magento_GroupedProduct"/> </depends> </module> </config> diff --git a/app/code/Magento/Index/App/Indexer.php b/app/code/Magento/Index/App/Indexer.php index 5f9826cc567e837c9f6958053877852016286c42..04a6b75cc72dda952736f626aba3fee62bb8b8f4 100644 --- a/app/code/Magento/Index/App/Indexer.php +++ b/app/code/Magento/Index/App/Indexer.php @@ -26,9 +26,9 @@ namespace Magento\Index\App; use Magento\App\Console\Response; -use Magento\AppInterface; +use Magento\LauncherInterface; -class Indexer implements AppInterface +class Indexer implements LauncherInterface { /** * Report directory @@ -75,7 +75,7 @@ class Indexer implements AppInterface * * @return \Magento\App\ResponseInterface */ - public function execute() + public function launch() { /* Clean reports */ $directory = $this->_filesystem->getDirectoryWrite(\Magento\App\Filesystem::ROOT_DIR); diff --git a/app/code/Magento/Index/App/Shell.php b/app/code/Magento/Index/App/Shell.php index fc90a6021676eed50b37b8043870c1f2d595db71..173cbf3232d42fb9c5e6b96d7f8827b2c6641edb 100644 --- a/app/code/Magento/Index/App/Shell.php +++ b/app/code/Magento/Index/App/Shell.php @@ -26,9 +26,9 @@ namespace Magento\Index\App; use Magento\App\Console\Response; -use Magento\AppInterface; +use Magento\LauncherInterface; -class Shell implements AppInterface +class Shell implements LauncherInterface { /** * Filename of the entry point script @@ -67,7 +67,7 @@ class Shell implements AppInterface * * @return \Magento\App\ResponseInterface */ - public function execute() + public function launch() { /** @var $shell \Magento\Index\Model\Shell */ $shell = $this->_shellFactory->create(array('entryPoint' => $this->_entryFileName)); diff --git a/app/code/Magento/Index/App/Shell/ErrorHandler.php b/app/code/Magento/Index/App/Shell/ErrorHandler.php index 2d316d7c600ea4cc2e631e32e5a9e555fe89cbae..2813a8980bf3bdc308c8d23e8f2c078d193195e0 100644 --- a/app/code/Magento/Index/App/Shell/ErrorHandler.php +++ b/app/code/Magento/Index/App/Shell/ErrorHandler.php @@ -29,6 +29,7 @@ class ErrorHandler * Terminate execution of the script * * @param int|string $status + * @return void * @SuppressWarnings(PHPMD.ExitExpression) */ public function terminate($status) diff --git a/app/code/Magento/Index/Block/Adminhtml/Process/Edit/Form.php b/app/code/Magento/Index/Block/Adminhtml/Process/Edit/Form.php index ef6c2cac4898c6139041bc3facc7da51c4b91cf3..4027f6cbc6cf95fdfeaac877fe20b44104751073 100644 --- a/app/code/Magento/Index/Block/Adminhtml/Process/Edit/Form.php +++ b/app/code/Magento/Index/Block/Adminhtml/Process/Edit/Form.php @@ -26,8 +26,15 @@ namespace Magento\Index\Block\Adminhtml\Process\Edit; +use Magento\Backend\Block\Widget\Form as WidgetForm; + class Form extends \Magento\Backend\Block\Widget\Form\Generic { + /** + * Prepare form + * + * @return WidgetForm + */ protected function _prepareForm() { /** @var \Magento\Data\Form $form */ @@ -43,6 +50,11 @@ class Form extends \Magento\Backend\Block\Widget\Form\Generic return parent::_prepareForm(); } + /** + * Get action url + * + * @return string + */ public function getActionUrl() { return $this->getUrl('adminhtml/process/save'); diff --git a/app/code/Magento/Index/Block/Adminhtml/Process/Edit/Tab/Main.php b/app/code/Magento/Index/Block/Adminhtml/Process/Edit/Tab/Main.php index d0ad453ecbeb77c9d69aabd011b4d642ae3dde8b..607f8218230174e973b0f4dccc6deff259a1c057 100644 --- a/app/code/Magento/Index/Block/Adminhtml/Process/Edit/Tab/Main.php +++ b/app/code/Magento/Index/Block/Adminhtml/Process/Edit/Tab/Main.php @@ -26,10 +26,17 @@ namespace Magento\Index\Block\Adminhtml\Process\Edit\Tab; +use Magento\Backend\Block\Widget\Form; + class Main extends \Magento\Backend\Block\Widget\Form\Generic implements \Magento\Backend\Block\Widget\Tab\TabInterface { + /** + * Prepare form + * + * @return Form + */ protected function _prepareForm() { $model = $this->_coreRegistry->registry('current_index_process'); @@ -88,7 +95,7 @@ class Main } /** - * Returns status flag about this tab can be showen or not + * Returns status flag about this tab can be shown or not * * @return true */ @@ -100,7 +107,7 @@ class Main /** * Returns status flag about this tab hidden or not * - * @return true + * @return false */ public function isHidden() { @@ -111,7 +118,7 @@ class Main * Check permission for passed action * * @param string $action - * @return bool + * @return true */ protected function _isAllowedAction($action) { diff --git a/app/code/Magento/Index/Block/Adminhtml/Process/Grid.php b/app/code/Magento/Index/Block/Adminhtml/Process/Grid.php index 36c02d6cfba016dddd2b2d9d91fbe8de859d109b..8aafd141cb35126d2ad62e5068e94c5b9c41d231 100644 --- a/app/code/Magento/Index/Block/Adminhtml/Process/Grid.php +++ b/app/code/Magento/Index/Block/Adminhtml/Process/Grid.php @@ -56,7 +56,6 @@ class Grid extends \Magento\Backend\Block\Widget\Grid\Extended /** * @param \Magento\Backend\Block\Template\Context $context - * @param \Magento\Core\Model\Url $urlModel * @param \Magento\Backend\Helper\Data $backendHelper * @param \Magento\Index\Model\Resource\Process\CollectionFactory $factory * @param \Magento\Index\Model\Process $indexProcess @@ -65,14 +64,13 @@ class Grid extends \Magento\Backend\Block\Widget\Grid\Extended */ public function __construct( \Magento\Backend\Block\Template\Context $context, - \Magento\Core\Model\Url $urlModel, \Magento\Backend\Helper\Data $backendHelper, \Magento\Index\Model\Resource\Process\CollectionFactory $factory, \Magento\Index\Model\Process $indexProcess, \Magento\Index\Model\EventRepository $eventRepository, array $data = array() ) { - parent::__construct($context, $urlModel, $backendHelper, $data); + parent::__construct($context, $backendHelper, $data); $this->_eventRepository = $eventRepository; $this->_indexProcess = $indexProcess; $this->_collectionFactory = $factory; diff --git a/app/code/Magento/Index/Controller/Adminhtml/Process.php b/app/code/Magento/Index/Controller/Adminhtml/Process.php index fd9fc29e16be5a45b1009a5f6241bc5478bd1648..befa6f651b08f663ff13125ad5e8864e69597c19 100644 --- a/app/code/Magento/Index/Controller/Adminhtml/Process.php +++ b/app/code/Magento/Index/Controller/Adminhtml/Process.php @@ -84,6 +84,8 @@ class Process extends \Magento\Backend\App\Action /** * Display processes grid action + * + * @return void */ public function listAction() { @@ -97,6 +99,8 @@ class Process extends \Magento\Backend\App\Action /** * Process detail and edit action + * + * @return void */ public function editAction() { @@ -121,6 +125,8 @@ class Process extends \Magento\Backend\App\Action /** * Save process data + * + * @return void */ public function saveAction() { @@ -154,6 +160,8 @@ class Process extends \Magento\Backend\App\Action /** * Reindex all data what process is responsible + * + * @return void */ public function reindexProcessAction() { @@ -186,6 +194,8 @@ class Process extends \Magento\Backend\App\Action /** * Reindex pending events for index process + * + * @return void */ public function reindexEventsAction() { @@ -194,6 +204,8 @@ class Process extends \Magento\Backend\App\Action /** * Rebiuld all processes index + * + * @return void */ public function reindexAllAction() { @@ -203,6 +215,7 @@ class Process extends \Magento\Backend\App\Action /** * Mass rebuild selected processes index * + * @return void */ public function massReindexAction() { @@ -236,6 +249,7 @@ class Process extends \Magento\Backend\App\Action /** * Mass change index mode of selected processes index * + * @return void */ public function massChangeModeAction() { diff --git a/app/code/Magento/Index/Model/Event.php b/app/code/Magento/Index/Model/Event.php index 606494f9400e2a6089105f4181c05f83632b7a69..e68a2896415cd038eab61b60dcd93b8a949685b4 100644 --- a/app/code/Magento/Index/Model/Event.php +++ b/app/code/Magento/Index/Model/Event.php @@ -43,6 +43,8 @@ */ namespace Magento\Index\Model; +use Magento\Index\Model\Indexer; + class Event extends \Magento\Core\Model\AbstractModel { /** @@ -68,11 +70,13 @@ class Event extends \Magento\Core\Model\AbstractModel /** * Process object which currently working with event + * + * @var null|Process $process */ protected $_process = null; /** - * @var \Magento\Index\Model\Indexer + * @var Indexer */ protected $_indexer; @@ -84,7 +88,7 @@ class Event extends \Magento\Core\Model\AbstractModel /** * @param \Magento\Core\Model\Context $context * @param \Magento\Core\Model\Registry $registry - * @param \Magento\Index\Model\Indexer $indexer + * @param Indexer $indexer * @param \Magento\Stdlib\DateTime $dateTime * @param \Magento\Core\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection @@ -93,7 +97,7 @@ class Event extends \Magento\Core\Model\AbstractModel public function __construct( \Magento\Core\Model\Context $context, \Magento\Core\Model\Registry $registry, - \Magento\Index\Model\Indexer $indexer, + Indexer $indexer, \Magento\Stdlib\DateTime $dateTime, \Magento\Core\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, @@ -127,7 +131,7 @@ class Event extends \Magento\Core\Model\AbstractModel /** * Get related process object * - * @return \Magento\Index\Model\Process|null + * @return Process|null */ public function getProcess() { @@ -136,6 +140,9 @@ class Event extends \Magento\Core\Model\AbstractModel /** * Specify namespace for old and new data + * + * @param string $namespace + * @return $this */ public function setDataNamespace($namespace) { @@ -146,7 +153,7 @@ class Event extends \Magento\Core\Model\AbstractModel /** * Reset old and new data arrays * - * @return \Magento\Index\Model\Event + * @return $this */ public function resetData() { @@ -165,7 +172,7 @@ class Event extends \Magento\Core\Model\AbstractModel * * @param string|int $processId * @param string $status - * @return \Magento\Index\Model\Event + * @return $this */ public function addProcessId($processId, $status = \Magento\Index\Model\Process::EVENT_STATUS_NEW) { @@ -219,7 +226,7 @@ class Event extends \Magento\Core\Model\AbstractModel * Used for events duplicated protection * * @param array $data - * @return \Magento\Index\Model\Event + * @return $this */ public function mergePreviousData($data) { @@ -240,7 +247,7 @@ class Event extends \Magento\Core\Model\AbstractModel /** * Clean new data, unset data for done processes * - * @return \Magento\Index\Model\Event + * @return $this */ public function cleanNewData() { @@ -304,7 +311,7 @@ class Event extends \Magento\Core\Model\AbstractModel * @deprecated since 1.6.2.0 * @param array|string $key * @param null|mixed $value - * @return \Magento\Index\Model\Event + * @return $this */ public function addOldData($key, $value = null) { @@ -316,7 +323,7 @@ class Event extends \Magento\Core\Model\AbstractModel * * @param array|string $key * @param null|mixed $value - * @return \Magento\Index\Model\Event + * @return $this */ public function addNewData($key, $value = null) { @@ -361,7 +368,7 @@ class Event extends \Magento\Core\Model\AbstractModel /** * Serelaize old and new data arrays before saving * - * @return \Magento\Index\Model\Event + * @return $this */ protected function _beforeSave() { diff --git a/app/code/Magento/Index/Model/EventRepository.php b/app/code/Magento/Index/Model/EventRepository.php index 69f18312bdec9f1659e9adf8eaa8b8ace392f939..eae45771559302d004809da88581134740ae7c1f 100644 --- a/app/code/Magento/Index/Model/EventRepository.php +++ b/app/code/Magento/Index/Model/EventRepository.php @@ -23,6 +23,8 @@ */ namespace Magento\Index\Model; +use Magento\Index\Model\Resource\Event\Collection; + class EventRepository { /** @@ -43,7 +45,7 @@ class EventRepository /** * Check whether unprocessed events exist for provided process * - * @param int|array|\Magento\Index\Model\Process $process + * @param int|array|Process $process * @return bool */ public function hasUnprocessed($process) @@ -54,8 +56,8 @@ class EventRepository /** * Retrieve list of unprocessed events * - * @param int|array|\Magento\Index\Model\Process $process - * @return \Magento\Index\Model\Resource\Event\Collection + * @param int|array|Process $process + * @return Collection */ public function getUnprocessed($process) { diff --git a/app/code/Magento/Index/Model/Indexer.php b/app/code/Magento/Index/Model/Indexer.php index 7995a8b8233d4e2e497e3e436a7359b3f27216d6..37250560234a8e67851d3f366546d42ca2fa3399 100644 --- a/app/code/Magento/Index/Model/Indexer.php +++ b/app/code/Magento/Index/Model/Indexer.php @@ -29,6 +29,10 @@ */ namespace Magento\Index\Model; +use Magento\Event\ManagerInterface; +use Magento\Index\Model\Resource\Process as ResourceProcess; +use Magento\Index\Model\Resource\Process\Collection; + class Indexer { /** @@ -39,14 +43,14 @@ class Indexer protected $_processesCollection; /** - * @var \Magento\Index\Model\Resource\Process + * @var ResourceProcess */ protected $_resourceProcess; /** * Core event manager proxy * - * @var \Magento\Event\ManagerInterface + * @var ManagerInterface */ protected $_eventManager = null; @@ -62,14 +66,14 @@ class Indexer /** * @param \Magento\Index\Model\Resource\Process\CollectionFactory $collectionFactory - * @param \Magento\Index\Model\Resource\Process $resourceProcess - * @param \Magento\Event\ManagerInterface $eventManager + * @param ResourceProcess $resourceProcess + * @param ManagerInterface $eventManager * @param \Magento\Index\Model\EventFactory $indexEventFactory */ public function __construct( \Magento\Index\Model\Resource\Process\CollectionFactory $collectionFactory, - \Magento\Index\Model\Resource\Process $resourceProcess, - \Magento\Event\ManagerInterface $eventManager, + ResourceProcess $resourceProcess, + ManagerInterface $eventManager, \Magento\Index\Model\EventFactory $indexEventFactory ) { $this->_collectionFactory = $collectionFactory; @@ -102,7 +106,7 @@ class Indexer * Get index process by specific id * * @param int $processId - * @return \Magento\Index\Model\Process | false + * @return false|Process */ public function getProcessById($processId) { @@ -118,7 +122,7 @@ class Indexer * Get index process by specific code * * @param string $code - * @return \Magento\Index\Model\Process | false + * @return false|Process */ public function getProcessByCode($code) { @@ -134,10 +138,10 @@ class Indexer * Indexing all pending events. * Events set can be limited by event entity and type * - * @param null | string $entity - * @param null | string $type - * @return \Magento\Index\Model\Indexer - * @throws Exception + * @param null|string $entity + * @param null|string $type + * @return $this + * @throws \Exception */ public function indexEvents($entity=null, $type=null) { @@ -157,10 +161,10 @@ class Indexer /** * Index one event by all processes * - * @param \Magento\Index\Model\Event $event - * @return \Magento\Index\Model\Indexer + * @param Event $event + * @return $this */ - public function indexEvent(\Magento\Index\Model\Event $event) + public function indexEvent(Event $event) { $this->_runAll('safeProcessEvent', array($event)); return $this; @@ -169,10 +173,10 @@ class Indexer /** * Register event in each indexing process process * - * @param \Magento\Index\Model\Event $event + * @param Event $event * @return $this */ - public function registerEvent(\Magento\Index\Model\Event $event) + public function registerEvent(Event $event) { $this->_runAll('register', array($event)); return $this; @@ -185,7 +189,7 @@ class Indexer * @param string $entityType * @param string $eventType * @param bool $doSave - * @return \Magento\Index\Model\Event + * @return Event */ public function logEvent(\Magento\Object $entity, $entityType, $eventType, $doSave=true) { @@ -209,8 +213,8 @@ class Indexer * @param \Magento\Object $entity * @param string $entityType * @param string $eventType - * @return \Magento\Index\Model\Indexer - * @throws Exception + * @return $this + * @throws \Exception */ public function processEntityAction(\Magento\Object $entity, $entityType, $eventType) { @@ -236,6 +240,8 @@ class Indexer /** * Reindex all processes + * + * @return void */ public function reindexAll() { @@ -244,6 +250,8 @@ class Indexer /** * Reindex only processes that are invalidated + * + * @return void */ public function reindexRequired() { @@ -255,7 +263,8 @@ class Indexer /** * Sub-routine for iterating collection and reindexing all processes of specified collection * - * @param \Magento\Index\Model\Resource\Process\Collection $collection + * @param Collection $collection + * @return void */ private function _reindexCollection(\Magento\Index\Model\Resource\Process\Collection $collection) { @@ -272,7 +281,7 @@ class Indexer * * @param string $method * @param array $args - * @return \Magento\Index\Model\Indexer + * @return void */ protected function _runAll($method, $args) { diff --git a/app/code/Magento/Index/Model/Indexer/AbstractIndexer.php b/app/code/Magento/Index/Model/Indexer/AbstractIndexer.php index 29e01aaf9bda7ad844425b29d2a45d906d7dead3..d020ddeed95d4faa85e32aa740da9411aa170118 100644 --- a/app/code/Magento/Index/Model/Indexer/AbstractIndexer.php +++ b/app/code/Magento/Index/Model/Indexer/AbstractIndexer.php @@ -30,9 +30,15 @@ */ namespace Magento\Index\Model\Indexer; +use Magento\Index\Model\Event; +use Magento\Index\Model\IndexerInterface; + abstract class AbstractIndexer extends \Magento\Core\Model\AbstractModel - implements \Magento\Index\Model\IndexerInterface + implements IndexerInterface { + /** + * @var array + */ protected $_matchedEntities = array(); /** @@ -62,24 +68,26 @@ abstract class AbstractIndexer extends \Magento\Core\Model\AbstractModel /** * Register indexer required data inside event object * - * @param \Magento\Index\Model\Event $event + * @param Event $event + * @return void */ - abstract protected function _registerEvent(\Magento\Index\Model\Event $event); + abstract protected function _registerEvent(Event $event); /** * Process event based on event state data * - * @param \Magento\Index\Model\Event $event + * @param Event $event + * @return $this */ - abstract protected function _processEvent(\Magento\Index\Model\Event $event); + abstract protected function _processEvent(Event $event); /** * Register data required by process in event object * - * @param \Magento\Index\Model\Event $event - * @return \Magento\Index\Model\IndexerInterface + * @param Event $event + * @return IndexerInterface */ - public function register(\Magento\Index\Model\Event $event) + public function register(Event $event) { if ($this->matchEvent($event)) { $this->_registerEvent($event); @@ -90,10 +98,10 @@ abstract class AbstractIndexer extends \Magento\Core\Model\AbstractModel /** * Process event * - * @param \Magento\Index\Model\Event $event - * @return \Magento\Index\Model\Indexer\AbstractIndexer + * @param Event $event + * @return $this */ - public function processEvent(\Magento\Index\Model\Event $event) + public function processEvent(Event $event) { if ($this->matchEvent($event)) { $this->_processEvent($event); @@ -104,10 +112,10 @@ abstract class AbstractIndexer extends \Magento\Core\Model\AbstractModel /** * Check if event can be matched by process * - * @param \Magento\Index\Model\Event $event + * @param Event $event * @return bool */ - public function matchEvent(\Magento\Index\Model\Event $event) + public function matchEvent(Event $event) { $entity = $event->getEntity(); $type = $event->getType(); @@ -133,6 +141,8 @@ abstract class AbstractIndexer extends \Magento\Core\Model\AbstractModel /** * Rebuild all index data + * + * @return void */ public function reindexAll() { @@ -143,10 +153,10 @@ abstract class AbstractIndexer extends \Magento\Core\Model\AbstractModel * Try dynamicly detect and call event hanler from resource model. * Handler name will be generated from event entity and type code * - * @param \Magento\Index\Model\Event $event - * @return \Magento\Index\Model\Indexer\AbstractIndexer + * @param Event $event + * @return $this */ - public function callEventHandler(\Magento\Index\Model\Event $event) + public function callEventHandler(Event $event) { if ($event->getEntity()) { $method = $event->getEntity() . '_' . $event->getType(); diff --git a/app/code/Magento/Index/Model/Indexer/Config.php b/app/code/Magento/Index/Model/Indexer/Config.php index 445dacb0845cbf8aa6de3312f4b39ace8313199f..6b335d64facd3032358a4e9f6349fb9e4b594b37 100644 --- a/app/code/Magento/Index/Model/Indexer/Config.php +++ b/app/code/Magento/Index/Model/Indexer/Config.php @@ -31,7 +31,7 @@ class Config extends \Magento\Config\Data\Scoped /** * Scope priority loading scheme * - * @var array + * @var string[] */ protected $_scopePriorityScheme = array('global'); diff --git a/app/code/Magento/Index/Model/Lock/Storage.php b/app/code/Magento/Index/Model/Lock/Storage.php index e0e783d8c773df80788bc3affad81bcf731f9cb2..fd4d8f2298837f16f0d199ccb4b74bcb7de28e36 100644 --- a/app/code/Magento/Index/Model/Lock/Storage.php +++ b/app/code/Magento/Index/Model/Lock/Storage.php @@ -29,10 +29,15 @@ */ namespace Magento\Index\Model\Lock; +use Magento\Index\Model\Process\File; +use Magento\Index\Model\Process\FileFactory; +use Magento\App\Filesystem; +use Magento\Filesystem\Directory\WriteInterface; + class Storage { /** - * @var \Magento\Index\Model\Process\FileFactory + * @var FileFactory */ protected $_fileFactory; @@ -46,27 +51,27 @@ class Storage /** * Directory instance * - * @var \Magento\Filesystem\Directory\WriteInterface + * @var WriteInterface */ protected $_varDirectory; /** - * @param \Magento\Index\Model\Process\FileFactory $fileFactory - * @param \Magento\App\Filesystem $filesystem + * @param FileFactory $fileFactory + * @param Filesystem $filesystem */ public function __construct( - \Magento\Index\Model\Process\FileFactory $fileFactory, - \Magento\App\Filesystem $filesystem + FileFactory $fileFactory, + Filesystem $filesystem ) { $this->_fileFactory = $fileFactory; - $this->_varDirectory = $filesystem->getDirectoryWrite(\Magento\App\Filesystem::VAR_DIR); + $this->_varDirectory = $filesystem->getDirectoryWrite(Filesystem::VAR_DIR); } /** * Get file handler by process ID * - * @param $processId - * @return \Magento\Index\Model\Process\File + * @param string $processId + * @return File */ public function getFile($processId) { diff --git a/app/code/Magento/Index/Model/Observer.php b/app/code/Magento/Index/Model/Observer.php index e2eca751f1b0c5340d207848321288eb9955a9c5..50336598d4b46e4aa5ef9d62011c82a0c5885291 100644 --- a/app/code/Magento/Index/Model/Observer.php +++ b/app/code/Magento/Index/Model/Observer.php @@ -26,6 +26,8 @@ namespace Magento\Index\Model; +use Magento\Event\Observer as EventObserver; + class Observer { /** @@ -47,9 +49,10 @@ class Observer /** * Store after commit observer. Process store related indexes * - * @param \Magento\Event\Observer $observer + * @param EventObserver $observer + * @return void */ - public function processStoreSave(\Magento\Event\Observer $observer) + public function processStoreSave(EventObserver $observer) { $store = $observer->getEvent()->getStore(); $this->_indexer->processEntityAction( @@ -62,9 +65,10 @@ class Observer /** * Store group after commit observer. Process store group related indexes * - * @param \Magento\Event\Observer $observer + * @param EventObserver $observer + * @return void */ - public function processStoreGroupSave(\Magento\Event\Observer $observer) + public function processStoreGroupSave(EventObserver $observer) { $storeGroup = $observer->getEvent()->getStoreGroup(); $this->_indexer->processEntityAction( @@ -77,9 +81,10 @@ class Observer /** * Website save after commit observer. Process website related indexes * - * @param \Magento\Event\Observer $observer + * @param EventObserver $observer + * @return void */ - public function processWebsiteSave(\Magento\Event\Observer $observer) + public function processWebsiteSave(EventObserver $observer) { $website = $observer->getEvent()->getWebsite(); $this->_indexer->processEntityAction( @@ -92,9 +97,10 @@ class Observer /** * Store after commit observer. Process store related indexes * - * @param \Magento\Event\Observer $observer + * @param EventObserver $observer + * @return void */ - public function processStoreDelete(\Magento\Event\Observer $observer) + public function processStoreDelete(EventObserver $observer) { $store = $observer->getEvent()->getStore(); $this->_indexer->processEntityAction( @@ -107,9 +113,10 @@ class Observer /** * Store group after commit observer. Process store group related indexes * - * @param \Magento\Event\Observer $observer + * @param EventObserver $observer + * @return void */ - public function processStoreGroupDelete(\Magento\Event\Observer $observer) + public function processStoreGroupDelete(EventObserver $observer) { $storeGroup = $observer->getEvent()->getStoreGroup(); $this->_indexer->processEntityAction( @@ -122,9 +129,10 @@ class Observer /** * Website save after commit observer. Process website related indexes * - * @param \Magento\Event\Observer $observer + * @param EventObserver $observer + * @return void */ - public function processWebsiteDelete(\Magento\Event\Observer $observer) + public function processWebsiteDelete(EventObserver $observer) { $website = $observer->getEvent()->getWebsite(); $this->_indexer->processEntityAction( @@ -137,14 +145,15 @@ class Observer /** * Config data after commit observer. * - * @param \Magento\Event\Observer $observer + * @param EventObserver $observer + * @return void */ - public function processConfigDataSave(\Magento\Event\Observer $observer) + public function processConfigDataSave(EventObserver $observer) { $configData = $observer->getEvent()->getConfigData(); $this->_indexer->processEntityAction( $configData, - \Magento\Core\Model\Config\Value::ENTITY, + \Magento\App\Config\ValueInterface::ENTITY, \Magento\Index\Model\Event::TYPE_SAVE ); } diff --git a/app/code/Magento/Index/Model/Process.php b/app/code/Magento/Index/Model/Process.php index d6c62d50dd6bfc90bf48fdb941a4d4fb27d0b585..98c0fddae5295c3432f4e11f005868558f727bfd 100644 --- a/app/code/Magento/Index/Model/Process.php +++ b/app/code/Magento/Index/Model/Process.php @@ -44,6 +44,8 @@ */ namespace Magento\Index\Model; +use Magento\Index\Model\Resource\Event\Collection; + class Process extends \Magento\Core\Model\AbstractModel { /** @@ -162,8 +164,8 @@ class Process extends \Magento\Core\Model\AbstractModel /** * Set indexer class name as data namespace for event object * - * @param \Magento\Index\Model\Event $event - * @return \Magento\Index\Model\Process + * @param Event $event + * @return $this */ protected function _setEventNamespace(\Magento\Index\Model\Event $event) { @@ -176,8 +178,8 @@ class Process extends \Magento\Core\Model\AbstractModel /** * Remove indexer namespace from event * - * @param \Magento\Index\Model\Event $event - * @return \Magento\Index\Model\Process + * @param Event $event + * @return $this */ protected function _resetEventNamespace($event) { @@ -189,8 +191,8 @@ class Process extends \Magento\Core\Model\AbstractModel /** * Register data required by process in event object * - * @param \Magento\Index\Model\Event $event - * @return \Magento\Index\Model\Process + * @param Event $event + * @return $this */ public function register(\Magento\Index\Model\Event $event) { @@ -236,6 +238,7 @@ class Process extends \Magento\Core\Model\AbstractModel /** * Reindex all data what this process responsible is * + * @return void * @throws \Magento\Core\Exception * @throws \Exception */ @@ -289,7 +292,7 @@ class Process extends \Magento\Core\Model\AbstractModel * Reindex all data what this process responsible is * Check and using depends processes * - * @return \Magento\Index\Model\Process + * @return $this|void */ public function reindexEverything() { @@ -317,10 +320,10 @@ class Process extends \Magento\Core\Model\AbstractModel /** * Process event with assigned indexer object * - * @param \Magento\Index\Model\Event $event - * @return \Magento\Index\Model\Process + * @param Event $event + * @return $this */ - public function processEvent(\Magento\Index\Model\Event $event) + public function processEvent(Event $event) { if (!$this->matchEvent($event)) { return $this; @@ -382,7 +385,7 @@ class Process extends \Magento\Core\Model\AbstractModel * * @param null|string $entity * @param null|string $type - * @return \Magento\Index\Model\Process + * @return $this * @throws \Exception */ public function indexEvents($entity = null, $type = null) @@ -429,12 +432,12 @@ class Process extends \Magento\Core\Model\AbstractModel /** * Process all events of the collection * - * @param \Magento\Index\Model\Resource\Event\Collection $eventsCollection + * @param Collection $eventsCollection * @param bool $skipUnmatched - * @return \Magento\Index\Model\Process + * @return $this */ protected function _processEventsCollection( - \Magento\Index\Model\Resource\Event\Collection $eventsCollection, + Collection $eventsCollection, $skipUnmatched = true ) { // We can't reload the collection because of transaction @@ -459,11 +462,11 @@ class Process extends \Magento\Core\Model\AbstractModel /** * Update status process/event association * - * @param \Magento\Index\Model\Event $event + * @param Event $event * @param string $status - * @return \Magento\Index\Model\Process + * @return $this */ - public function updateEventStatus(\Magento\Index\Model\Event $event, $status) + public function updateEventStatus(Event $event, $status) { $this->_getResource()->updateEventStatus($this->getId(), $event->getId(), $status); return $this; @@ -486,7 +489,7 @@ class Process extends \Magento\Core\Model\AbstractModel * Lock process without blocking. * This method allow protect multiple process running and fast lock validation. * - * @return \Magento\Index\Model\Process + * @return $this */ public function lock() { @@ -499,7 +502,7 @@ class Process extends \Magento\Core\Model\AbstractModel * If new instance of the process will try validate locking state * script will wait until process will be unlocked * - * @return \Magento\Index\Model\Process + * @return $this */ public function lockAndBlock() { @@ -510,7 +513,7 @@ class Process extends \Magento\Core\Model\AbstractModel /** * Unlock process * - * @return \Magento\Index\Model\Process + * @return $this */ public function unlock() { @@ -533,7 +536,7 @@ class Process extends \Magento\Core\Model\AbstractModel * Change process status * * @param string $status - * @return \Magento\Index\Model\Process + * @return $this */ public function changeStatus($status) { @@ -611,8 +614,8 @@ class Process extends \Magento\Core\Model\AbstractModel /** * Process event with locks checking * - * @param \Magento\Index\Model\Event $event - * @return \Magento\Index\Model\Process + * @param Event $event + * @return $this * @throws \Exception */ public function safeProcessEvent(\Magento\Index\Model\Event $event) diff --git a/app/code/Magento/Index/Model/Resource/AbstractResource.php b/app/code/Magento/Index/Model/Resource/AbstractResource.php index 0fd148673c178518851fec80803c4fff0e967127..ed4ba883b9a4301f45db1f7ab05512d23fd95513 100644 --- a/app/code/Magento/Index/Model/Resource/AbstractResource.php +++ b/app/code/Magento/Index/Model/Resource/AbstractResource.php @@ -33,6 +33,9 @@ */ namespace Magento\Index\Model\Resource; +use Magento\DB\Adapter\AdapterInterface; +use Magento\DB\Select; + abstract class AbstractResource extends \Magento\Core\Model\Resource\Db\AbstractDb { const IDX_SUFFIX= '_idx'; @@ -48,7 +51,7 @@ abstract class AbstractResource extends \Magento\Core\Model\Resource\Db\Abstract /** * Reindex all * - * @return \Magento\Index\Model\Resource\AbstractResource + * @return $this */ public function reindexAll() { @@ -59,7 +62,7 @@ abstract class AbstractResource extends \Magento\Core\Model\Resource\Db\Abstract /** * Get DB adapter for index data processing * - * @return \Magento\DB\Adapter\AdapterInterface + * @return AdapterInterface */ protected function _getIndexAdapter() { @@ -87,7 +90,7 @@ abstract class AbstractResource extends \Magento\Core\Model\Resource\Db\Abstract /** * Synchronize data between index storage and original storage * - * @return \Magento\Index\Model\Resource\AbstractResource + * @return $this */ public function syncData() { @@ -112,7 +115,7 @@ abstract class AbstractResource extends \Magento\Core\Model\Resource\Db\Abstract * @param string $sourceTable * @param string $destTable * @param bool $readToIndex data migration direction (true - read=>index, false - index=>read) - * @return \Magento\Index\Model\Resource\AbstractResource + * @return $this */ public function insertFromTable($sourceTable, $destTable, $readToIndex = true) { @@ -133,11 +136,11 @@ abstract class AbstractResource extends \Magento\Core\Model\Resource\Db\Abstract * Insert data from select statement of read adapter to * destination table related with index adapter * - * @param \Magento\DB\Select $select + * @param Select $select * @param string $destTable * @param array $columns * @param bool $readToIndex data migration direction (true - read=>index, false - index=>read) - * @return \Magento\Index\Model\Resource\AbstractResource + * @return $this */ public function insertFromSelect($select, $destTable, array $columns, $readToIndex = true) { @@ -190,6 +193,7 @@ abstract class AbstractResource extends \Magento\Core\Model\Resource\Db\Abstract /** * Clean up temporary index table * + * @return void */ public function clearTemporaryIndexTable() { diff --git a/app/code/Magento/Index/Model/Resource/Event.php b/app/code/Magento/Index/Model/Resource/Event.php index 85b880db3f11d825ee675f16dc3a00fe07c2fb7f..9c5283b33d5399577e18edd1ff3fcbbccabfbbde 100644 --- a/app/code/Magento/Index/Model/Resource/Event.php +++ b/app/code/Magento/Index/Model/Resource/Event.php @@ -34,6 +34,9 @@ */ namespace Magento\Index\Model\Resource; +use Magento\Core\Model\AbstractModel; +use Magento\Index\Model\Process as ProcessModel; + class Event extends \Magento\Core\Model\Resource\Db\AbstractDb { protected function _construct() @@ -44,10 +47,10 @@ class Event extends \Magento\Core\Model\Resource\Db\AbstractDb /** * Check if semilar event exist before start saving data * - * @param \Magento\Core\Model\AbstractModel $object - * @return \Magento\Index\Model\Resource\Event + * @param AbstractModel $object + * @return $this */ - protected function _beforeSave(\Magento\Core\Model\AbstractModel $object) + protected function _beforeSave(AbstractModel $object) { /** * Check if event already exist and merge previous data @@ -72,10 +75,10 @@ class Event extends \Magento\Core\Model\Resource\Db\AbstractDb /** * Save assigned processes * - * @param \Magento\Core\Model\AbstractModel $object - * @return \Magento\Index\Model\Resource\Event + * @param AbstractModel $object + * @return $this */ - protected function _afterSave(\Magento\Core\Model\AbstractModel $object) + protected function _afterSave(AbstractModel $object) { $processIds = $object->getProcessIds(); if (is_array($processIds)) { @@ -84,7 +87,7 @@ class Event extends \Magento\Core\Model\Resource\Db\AbstractDb $this->_getWriteAdapter()->delete($processTable); } else { foreach ($processIds as $processId => $processStatus) { - if (is_null($processStatus) || $processStatus == \Magento\Index\Model\Process::EVENT_STATUS_DONE) { + if (is_null($processStatus) || $processStatus == ProcessModel::EVENT_STATUS_DONE) { $this->_getWriteAdapter()->delete($processTable, array( 'process_id = ?' => $processId, 'event_id = ?' => $object->getId(), @@ -106,14 +109,14 @@ class Event extends \Magento\Core\Model\Resource\Db\AbstractDb /** * Update status for events of process * - * @param int|array|\Magento\Index\Model\Process $process + * @param int|array|ProcessModel $process * @param string $status - * @return \Magento\Index\Model\Resource\Event + * @return $this */ - public function updateProcessEvents($process, $status = \Magento\Index\Model\Process::EVENT_STATUS_DONE) + public function updateProcessEvents($process, $status = ProcessModel::EVENT_STATUS_DONE) { $whereCondition = ''; - if ($process instanceof \Magento\Index\Model\Process) { + if ($process instanceof ProcessModel) { $whereCondition = array('process_id = ?' => $process->getId()); } elseif (is_array($process) && !empty($process)) { $whereCondition = array('process_id IN (?)' => $process); diff --git a/app/code/Magento/Index/Model/Resource/Event/Collection.php b/app/code/Magento/Index/Model/Resource/Event/Collection.php index 37e972148708689fb784a072d48ebaa10e8bdad0..ddd28a9887bd60df269ba625e0f6a0ca82d6f7f7 100644 --- a/app/code/Magento/Index/Model/Resource/Event/Collection.php +++ b/app/code/Magento/Index/Model/Resource/Event/Collection.php @@ -34,6 +34,8 @@ */ namespace Magento\Index\Model\Resource\Event; +use Magento\Index\Model\Process; + class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractCollection { /** @@ -49,7 +51,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl * Add filter by entity * * @param string | array $entity - * @return \Magento\Index\Model\Resource\Event\Collection + * @return $this */ public function addEntityFilter($entity) { @@ -65,7 +67,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl * Add filter by type * * @param string | array $type - * @return \Magento\Index\Model\Resource\Event\Collection + * @return $this */ public function addTypeFilter($type) { @@ -80,14 +82,14 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl /** * Add filter by process and status to events collection * - * @param int|array|\Magento\Index\Model\Process $process + * @param int|array|Process $process * @param string $status - * @return \Magento\Index\Model\Resource\Event\Collection + * @return $this */ public function addProcessFilter($process, $status = null) { $this->_joinProcessEventTable(); - if ($process instanceof \Magento\Index\Model\Process) { + if ($process instanceof Process) { $this->addFieldToFilter('process_event.process_id', $process->getId()); } elseif (is_array($process) && !empty($process)) { $this->addFieldToFilter('process_event.process_id', array('in' => $process)); @@ -108,7 +110,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl /** * Join index_process_event table to event table * - * @return \Magento\Index\Model\Resource\Event\Collection + * @return $this */ protected function _joinProcessEventTable() { @@ -125,7 +127,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl /** * Reset collection state * - * @return \Magento\Index\Model\Resource\Event\Collection + * @return $this */ public function reset() { diff --git a/app/code/Magento/Index/Model/Resource/Process.php b/app/code/Magento/Index/Model/Resource/Process.php index 8be71605f2e615ba1c0d64e247b902c8a8979333..91e60e17913634233190a6e4b8f2ef8ef46da744 100644 --- a/app/code/Magento/Index/Model/Resource/Process.php +++ b/app/code/Magento/Index/Model/Resource/Process.php @@ -34,6 +34,8 @@ */ namespace Magento\Index\Model\Resource; +use Magento\Index\Model\Process as ModelProcess; + class Process extends \Magento\Core\Model\Resource\Db\AbstractDb { /** @@ -65,7 +67,7 @@ class Process extends \Magento\Core\Model\Resource\Db\AbstractDb * @param int $processId * @param int $eventId * @param string $status - * @return \Magento\Index\Model\Resource\Process + * @return $this */ public function updateEventStatus($processId, $eventId, $status) { @@ -81,13 +83,13 @@ class Process extends \Magento\Core\Model\Resource\Db\AbstractDb /** * Register process end * - * @param \Magento\Index\Model\Process $process - * @return \Magento\Index\Model\Resource\Process + * @param ModelProcess $process + * @return $this */ - public function endProcess(\Magento\Index\Model\Process $process) + public function endProcess(ModelProcess $process) { $data = array( - 'status' => \Magento\Index\Model\Process::STATUS_PENDING, + 'status' => ModelProcess::STATUS_PENDING, 'ended_at' => $this->dateTime->formatDate(time()), ); $this->_updateProcessData($process->getId(), $data); @@ -97,13 +99,13 @@ class Process extends \Magento\Core\Model\Resource\Db\AbstractDb /** * Register process start * - * @param \Magento\Index\Model\Process $process - * @return \Magento\Index\Model\Resource\Process + * @param ModelProcess $process + * @return $this */ - public function startProcess(\Magento\Index\Model\Process $process) + public function startProcess(ModelProcess $process) { $data = array( - 'status' => \Magento\Index\Model\Process::STATUS_RUNNING, + 'status' => ModelProcess::STATUS_RUNNING, 'started_at' => $this->dateTime->formatDate(time()), ); $this->_updateProcessData($process->getId(), $data); @@ -113,13 +115,13 @@ class Process extends \Magento\Core\Model\Resource\Db\AbstractDb /** * Register process fail * - * @param \Magento\Index\Model\Process $process - * @return \Magento\Index\Model\Resource\Process + * @param ModelProcess $process + * @return $this */ - public function failProcess(\Magento\Index\Model\Process $process) + public function failProcess(ModelProcess $process) { $data = array( - 'status' => \Magento\Index\Model\Process::STATUS_REQUIRE_REINDEX, + 'status' => ModelProcess::STATUS_REQUIRE_REINDEX, 'ended_at' => $this->dateTime->formatDate(time()), ); $this->_updateProcessData($process->getId(), $data); @@ -130,9 +132,9 @@ class Process extends \Magento\Core\Model\Resource\Db\AbstractDb * Update process status field * * - * @param \Magento\Index\Model\Process $process + * @param ModelProcess $process * @param string $status - * @return \Magento\Index\Model\Resource\Process + * @return $this */ public function updateStatus($process, $status) { @@ -145,7 +147,7 @@ class Process extends \Magento\Core\Model\Resource\Db\AbstractDb * Updates process data * @param int $processId * @param array $data - * @return \Magento\Index\Model\Resource\Process + * @return $this */ protected function _updateProcessData($processId, $data) { @@ -158,10 +160,10 @@ class Process extends \Magento\Core\Model\Resource\Db\AbstractDb /** * Update process start date * - * @param \Magento\Index\Model\Process $process - * @return \Magento\Index\Model\Resource\Process + * @param ModelProcess $process + * @return $this */ - public function updateProcessStartDate(\Magento\Index\Model\Process $process) + public function updateProcessStartDate(ModelProcess $process) { $this->_updateProcessData($process->getId(), array('started_at' => $this->dateTime->formatDate(time()))); return $this; @@ -170,10 +172,10 @@ class Process extends \Magento\Core\Model\Resource\Db\AbstractDb /** * Update process end date * - * @param \Magento\Index\Model\Process $process - * @return \Magento\Index\Model\Resource\Process + * @param ModelProcess $process + * @return $this */ - public function updateProcessEndDate(\Magento\Index\Model\Process $process) + public function updateProcessEndDate(ModelProcess $process) { $this->_updateProcessData($process->getId(), array('ended_at' => $this->dateTime->formatDate(time()))); return $this; diff --git a/app/code/Magento/Index/Model/Shell.php b/app/code/Magento/Index/Model/Shell.php index cc69d816146e9e0c238915c66ea93fae67956f40..b3bf2c8d0d28b1d7220fa6e5c5c0703be903e6a9 100644 --- a/app/code/Magento/Index/Model/Shell.php +++ b/app/code/Magento/Index/Model/Shell.php @@ -64,7 +64,7 @@ class Shell extends \Magento\Core\Model\AbstractShell /** * Runs this model, assumed to be run by command-line * - * @return \Magento\Index\Model\Shell + * @return $this */ public function run() { @@ -89,7 +89,7 @@ class Shell extends \Magento\Core\Model\AbstractShell /** * Shows information about indexes * - * @return \Magento\Index\Model\Shell + * @return $this */ protected function _runShowInfo() { @@ -105,7 +105,7 @@ class Shell extends \Magento\Core\Model\AbstractShell /** * Shows information about statuses or modes * - * @return \Magento\Index\Model\Shell + * @return $this */ protected function _runShowStatusOrMode() { @@ -152,7 +152,7 @@ class Shell extends \Magento\Core\Model\AbstractShell /** * Sets new mode for indexes * - * @return \Magento\Index\Model\Shell + * @return $this */ protected function _runSetMode() { @@ -183,7 +183,7 @@ class Shell extends \Magento\Core\Model\AbstractShell /** * Reindexes indexer(s) * - * @return \Magento\Index\Model\Shell + * @return $this */ protected function _runReindex() { diff --git a/app/code/Magento/Index/etc/adminhtml/di.xml b/app/code/Magento/Index/etc/adminhtml/di.xml index 00e69d7de90e4868bde71747b8df33ab7e35b16d..5994d510e996f2b5670dd47c0e1c9d928e0a2649 100644 --- a/app/code/Magento/Index/etc/adminhtml/di.xml +++ b/app/code/Magento/Index/etc/adminhtml/di.xml @@ -26,9 +26,9 @@ <config> <type name="Magento\AdminNotification\Model\System\MessageList"> <param name="messages"> - <value> - <indexer>Magento\Index\Model\System\Message\IndexOutdated</indexer> - </value> + <array> + <item key="indexer"><value>Magento\Index\Model\System\Message\IndexOutdated</value></item> + </array> </param> </type> </config> diff --git a/app/code/Magento/Index/etc/di.xml b/app/code/Magento/Index/etc/di.xml index c0a9fc08d103437eb1c2426d2a541fc7a2e6026c..97736214cee7a4d71c1e7f09d511ecfe04ec3ee7 100644 --- a/app/code/Magento/Index/etc/di.xml +++ b/app/code/Magento/Index/etc/di.xml @@ -27,9 +27,9 @@ <preference for="Magento\Index\Model\Indexer\ConfigInterface" type="Magento\Index\Model\Indexer\Config" /> <type name="Magento\Module\Updater\SetupFactory"> <param name="resourceTypes"> - <value> - <index_setup>Magento\Index\Model\Resource\Setup</index_setup> - </value> + <array> + <item key="index_setup"><value>Magento\Index\Model\Resource\Setup</value></item> + </array> </param> </type> </config> diff --git a/app/code/Magento/Indexer/App/Indexer.php b/app/code/Magento/Indexer/App/Indexer.php new file mode 100644 index 0000000000000000000000000000000000000000..478e64549794cce5aafb3d80200ecc332bc7802a --- /dev/null +++ b/app/code/Magento/Indexer/App/Indexer.php @@ -0,0 +1,84 @@ +<?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\Indexer\App; + +class Indexer implements \Magento\LauncherInterface +{ + /** + * Report directory + * + * @var string + */ + protected $reportDir; + + /** + * @var \Magento\Filesystem + */ + protected $filesystem; + + /** + * @var \Magento\App\Console\Response + */ + protected $response; + + /** + * @param $reportDir + * @param \Magento\Filesystem $filesystem + * @param \Magento\Indexer\Model\Processor $processor + * @param \Magento\App\Console\Response $response + */ + public function __construct( + $reportDir, + \Magento\Filesystem $filesystem, + \Magento\Indexer\Model\Processor $processor, + \Magento\App\Console\Response $response + ) { + $this->reportDir = $reportDir; + $this->filesystem = $filesystem; + $this->processor = $processor; + $this->response = $response; + } + + /** + * Run application + * + * @return \Magento\App\ResponseInterface + */ + public function launch() + { + /* Clean reports */ + $directory = $this->filesystem->getDirectoryWrite(\Magento\App\Filesystem::ROOT_DIR); + $path = $directory->getRelativePath($this->reportDir); + if ($directory->isExist($path)) { + $directory->delete($path); + } + + /* Regenerate all indexers */ + $this->processor->reindexAll(); + $this->response->setCode(0); + + return $this->response; + } +} diff --git a/app/code/Magento/Indexer/App/Shell.php b/app/code/Magento/Indexer/App/Shell.php new file mode 100644 index 0000000000000000000000000000000000000000..a11aa601de97e57d58a25c61d039729d37ae4af5 --- /dev/null +++ b/app/code/Magento/Indexer/App/Shell.php @@ -0,0 +1,78 @@ +<?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\Indexer\App; + +class Shell implements \Magento\LauncherInterface +{ + /** + * Filename of the entry point script + * + * @var string + */ + protected $entryFileName; + + /** + * @var \Magento\App\Console\Response + */ + protected $response; + + /** + * @var \Magento\Indexer\Model\ShellFactory + */ + protected $shellFactory; + + /** + * @param $entryFileName + * @param \Magento\Indexer\Model\ShellFactory $shellFactory + * @param \Magento\App\Console\Response $response + */ + public function __construct( + $entryFileName, + \Magento\Indexer\Model\ShellFactory $shellFactory, + \Magento\App\Console\Response $response + ) { + $this->entryFileName = $entryFileName; + $this->shellFactory = $shellFactory; + $this->response = $response; + } + + /** + * Run application + * + * @return \Magento\App\ResponseInterface + */ + public function launch() + { + /** @var $shell \Magento\Indexer\Model\Shell */ + $shell = $this->shellFactory->create(array('entryPoint' => $this->entryFileName)); + $shell->run(); + if ($shell->hasErrors()) { + $this->response->setCode(-1); + } else { + $this->response->setCode(0); + } + return $this->response; + } +} diff --git a/app/code/Magento/Indexer/Block/Backend/Container.php b/app/code/Magento/Indexer/Block/Backend/Container.php new file mode 100644 index 0000000000000000000000000000000000000000..520a1e08f1ab963fff54c8f87111103dea5da2a5 --- /dev/null +++ b/app/code/Magento/Indexer/Block/Backend/Container.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\Indexer\Block\Backend; + +class Container extends \Magento\Backend\Block\Widget\Grid\Container +{ + /** + * Initialize object state with incoming parameters + */ + protected function _construct() + { + $this->_controller = 'indexer'; + $this->_blockGroup = 'Magento_Indexer'; + $this->_headerText = __('New Indexer Management'); + parent::_construct(); + } + + /** + * Prepare layout, remove button + * + * @return $this|\Magento\View\Element\AbstractBlock + */ + protected function _prepareLayout() + { + parent::_prepareLayout(); + $this->_removeButton('add'); + return $this; + } +} diff --git a/app/code/Magento/Indexer/Block/Backend/Grid/Column/Renderer/Mode.php b/app/code/Magento/Indexer/Block/Backend/Grid/Column/Renderer/Mode.php new file mode 100644 index 0000000000000000000000000000000000000000..55814d9decdabcb8f10efd1c10bf9e64fe99ca5e --- /dev/null +++ b/app/code/Magento/Indexer/Block/Backend/Grid/Column/Renderer/Mode.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\Indexer\Block\Backend\Grid\Column\Renderer; + +class Mode extends \Magento\Backend\Block\Widget\Grid\Column\Renderer\AbstractRenderer +{ + /** + * Render indexer mode + * + * @param \Magento\Object $row + * @return string + */ + public function render(\Magento\Object $row) + { + $class = ''; + $text = ''; + switch ($this->_getValue($row)) { + case \Magento\Mview\View\StateInterface::MODE_DISABLED: + $class = 'grid-severity-notice'; + $text = __('Update on Save'); + break; + case \Magento\Mview\View\StateInterface::MODE_ENABLED: + $class = 'grid-severity-major'; + $text = __('Update by Schedule'); + break; + } + return '<span class="' . $class . '"><span>' . $text . '</span></span>'; + } +} diff --git a/app/code/Magento/Indexer/Block/Backend/Grid/Column/Renderer/Status.php b/app/code/Magento/Indexer/Block/Backend/Grid/Column/Renderer/Status.php new file mode 100644 index 0000000000000000000000000000000000000000..5c3cac4e1c0ee19f4d415231cad1b6bfaa1ec36b --- /dev/null +++ b/app/code/Magento/Indexer/Block/Backend/Grid/Column/Renderer/Status.php @@ -0,0 +1,55 @@ +<?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\Indexer\Block\Backend\Grid\Column\Renderer; + +class Status extends \Magento\Backend\Block\Widget\Grid\Column\Renderer\AbstractRenderer +{ + /** + * Render indexer status + * + * @param \Magento\Object $row + * @return string + */ + public function render(\Magento\Object $row) + { + $class = ''; + $text = ''; + switch ($this->_getValue($row)) { + case \Magento\Indexer\Model\Indexer\State::STATUS_INVALID: + $class = 'grid-severity-critical'; + $text = __('Reindex required'); + break; + case \Magento\Indexer\Model\Indexer\State::STATUS_VALID: + $class = 'grid-severity-notice'; + $text = __('Ready'); + break; + case \Magento\Indexer\Model\Indexer\State::STATUS_WORKING: + $class = 'grid-severity-major'; + $text = __('Processing'); + break; + } + return '<span class="' . $class . '"><span>' . $text . '</span></span>'; + } +} diff --git a/lib/Magento/Acl/Resource/Config/Dom.php b/app/code/Magento/Indexer/Block/Backend/Grid/Column/Renderer/Updated.php similarity index 67% rename from lib/Magento/Acl/Resource/Config/Dom.php rename to app/code/Magento/Indexer/Block/Backend/Grid/Column/Renderer/Updated.php index 1238ace8113f1fc576b42ba327f0da2296fa3683..7a7b88995b9727c057a6250337e19a00ef457f77 100644 --- a/lib/Magento/Acl/Resource/Config/Dom.php +++ b/app/code/Magento/Indexer/Block/Backend/Grid/Column/Renderer/Updated.php @@ -19,21 +19,25 @@ * 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)\Magento\Acl\Loader\Resource + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Acl\Resource\Config; -class Dom extends \Magento\Config\Dom +namespace Magento\Indexer\Block\Backend\Grid\Column\Renderer; + +class Updated extends \Magento\Backend\Block\Widget\Grid\Column\Renderer\Datetime { /** - * Return attribute for resource node that identify it as unique + * Render indexer updated time * - * @param string $xPath - * @return bool|string + * @param \Magento\Object $row + * @return string */ - protected function _findIdAttribute($xPath) + public function render(\Magento\Object $row) { - $needle = 'resource'; - return substr($xPath, -strlen($needle)) === $needle ? 'id' : false; + $value = parent::render($row); + if (!$value) { + return __('Never'); + } + return $value; } } diff --git a/app/code/Magento/Indexer/Block/Backend/Grid/ItemsUpdater.php b/app/code/Magento/Indexer/Block/Backend/Grid/ItemsUpdater.php new file mode 100644 index 0000000000000000000000000000000000000000..1f47d7e64e797847e0a128bc2b615787090f9874 --- /dev/null +++ b/app/code/Magento/Indexer/Block/Backend/Grid/ItemsUpdater.php @@ -0,0 +1,55 @@ +<?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\Indexer\Block\Backend\Grid; + +class ItemsUpdater implements \Magento\Core\Model\Layout\Argument\UpdaterInterface +{ + /** + * @var \Magento\AuthorizationInterface + */ + protected $authorization; + + /** + * @param \Magento\AuthorizationInterface $authorization + */ + public function __construct(\Magento\AuthorizationInterface $authorization) + { + $this->authorization = $authorization; + } + + /** + * Remove massaction items in case they disallowed for user + * @param mixed $argument + * @return mixed + */ + public function update($argument) + { + if (false === $this->authorization->isAllowed('Magento_Indexer::changeMode')) { + unset($argument['change_mode_onthefly']); + unset($argument['change_mode_changelog']); + } + return $argument; + } +} diff --git a/app/code/Magento/Indexer/Controller/Adminhtml/Indexer.php b/app/code/Magento/Indexer/Controller/Adminhtml/Indexer.php new file mode 100644 index 0000000000000000000000000000000000000000..ba2e376c6aa1b756d4cc594de0117bca2e33b53e --- /dev/null +++ b/app/code/Magento/Indexer/Controller/Adminhtml/Indexer.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. + * + * @category Magento + * @package Magento_Index + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Indexer\Controller\Adminhtml; + +class Indexer extends \Magento\Backend\App\Action +{ + /** + * Display processes grid action + */ + public function listAction() + { + $this->_title->add(__('New Index Management')); + + $this->_view->loadLayout(); + $this->_setActiveMenu('Magento_Indexer::system_index'); + $this->_view->renderLayout(); + } + + /** + * Turn mview off for the given indexers + */ + public function massOnTheFlyAction() + { + $indexerIds = $this->getRequest()->getParam('indexer_ids'); + if (!is_array($indexerIds)) { + $this->messageManager->addError(__('Please select indexers.')); + } else { + try { + foreach ($indexerIds as $indexer_id) { + /** @var \Magento\Indexer\Model\Indexer $model */ + $model = $this->_objectManager->create('Magento\Indexer\Model\Indexer') + ->load($indexer_id); + $model->turnViewOff(); + } + $this->messageManager->addSuccess( + __('A total of %1 indexer(s) have been turned Update on Save mode on.', count($indexerIds)) + ); + } catch (\Magento\Core\Exception $e) { + $this->messageManager->addError($e->getMessage()); + } catch (\Exception $e) { + $this->messageManager->addException( + $e, + __("We couldn't change indexer(s)' mode because of an error.") + ); + } + } + $this->_redirect('*/*/list'); + } + + /** + * Turn mview on for the given indexers + */ + public function massChangelogAction() + { + $indexerIds = $this->getRequest()->getParam('indexer_ids'); + if (!is_array($indexerIds)) { + $this->messageManager->addError(__('Please select indexers.')); + } else { + try { + foreach ($indexerIds as $indexer_id) { + /** @var \Magento\Indexer\Model\Indexer $model */ + $model = $this->_objectManager->create('Magento\Indexer\Model\Indexer') + ->load($indexer_id); + $model->turnViewOn(); + } + $this->messageManager->addSuccess( + __('A total of %1 indexer(s) have been turned Update by Schedule mode on.', count($indexerIds)) + ); + } catch (\Magento\Core\Exception $e) { + $this->messageManager->addError($e->getMessage()); + } catch (\Exception $e) { + $this->messageManager->addException( + $e, + __("We couldn't change indexer(s)' mode because of an error.") + ); + } + } + $this->_redirect('*/*/list'); + } + + /** + * Check ACL permissions + * + * @return bool + */ + protected function _isAllowed() + { + switch ($this->_request->getActionName()) { + case 'list': + return $this->_authorization->isAllowed('Magento_Indexer::index'); + case 'massOnTheFly': + case 'massChangelog': + return $this->_authorization->isAllowed('Magento_Indexer::changeMode'); + } + return false; + } +} diff --git a/app/code/Magento/Indexer/Model/ActionFactory.php b/app/code/Magento/Indexer/Model/ActionFactory.php new file mode 100644 index 0000000000000000000000000000000000000000..e994e6680d19db9d00913adffb4f6a4ae8b0edf3 --- /dev/null +++ b/app/code/Magento/Indexer/Model/ActionFactory.php @@ -0,0 +1,60 @@ +<?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\Indexer\Model; + +class ActionFactory +{ + /** + * @var \Magento\ObjectManager + */ + protected $objectManager; + + /** + * @param \Magento\ObjectManager $objectManager + */ + public function __construct(\Magento\ObjectManager $objectManager) + { + $this->objectManager = $objectManager; + } + + /** + * Get action class instance by class name + * + * @param string $className + * @throws \InvalidArgumentException + * @return ActionInterface + */ + public function get($className) + { + $action = $this->objectManager->get($className); + if (!($action instanceof ActionInterface)) { + throw new \InvalidArgumentException( + $className . ' doesn\'t implement \Magento\Indexer\Model\ActionInterface' + ); + } + + return $action; + } +} diff --git a/app/code/Magento/Indexer/Model/ActionInterface.php b/app/code/Magento/Indexer/Model/ActionInterface.php new file mode 100644 index 0000000000000000000000000000000000000000..a9c2cb67dc9b4bb364a2509c3d603d02400f455d --- /dev/null +++ b/app/code/Magento/Indexer/Model/ActionInterface.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\Indexer\Model; + +interface ActionInterface +{ + /** + * Execute full indexation + */ + public function executeFull(); + + /** + * Execute partial indexation by ID list + * + * @param int[] $ids + */ + public function executeList($ids); + + /** + * Execute partial indexation by ID + * + * @param int $id + */ + public function executeRow($id); +} diff --git a/app/code/Magento/Indexer/Model/Config.php b/app/code/Magento/Indexer/Model/Config.php new file mode 100644 index 0000000000000000000000000000000000000000..db905bd786423329124c2473cc5de3d0d01161ae --- /dev/null +++ b/app/code/Magento/Indexer/Model/Config.php @@ -0,0 +1,59 @@ +<?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\Indexer\Model; + +class Config extends \Magento\Config\Data implements ConfigInterface +{ + /** + * @param \Magento\Indexer\Model\Config\Reader $reader + * @param \Magento\Config\CacheInterface $cache + * @param string $cacheId + */ + public function __construct( + \Magento\Indexer\Model\Config\Reader $reader, + \Magento\Config\CacheInterface $cache, + $cacheId = 'indexer_config' + ) { + parent::__construct($reader, $cache, $cacheId); + } + + /** + * Get indexer's config + * + * @return mixed + */ + public function getAll() + { + return $this->get(); + } + + /** + * @return array + */ + public function getIndexerIds() + { + return array_keys($this->get()); + } +} diff --git a/app/code/Magento/Indexer/Model/Config/Converter.php b/app/code/Magento/Indexer/Model/Config/Converter.php new file mode 100644 index 0000000000000000000000000000000000000000..f8feccfd0773223b6202895635cff53b343fd78b --- /dev/null +++ b/app/code/Magento/Indexer/Model/Config/Converter.php @@ -0,0 +1,111 @@ +<?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\Indexer\Model\Config; + +class Converter implements \Magento\Config\ConverterInterface +{ + /** + * Convert dom node tree to array + * + * @param \DOMDocument $source + * @return array + * @throws \InvalidArgumentException + */ + public function convert($source) + { + $output = array(); + $xpath = new \DOMXPath($source); + $indexers = $xpath->evaluate('/config/indexer'); + /** @var $typeNode \DOMNode */ + foreach ($indexers as $indexerNode) { + $data = array(); + $indexerId = $this->getAttributeValue($indexerNode, 'id'); + $data['indexer_id'] = $indexerId; + $data['view_id'] = $this->getAttributeValue($indexerNode, 'view_id'); + $data['action_class'] = $this->getAttributeValue($indexerNode, 'class'); + $data['title'] = ''; + $data['description'] = ''; + + /** @var $childNode \DOMNode */ + foreach ($indexerNode->childNodes as $childNode) { + if ($childNode->nodeType != XML_ELEMENT_NODE) { + continue; + } + + $data = $this->convertChild($childNode, $data); + } + $output[$indexerId] = $data; + } + return $output; + } + + /** + * Get attribute value + * + * @param \DOMNode $input + * @param string $attributeName + * @param mixed $default + * @return null|string + */ + protected function getAttributeValue(\DOMNode $input, $attributeName, $default = null) + { + $node = $input->attributes->getNamedItem($attributeName); + return $node ? $node->nodeValue : $default; + } + + /** + * Convert child from dom to array + * + * @param \DOMNode $childNode + * @param array $data + * @return array + */ + protected function convertChild(\DOMNode $childNode, $data) + { + switch ($childNode->nodeName) { + case 'title': + $data['title'] = $this->getTranslatedNodeValue($childNode); + break; + case 'description': + $data['description'] = $this->getTranslatedNodeValue($childNode); + break; + } + return $data; + } + + /** + * Return node value translated if applicable + * + * @param \DOMNode $node + * @return string + */ + protected function getTranslatedNodeValue(\DOMNode $node) + { + $value = $node->nodeValue; + if ($this->getAttributeValue($node, 'translate') == 'true') { + $value = __($value); + } + return $value; + } +} diff --git a/app/code/Magento/Indexer/Model/Config/Reader.php b/app/code/Magento/Indexer/Model/Config/Reader.php new file mode 100644 index 0000000000000000000000000000000000000000..03cd2591d1d3fd5d2e94569ea2e15cc32d2ed668 --- /dev/null +++ b/app/code/Magento/Indexer/Model/Config/Reader.php @@ -0,0 +1,69 @@ +<?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\Indexer\Model\Config; + +class Reader extends \Magento\Config\Reader\Filesystem +{ + /** + * List of id attributes for merge + * + * @var array + */ + protected $_idAttributes = array( + '/config/indexer' => '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\Indexer\Model\Config\Converter $converter, + \Magento\Indexer\Model\Config\SchemaLocator $schemaLocator, + \Magento\Config\ValidationStateInterface $validationState, + $fileName = 'indexer.xml', + $idAttributes = array(), + $domDocumentClass = 'Magento\Config\Dom', + $defaultScope = 'global' + ) { + parent::__construct( + $fileResolver, + $converter, + $schemaLocator, + $validationState, + $fileName, + $idAttributes, + $domDocumentClass, + $defaultScope + ); + } +} diff --git a/app/code/Magento/Indexer/Model/Config/SchemaLocator.php b/app/code/Magento/Indexer/Model/Config/SchemaLocator.php new file mode 100644 index 0000000000000000000000000000000000000000..719ac0880a1fffdac3ce2be1abda46a31c5d3c35 --- /dev/null +++ b/app/code/Magento/Indexer/Model/Config/SchemaLocator.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\Indexer\Model\Config; + +class SchemaLocator implements \Magento\Config\SchemaLocatorInterface +{ + /** + * Path to corresponding XSD file with validation rules for merged config + * + * @var string + */ + protected $_schema = null; + + /** + * Path to corresponding XSD file with validation rules for separate config files + * + * @var string + */ + protected $_perFileSchema = null; + + /** + * @param \Magento\Module\Dir\Reader $moduleReader + */ + public function __construct(\Magento\Module\Dir\Reader $moduleReader) + { + $etcDir = $moduleReader->getModuleDir('etc', 'Magento_Indexer'); + $this->_schema = $etcDir . '/indexer.xsd'; + $this->_perFileSchema = $etcDir . '/indexer.xsd'; + } + + /** + * Get path to merged config schema + * + * @return string|null + */ + public function getSchema() + { + return $this->_schema; + } + + /** + * Get path to pre file validation schema + * + * @return string|null + */ + public function getPerFileSchema() + { + return $this->_perFileSchema; + } +} diff --git a/app/code/Magento/Indexer/Model/ConfigInterface.php b/app/code/Magento/Indexer/Model/ConfigInterface.php new file mode 100644 index 0000000000000000000000000000000000000000..258219ee9c8b23bf6ba626f9b8ea21f00f3f3cbf --- /dev/null +++ b/app/code/Magento/Indexer/Model/ConfigInterface.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\Indexer\Model; + +interface ConfigInterface +{ + /** + * Get indexer's config + * + * @return array + */ + public function getAll(); + + /** + * Get config value by key + * + * @param string $path + * @param mixed $default + * @return mixed + */ + public function get($path = null, $default = null); + + /** + * Get list of indexer ids + * + * @return array + */ + public function getIndexerIds(); +} diff --git a/app/code/Magento/Indexer/Model/Indexer.php b/app/code/Magento/Indexer/Model/Indexer.php new file mode 100644 index 0000000000000000000000000000000000000000..670a6c569379e0f46a8a363d4f205d60b625acad --- /dev/null +++ b/app/code/Magento/Indexer/Model/Indexer.php @@ -0,0 +1,279 @@ +<?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\Indexer\Model; + +/** + * @method int getViewId() + * @method string getActionClass() + * @method string getTitle() + * @method string getDescription() + */ +class Indexer extends \Magento\Object +{ + /** + * @var string + */ + protected $_idFieldName = 'indexer_id'; + + /** + * @var ConfigInterface + */ + protected $config; + + /** + * @var ActionFactory + */ + protected $actionFactory; + + /** + * @var \Magento\Mview\View + */ + protected $view; + + /** + * @var \Magento\Indexer\Model\Indexer\StateFactory + */ + protected $stateFactory; + + /** + * @var \Magento\Indexer\Model\Indexer\State + */ + protected $state; + + /** + * @var Indexer\CollectionFactory + */ + protected $indexersFactory; + + /** + * @param ConfigInterface $config + * @param ActionFactory $actionFactory + * @param \Magento\Mview\ViewInterface $view + * @param Indexer\StateFactory $stateFactory + * @param Indexer\CollectionFactory $indexersFactory + * @param array $data + */ + public function __construct( + ConfigInterface $config, + ActionFactory $actionFactory, + \Magento\Mview\ViewInterface $view, + Indexer\StateFactory $stateFactory, + Indexer\CollectionFactory $indexersFactory, + array $data = array() + ) { + $this->config = $config; + $this->actionFactory = $actionFactory; + $this->view = $view; + $this->stateFactory = $stateFactory; + $this->indexersFactory = $indexersFactory; + parent::__construct($data); + } + + /** + * Fill indexer data from config + * + * @param string $indexerId + * @return \Magento\Indexer\Model\Indexer + * @throws \InvalidArgumentException + */ + public function load($indexerId) + { + $indexer = $this->config->get($indexerId); + if (empty($indexer) || empty($indexer['indexer_id']) || $indexer['indexer_id'] != $indexerId) { + throw new \InvalidArgumentException("{$indexerId} indexer does not exist."); + } + + $this->setId($indexerId); + $this->setData($indexer); + + return $this; + } + + /** + * Return related view object + * + * @return \Magento\Mview\View + */ + public function getView() + { + if (!$this->view->getId()) { + $this->view->load($this->getViewId()); + } + return $this->view; + } + + /** + * Return related state object + * + * @return Indexer\State + */ + public function getState() + { + if (!$this->state) { + $this->state = $this->stateFactory->create(); + $this->state->load($this->getId(), 'indexer_id'); + if (!$this->state->getId()) { + $this->state->setIndexerId($this->getId()); + } + } + return $this->state; + } + + /** + * Set indexer state object + * + * @param Indexer\State $state + * @return Indexer + */ + public function setState(Indexer\State $state) + { + $this->state = $state; + return $this; + } + + /** + * Return indexer mode + * + * @return string + */ + public function getMode() + { + return $this->getView()->getMode(); + } + + /** + * Turn changelog mode of + * + * @return string + */ + public function turnViewOff() + { + $this->getView()->unsubscribe(); + $this->getState()->save(); + } + + /** + * Turn changelog mode on + * + * @return string + */ + public function turnViewOn() + { + $this->getView()->subscribe(); + $this->getState()->save(); + } + + /** + * Return indexer status + * + * @return string + */ + public function getStatus() + { + if ($this->getView()->getMode() == \Magento\Mview\View\StateInterface::MODE_ENABLED + && $this->getView()->getStatus() == \Magento\Mview\View\StateInterface::STATUS_WORKING + ) { + return \Magento\Indexer\Model\Indexer\State::STATUS_WORKING; + } + return $this->getState()->getStatus(); + } + + /** + * Return indexer updated time + * + * @return string + */ + public function getUpdated() + { + if ($this->getView()->getMode() == \Magento\Mview\View\StateInterface::MODE_ENABLED + && $this->getView()->getUpdated() + ) { + if (!$this->getState()->getUpdated()) { + return $this->getView()->getUpdated(); + } + $indexerUpdatedDate = new \Zend_Date($this->getState()->getUpdated()); + $viewUpdatedDate = new \Zend_Date($this->getView()->getUpdated()); + if ($viewUpdatedDate->compare($indexerUpdatedDate) == 1) { + return $this->getView()->getUpdated(); + } + } + return $this->getState()->getUpdated(); + } + + /** + * Return indexer action instance + * + * @return ActionInterface + */ + protected function getActionInstance() + { + return $this->actionFactory->get($this->getActionClass()); + } + + /** + * Regenerate full index + * + * @throws \Exception + */ + public function reindexAll() + { + if ($this->getState()->getStatus() != Indexer\State::STATUS_WORKING) { + $this->getState() + ->setStatus(Indexer\State::STATUS_WORKING) + ->save(); + try { + $this->getActionInstance()->executeFull(); + $this->getState() + ->setStatus(Indexer\State::STATUS_VALID) + ->save(); + } catch (\Exception $exception) { + $this->getState() + ->setStatus(Indexer\State::STATUS_INVALID) + ->save(); + throw $exception; + } + } + } + + /** + * Regenerate one row in index by ID + * + * @param int $id + */ + public function reindexRow($id) + { + $this->getActionInstance()->executeRow($id); + } + + /** + * Regenerate rows in index by ID list + * + * @param int[] $ids + */ + public function reindexList($ids) + { + $this->getActionInstance()->executeList($ids); + } +} diff --git a/app/code/Magento/Indexer/Model/Indexer/Collection.php b/app/code/Magento/Indexer/Model/Indexer/Collection.php new file mode 100644 index 0000000000000000000000000000000000000000..ac1582b80f486038653f6956093840e9a70af8fd --- /dev/null +++ b/app/code/Magento/Indexer/Model/Indexer/Collection.php @@ -0,0 +1,111 @@ +<?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\Indexer\Model\Indexer; + +class Collection extends \Magento\Data\Collection +{ + /** + * Item object class name + * + * @var string + */ + protected $_itemObjectClass = 'Magento\Indexer\Model\Indexer'; + + /** + * @var \Magento\Indexer\Model\ConfigInterface + */ + protected $config; + + /** + * @var \Magento\Indexer\Model\Resource\Indexer\State\CollectionFactory + */ + protected $statesFactory; + + /** + * @param \Magento\Data\Collection\EntityFactoryInterface $entityFactory + * @param \Magento\Indexer\Model\ConfigInterface $config + * @param \Magento\Indexer\Model\Resource\Indexer\State\CollectionFactory $statesFactory + */ + public function __construct( + \Magento\Data\Collection\EntityFactoryInterface $entityFactory, + \Magento\Indexer\Model\ConfigInterface $config, + \Magento\Indexer\Model\Resource\Indexer\State\CollectionFactory $statesFactory + ) { + $this->config = $config; + $this->statesFactory = $statesFactory; + parent::__construct($entityFactory); + } + + /** + * Load data + * + * @param bool $printQuery + * @param bool $logQuery + * @return \Magento\Indexer\Model\Indexer\Collection + * + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + */ + public function loadData($printQuery = false, $logQuery = false) + { + if (!$this->isLoaded()) { + $states = $this->statesFactory->create(); + foreach ($this->config->getIndexerIds() as $indexerId) { + /** @var \Magento\Indexer\Model\Indexer $indexer */ + $indexer = $this->getNewEmptyItem(); + $indexer->load($indexerId); + foreach ($states->getItems() as $state) { + /** @var \Magento\Indexer\Model\Indexer\State $state */ + if ($state->getIndexerId() == $indexerId) { + $indexer->setState($state); + break; + } + } + $this->_addItem($indexer); + } + $this->_setIsLoaded(true); + } + return $this; + } + + /** + * Return indexers by given state status + * + * @param string $status + * @return \Magento\Indexer\Model\Indexer[] + */ + public function getIndexersByStateStatus($status) + { + $this->load(); + + $result = array(); + foreach ($this as $indexer) { + /** @var \Magento\Indexer\Model\Indexer $indexer */ + if ($indexer->getState()->getStatus() == $status) { + $result[] = $indexer; + } + } + return $result; + } +} diff --git a/app/code/Magento/Indexer/Model/Indexer/State.php b/app/code/Magento/Indexer/Model/Indexer/State.php new file mode 100644 index 0000000000000000000000000000000000000000..bcee2f9b957c2878f1342e482dc79d845eccd2ac --- /dev/null +++ b/app/code/Magento/Indexer/Model/Indexer/State.php @@ -0,0 +1,83 @@ +<?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\Indexer\Model\Indexer; + +/** + * @method string getIndexerId() + * @method \Magento\Indexer\Model\Indexer\State setIndexerId($value) + * @method string getStatus() + * @method \Magento\Indexer\Model\Indexer\State setStatus($value) + * @method string getUpdated() + * @method \Magento\Indexer\Model\Indexer\State setUpdated($value) + */ +class State extends \Magento\Core\Model\AbstractModel +{ + /** + * Indexer statuses + */ + const STATUS_WORKING = 'working'; + const STATUS_VALID = 'valid'; + const STATUS_INVALID = 'invalid'; + + /** + * Prefix of model events names + * + * @var string + */ + protected $_eventPrefix = 'indexer_state'; + + /** + * Parameter name in event + * + * @var string + */ + protected $_eventObject = 'indexer_state'; + + /** + * @param \Magento\Core\Model\Context $context + * @param \Magento\Core\Model\Registry $registry + * @param \Magento\Indexer\Model\Resource\Indexer\State $resource + * @param \Magento\Indexer\Model\Resource\Indexer\State\Collection $resourceCollection + * @param array $data + */ + public function __construct( + \Magento\Core\Model\Context $context, + \Magento\Core\Model\Registry $registry, + \Magento\Indexer\Model\Resource\Indexer\State $resource, + \Magento\Indexer\Model\Resource\Indexer\State\Collection $resourceCollection, + array $data = array() + ) { + if (!isset($data['status'])) { + $data['status'] = self::STATUS_INVALID; + } + parent::__construct($context, $registry, $resource, $resourceCollection, $data); + } + + protected function _beforeSave() + { + $this->setUpdated(time()); + return parent::_beforeSave(); + } +} diff --git a/app/code/Magento/Indexer/Model/Processor.php b/app/code/Magento/Indexer/Model/Processor.php new file mode 100644 index 0000000000000000000000000000000000000000..f152c82a1e4de867d0b32f9077c76ed808e3c5ce --- /dev/null +++ b/app/code/Magento/Indexer/Model/Processor.php @@ -0,0 +1,108 @@ +<?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\Indexer\Model; + +class Processor +{ + /** + * @var Config + */ + protected $config; + + /** + * @var IndexerFactory + */ + protected $indexerFactory; + + /** + * @var Indexer\CollectionFactory + */ + protected $indexersFactory; + + /** + * @var \Magento\Mview\ProcessorInterface + */ + protected $mviewProcessor; + + /** + * @param Config $config + * @param IndexerFactory $indexerFactory + * @param Indexer\CollectionFactory $indexersFactory + * @param \Magento\Mview\ProcessorInterface $mviewProcessor + */ + public function __construct( + Config $config, + IndexerFactory $indexerFactory, + Indexer\CollectionFactory $indexersFactory, + \Magento\Mview\ProcessorInterface $mviewProcessor + ) { + $this->config = $config; + $this->indexerFactory = $indexerFactory; + $this->indexersFactory = $indexersFactory; + $this->mviewProcessor = $mviewProcessor; + } + + /** + * Regenerate indexes for all invalid indexers + */ + public function reindexAllInvalid() + { + foreach ($this->config->getIndexerIds() as $indexerId) { + $indexer = $this->indexerFactory->create(); + $indexer->load($indexerId); + if ($indexer->getState()->getStatus() == Indexer\State::STATUS_INVALID) { + $indexer->reindexAll(); + } + } + } + + /** + * Regenerate indexes for all indexers + */ + public function reindexAll() + { + /** @var Indexer[] $indexers */ + $indexers = $this->indexersFactory->create()->getItems(); + foreach ($indexers as $indexer) { + $indexer->reindexAll(); + } + } + + /** + * Update indexer views + */ + public function updateMview() + { + $this->mviewProcessor->update('indexer'); + } + + /** + * Clean indexer view changelogs + */ + public function clearChangelog() + { + $this->mviewProcessor->clearChangelog('indexer'); + } +} diff --git a/app/code/Magento/Indexer/Model/Resource/Indexer/State.php b/app/code/Magento/Indexer/Model/Resource/Indexer/State.php new file mode 100644 index 0000000000000000000000000000000000000000..e0840f57781aa413dca6057c03f74a208806abfa --- /dev/null +++ b/app/code/Magento/Indexer/Model/Resource/Indexer/State.php @@ -0,0 +1,40 @@ +<?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\Indexer\Model\Resource\Indexer; + +class State extends \Magento\Core\Model\Resource\Db\AbstractDb +{ + /** + * Resource initialization + */ + protected function _construct() + { + $this->_init('indexer_state', 'state_id'); + $this->addUniqueField(array( + 'field' => array('indexer_id'), + 'title' => __('State for the same indexer') + )); + } +} diff --git a/app/code/Magento/Indexer/Model/Resource/Indexer/State/Collection.php b/app/code/Magento/Indexer/Model/Resource/Indexer/State/Collection.php new file mode 100644 index 0000000000000000000000000000000000000000..93d62cb3076e7ba08c0db2b67b956d9ad379b5e1 --- /dev/null +++ b/app/code/Magento/Indexer/Model/Resource/Indexer/State/Collection.php @@ -0,0 +1,36 @@ +<?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\Indexer\Model\Resource\Indexer\State; + +class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractCollection +{ + /** + * Collection initialization + */ + protected function _construct() + { + $this->_init('Magento\Indexer\Model\Indexer\State', 'Magento\Indexer\Model\Resource\Indexer\State'); + } +} diff --git a/app/code/Magento/Indexer/Model/Shell.php b/app/code/Magento/Indexer/Model/Shell.php new file mode 100644 index 0000000000000000000000000000000000000000..c94cf987b40f3d81202e1f3b3745093f0558616c --- /dev/null +++ b/app/code/Magento/Indexer/Model/Shell.php @@ -0,0 +1,271 @@ +<?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\Indexer\Model; + +class Shell extends \Magento\Core\Model\AbstractShell +{ + /** + * Error status - whether errors have happened + * + * @var bool + */ + protected $hasErrors = false; + + /** + * @var Indexer\CollectionFactory + */ + protected $indexersFactory; + + /** + * @var IndexerFactory + */ + protected $indexerFactory; + + /** + * @param \Magento\App\Filesystem $filesystem + * @param string $entryPoint + * @param Indexer\CollectionFactory $indexersFactory + * @param IndexerFactory $indexerFactory + */ + public function __construct( + \Magento\App\Filesystem $filesystem, + $entryPoint, + Indexer\CollectionFactory $indexersFactory, + IndexerFactory $indexerFactory + ) { + $this->indexersFactory = $indexersFactory; + $this->indexerFactory = $indexerFactory; + parent::__construct($filesystem, $entryPoint); + } + + /** + * Run this model, assumed to be run by command-line + * + * @return \Magento\Indexer\Model\Shell + */ + public function run() + { + if ($this->_showHelp()) { + return $this; + } + + if ($this->getArg('info')) { + $this->runShowInfo(); + } else if ($this->getArg('status') || $this->getArg('mode')) { + $this->runShowStatusOrMode(); + } else if ($this->getArg('mode-realtime') || $this->getArg('mode-schedule')) { + $this->runSetMode(); + } else if ($this->getArg('reindex') || $this->getArg('reindexall')) { + $this->runReindex(); + } else { + echo $this->getUsageHelp(); + } + + return $this; + } + + /** + * Show information about indexes + * + * @return \Magento\Indexer\Model\Shell + */ + protected function runShowInfo() + { + $indexers = $this->parseIndexerString('all'); + foreach ($indexers as $indexer) { + echo sprintf('%-40s', $indexer->getId()); + echo $indexer->getTitle() . PHP_EOL; + } + + return $this; + } + + /** + * Show information about statuses or modes + * + * @return \Magento\Indexer\Model\Shell + */ + protected function runShowStatusOrMode() + { + if ($this->getArg('status')) { + $indexers = $this->parseIndexerString($this->getArg('status')); + } else { + $indexers = $this->parseIndexerString($this->getArg('mode')); + } + + foreach ($indexers as $indexer) { + $status = 'unknown'; + if ($this->getArg('status')) { + switch ($indexer->getStatus()) { + case \Magento\Indexer\Model\Indexer\State::STATUS_VALID: + $status = 'Ready'; + break; + case \Magento\Indexer\Model\Indexer\State::STATUS_INVALID: + $status = 'Reindex required'; + break; + + case \Magento\Indexer\Model\Indexer\State::STATUS_WORKING: + $status = 'Processing'; + break; + } + } else { + switch ($indexer->getMode()) { + case \Magento\Mview\View\StateInterface::MODE_DISABLED: + $status = 'Update on Save'; + break; + case \Magento\Mview\View\StateInterface::MODE_ENABLED: + $status = 'Update by Schedule'; + break; + } + } + echo sprintf('%-50s ', $indexer->getTitle() . ':') . $status . PHP_EOL; + } + + return $this; + } + + /** + * Set new mode for indexers + * + * @return \Magento\Indexer\Model\Shell + */ + protected function runSetMode() + { + if ($this->getArg('mode-realtime')) { + $method = 'turnViewOff'; + $indexers = $this->parseIndexerString($this->getArg('mode-realtime')); + } else { + $method = 'turnViewOn'; + $indexers = $this->parseIndexerString($this->getArg('mode-schedule')); + } + + foreach ($indexers as $indexer) { + try { + $indexer->$method(); + echo $indexer->getTitle() . " indexer was successfully changed index mode" . PHP_EOL; + } catch (\Magento\Core\Exception $e) { + echo $e->getMessage() . PHP_EOL; + $this->hasErrors = true; + } catch (\Exception $e) { + echo $indexer->getTitle() . " indexer process unknown error:" . PHP_EOL; + echo $e . PHP_EOL; + $this->hasErrors = true; + } + } + + return $this; + } + + /** + * Reindex indexer(s) + * + * @return \Magento\Indexer\Model\Shell + */ + protected function runReindex() + { + if ($this->getArg('reindex')) { + $indexers = $this->parseIndexerString($this->getArg('reindex')); + } else { + $indexers = $this->parseIndexerString('all'); + } + + foreach ($indexers as $indexer) { + try { + $indexer->reindexAll(); + echo $indexer->getTitle() . " index has been rebuilt successfully" . PHP_EOL; + } catch (\Magento\Core\Exception $e) { + echo $e->getMessage() . PHP_EOL; + $this->hasErrors = true; + } catch (\Exception $e) { + echo $indexer->getTitle() . " indexer process unknown error:" . PHP_EOL; + echo $e . PHP_EOL; + $this->hasErrors = true; + } + } + + return $this; + } + + /** + * Parses string with indexers and return array of indexer instances + * + * @param string $string + * @return Indexer[] + */ + protected function parseIndexerString($string) + { + $indexers = array(); + if ($string == 'all') { + /** @var Indexer[] $indexers */ + $indexers = $this->indexersFactory->create()->getItems(); + } else if (!empty($string)) { + $codes = explode(',', $string); + foreach ($codes as $code) { + $indexer = $this->indexerFactory->create(); + try { + $indexer->load($code); + $indexers[] = $indexer; + } catch (\Exception $e) { + echo 'Warning: Unknown indexer with code ' . trim($code) . PHP_EOL; + $this->hasErrors = true; + } + } + } + return $indexers; + } + + /** + * Return whether there errors have happened + * + * @return bool + */ + public function hasErrors() + { + return $this->hasErrors; + } + + /** + * Retrieves usage help message + * + * @return string + */ + public function getUsageHelp() + { + return <<<USAGE +Usage: php -f {$this->_entryPoint} -- [options] + + --status <indexer> Show Indexer(s) Status + --mode <indexer> Show Indexer(s) Index Mode + --mode-realtime <indexer> Set index mode type "Update on Save" + --mode-schedule <indexer> Set index mode type "Update by Schedule" + --reindex <indexer> Reindex Data + info Show allowed indexers + reindexall Reindex Data by all indexers + help This help + + <indexer> Comma separated indexer codes or value "all" for all indexers +USAGE; + } +} diff --git a/app/code/Magento/PaypalUk/etc/adminhtml/di.xml b/app/code/Magento/Indexer/etc/adminhtml/acl.xml similarity index 64% rename from app/code/Magento/PaypalUk/etc/adminhtml/di.xml rename to app/code/Magento/Indexer/etc/adminhtml/acl.xml index f406f6730c0e4b7e92dae0bad9713303ee8d35f1..24ab4689680e1b92eddef3d4277b6281153ed551 100644 --- a/app/code/Magento/PaypalUk/etc/adminhtml/di.xml +++ b/app/code/Magento/Indexer/etc/adminhtml/acl.xml @@ -24,17 +24,16 @@ */ --> <config> - <virtualType name="Magento\PaypalUk\Model\Session\Storage" type="Magento\Session\Storage"> - <param name="namespace"> - <value>paypaluk</value> - </param> - </virtualType> - <virtualType name="Magento\PaypalUk\Model\Session" type="Magento\Session\Generic"> - <param name="storage"> - <instance type="Magento\PaypalUk\Model\Session\Storage" /> - </param> - <param name="sessionName"> - <value>adminhtml</value> - </param> - </virtualType> + <acl> + <resources> + <resource id="Magento_Adminhtml::admin"> + <resource id="Magento_Adminhtml::system"> + <resource id="Magento_Adminhtml::tools"> + <resource id="Magento_Indexer::index" title="New Index Management" sortOrder="30" /> + <resource id="Magento_Indexer::changeMode" title="Change indexer mode" sortOrder="40" /> + </resource> + </resource> + </resource> + </resources> + </acl> </config> diff --git a/app/code/Magento/Indexer/etc/adminhtml/menu.xml b/app/code/Magento/Indexer/etc/adminhtml/menu.xml new file mode 100644 index 0000000000000000000000000000000000000000..eae28eb605f2100325ac9fa6372c4e2fb2611633 --- /dev/null +++ b/app/code/Magento/Indexer/etc/adminhtml/menu.xml @@ -0,0 +1,30 @@ +<?xml version="1.0"?> +<!-- +/** + * 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) + */ +--> +<config> + <menu> + <add id="Magento_Indexer::system_index" title="New Index Management" module="Magento_Indexer" sortOrder="30" parent="Magento_Backend::system_tools" action="indexer/indexer/list" resource="Magento_Indexer::index"/> + </menu> +</config> diff --git a/app/code/Magento/Indexer/etc/adminhtml/routes.xml b/app/code/Magento/Indexer/etc/adminhtml/routes.xml new file mode 100644 index 0000000000000000000000000000000000000000..ee871b2e370349d42d147f0c7820e41c7fb8a30e --- /dev/null +++ b/app/code/Magento/Indexer/etc/adminhtml/routes.xml @@ -0,0 +1,32 @@ +<?xml version="1.0"?> +<!-- +/** + * 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) + */ +--> +<config> + <router id="admin"> + <route id="indexer" frontName="indexer"> + <module name="Magento_Indexer"/> + </route> + </router> +</config> diff --git a/app/code/Magento/Indexer/etc/crontab.xml b/app/code/Magento/Indexer/etc/crontab.xml new file mode 100644 index 0000000000000000000000000000000000000000..55aece105ca417d7138898353171354a093296c5 --- /dev/null +++ b/app/code/Magento/Indexer/etc/crontab.xml @@ -0,0 +1,36 @@ +<?xml version="1.0"?> +<!-- +/** + * 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) + */ +--> +<config> + <job name="indexer_reindex_all_invalid" instance="Magento\Indexer\Model\Processor" method="reindexAllInvalid"> + <schedule>* * * * *</schedule> + </job> + <job name="indexer_update_all_views" instance="Magento\Indexer\Model\Processor" method="updateMview"> + <schedule>* * * * *</schedule> + </job> + <job name="indexer_clean_all_changelogs" instance="Magento\Indexer\Model\Processor" method="clearChangelog"> + <schedule>0 * * * *</schedule> + </job> +</config> diff --git a/app/code/Magento/Indexer/etc/di.xml b/app/code/Magento/Indexer/etc/di.xml new file mode 100644 index 0000000000000000000000000000000000000000..01003bc4b1d5e5280c119658129a6a749b579103 --- /dev/null +++ b/app/code/Magento/Indexer/etc/di.xml @@ -0,0 +1,33 @@ +<?xml version="1.0"?> +<!-- +/** + * 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) + */ +--> +<config> + <preference for="Magento\Indexer\Model\ConfigInterface" type="Magento\Indexer\Model\Config" /> + <type name="Magento\Indexer\Model\Indexer"> + <param name="view"> + <instance type="Magento\Mview\View" shared="false"/> + </param> + </type> +</config> \ No newline at end of file diff --git a/app/code/Magento/Indexer/etc/indexer.xsd b/app/code/Magento/Indexer/etc/indexer.xsd new file mode 100644 index 0000000000000000000000000000000000000000..29bdac34f384e7bde40cbe0aaafd5d5cc127bc23 --- /dev/null +++ b/app/code/Magento/Indexer/etc/indexer.xsd @@ -0,0 +1,99 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- +/** + * 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) + */ +--> +<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> + <xs:element name="config"> + <xs:complexType> + <xs:sequence> + <xs:element name="indexer" type="indexerType" minOccurs="1" maxOccurs="unbounded" /> + </xs:sequence> + </xs:complexType> + <xs:unique name="uniqueIndexertId"> + <xs:annotation> + <xs:documentation> + Indexer Id must be unique. + </xs:documentation> + </xs:annotation> + <xs:selector xpath="indexer" /> + <xs:field xpath="@id" /> + <xs:field xpath="@view_id" /> + </xs:unique> + <xs:unique name="uniqueViewId"> + <xs:annotation> + <xs:documentation> + Indexer Id must be unique. + </xs:documentation> + </xs:annotation> + <xs:selector xpath="indexer" /> + <xs:field xpath="@view_id" /> + </xs:unique> + </xs:element> + + <xs:complexType name="indexerType"> + <xs:annotation> + <xs:documentation> + Indexer declaration. + </xs:documentation> + </xs:annotation> + <xs:sequence> + <xs:element name="title" type="translatableType" /> + <xs:element name="description" type="translatableType" /> + </xs:sequence> + <xs:attribute name="id" type="xs:string" use="required" /> + <xs:attribute name="view_id" type="viewIdType" use="required" /> + <xs:attribute name="class" type="classType" use="required" /> + </xs:complexType> + + <xs:complexType name="translatableType"> + <xs:simpleContent> + <xs:extension base="xs:string"> + <xs:attribute name="translate" use="optional" fixed="true" type="xs:boolean"/> + </xs:extension> + </xs:simpleContent> + </xs:complexType> + + <xs:simpleType name="viewIdType"> + <xs:annotation> + <xs:documentation> + View ID can contain only [a-zA-Z0-9_]. + </xs:documentation> + </xs:annotation> + <xs:restriction base="xs:string"> + <xs:pattern value="[a-zA-Z0-9_]+" /> + </xs:restriction> + </xs:simpleType> + + <xs:simpleType name="classType"> + <xs:annotation> + <xs:documentation> + Class name can contain only [a-zA-Z\]. + </xs:documentation> + </xs:annotation> + <xs:restriction base="xs:string"> + <xs:pattern value="[a-zA-Z\\]+" /> + </xs:restriction> + </xs:simpleType> + +</xs:schema> diff --git a/app/code/Magento/Indexer/etc/module.xml b/app/code/Magento/Indexer/etc/module.xml new file mode 100644 index 0000000000000000000000000000000000000000..5906d1b2aeb6f497ad4dc30c10edec1e513332b6 --- /dev/null +++ b/app/code/Magento/Indexer/etc/module.xml @@ -0,0 +1,36 @@ +<?xml version="1.0"?> +<!-- +/** + * 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) + */ +--> +<config> + <module name="Magento_Indexer" version="1.0.0.0" active="true"> + <sequence> + <module name="Magento_Core"/> + </sequence> + <depends> + <module name="Magento_Core"/> + <module name="Magento_Backend"/> + </depends> + </module> +</config> diff --git a/app/code/Magento/Indexer/sql/indexer_setup/install-1.0.0.0.php b/app/code/Magento/Indexer/sql/indexer_setup/install-1.0.0.0.php new file mode 100644 index 0000000000000000000000000000000000000000..e15f16222763a93e462bbffe1b24a6c4f3a23569 --- /dev/null +++ b/app/code/Magento/Indexer/sql/indexer_setup/install-1.0.0.0.php @@ -0,0 +1,53 @@ +<?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) + */ + +$installer = $this; +/* @var $installer \Magento\Core\Model\Resource\Setup */ + +$installer->startSetup(); + +/** + * Create table 'indexer_state' + */ +$table = $installer->getConnection() + ->newTable($installer->getTable('indexer_state')) + ->addColumn('state_id', \Magento\DB\Ddl\Table::TYPE_INTEGER, null, array( + 'identity' => true, + 'unsigned' => true, + 'nullable' => false, + 'primary' => true, + ), 'Indexer State Id') + ->addColumn('indexer_id', \Magento\DB\Ddl\Table::TYPE_TEXT, 255, array( + ), 'Indexer Id') + ->addColumn('status', \Magento\DB\Ddl\Table::TYPE_TEXT, 16, array( + 'default' => \Magento\Indexer\Model\Indexer\State::STATUS_INVALID, + ), 'Indexer Status') + ->addColumn('updated', \Magento\DB\Ddl\Table::TYPE_DATETIME, null, array( + ), 'Indexer Status') + ->addIndex($installer->getIdxName('indexer_state', array('indexer_id')), + array('indexer_id')) + ->setComment('Indexer State'); +$installer->getConnection()->createTable($table); + +$installer->endSetup(); diff --git a/app/code/Magento/Indexer/view/adminhtml/layout/indexer_indexer_list.xml b/app/code/Magento/Indexer/view/adminhtml/layout/indexer_indexer_list.xml new file mode 100644 index 0000000000000000000000000000000000000000..f5ceab83e0b36d092effde7aa2088e4071cf8a25 --- /dev/null +++ b/app/code/Magento/Indexer/view/adminhtml/layout/indexer_indexer_list.xml @@ -0,0 +1,31 @@ +<?xml version="1.0"?> +<!-- +/** + * 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) + */ +--> +<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <update handle="indexer_indexer_list_grid"/> + <referenceContainer name="content"> + <block class="Magento\Indexer\Block\Backend\Container" name="adminhtml.indexer.grid.container"/> + </referenceContainer> +</layout> \ No newline at end of file diff --git a/app/code/Magento/Indexer/view/adminhtml/layout/indexer_indexer_list_grid.xml b/app/code/Magento/Indexer/view/adminhtml/layout/indexer_indexer_list_grid.xml new file mode 100644 index 0000000000000000000000000000000000000000..ee5b6db133add6849fef211f5e30fdfb7a57d002 --- /dev/null +++ b/app/code/Magento/Indexer/view/adminhtml/layout/indexer_indexer_list_grid.xml @@ -0,0 +1,115 @@ +<?xml version="1.0"?> +<!-- +/** + * 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) + */ +--> +<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <referenceBlock name="adminhtml.indexer.grid.container"> + <block class="Magento\Backend\Block\Widget\Grid" name="adminhtml.indexer.grid" as="grid"> + <arguments> + <argument name="use_ajax" xsi:type="string">0</argument> + <argument name="pager_visibility" xsi:type="string">0</argument> + <argument name="id" xsi:type="string">gridIndexer</argument> + <argument name="dataSource" xsi:type="object">Magento\Indexer\Model\Indexer\Collection</argument> + </arguments> + <block class="Magento\Backend\Block\Widget\Grid\Massaction" name="adminhtml.indexer.grid.grid.massaction" as="grid.massaction"> + <arguments> + <argument name="massaction_id_field" xsi:type="string">indexer_id</argument> + <argument name="form_field_name" xsi:type="string">indexer_ids</argument> + <argument name="use_select_all" xsi:type="string">1</argument> + <argument name="options" xsi:type="array"> + <updater>Magento\Indexer\Block\Backend\Grid\ItemsUpdater</updater> + <item name="change_mode_onthefly" xsi:type="array"> + <item name="label" xsi:type="string" translate="true">Update on Save</item> + <item name="url" xsi:type="string">*/indexer/massOnTheFly</item> + </item> + <item name="change_mode_changelog" xsi:type="array"> + <item name="label" xsi:type="string" translate="true">Update by Schedule</item> + <item name="url" xsi:type="string">*/indexer/massChangelog</item> + </item> + </argument> + </arguments> + </block> + <block class="Magento\Backend\Block\Widget\Grid\ColumnSet" as="grid.columnSet" name="adminhtml.indexer.grid.columnSet"> + <arguments> + <argument name="id" xsi:type="string">indexer_grid</argument> + <argument name="filter_visibility" xsi:type="string">0</argument> + </arguments> + <block class="Magento\Backend\Block\Widget\Grid\Column" as="indexer_title"> + <arguments> + <argument name="header" xsi:type="string" translate="true">Indexer</argument> + <argument name="width" xsi:type="string">180</argument> + <argument name="align" xsi:type="string">left</argument> + <argument name="index" xsi:type="string">title</argument> + <argument name="sortable" xsi:type="string">0</argument> + <argument name="column_css_class" xsi:type="string">indexer-title</argument> + </arguments> + </block> + <block class="Magento\Backend\Block\Widget\Grid\Column" as="indexer_description"> + <arguments> + <argument name="header" xsi:type="string" translate="true">Description</argument> + <argument name="align" xsi:type="string">left</argument> + <argument name="index" xsi:type="string">description</argument> + <argument name="sortable" xsi:type="string">0</argument> + <argument name="column_css_class" xsi:type="string">indexer-description</argument> + </arguments> + </block> + <block class="Magento\Backend\Block\Widget\Grid\Column" as="indexer_mode"> + <arguments> + <argument name="header" xsi:type="string" translate="true">Mode</argument> + <argument name="width" xsi:type="string">150</argument> + <argument name="align" xsi:type="string">left</argument> + <argument name="getter" xsi:type="string">getMode</argument> + <argument name="renderer" xsi:type="string">\Magento\Indexer\Block\Backend\Grid\Column\Renderer\Mode</argument> + <argument name="sortable" xsi:type="string">0</argument> + <argument name="column_css_class" xsi:type="string">indexer-mode</argument> + </arguments> + </block> + <block class="Magento\Backend\Block\Widget\Grid\Column" as="indexer_status"> + <arguments> + <argument name="header" xsi:type="string" translate="true">Status</argument> + <argument name="width" xsi:type="string">120</argument> + <argument name="align" xsi:type="string">left</argument> + <argument name="getter" xsi:type="string">getStatus</argument> + <argument name="renderer" xsi:type="string">\Magento\Indexer\Block\Backend\Grid\Column\Renderer\Status</argument> + <argument name="sortable" xsi:type="string">0</argument> + <argument name="column_css_class" xsi:type="string">indexer-status</argument> + </arguments> + </block> + <block class="Magento\Backend\Block\Widget\Grid\Column" as="indexer_updated"> + <arguments> + <argument name="header" xsi:type="string" translate="true">Updated</argument> + <argument name="width" xsi:type="string">180</argument> + <argument name="align" xsi:type="string">left</argument> + <argument name="index" xsi:type="string">updated</argument> + <argument name="type" xsi:type="string">datetime</argument> + <argument name="getter" xsi:type="string">getUpdated</argument> + <argument name="renderer" xsi:type="string">\Magento\Indexer\Block\Backend\Grid\Column\Renderer\Updated</argument> + <argument name="sortable" xsi:type="string">0</argument> + <argument name="column_css_class" xsi:type="string">indexer-updated</argument> + </arguments> + </block> + </block> + </block> + </referenceBlock> +</layout> diff --git a/app/code/Magento/Install/App/Console.php b/app/code/Magento/Install/App/Console.php index e35f7491681326e3bda95364264f4dc013b0d967..233df7afc90f9226c51ae13097bf9d8781b86f1b 100644 --- a/app/code/Magento/Install/App/Console.php +++ b/app/code/Magento/Install/App/Console.php @@ -27,7 +27,7 @@ namespace Magento\Install\App; use Magento\App\Console\Response; -class Console implements \Magento\AppInterface +class Console implements \Magento\LauncherInterface { /** * @var \Magento\Install\Model\Installer\ConsoleFactory @@ -155,7 +155,7 @@ class Console implements \Magento\AppInterface * * @return \Magento\App\ResponseInterface */ - public function execute() + public function launch() { $areaCode = 'install'; $this->_state->setAreaCode($areaCode); diff --git a/app/code/Magento/Install/Block/End.php b/app/code/Magento/Install/Block/End.php index 8c9f7254c8ffd36d2288b79779f1cbf2dee3bf96..0d427c0d60cd56ee5457626532b3754cf6790509 100644 --- a/app/code/Magento/Install/Block/End.php +++ b/app/code/Magento/Install/Block/End.php @@ -39,7 +39,7 @@ class End extends \Magento\Install\Block\AbstractBlock protected $_template = 'end.phtml'; /** - * @var \Magento\Core\Model\Config + * @var \Magento\App\ConfigInterface */ protected $_coreConfig; @@ -60,7 +60,7 @@ class End extends \Magento\Install\Block\AbstractBlock * @param \Magento\Install\Model\Installer $installer * @param \Magento\Install\Model\Wizard $installWizard * @param \Magento\Session\Generic $session - * @param \Magento\Core\Model\Config $coreConfig + * @param \Magento\App\ConfigInterface $coreConfig * @param \Magento\AdminNotification\Model\Survey $survey * @param $cryptKey * @param array $data @@ -70,7 +70,7 @@ class End extends \Magento\Install\Block\AbstractBlock \Magento\Install\Model\Installer $installer, \Magento\Install\Model\Wizard $installWizard, \Magento\Session\Generic $session, - \Magento\Core\Model\Config $coreConfig, + \Magento\App\ConfigInterface $coreConfig, \Magento\AdminNotification\Model\Survey $survey, $cryptKey, array $data = array() diff --git a/app/code/Magento/Install/Model/Installer.php b/app/code/Magento/Install/Model/Installer.php index 3cda1fc26d64c4c69c28cc1434f2d801c59660df..b3cc7b69e6abace708e0672e4b323cfde9d5f44c 100644 --- a/app/code/Magento/Install/Model/Installer.php +++ b/app/code/Magento/Install/Model/Installer.php @@ -56,7 +56,7 @@ class Installer extends \Magento\Object /** * Application config model * - * @var \Magento\Core\Model\ConfigInterface + * @var \Magento\App\ReinitableConfigInterface */ protected $_config; @@ -159,13 +159,20 @@ class Installer extends \Magento\Object protected $mathRandom; /** - * @param \Magento\Core\Model\ConfigInterface $config + * Configuration arguments + * + * @var \Magento\App\Arguments + */ + protected $_arguments; + + /** + * @param \Magento\App\ReinitableConfigInterface $config * @param \Magento\Module\UpdaterInterface $dbUpdater * @param \Magento\App\CacheInterface $cache * @param \Magento\App\Cache\TypeListInterface $cacheTypeList * @param \Magento\App\Cache\StateInterface $cacheState * @param \Magento\Module\Updater\SetupFactory $setupFactory - * @param \Magento\App\Config $localConfig + * @param \Magento\App\Arguments $arguments * @param \Magento\Core\Model\App $app * @param \Magento\App\State $appState * @param \Magento\Core\Model\StoreManagerInterface $storeManager @@ -181,13 +188,13 @@ class Installer extends \Magento\Object * @param array $data */ public function __construct( - \Magento\Core\Model\ConfigInterface $config, + \Magento\App\ReinitableConfigInterface $config, \Magento\Module\UpdaterInterface $dbUpdater, \Magento\App\CacheInterface $cache, \Magento\App\Cache\TypeListInterface $cacheTypeList, \Magento\App\Cache\StateInterface $cacheState, \Magento\Module\Updater\SetupFactory $setupFactory, - \Magento\App\Config $localConfig, + \Magento\App\Arguments $arguments, \Magento\Core\Model\App $app, \Magento\App\State $appState, \Magento\Core\Model\StoreManagerInterface $storeManager, @@ -211,7 +218,7 @@ class Installer extends \Magento\Object $this->_encryptor = $encryptor; $this->mathRandom = $mathRandom; parent::__construct($data); - $this->_localConfig = $localConfig; + $this->_arguments = $arguments; $this->_app = $app; $this->_appState = $appState; $this->_storeManager = $storeManager; @@ -323,7 +330,7 @@ class Installer extends \Magento\Object ->setConfigData($data) ->install(); - $this->_localConfig->reload(); + $this->_arguments->reload(); $this->_resource->setTablePrefix($data['db_prefix']); $this->_config->reinit(); diff --git a/app/code/Magento/Install/Model/Installer/Db/AbstractDb.php b/app/code/Magento/Install/Model/Installer/Db/AbstractDb.php index f74d53aa7fff46f821038e8b9237ac0a8bfb7d5c..f6581c25612265ae34748e6a6c2a360fb7044fcb 100644 --- a/app/code/Magento/Install/Model/Installer/Db/AbstractDb.php +++ b/app/code/Magento/Install/Model/Installer/Db/AbstractDb.php @@ -70,20 +70,26 @@ abstract class AbstractDb */ protected $_configData; + /** + * Configuration arguments + * + * @var \Magento\App\Arguments + */ + protected $_arguments; /** * @param \Magento\Core\Model\Resource\Type\Db\Pdo\MysqlFactory $adapterFactory - * @param \Magento\App\Config $localConfig + * @param \Magento\App\Arguments $arguments * @param array $dbExtensions */ public function __construct( \Magento\Core\Model\Resource\Type\Db\Pdo\MysqlFactory $adapterFactory, - \Magento\App\Config $localConfig, + \Magento\App\Arguments $arguments, array $dbExtensions = array() ) { $this->_adapterFactory = $adapterFactory; $this->_dbExtensions = $dbExtensions; - $this->_localConfig = $localConfig; + $this->_arguments = $arguments; } /** @@ -134,7 +140,7 @@ abstract class AbstractDb 'pdoType' => $this->getPdoType() ); } else { - $default = $this->_localConfig->getConnection('default'); + $default = $this->_arguments->getConnection('default'); $connectionData = array( 'host' => $default['host'], 'username' => $default['username'], diff --git a/app/code/Magento/Install/etc/di.xml b/app/code/Magento/Install/etc/di.xml index 94470d83d9df2cbbf4a06df0853d6c5519216181..e9504dd992f76df61caa8c308124518e46ca4aff 100644 --- a/app/code/Magento/Install/etc/di.xml +++ b/app/code/Magento/Install/etc/di.xml @@ -53,22 +53,26 @@ </type> <type name="Magento\Install\Model\Installer\Db"> <param name="dbConfig"> - <value> - <mysql4> - <type>pdo_mysql</type> - <initStatements>SET NAMES utf8</initStatements> - <min_version>4.1.20</min_version> - </mysql4> - </value> + <array> + <item key="mysql4"> + <array> + <item key="type"><value>pdo_mysql</value></item> + <item key="initStatements"><value>SET NAMES utf8</value></item> + <item key="min_version"><value>4.1.20</value></item> + </array> + </item> + </array> </param> </type> <type name="Magento\Install\Model\Installer\Db\AbstractDb"> <param name="dbExtensions"> - <value> - <mysql4> - <pdo>pdo_mysql</pdo> - </mysql4> - </value> + <array> + <item key="mysql4"> + <array> + <item key="pdo"><value>pdo_mysql</value></item> + </array> + </item> + </array> </param> </type> <type name="Magento\Install\Model\Config\Reader"> @@ -137,15 +141,17 @@ </type> <type name="Magento\App\AreaList"> <param name="areas"> - <value> - <install> - <frontName>install</frontName> - <router>install</router> - </install> - </value> + <array> + <item key="install"> + <array> + <item key="frontName"><value>install</value></item> + <item key="router"><value>install</value></item> + </array> + </item> + </array> </param> </type> - <type name="Magento\Backend\Model\Url"> + <type name="Magento\Backend\Model\Url\ScopeResolver" shared="false"> <param name="areaCode"> <value>adminhtml</value> </param> diff --git a/app/code/Magento/Install/etc/frontend/di.xml b/app/code/Magento/Install/etc/frontend/di.xml index 14ed2d04e343fba482b3c2e35c982ee82ac25c71..08ed9dee82e332e3ec63d53706b1f5fd19a10e63 100644 --- a/app/code/Magento/Install/etc/frontend/di.xml +++ b/app/code/Magento/Install/etc/frontend/di.xml @@ -26,9 +26,9 @@ <config> <type name="Magento\Core\Model\Url\SecurityInfo"> <param name="secureUrlList"> - <value> - <install>/install/wizard/checkSecureHost</install> - </value> + <array> + <item key="install"><value>/install/wizard/checkSecureHost</value></item> + </array> </param> </type> <virtualType name="Magento\Install\Model\Session\Storage" type="Magento\Session\Storage"> diff --git a/app/code/Magento/Install/etc/install/di.xml b/app/code/Magento/Install/etc/install/di.xml index 18b28f198f73355ec81e823dbbbb2516ec5019d6..fdd72048ef3eac2696b5f1b14b15709d87b7b7e4 100644 --- a/app/code/Magento/Install/etc/install/di.xml +++ b/app/code/Magento/Install/etc/install/di.xml @@ -27,13 +27,15 @@ <preference for="Magento\Core\Model\Theme" type="Magento\Core\Model\Theme\Data" /> <type name="Magento\App\RouterList" shared="true"> <param name="routerList"> - <value> - <install> - <instance>Magento\Core\App\Router\Base</instance> - <disable type="bool">false</disable> - <sortOrder>20</sortOrder> - </install> - </value> + <array> + <item key="install"> + <array> + <item key="instance"><value>Magento\Core\App\Router\Base</value></item> + <item key="disable"><value type="bool">false</value></item> + <item key="sortOrder"><value>20</value></item> + </array> + </item> + </array> </param> </type> <type name="Magento\Install\Controller\Action"> diff --git a/app/code/Magento/Log/App/Shell.php b/app/code/Magento/Log/App/Shell.php index fb56d6e8004cdcc3e7d45e2ae1c401421d4073e3..1d9a5688bf3a6ee72fbad3572348cfab536ee10f 100644 --- a/app/code/Magento/Log/App/Shell.php +++ b/app/code/Magento/Log/App/Shell.php @@ -26,9 +26,9 @@ namespace Magento\Log\App; use Magento\App\Console\Response; -use Magento\AppInterface; +use Magento\LauncherInterface; -class Shell implements AppInterface +class Shell implements LauncherInterface { /** * Filename of the entry point script @@ -68,7 +68,7 @@ class Shell implements AppInterface * * @return \Magento\App\ResponseInterface */ - public function execute() + public function launch() { /** @var $shell \Magento\Log\Model\Shell */ $shell = $this->_shellFactory->create(array('entryPoint' => $this->_entryFileName)); diff --git a/app/code/Magento/Log/Model/Aggregation.php b/app/code/Magento/Log/Model/Aggregation.php index db6dc90e6ceee85c0ac9429316c57ed875d6f3df..ba257b5f6faf062e23563ecb3063ead4a85f33bd 100644 --- a/app/code/Magento/Log/Model/Aggregation.php +++ b/app/code/Magento/Log/Model/Aggregation.php @@ -80,6 +80,7 @@ class Aggregation extends \Magento\Core\Model\AbstractModel /** * Run action + * @return void */ public function run() { @@ -104,7 +105,7 @@ class Aggregation extends \Magento\Core\Model\AbstractModel * Process * * @param int $store - * @return mixed + * @return null|array */ private function _process($store) { @@ -136,9 +137,10 @@ class Aggregation extends \Magento\Core\Model\AbstractModel /** * Save log data * - * @param array $data - * @param string $from - * @param string $to + * @param array $data + * @param string $from + * @param string $to + * @return void */ private function _save($data, $from, $to) { @@ -150,21 +152,45 @@ class Aggregation extends \Magento\Core\Model\AbstractModel } } + /** + * Update log data + * + * @param int $id + * @param array $data + * @return mixed + */ private function _update($id, $data) { return $this->_getResource()->saveLog($data, $id); } + /** + * Insert log data + * + * @param array $data + * @return mixed + */ private function _insert($data) { return $this->_getResource()->saveLog($data); } + /** + * @param string $from + * @param string $to + * @param int $store + * @return array + */ private function _getCounts($from, $to, $store) { return $this->_getResource()->getCounts($from, $to, $store); } + /** + * Get last recorded date + * + * @return bool|string + */ public function getLastRecordDate() { $result = $this->_getResource()->getLastRecordDate(); @@ -174,6 +200,13 @@ class Aggregation extends \Magento\Core\Model\AbstractModel return $result; } + /** + * Get date + * + * @param int|string $in + * @param null $offset + * @return bool|string + */ private function _date($in, $offset = null) { $out = $in; @@ -183,6 +216,13 @@ class Aggregation extends \Magento\Core\Model\AbstractModel return $out; } + /** + * Get timestamp + * + * @param int|string $in + * @param null $offset + * @return int + */ private function _timestamp($in, $offset = null) { $out = $in; @@ -193,7 +233,7 @@ class Aggregation extends \Magento\Core\Model\AbstractModel } /** - * @param $in + * @param int|string $in * @return string */ private function _round($in) diff --git a/app/code/Magento/Log/Model/Log.php b/app/code/Magento/Log/Model/Log.php index a3f4c3e818d4018613095fd8586340d3ff1ec6cb..b16efc3fa5c61661581153910e49124010d330f0 100644 --- a/app/code/Magento/Log/Model/Log.php +++ b/app/code/Magento/Log/Model/Log.php @@ -87,6 +87,10 @@ class Log extends \Magento\Core\Model\AbstractModel $this->_init('Magento\Log\Model\Resource\Log'); } + /** + * Return log clean time in seconds + * @return null|string + */ public function getLogCleanTime() { return $this->_coreStoreConfig->getConfig(self::XML_LOG_CLEAN_DAYS) * 60 * 60 * 24; diff --git a/app/code/Magento/Log/Model/Resource/Aggregation.php b/app/code/Magento/Log/Model/Resource/Aggregation.php index 62a7084078455e97f4611ff9942d2e8123016949..bf7a9748ae7f282221d063e931a8192452007f43 100644 --- a/app/code/Magento/Log/Model/Resource/Aggregation.php +++ b/app/code/Magento/Log/Model/Resource/Aggregation.php @@ -123,6 +123,7 @@ class Aggregation extends \Magento\Core\Model\Resource\Db\AbstractDb * Remove empty records * * @param string $date + * @return void */ public function removeEmpty($date) { diff --git a/app/code/Magento/Log/Model/Resource/Shell.php b/app/code/Magento/Log/Model/Resource/Shell.php index 8a09b9b6548372c1008398818bde2eb892809f1a..d119d9bfde0bb24d8185f534ce4cc8c895303a4c 100644 --- a/app/code/Magento/Log/Model/Resource/Shell.php +++ b/app/code/Magento/Log/Model/Resource/Shell.php @@ -60,7 +60,7 @@ class Shell /** * Retrieves information about log tables * - * @return array + * @return string[] */ public function getTablesInfo() { diff --git a/app/code/Magento/Log/Model/Resource/Visitor/Collection.php b/app/code/Magento/Log/Model/Resource/Visitor/Collection.php index e8345ee82d9b5c4f735993d06d45ea52dc1a4023..9453c6dbee4b34d131dd5c3a565f5d3e16b83a20 100644 --- a/app/code/Magento/Log/Model/Resource/Visitor/Collection.php +++ b/app/code/Magento/Log/Model/Resource/Visitor/Collection.php @@ -148,7 +148,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl * * @param string $fieldName * @param array $condition - * @return \Magento\Log\Model\Resource\Visitor\Collection + * @return $this */ public function addFieldToFilter($fieldName, $condition = null) { @@ -207,7 +207,8 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl /** * Filter visitors by specified store ids * - * @param array|int $storeIds + * @param int[]|int $storeIds + * @return void */ public function addVisitorStoreFilter($storeIds) { diff --git a/app/code/Magento/Log/Model/Resource/Visitor/Online/Collection.php b/app/code/Magento/Log/Model/Resource/Visitor/Online/Collection.php index 5994a3884e2eb88f1ccc65c601fb6e6e354ce1a5..82575aef75a9209ca7c6a631806c92a18e9d2404 100644 --- a/app/code/Magento/Log/Model/Resource/Visitor/Online/Collection.php +++ b/app/code/Magento/Log/Model/Resource/Visitor/Online/Collection.php @@ -134,8 +134,8 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl /** * Filter collection by specified website(s) * - * @param int|array $websiteIds - * @return \Magento\Log\Model\Resource\Visitor\Online\Collection + * @param int|int[] $websiteIds + * @return $this */ public function addWebsiteFilter($websiteIds) { diff --git a/app/code/Magento/Log/Model/Resource/Visitor/Online/Grid/Collection.php b/app/code/Magento/Log/Model/Resource/Visitor/Online/Grid/Collection.php index d5872c8a43e571270ed146c8e57e4fc1186b17d4..9c784e931fa0c2ad5c6a48e75f0524eeaf72952b 100644 --- a/app/code/Magento/Log/Model/Resource/Visitor/Online/Grid/Collection.php +++ b/app/code/Magento/Log/Model/Resource/Visitor/Online/Grid/Collection.php @@ -65,7 +65,7 @@ class Collection extends \Magento\Log\Model\Resource\Visitor\Online\Collection } /** - * @return \Magento\Log\Model\Resource\Visitor\Online\Grid\Collection + * @return $this */ protected function _initSelect() { diff --git a/app/code/Magento/Log/Model/Resource/Visitor/Online/Grid/Row/UrlGenerator.php b/app/code/Magento/Log/Model/Resource/Visitor/Online/Grid/Row/UrlGenerator.php index cad7d4bb0dc62919800eacc6139367698740e7c1..4363ad68c645130e7ad6ce97ebecc44699913ea6 100644 --- a/app/code/Magento/Log/Model/Resource/Visitor/Online/Grid/Row/UrlGenerator.php +++ b/app/code/Magento/Log/Model/Resource/Visitor/Online/Grid/Row/UrlGenerator.php @@ -35,12 +35,12 @@ class UrlGenerator protected $_authorization; /** - * @param \Magento\Backend\Model\Url $backendUrl + * @param \Magento\Backend\Model\UrlInterface $backendUrl * @param \Magento\AuthorizationInterface $authorization * @param array $args */ public function __construct( - \Magento\Backend\Model\Url $backendUrl, + \Magento\Backend\Model\UrlInterface $backendUrl, \Magento\AuthorizationInterface $authorization, array $args = array() ) { diff --git a/app/code/Magento/Log/Model/Shell/Command/Clean.php b/app/code/Magento/Log/Model/Shell/Command/Clean.php index bff4ad28152a0668a7fb5f0fff0e91f528812516..86c8b0e489bb9ca0d26c4be6edcb73f32c4add42 100644 --- a/app/code/Magento/Log/Model/Shell/Command/Clean.php +++ b/app/code/Magento/Log/Model/Shell/Command/Clean.php @@ -23,15 +23,18 @@ */ namespace Magento\Log\Model\Shell\Command; +use Magento\Core\Model\StoreManagerInterface; +use Magento\Log\Model\LogFactory; + class Clean implements \Magento\Log\Model\Shell\CommandInterface { /** - * @var \Magento\Core\Model\StoreManagerInterface + * @var StoreManagerInterface */ protected $_storeManager; /** - * @var \Magento\Log\Model\LogFactory + * @var LogFactory */ protected $_logFactory; @@ -42,9 +45,14 @@ class Clean implements \Magento\Log\Model\Shell\CommandInterface */ protected $_days; + /** + * @param StoreManagerInterface $storeManager + * @param LogFactory $logFactory + * @param int $days + */ public function __construct( - \Magento\Core\Model\StoreManagerInterface $storeManager, - \Magento\Log\Model\LogFactory $logFactory, + StoreManagerInterface $storeManager, + LogFactory $logFactory, $days ) { $this->_storeManager = $storeManager; diff --git a/app/code/Magento/Log/Model/Shell/Command/Status.php b/app/code/Magento/Log/Model/Shell/Command/Status.php index ab7e6a5b487754d77b0c854685f61159550c361e..98cb58ea2750f078cfc91882ea7e60b41a52d78b 100644 --- a/app/code/Magento/Log/Model/Shell/Command/Status.php +++ b/app/code/Magento/Log/Model/Shell/Command/Status.php @@ -49,6 +49,7 @@ class Status implements \Magento\Log\Model\Shell\CommandInterface * Add output data * * @param string $output + * @return void */ protected function _addOutput($output) { @@ -105,6 +106,8 @@ class Status implements \Magento\Log\Model\Shell\CommandInterface /** * Add row delimiter + * + * @return void */ protected function _addRowDelimiter() { diff --git a/app/code/Magento/Log/Model/Visitor.php b/app/code/Magento/Log/Model/Visitor.php index 8a6d85e7c4500097a36686d9edd768c7f8987c15..f0f182386896273741b58e223df5a2eb00358ed9 100644 --- a/app/code/Magento/Log/Model/Visitor.php +++ b/app/code/Magento/Log/Model/Visitor.php @@ -50,7 +50,7 @@ class Visitor extends \Magento\Core\Model\AbstractModel protected $_skipRequestLogging = false; /** - * @var array + * @var string[] */ protected $_ignoredUserAgents; @@ -62,7 +62,7 @@ class Visitor extends \Magento\Core\Model\AbstractModel protected $_coreStoreConfig; /** - * @var \Magento\Core\Model\Config + * @var \Magento\App\ConfigInterface */ protected $_coreConfig; @@ -73,7 +73,7 @@ class Visitor extends \Magento\Core\Model\AbstractModel */ protected $_ignores; - /* + /** * @var \Magento\Core\Model\StoreManagerInterface */ protected $_storeManager; @@ -121,14 +121,14 @@ class Visitor extends \Magento\Core\Model\AbstractModel * @param \Magento\Sales\Model\QuoteFactory $quoteFactory * @param \Magento\Session\SessionManagerInterface $session * @param \Magento\Core\Model\StoreManagerInterface $storeManager - * @param \Magento\Core\Model\Config $coreConfig + * @param \Magento\App\ConfigInterface $coreConfig * @param \Magento\HTTP\Header $httpHeader * @param \Magento\HTTP\PhpEnvironment\RemoteAddress $remoteAddress * @param \Magento\HTTP\PhpEnvironment\ServerAddress $serverAddress * @param \Magento\Stdlib\DateTime $dateTime * @param \Magento\Core\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection - * @param array $ignoredUserAgents + * @param string[] $ignoredUserAgents * @param array $ignores * @param array $data */ @@ -140,7 +140,7 @@ class Visitor extends \Magento\Core\Model\AbstractModel \Magento\Sales\Model\QuoteFactory $quoteFactory, \Magento\Session\SessionManagerInterface $session, \Magento\Core\Model\StoreManagerInterface $storeManager, - \Magento\Core\Model\Config $coreConfig, + \Magento\App\ConfigInterface $coreConfig, \Magento\HTTP\Header $httpHeader, \Magento\HTTP\PhpEnvironment\RemoteAddress $remoteAddress, \Magento\HTTP\PhpEnvironment\ServerAddress $serverAddress, @@ -240,6 +240,11 @@ class Visitor extends \Magento\Core\Model\AbstractModel return $url; } + /** + * Return First Visit data in internal format. + * + * @return string + */ public function getFirstVisitAt() { if (!$this->hasData('first_visit_at')) { @@ -248,6 +253,11 @@ class Visitor extends \Magento\Core\Model\AbstractModel return $this->getData('first_visit_at'); } + /** + * Return Last Visit data in internal format. + * + * @return string + */ public function getLastVisitAt() { if (!$this->hasData('last_visit_at')) { @@ -341,6 +351,8 @@ class Visitor extends \Magento\Core\Model\AbstractModel } /** + * Create binding of checkout quote + * * @param \Magento\Event\Observer $observer * @return $this */ @@ -357,6 +369,7 @@ class Visitor extends \Magento\Core\Model\AbstractModel } /** + * Destroy binding of checkout quote * @param \Magento\Event\Observer $observer * @return $this */ @@ -371,6 +384,9 @@ class Visitor extends \Magento\Core\Model\AbstractModel /** * Methods for research (depends from customer online admin section) + * + * @param array $data + * @return $this */ public function addIpData($data) { @@ -380,6 +396,8 @@ class Visitor extends \Magento\Core\Model\AbstractModel } /** + * Load customer data into $data + * * @param object $data * @return $this */ @@ -400,6 +418,8 @@ class Visitor extends \Magento\Core\Model\AbstractModel } /** + * Load quote data into $data + * * @param object $data * @return $this */ @@ -414,6 +434,8 @@ class Visitor extends \Magento\Core\Model\AbstractModel } /** + * Returns true if the module is required + * * @param \Magento\Event\Observer $observer * @return bool */ diff --git a/app/code/Magento/Log/etc/di.xml b/app/code/Magento/Log/etc/di.xml index 56de1c1c016700437161e538535d272c147455ba..6fa6f57f52d9a68d12706ee4384453fc4731e1e7 100644 --- a/app/code/Magento/Log/etc/di.xml +++ b/app/code/Magento/Log/etc/di.xml @@ -31,11 +31,11 @@ </type> <type name="Magento\Log\Model\Visitor"> <param name="ignoredUserAgents"> - <value> - <google1>Googlebot/1.0 (googlebot@googlebot.com http://googlebot.com/)</google1> - <google2>Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)</google2> - <google3>Googlebot/2.1 (+http://www.googlebot.com/bot.html)</google3> - </value> + <array> + <item key="google1"><value>Googlebot/1.0 (googlebot@googlebot.com http://googlebot.com/)</value></item> + <item key="google2"><value>Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)</value></item> + <item key="google3"><value>Googlebot/2.1 (+http://www.googlebot.com/bot.html)</value></item> + </array> </param> </type> </config> diff --git a/app/code/Magento/Multishipping/Block/Checkout/Overview.php b/app/code/Magento/Multishipping/Block/Checkout/Overview.php index 9e1caad669920206a25a7dc15c55fec2c4a51498..be417ca7f58aa90023e6f595a0cbb5a6ea41b5ba 100644 --- a/app/code/Magento/Multishipping/Block/Checkout/Overview.php +++ b/app/code/Magento/Multishipping/Block/Checkout/Overview.php @@ -73,14 +73,6 @@ class Overview extends \Magento\Sales\Block\Items\AbstractItems */ protected function _prepareLayout() { - $rowItemType = $this->_getRowItemType(self::DEFAULT_TYPE); - if (!$this->getChildBlock($rowItemType)) { - $this->addChild( - $rowItemType, - 'Magento\Checkout\Block\Cart\Item\Renderer', - array('template' => 'Magento_Multishipping::checkout/overview/item.phtml') - ); - } $headBlock = $this->getLayout()->getBlock('head'); if ($headBlock) { $headBlock->setTitle( @@ -373,22 +365,10 @@ class Overview extends \Magento\Sales\Block\Items\AbstractItems */ protected function _getRowItemRenderer($type) { - $renderer = $this->getChildBlock($this->_getRowItemType($type)); - if ($renderer instanceof \Magento\View\Element\BlockInterface) { - $renderer->setRenderedBlock($this); - return $renderer; + $renderer = $this->getItemRenderer($type); + if ($renderer !== $this->getItemRenderer(self::DEFAULT_TYPE)) { + $renderer->setTemplate($this->getRowRendererTemplate()); } - return parent::getItemRenderer($this->_getRowItemType(self::DEFAULT_TYPE)); - } - - /** - * Wrap row renderers into namespace by adding 'row-' prefix - * - * @param string $type Product type - * @return string - */ - protected function _getRowItemType($type) - { - return 'row-' . $type; + return $renderer; } } diff --git a/app/code/Magento/Multishipping/Controller/Checkout.php b/app/code/Magento/Multishipping/Controller/Checkout.php index b63b4d91fe42562a76ff5599c545f66f1b37b33a..9b1642fd76ca3603fcaeb39fd10a9030747da1df 100644 --- a/app/code/Magento/Multishipping/Controller/Checkout.php +++ b/app/code/Magento/Multishipping/Controller/Checkout.php @@ -77,24 +77,15 @@ class Checkout extends \Magento\Checkout\Controller\Action return $this->_objectManager->get('Magento\Checkout\Model\Session'); } - /** - * @var \Magento\Core\Model\Url - */ - protected $_urlBuilder; - - /** * @param \Magento\App\Action\Context $context * @param \Magento\Customer\Model\Session $customerSession - * @param \Magento\Core\Model\Url $urlBuilder */ public function __construct( \Magento\App\Action\Context $context, - \Magento\Customer\Model\Session $customerSession, - \Magento\Core\Model\Url $urlBuilder + \Magento\Customer\Model\Session $customerSession ) { parent::__construct($context, $customerSession); - $this->_urlBuilder = $urlBuilder; } /** @@ -217,7 +208,7 @@ class Checkout extends \Magento\Checkout\Controller\Action $registerForm->setShowAddressFields(true) ->setBackUrl($this->_getHelper()->getMSLoginUrl()) ->setSuccessUrl($this->_getHelper()->getMSShippingAddressSavedUrl()) - ->setErrorUrl($this->_urlBuilder->getCurrentUrl()); + ->setErrorUrl($this->_url->getCurrentUrl()); } $this->_view->renderLayout(); diff --git a/app/code/Magento/Multishipping/etc/frontend/di.xml b/app/code/Magento/Multishipping/etc/frontend/di.xml index b8ee929ff009aaa33f5f2f7596bf69f3bbe12ac8..1aafdd30e2f9a509c106e1c0c6d8c4d35f0423de 100644 --- a/app/code/Magento/Multishipping/etc/frontend/di.xml +++ b/app/code/Magento/Multishipping/etc/frontend/di.xml @@ -26,9 +26,9 @@ <config> <type name="Magento\Core\Model\Url\SecurityInfo"> <param name="secureUrlList"> - <value> - <multishipping_checkout>/multishipping/checkout</multishipping_checkout> - </value> + <array> + <item key="multishipping_checkout"><value>/multishipping/checkout</value></item> + </array> </param> </type> </config> diff --git a/app/code/Magento/Multishipping/view/frontend/layout/multishipping_checkout_addresses.xml b/app/code/Magento/Multishipping/view/frontend/layout/multishipping_checkout_addresses.xml index 1169fa4cb3afef8bee5288f1e8e5e321c13d3a0e..ca2b0b54bfe142c99f712e29137d0ee257a741a5 100644 --- a/app/code/Magento/Multishipping/view/frontend/layout/multishipping_checkout_addresses.xml +++ b/app/code/Magento/Multishipping/view/frontend/layout/multishipping_checkout_addresses.xml @@ -25,6 +25,7 @@ --> <layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <update handle="multishipping_checkout"/> + <update handle="checkout_cart_item_renderers" /> <referenceBlock name="page.main.title"> <action method="setPageTitle"> <argument translate="true" name="label" xsi:type="string">Ship to Multiple Addresses</argument> @@ -32,9 +33,10 @@ </referenceBlock> <referenceContainer name="content"> <block class="Magento\Multishipping\Block\Checkout\Addresses" name="checkout_addresses" template="checkout/addresses.phtml" cacheable="false"> - <block class="Magento\Checkout\Block\Cart\Item\Renderer" as="default" template="Magento_Multishipping::checkout/item/default.phtml" cacheable="false"/> - <block class="Magento\Checkout\Block\Cart\Item\Renderer\Grouped" as="grouped" template="Magento_Multishipping::checkout/item/default.phtml" cacheable="false"/> - <block class="Magento\Checkout\Block\Cart\Item\Renderer\Configurable" as="configurable" template="Magento_Multishipping::checkout/item/default.phtml" cacheable="false"/> + <arguments> + <argument name="renderer_template" xsi:type="string">Magento_Multishipping::checkout/item/default.phtml</argument> + </arguments> + <block class="Magento\View\Element\RendererList" name="checkout.cart.item.renderers" as="renderer.list" /> </block> </referenceContainer> <block class="Magento\View\Element\Template" name="additional.product.info" template="Magento_Core::template.phtml"/> diff --git a/app/code/Magento/Multishipping/view/frontend/layout/multishipping_checkout_overview.xml b/app/code/Magento/Multishipping/view/frontend/layout/multishipping_checkout_overview.xml index f52b3d6220be483a186a2838f9f57bb4f971ebf2..3ab2ed219a8280d8094a467f40640394fc965805 100644 --- a/app/code/Magento/Multishipping/view/frontend/layout/multishipping_checkout_overview.xml +++ b/app/code/Magento/Multishipping/view/frontend/layout/multishipping_checkout_overview.xml @@ -25,6 +25,7 @@ --> <layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <update handle="multishipping_checkout"/> + <update handle="checkout_cart_item_renderers" /> <referenceBlock name="page.main.title"> <action method="setPageTitle"> <argument translate="true" name="label" xsi:type="string">Review Order</argument> @@ -32,11 +33,11 @@ </referenceBlock> <referenceContainer name="content"> <block class="Magento\Multishipping\Block\Checkout\Overview" name="checkout_overview" template="checkout/overview.phtml" cacheable="false"> - <block class="Magento\Checkout\Block\Cart\Item\Renderer" as="default" template="Magento_Multishipping::checkout/item/default.phtml" cacheable="false"/> - <block class="Magento\Checkout\Block\Cart\Item\Renderer\Grouped" as="grouped" template="Magento_Multishipping::checkout/item/default.phtml" cacheable="false"/> - <block class="Magento\Checkout\Block\Cart\Item\Renderer\Configurable" as="configurable" template="Magento_Multishipping::checkout/item/default.phtml" cacheable="false"/> - <block class="Magento\Checkout\Block\Cart\Item\Renderer\Grouped" as="row-grouped" template="Magento_Multishipping::checkout/overview/item.phtml" cacheable="false"/> - <block class="Magento\Checkout\Block\Cart\Item\Renderer\Configurable" as="row-configurable" template="Magento_Multishipping::checkout/overview/item.phtml" cacheable="false"/> + <arguments> + <argument name="renderer_template" xsi:type="string">Magento_Multishipping::checkout/item/default.phtml</argument> + <argument name="row_renderer_template" xsi:type="string">Magento_Multishipping::checkout/overview/item.phtml</argument> + </arguments> + <block class="Magento\View\Element\RendererList" name="checkout.cart.item.renderers" as="renderer.list" /> <block class="Magento\Multishipping\Block\Checkout\Payment\Info" name="payment_info"> <action method="setInfoTemplate"> <argument name="method" xsi:type="string"/> diff --git a/app/code/Magento/Multishipping/view/frontend/layout/multishipping_checkout_shipping.xml b/app/code/Magento/Multishipping/view/frontend/layout/multishipping_checkout_shipping.xml index ab98a3006c98bb9953e15e5ddd63f09572ebda48..588681f989ae0ba79e8d5719dfa0c01aa0916f61 100644 --- a/app/code/Magento/Multishipping/view/frontend/layout/multishipping_checkout_shipping.xml +++ b/app/code/Magento/Multishipping/view/frontend/layout/multishipping_checkout_shipping.xml @@ -25,6 +25,7 @@ --> <layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <update handle="multishipping_checkout"/> + <update handle="checkout_cart_item_renderers" /> <referenceBlock name="page.main.title"> <action method="setPageTitle"> <argument translate="true" name="title" xsi:type="string">Shipping Information</argument> @@ -32,13 +33,15 @@ </referenceBlock> <referenceContainer name="content"> <block class="Magento\Multishipping\Block\Checkout\Shipping" name="checkout_shipping" template="checkout/shipping.phtml" cacheable="false"> - <block class="Magento\Checkout\Block\Cart\Item\Renderer" as="default" template="Magento_Multishipping::checkout/item/default.phtml" cacheable="false"/> - <block class="Magento\Checkout\Block\Cart\Item\Renderer\Grouped" as="grouped" template="Magento_Multishipping::checkout/item/default.phtml" cacheable="false"/> - <block class="Magento\Checkout\Block\Cart\Item\Renderer\Configurable" as="configurable" template="Magento_Multishipping::checkout/item/default.phtml" cacheable="false"/> + <arguments> + <argument name="renderer_template" xsi:type="string">Magento_Multishipping::checkout/item/default.phtml</argument> + </arguments> + <block class="Magento\View\Element\RendererList" name="checkout.cart.item.renderers" as="renderer.list"/> <block class="Magento\Multishipping\Block\Checkout\Billing\Items" name="checkout_billing_items" template="Magento_Multishipping::checkout/billing/items.phtml" cacheable="false"> - <block class="Magento\Checkout\Block\Cart\Item\Renderer" as="default" template="Magento_Multishipping::checkout/item/default.phtml" cacheable="false"/> - <block class="Magento\Checkout\Block\Cart\Item\Renderer\Grouped" as="grouped" template="Magento_Multishipping::checkout/item/default.phtml" cacheable="false"/> - <block class="Magento\Checkout\Block\Cart\Item\Renderer\Configurable" as="configurable" template="Magento_Multishipping::checkout/item/default.phtml" cacheable="false"/> + <arguments> + <argument name="renderer_template" xsi:type="string">Magento_Multishipping::checkout/item/default.phtml</argument> + <argument name="renderer_list_name" xsi:type="string">checkout.cart.item.renderers</argument> + </arguments> </block> </block> </referenceContainer> diff --git a/app/code/Magento/Newsletter/Block/Adminhtml/Problem.php b/app/code/Magento/Newsletter/Block/Adminhtml/Problem.php index 7e31654e47eb37c6d41c6d30ab81fa989233e7e4..44979e66fe841c19c90679747daa02183c7e4481 100644 --- a/app/code/Magento/Newsletter/Block/Adminhtml/Problem.php +++ b/app/code/Magento/Newsletter/Block/Adminhtml/Problem.php @@ -33,9 +33,14 @@ */ namespace Magento\Newsletter\Block\Adminhtml; +use Magento\Newsletter\Model\Resource\Problem\Collection; + class Problem extends \Magento\Backend\Block\Template { + /** + * @var string + */ protected $_template = 'problem/list.phtml'; /** @@ -45,12 +50,12 @@ class Problem extends \Magento\Backend\Block\Template /** * @param \Magento\Backend\Block\Template\Context $context - * @param \Magento\Newsletter\Model\Resource\Problem\Collection $problemCollection + * @param Collection $problemCollection * @param array $data */ public function __construct( \Magento\Backend\Block\Template\Context $context, - \Magento\Newsletter\Model\Resource\Problem\Collection $problemCollection, + Collection $problemCollection, array $data = array() ) { $this->_problemCollection = $problemCollection; @@ -65,6 +70,11 @@ class Problem extends \Magento\Backend\Block\Template ->addQueueInfo(); } + /** + * Prepare for the newsletter block layout + * + * @return $this + */ protected function _prepareLayout() { $this->setChild('deleteButton', @@ -89,16 +99,31 @@ class Problem extends \Magento\Backend\Block\Template return parent::_prepareLayout(); } + /** + * Get the html element for unsubscribe button + * + * @return $string + */ public function getUnsubscribeButtonHtml() { return $this->getChildHtml('unsubscribeButton'); } + /** + * Get the html element for delete button + * + * @return $string + */ public function getDeleteButtonHtml() { return $this->getChildHtml('deleteButton'); } + /** + * Return true if the size is greater than 0 + * + * @return bool + */ public function getShowButtons() { return $this->_problemCollection->getSize() > 0; diff --git a/app/code/Magento/Newsletter/Block/Adminhtml/Problem/Grid/Filter/Checkbox.php b/app/code/Magento/Newsletter/Block/Adminhtml/Problem/Grid/Filter/Checkbox.php index 7700dc0e11d6bbff523105fdfb4b4bc1e25ee3d7..13f7d257e238cbe063ad328819fe83dda676d52c 100644 --- a/app/code/Magento/Newsletter/Block/Adminhtml/Problem/Grid/Filter/Checkbox.php +++ b/app/code/Magento/Newsletter/Block/Adminhtml/Problem/Grid/Filter/Checkbox.php @@ -36,11 +36,21 @@ namespace Magento\Newsletter\Block\Adminhtml\Problem\Grid\Filter; class Checkbox extends \Magento\Backend\Block\Widget\Grid\Column\Filter\AbstractFilter { + /** + * Get the condition of grid filter checkbox + * + * @return array + */ public function getCondition() { return array(); } + /** + * Get html code for grid filter checkbox + * + * @return string + */ public function getHtml() { return '<input type="checkbox" onclick="problemController.checkCheckboxes(this)"/>'; diff --git a/app/code/Magento/Newsletter/Block/Adminhtml/Queue/Edit.php b/app/code/Magento/Newsletter/Block/Adminhtml/Queue/Edit.php index 4dc371cbe7807e8105c8651335876d7ebd737884..a60fe76a1558247d49ddd717556cb58ab936a0b2 100644 --- a/app/code/Magento/Newsletter/Block/Adminhtml/Queue/Edit.php +++ b/app/code/Magento/Newsletter/Block/Adminhtml/Queue/Edit.php @@ -29,8 +29,14 @@ */ namespace Magento\Newsletter\Block\Adminhtml\Queue; +use Magento\View\Element\AbstractBlock; +use Magento\Newsletter\Model\Queue as ModelQueue; + class Edit extends \Magento\Backend\Block\Template { + /** + * @var string + */ protected $_template = 'queue/edit.phtml'; /** @@ -74,13 +80,18 @@ class Edit extends \Magento\Backend\Block\Template /** * Retrieve current Newsletter Queue Object * - * @return \Magento\Newsletter\Model\Queue + * @return ModelQueue */ public function getQueue() { return $this->_coreRegistry->registry('current_queue'); } + /** + * Before rendering html, but after trying to load cache + * + * @return AbstractBlock + */ protected function _beforeToHtml() { $this->setChild('form', @@ -89,6 +100,11 @@ class Edit extends \Magento\Backend\Block\Template return parent::_beforeToHtml(); } + /** + * Get the url for save + * + * @return string + */ public function getSaveUrl() { if ($this->getTemplateId()) { @@ -99,6 +115,11 @@ class Edit extends \Magento\Backend\Block\Template return $this->getUrl('*/*/save', $params); } + /** + * Prepare for the layout + * + * @return AbstractBlock + */ protected function _prepareLayout() { // Load Wysiwyg on demand and Prepare layout @@ -218,20 +239,20 @@ class Edit extends \Magento\Backend\Block\Template /** * Getter for availability preview mode * - * @return boolean + * @return bool */ public function getIsPreview() { return !in_array($this->getQueue()->getQueueStatus(), array( - \Magento\Newsletter\Model\Queue::STATUS_NEVER, - \Magento\Newsletter\Model\Queue::STATUS_PAUSE + ModelQueue::STATUS_NEVER, + ModelQueue::STATUS_PAUSE )); } /** * Getter for single store mode check * - * @return boolean + * @return bool */ protected function isSingleStoreMode() { @@ -241,7 +262,7 @@ class Edit extends \Magento\Backend\Block\Template /** * Getter for id of current store (the only one in single-store mode and current in multi-stores mode) * - * @return boolean + * @return bool */ protected function getStoreId() { @@ -251,7 +272,7 @@ class Edit extends \Magento\Backend\Block\Template /** * Getter for check is this newsletter the plain text. * - * @return boolean + * @return bool */ public function getIsTextType() { @@ -261,19 +282,19 @@ class Edit extends \Magento\Backend\Block\Template /** * Getter for availability resume action * - * @return boolean + * @return bool */ public function getCanResume() { return in_array($this->getQueue()->getQueueStatus(), array( - \Magento\Newsletter\Model\Queue::STATUS_PAUSE + ModelQueue::STATUS_PAUSE )); } /** * Getter for header text * - * @return boolean + * @return bool */ public function getHeaderText() { diff --git a/app/code/Magento/Newsletter/Block/Adminhtml/Queue/Grid/Renderer/Action.php b/app/code/Magento/Newsletter/Block/Adminhtml/Queue/Grid/Renderer/Action.php index 91a3596f5c023b20008790ed3d0a7a7fcc550776..20ee5b3979afed00609a764c4b98666042ec68d3 100644 --- a/app/code/Magento/Newsletter/Block/Adminhtml/Queue/Grid/Renderer/Action.php +++ b/app/code/Magento/Newsletter/Block/Adminhtml/Queue/Grid/Renderer/Action.php @@ -36,6 +36,12 @@ namespace Magento\Newsletter\Block\Adminhtml\Queue\Grid\Renderer; class Action extends \Magento\Backend\Block\Widget\Grid\Column\Renderer\Action { + /** + * Renders column + * + * @param \Magento\Object $row + * @return string + */ public function render(\Magento\Object $row) { $actions = array(); diff --git a/app/code/Magento/Newsletter/Block/Adminhtml/Queue/Preview.php b/app/code/Magento/Newsletter/Block/Adminhtml/Queue/Preview.php index dfeccef6f9fcfcc43d6b2002e41fd804ef1a4ec4..3b953e5f61c344070b27bcebc86c21ff34b2f241 100644 --- a/app/code/Magento/Newsletter/Block/Adminhtml/Queue/Preview.php +++ b/app/code/Magento/Newsletter/Block/Adminhtml/Queue/Preview.php @@ -70,6 +70,11 @@ class Preview extends \Magento\Backend\Block\Widget parent::__construct($context, $data); } + /** + * Get html code + * + * @return string + */ protected function _toHtml() { /* @var $template \Magento\Newsletter\Model\Template */ diff --git a/app/code/Magento/Newsletter/Block/Adminhtml/Subscriber.php b/app/code/Magento/Newsletter/Block/Adminhtml/Subscriber.php index 76565e213e15d7bef0f75388f0ff4343d6b4023c..d7fd522ff77eb619e21db52b1fd8c943e6232659 100644 --- a/app/code/Magento/Newsletter/Block/Adminhtml/Subscriber.php +++ b/app/code/Magento/Newsletter/Block/Adminhtml/Subscriber.php @@ -34,15 +34,20 @@ namespace Magento\Newsletter\Block\Adminhtml; +use Magento\Newsletter\Model\Resource\Queue\Collection; + class Subscriber extends \Magento\Backend\Block\Template { /** * Queue collection * - * @var \Magento\Newsletter\Model\Resource\Queue\Collection + * @var Collection */ protected $_queueCollection = null; + /** + * @var string + */ protected $_template = 'subscriber/list.phtml'; /** @@ -67,7 +72,7 @@ class Subscriber extends \Magento\Backend\Block\Template /** * Prepares block to render * - * @return \Magento\Newsletter\Block\Adminhtml\Subscriber + * @return $this */ protected function _beforeToHtml() { @@ -77,7 +82,7 @@ class Subscriber extends \Magento\Backend\Block\Template /** * Return queue collection with loaded neversent queues * - * @return \Magento\Newsletter\Model\Resource\Queue\Collection + * @return Collection */ public function getQueueCollection() { @@ -92,6 +97,11 @@ class Subscriber extends \Magento\Backend\Block\Template return $this->_queueCollection; } + /** + * Get add option for queue + * + * @return mixed + */ public function getShowQueueAdd() { return $this->getChildBlock('grid')->getShowQueueAdd(); diff --git a/app/code/Magento/Newsletter/Block/Adminhtml/Subscriber/Grid.php b/app/code/Magento/Newsletter/Block/Adminhtml/Subscriber/Grid.php index f5a1508aa51235922cd2dd687b4e5c586278a580..7a3ab8b064c83e85e902e44e2c75528ac44a0f11 100644 --- a/app/code/Magento/Newsletter/Block/Adminhtml/Subscriber/Grid.php +++ b/app/code/Magento/Newsletter/Block/Adminhtml/Subscriber/Grid.php @@ -42,20 +42,18 @@ class Grid extends \Magento\Backend\Block\Widget\Grid /** * @param \Magento\Backend\Block\Template\Context $context - * @param \Magento\Core\Model\Url $urlModel * @param \Magento\Backend\Helper\Data $backendHelper * @param \Magento\Newsletter\Model\QueueFactory $queueFactory * @param array $data */ public function __construct( \Magento\Backend\Block\Template\Context $context, - \Magento\Core\Model\Url $urlModel, \Magento\Backend\Helper\Data $backendHelper, \Magento\Newsletter\Model\QueueFactory $queueFactory, array $data = array() ) { $this->_queueFactory = $queueFactory; - parent::__construct($context, $urlModel, $backendHelper, $data); + parent::__construct($context, $backendHelper, $data); } /** diff --git a/app/code/Magento/Newsletter/Block/Adminhtml/Subscriber/Grid/Filter/Checkbox.php b/app/code/Magento/Newsletter/Block/Adminhtml/Subscriber/Grid/Filter/Checkbox.php index 3f69b9d73ded23f8c83c43f34c231221055c3cea..9fbbb798be3da9810a233a73c8fd9cce083e727c 100644 --- a/app/code/Magento/Newsletter/Block/Adminhtml/Subscriber/Grid/Filter/Checkbox.php +++ b/app/code/Magento/Newsletter/Block/Adminhtml/Subscriber/Grid/Filter/Checkbox.php @@ -36,11 +36,21 @@ namespace Magento\Newsletter\Block\Adminhtml\Subscriber\Grid\Filter; class Checkbox extends \Magento\Backend\Block\Widget\Grid\Column\Filter\AbstractFilter { + /** + * Get the condition of grid filter checkbox + * + * @return array + */ public function getCondition() { return array(); } + /** + * Get html code for grid filter checkbox + * + * @return string + */ public function getHtml() { return '<input type="checkbox" onclick="subscriberController.checkCheckboxes(this)"/>'; diff --git a/app/code/Magento/Newsletter/Block/Adminhtml/Subscriber/Grid/Filter/Website.php b/app/code/Magento/Newsletter/Block/Adminhtml/Subscriber/Grid/Filter/Website.php index d42a3997cb651c0d9e5c159c874520d73a2d905e..5a02cb98f3a9b1a1d03d868b12f24a45b58c30d2 100644 --- a/app/code/Magento/Newsletter/Block/Adminhtml/Subscriber/Grid/Filter/Website.php +++ b/app/code/Magento/Newsletter/Block/Adminhtml/Subscriber/Grid/Filter/Website.php @@ -29,9 +29,16 @@ */ namespace Magento\Newsletter\Block\Adminhtml\Subscriber\Grid\Filter; +use Magento\Core\Model\Resource\Website\Collection; + class Website extends \Magento\Backend\Block\Widget\Grid\Column\Filter\Select { + /** + * Website collection + * + * @var Collection + */ protected $_websiteCollection = null; /** @@ -73,6 +80,11 @@ class Website parent::__construct($context, $resourceHelper, $data); } + /** + * Get options for grid filter + * + * @return array + */ protected function _getOptions() { $result = $this->getCollection()->toOptionArray(); @@ -81,7 +93,7 @@ class Website } /** - * @return \Magento\Core\Model\Resource\Website\Collection|null + * @return Collection|null */ public function getCollection() { @@ -94,6 +106,11 @@ class Website return $this->_websiteCollection; } + /** + * Get options for grid filter + * + * @return null|array + */ public function getCondition() { $id = $this->getValue(); diff --git a/app/code/Magento/Newsletter/Block/Adminhtml/Template.php b/app/code/Magento/Newsletter/Block/Adminhtml/Template.php index d424806a1b86072c67aefbdcc293999fb08307cf..bdad7a4bcb613d8bb56eb267db8b48bb8c80ceac 100644 --- a/app/code/Magento/Newsletter/Block/Adminhtml/Template.php +++ b/app/code/Magento/Newsletter/Block/Adminhtml/Template.php @@ -36,8 +36,14 @@ namespace Magento\Newsletter\Block\Adminhtml; class Template extends \Magento\Backend\Block\Template { + /** + * @var string + */ protected $_template = 'template/list.phtml'; + /** + * @return $this + */ protected function _prepareLayout() { $this->setChild( @@ -47,11 +53,21 @@ class Template extends \Magento\Backend\Block\Template return parent::_prepareLayout(); } + /** + * Get the url for create + * + * @return string + */ public function getCreateUrl() { return $this->getUrl('*/*/new'); } + /** + * Get header text + * + * @return string + */ public function getHeaderText() { return __('Newsletter Templates'); diff --git a/app/code/Magento/Newsletter/Block/Adminhtml/Template/Grid.php b/app/code/Magento/Newsletter/Block/Adminhtml/Template/Grid.php index 8e3e1ba4f14efe87d5be4b99c5a1f039410d89b9..43291107d4d17d25989919c288fcb0d566a68917 100644 --- a/app/code/Magento/Newsletter/Block/Adminhtml/Template/Grid.php +++ b/app/code/Magento/Newsletter/Block/Adminhtml/Template/Grid.php @@ -33,6 +33,8 @@ */ namespace Magento\Newsletter\Block\Adminhtml\Template; +use Magento\Backend\Block\Widget\Grid as WidgetGrid; + class Grid extends \Magento\Backend\Block\Widget\Grid\Extended { /** @@ -42,23 +44,26 @@ class Grid extends \Magento\Backend\Block\Widget\Grid\Extended /** * @param \Magento\Backend\Block\Template\Context $context - * @param \Magento\Core\Model\Url $urlModel * @param \Magento\Backend\Helper\Data $backendHelper * @param \Magento\Newsletter\Model\Resource\Template\Collection $templateCollection * @param array $data */ public function __construct( \Magento\Backend\Block\Template\Context $context, - \Magento\Core\Model\Url $urlModel, \Magento\Backend\Helper\Data $backendHelper, \Magento\Newsletter\Model\Resource\Template\Collection $templateCollection, array $data = array() ) { $this->_templateCollection = $templateCollection; - parent::__construct($context, $urlModel, $backendHelper, $data); + parent::__construct($context, $backendHelper, $data); $this->setEmptyText(__('No Templates Found')); } + /** + * Apply sorting and filtering to collection + * + * @return WidgetGrid + */ protected function _prepareCollection() { $this->setCollection($this->_templateCollection->useOnlyActual()); @@ -66,6 +71,11 @@ class Grid extends \Magento\Backend\Block\Widget\Grid\Extended return parent::_prepareCollection(); } + /** + * Prepare grid columns + * + * @return $this + */ protected function _prepareColumns() { $this->addColumn('template_code', @@ -148,6 +158,12 @@ class Grid extends \Magento\Backend\Block\Widget\Grid\Extended return $this; } + /** + * Get row url + * + * @param \Magento\Object $row + * @return string + */ public function getRowUrl($row) { return $this->getUrl('*/*/edit', array('id'=>$row->getId())); diff --git a/app/code/Magento/Newsletter/Block/Adminhtml/Template/Grid/Renderer/Action.php b/app/code/Magento/Newsletter/Block/Adminhtml/Template/Grid/Renderer/Action.php index 14832c52297825f05e5fe45cb1851e8d00737c5d..917b4ca7c07c17fd50ffa63b3f28d14963206358 100644 --- a/app/code/Magento/Newsletter/Block/Adminhtml/Template/Grid/Renderer/Action.php +++ b/app/code/Magento/Newsletter/Block/Adminhtml/Template/Grid/Renderer/Action.php @@ -39,7 +39,7 @@ class Action extends \Magento\Backend\Block\Widget\Grid\Column\Renderer\Action /** * Renderer for "Action" column in Newsletter templates grid * - * @var \Magento\Newsletter\Model\Template $row + * @param \Magento\Object $row * @return string */ public function render(\Magento\Object $row) diff --git a/app/code/Magento/Newsletter/Block/Adminhtml/Template/Grid/Renderer/Sender.php b/app/code/Magento/Newsletter/Block/Adminhtml/Template/Grid/Renderer/Sender.php index 89e27750ed8ebefe260374ca81c4f4c933fe4311..e9c0f430d2cf98e059855c6bf9f8e07f15a7afee 100644 --- a/app/code/Magento/Newsletter/Block/Adminhtml/Template/Grid/Renderer/Sender.php +++ b/app/code/Magento/Newsletter/Block/Adminhtml/Template/Grid/Renderer/Sender.php @@ -36,6 +36,12 @@ namespace Magento\Newsletter\Block\Adminhtml\Template\Grid\Renderer; class Sender extends \Magento\Backend\Block\Widget\Grid\Column\Renderer\AbstractRenderer { + /** + * Renderer for "Action" column in Newsletter templates grid + * + * @param \Magento\Object $row + * @return string + */ public function render(\Magento\Object $row) { $str = ''; diff --git a/app/code/Magento/Newsletter/Block/Adminhtml/Template/Preview.php b/app/code/Magento/Newsletter/Block/Adminhtml/Template/Preview.php index 8f7368bd3faba17fe27fe12a299c26e8deb0d6ce..a16b17680a8a587e3a2d0a9f9cfc811bde731ad7 100644 --- a/app/code/Magento/Newsletter/Block/Adminhtml/Template/Preview.php +++ b/app/code/Magento/Newsletter/Block/Adminhtml/Template/Preview.php @@ -62,6 +62,11 @@ class Preview extends \Magento\Backend\Block\Widget parent::__construct($context, $data); } + /** + * Get html code + * + * @return string + */ protected function _toHtml() { /* @var $template \Magento\Newsletter\Model\Template */ diff --git a/app/code/Magento/Newsletter/Block/Subscribe.php b/app/code/Magento/Newsletter/Block/Subscribe.php index 4451b423089f31766c7d3cb081db5191bc113416..b163f3c9bdc4471c77f68b7d6b9c3ed6952e7f82 100644 --- a/app/code/Magento/Newsletter/Block/Subscribe.php +++ b/app/code/Magento/Newsletter/Block/Subscribe.php @@ -58,11 +58,21 @@ class Subscribe extends \Magento\View\Element\Template $this->_isScopePrivate = true; } + /** + * Get success message + * + * @return string + */ public function getSuccessMessage() { return $this->_newsletterSession->getSuccess(); } + /** + * Get error message + * + * @return string + */ public function getErrorMessage() { return $this->_newsletterSession->getError(); diff --git a/app/code/Magento/Newsletter/Controller/Adminhtml/Problem.php b/app/code/Magento/Newsletter/Controller/Adminhtml/Problem.php index baa854011515ec82740a1d3bddee9f536903a793..ede8459ebc6e1debd83069817fae7bafff0b68f5 100644 --- a/app/code/Magento/Newsletter/Controller/Adminhtml/Problem.php +++ b/app/code/Magento/Newsletter/Controller/Adminhtml/Problem.php @@ -31,6 +31,11 @@ namespace Magento\Newsletter\Controller\Adminhtml; */ class Problem extends \Magento\Backend\App\Action { + /** + * Newsletter problems report page + * + * @return void + */ public function indexAction() { $this->_title->add(__('Newsletter Problems Report')); @@ -49,6 +54,11 @@ class Problem extends \Magento\Backend\App\Action $this->_view->renderLayout(); } + /** + * Newsletter problems grid + * + * @return void + */ public function gridAction() { if ($this->getRequest()->getParam('_unsubscribe')) { @@ -85,6 +95,11 @@ class Problem extends \Magento\Backend\App\Action $this->_view->renderLayout(); } + /** + * Check if user has enough privileges + * + * @return bool + */ protected function _isAllowed() { return $this->_authorization->isAllowed('Magento_Newsletter::problem'); diff --git a/app/code/Magento/Newsletter/Controller/Adminhtml/Queue.php b/app/code/Magento/Newsletter/Controller/Adminhtml/Queue.php index 1b98f1dd9d4524e76e07b1db3b363435d84ca524..c9aac04b51ed7a6f6c0edb8c68c8ecee589f26f1 100644 --- a/app/code/Magento/Newsletter/Controller/Adminhtml/Queue.php +++ b/app/code/Magento/Newsletter/Controller/Adminhtml/Queue.php @@ -56,6 +56,8 @@ class Queue extends \Magento\Backend\App\Action /** * Queue list action + * + * @return void */ public function indexAction() { @@ -78,6 +80,8 @@ class Queue extends \Magento\Backend\App\Action /** * Drop Newsletter queue template + * + * @return void */ public function dropAction() { @@ -87,6 +91,8 @@ class Queue extends \Magento\Backend\App\Action /** * Preview Newsletter queue template + * + * @return void */ public function previewAction() { @@ -107,6 +113,8 @@ class Queue extends \Magento\Backend\App\Action /** * Queue list Ajax action + * + * @return void */ public function gridAction() { @@ -114,6 +122,11 @@ class Queue extends \Magento\Backend\App\Action $this->_view->renderLayout(); } + /** + * Start Newsletter queue + * + * @return void + */ public function startAction() { $queue = $this->_objectManager->create('Magento\Newsletter\Model\Queue') @@ -134,6 +147,11 @@ class Queue extends \Magento\Backend\App\Action $this->_redirect('*/*'); } + /** + * Pause Newsletter queue + * + * @return void + */ public function pauseAction() { $queue = $this->_objectManager->get('Magento\Newsletter\Model\Queue') @@ -151,6 +169,11 @@ class Queue extends \Magento\Backend\App\Action $this->_redirect('*/*'); } + /** + * Resume Newsletter queue + * + * @return void + */ public function resumeAction() { $queue = $this->_objectManager->get('Magento\Newsletter\Model\Queue') @@ -168,6 +191,11 @@ class Queue extends \Magento\Backend\App\Action $this->_redirect('*/*'); } + /** + * Cancel Newsletter queue + * + * @return void + */ public function cancelAction() { $queue = $this->_objectManager->get('Magento\Newsletter\Model\Queue') @@ -185,6 +213,11 @@ class Queue extends \Magento\Backend\App\Action $this->_redirect('*/*'); } + /** + * Send Newsletter queue + * + * @return void + */ public function sendingAction() { // Todo: put it somewhere in config! @@ -200,6 +233,11 @@ class Queue extends \Magento\Backend\App\Action $collection->walk('sendPerSubscriber', array($countOfSubscritions)); } + /** + * Edit Newsletter queue + * + * @return void + */ public function editAction() { $this->_title->add(__('Newsletter Queue')); @@ -232,6 +270,12 @@ class Queue extends \Magento\Backend\App\Action $this->_view->renderLayout(); } + /** + * Save Newsletter queue + * + * @throws \Magento\Core\Exception + * @return void + */ public function saveAction() { try { @@ -294,6 +338,11 @@ class Queue extends \Magento\Backend\App\Action } } + /** + * Check if user has enough privileges + * + * @return bool + */ protected function _isAllowed() { return $this->_authorization->isAllowed('Magento_Newsletter::queue'); diff --git a/app/code/Magento/Newsletter/Controller/Adminhtml/Subscriber.php b/app/code/Magento/Newsletter/Controller/Adminhtml/Subscriber.php index 3817fe028d51cf1b52e37d081202e121d3290c80..339b2f5110aaaa6225e2a786b67110001b031b66 100644 --- a/app/code/Magento/Newsletter/Controller/Adminhtml/Subscriber.php +++ b/app/code/Magento/Newsletter/Controller/Adminhtml/Subscriber.php @@ -48,6 +48,11 @@ class Subscriber extends \Magento\Backend\App\Action parent::__construct($context); } + /** + * Newsletter subscribers page + * + * @return void + */ public function indexAction() { $this->_title->add(__('Newsletter Subscribers')); @@ -67,6 +72,11 @@ class Subscriber extends \Magento\Backend\App\Action $this->_view->renderLayout(); } + /** + * Managing newsletter grid + * + * @return void + */ public function gridAction() { $this->_view->loadLayout(false); @@ -75,6 +85,8 @@ class Subscriber extends \Magento\Backend\App\Action /** * Export subscribers grid to CSV format + * + * @return void */ public function exportCsvAction() { @@ -91,6 +103,8 @@ class Subscriber extends \Magento\Backend\App\Action /** * Export subscribers grid to XML format + * + * @return void */ public function exportXmlAction() { @@ -104,6 +118,11 @@ class Subscriber extends \Magento\Backend\App\Action ); } + /** + * Unsubscribe one or more subscribers action + * + * @return void + */ public function massUnsubscribeAction() { $subscribersIds = $this->getRequest()->getParam('subscriber'); @@ -127,6 +146,11 @@ class Subscriber extends \Magento\Backend\App\Action $this->_redirect('*/*/index'); } + /** + * Delete one or more subscribers action + * + * @return void + */ public function massDeleteAction() { $subscribersIds = $this->getRequest()->getParam('subscriber'); @@ -148,6 +172,11 @@ class Subscriber extends \Magento\Backend\App\Action $this->_redirect('*/*/index'); } + /** + * Check if user has enough privileges + * + * @return bool + */ protected function _isAllowed() { return $this->_authorization->isAllowed('Magento_Newsletter::subscriber'); diff --git a/app/code/Magento/Newsletter/Controller/Adminhtml/Template.php b/app/code/Magento/Newsletter/Controller/Adminhtml/Template.php index 113f54aca76e9cb9f284bfe386ac25005f6683e5..d23f4f97730583e49aef24d1dc37003c2066d8b3 100644 --- a/app/code/Magento/Newsletter/Controller/Adminhtml/Template.php +++ b/app/code/Magento/Newsletter/Controller/Adminhtml/Template.php @@ -66,7 +66,7 @@ class Template extends \Magento\Backend\App\Action /** * Set title of page * - * @return \Magento\Newsletter\Controller\Adminhtml\Template + * @return $this */ protected function _setTitle() { @@ -76,6 +76,7 @@ class Template extends \Magento\Backend\App\Action /** * View Templates list * + * @return void */ public function indexAction() { @@ -95,6 +96,7 @@ class Template extends \Magento\Backend\App\Action /** * JSON Grid Action * + * @return void */ public function gridAction() { @@ -107,6 +109,7 @@ class Template extends \Magento\Backend\App\Action /** * Create new Newsletter Template * + * @return void */ public function newAction() { @@ -116,6 +119,7 @@ class Template extends \Magento\Backend\App\Action /** * Edit Newsletter Template * + * @return void */ public function editAction() { @@ -161,6 +165,7 @@ class Template extends \Magento\Backend\App\Action /** * Drop Newsletter Template * + * @return void */ public function dropAction() { @@ -171,6 +176,7 @@ class Template extends \Magento\Backend\App\Action /** * Save Newsletter Template * + * @return void */ public function saveAction() { @@ -230,6 +236,7 @@ class Template extends \Magento\Backend\App\Action /** * Delete newsletter Template * + * @return void */ public function deleteAction() { @@ -254,6 +261,7 @@ class Template extends \Magento\Backend\App\Action /** * Preview Newsletter template * + * @return void|$this */ public function previewAction() { diff --git a/app/code/Magento/Newsletter/Controller/Manage.php b/app/code/Magento/Newsletter/Controller/Manage.php index 45f7c5121aca8a420024fcde805949a712ea3a6e..dac326c3f391183bfdbf251eb69e94a1fe309c04 100644 --- a/app/code/Magento/Newsletter/Controller/Manage.php +++ b/app/code/Magento/Newsletter/Controller/Manage.php @@ -83,6 +83,11 @@ class Manage extends \Magento\App\Action\Action return parent::dispatch($request); } + /** + * Managing newsletter subscription page + * + * @return void + */ public function indexAction() { $this->_view->loadLayout(); @@ -95,6 +100,11 @@ class Manage extends \Magento\App\Action\Action $this->_view->renderLayout(); } + /** + * Save newsletter subscription preference action + * + * @return void + */ public function saveAction() { if (!$this->_formKeyValidator->validate($this->getRequest())) { diff --git a/app/code/Magento/Newsletter/Controller/Subscriber.php b/app/code/Magento/Newsletter/Controller/Subscriber.php index 5582b16258d1d029acbe7db2e680cd01c9113bbc..ba201dd3c3bbeca967981c5f223e32efd6526510 100644 --- a/app/code/Magento/Newsletter/Controller/Subscriber.php +++ b/app/code/Magento/Newsletter/Controller/Subscriber.php @@ -96,6 +96,7 @@ class Subscriber extends \Magento\App\Action\Action * New subscription action * * @throws \Magento\Core\Exception + * @return void */ public function newAction() { @@ -141,6 +142,7 @@ class Subscriber extends \Magento\App\Action\Action /** * Subscription confirm action + * @return void */ public function confirmAction() { @@ -167,6 +169,7 @@ class Subscriber extends \Magento\App\Action\Action /** * Unsubscribe newsletter + * @return void */ public function unsubscribeAction() { diff --git a/app/code/Magento/Newsletter/Model/Observer.php b/app/code/Magento/Newsletter/Model/Observer.php index a6828f56c485ecbdd5db2e406c6e3de0ed967845..17e84ab2a3bcef2358be67c1a67f3a91cf4cfaae 100644 --- a/app/code/Magento/Newsletter/Model/Observer.php +++ b/app/code/Magento/Newsletter/Model/Observer.php @@ -26,6 +26,8 @@ namespace Magento\Newsletter\Model; +use Magento\Cron\Model\Schedule; + /** * Newsletter module observer * @@ -61,6 +63,12 @@ class Observer $this->_queueCollectionFactory = $queueCollectionFactory; } + /** + * Subscribe customer handler + * + * @param \Magento\Object $observer + * @return $this + */ public function subscribeCustomer($observer) { $customer = $observer->getEvent()->getCustomer(); @@ -74,7 +82,7 @@ class Observer * Customer delete handler * * @param \Magento\Object $observer - * @return \Magento\Newsletter\Model\Observer + * @return $this */ public function customerDeleted($observer) { @@ -87,6 +95,12 @@ class Observer return $this; } + /** + * Customer delete handler + * + * @param Schedule $schedule + * @return void + */ public function scheduledSend($schedule) { $countOfQueue = 3; diff --git a/app/code/Magento/Newsletter/Model/Queue.php b/app/code/Magento/Newsletter/Model/Queue.php index 97875cba2f7b9fd5c3760cfdb201c077541c642e..49e1f4251d1dfc37d37836d41b684e382f2e4611 100644 --- a/app/code/Magento/Newsletter/Model/Queue.php +++ b/app/code/Magento/Newsletter/Model/Queue.php @@ -207,7 +207,7 @@ class Queue extends \Magento\Core\Model\Template * Set $_data['queue_start'] based on string from backend, which based on locale. * * @param string|null $startAt start date of the mailing queue - * @return \Magento\Newsletter\Model\Queue + * @return $this */ public function setQueueStartAtByString($startAt) { @@ -226,7 +226,7 @@ class Queue extends \Magento\Core\Model\Template * * @param int $count * @param array $additionalVariables - * @return \Magento\Newsletter\Model\Queue + * @return $this */ public function sendPerSubscriber($count = 20, array $additionalVariables = array()) { @@ -300,7 +300,7 @@ class Queue extends \Magento\Core\Model\Template /** * Finish queue: set status SENT and update finish date * - * @return \Magento\Newsletter\Model\Queue + * @return $this */ protected function _finishQueue() { @@ -330,7 +330,7 @@ class Queue extends \Magento\Core\Model\Template * Add subscribers to queue. * * @param array $subscriberIds - * @return \Magento\Newsletter\Model\Queue + * @return $this */ public function addSubscribersToQueue(array $subscriberIds) { @@ -342,7 +342,7 @@ class Queue extends \Magento\Core\Model\Template * Setter for save stores flag. * * @param boolean|integer|string $value - * @return \Magento\Newsletter\Model\Queue + * @return $this */ public function setSaveStoresFlag($value) { @@ -364,8 +364,8 @@ class Queue extends \Magento\Core\Model\Template /** * Setter for stores of queue. * - * @param array - * @return \Magento\Newsletter\Model\Queue + * @param array $storesIds + * @return $this */ public function setStores(array $storesIds) { diff --git a/app/code/Magento/Newsletter/Model/Resource/Problem/Collection.php b/app/code/Magento/Newsletter/Model/Resource/Problem/Collection.php index df7ccb11e7c2390708115f37ac1a2e290bc5f6f9..f435457ca12546fec83e440beb2b5685c97a35c5 100644 --- a/app/code/Magento/Newsletter/Model/Resource/Problem/Collection.php +++ b/app/code/Magento/Newsletter/Model/Resource/Problem/Collection.php @@ -60,7 +60,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\Customer\Model\Resource\Customer\CollectionFactory $customerCollectionFactory - * @param mixed $connection + * @param null|\Zend_Db_Adapter_Abstract $connection * @param \Magento\Core\Model\Resource\Db\AbstractDb $resource */ public function __construct( @@ -88,7 +88,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl /** * Adds subscribers info * - * @return \Magento\Newsletter\Model\Resource\Problem\Collection + * @return $this */ public function addSubscriberInfo() { @@ -105,7 +105,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl /** * Adds queue info * - * @return \Magento\Newsletter\Model\Resource\Problem\Collection + * @return $this */ public function addQueueInfo() { @@ -122,6 +122,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl /** * Loads customers info to collection * + * @return void */ protected function _addCustomersData() { @@ -159,7 +160,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl * * @param bool $printQuery * @param bool $logQuery - * @return \Magento\Newsletter\Model\Resource\Problem\Collection + * @return $this */ public function load($printQuery = false, $logQuery = false) { diff --git a/app/code/Magento/Newsletter/Model/Resource/Queue.php b/app/code/Magento/Newsletter/Model/Resource/Queue.php index 103bec7ee2f20e3f9cf590fc1c9faadae471332b..2864392ba96e81383ca3093109af0e1df5b9154b 100644 --- a/app/code/Magento/Newsletter/Model/Resource/Queue.php +++ b/app/code/Magento/Newsletter/Model/Resource/Queue.php @@ -34,6 +34,9 @@ */ namespace Magento\Newsletter\Model\Resource; +use Magento\Newsletter\Model\Queue as ModelQueue; +use Magento\Core\Model\AbstractModel; + class Queue extends \Magento\Core\Model\Resource\Db\AbstractDb { /** @@ -69,11 +72,11 @@ class Queue extends \Magento\Core\Model\Resource\Db\AbstractDb /** * Add subscribers to queue * - * @param \Magento\Newsletter\Model\Queue $queue + * @param ModelQueue $queue * @param array $subscriberIds * @throws \Magento\Core\Exception */ - public function addSubscribersToQueue(\Magento\Newsletter\Model\Queue $queue, array $subscriberIds) + public function addSubscribersToQueue(ModelQueue $queue, array $subscriberIds) { if (count($subscriberIds)==0) { throw new \Magento\Core\Exception(__('There are no subscribers selected.')); @@ -112,9 +115,11 @@ class Queue extends \Magento\Core\Model\Resource\Db\AbstractDb /** * Removes subscriber from queue * - * @param \Magento\Newsletter\Model\Queue $queue + * @param ModelQueue $queue + * @return void + * @throws \Exception */ - public function removeSubscribersFromQueue(\Magento\Newsletter\Model\Queue $queue) + public function removeSubscribersFromQueue(ModelQueue $queue) { $adapter = $this->_getWriteAdapter(); try { @@ -138,10 +143,10 @@ class Queue extends \Magento\Core\Model\Resource\Db\AbstractDb /** * Links queue to store * - * @param \Magento\Newsletter\Model\Queue $queue - * @return \Magento\Newsletter\Model\Resource\Queue + * @param ModelQueue $queue + * @return $this */ - public function setStores(\Magento\Newsletter\Model\Queue $queue) + public function setStores(ModelQueue $queue) { $adapter = $this->_getWriteAdapter(); $adapter->delete( @@ -186,10 +191,10 @@ class Queue extends \Magento\Core\Model\Resource\Db\AbstractDb /** * Returns queue linked stores * - * @param \Magento\Newsletter\Model\Queue $queue + * @param ModelQueue $queue * @return array */ - public function getStores(\Magento\Newsletter\Model\Queue $queue) + public function getStores(ModelQueue $queue) { $adapter = $this->_getReadAdapter(); $select = $adapter->select()->from($this->getTable('newsletter_queue_store_link'), 'store_id') @@ -205,10 +210,10 @@ class Queue extends \Magento\Core\Model\Resource\Db\AbstractDb /** * Saving template after saving queue action * - * @param \Magento\Core\Model\AbstractModel $queue - * @return \Magento\Newsletter\Model\Resource\Queue + * @param AbstractModel $queue + * @return $this */ - protected function _afterSave(\Magento\Core\Model\AbstractModel $queue) + protected function _afterSave(AbstractModel $queue) { if ($queue->getSaveStoresFlag()) { $this->setStores($queue); diff --git a/app/code/Magento/Newsletter/Model/Resource/Queue/Collection.php b/app/code/Magento/Newsletter/Model/Resource/Queue/Collection.php index a35915cbd84ecfa85ebb44e37fe6cd2257a93b85..b1f728ab26421e639896e079eecf752a7ee6e246 100644 --- a/app/code/Magento/Newsletter/Model/Resource/Queue/Collection.php +++ b/app/code/Magento/Newsletter/Model/Resource/Queue/Collection.php @@ -63,7 +63,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\Date $date - * @param mixed $connection + * @param null|\Zend_Db_Adapter_Abstract $connection * @param \Magento\Core\Model\Resource\Db\AbstractDb $resource */ public function __construct( @@ -92,7 +92,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl /** * Joines templates information * - * @return \Magento\Newsletter\Model\Resource\Queue\Collection + * @return $this */ public function addTemplateInfo() { @@ -107,7 +107,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl /** * Adds subscribers info to selelect * - * @return \Magento\Newsletter\Model\Resource\Queue\Collection + * @return $this */ protected function _addSubscriberInfoToSelect() { @@ -134,7 +134,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl * * @param bool $printQuery * @param bool $logQuery - * @return \Magento\Newsletter\Model\Resource\Queue\Collection + * @return $this */ public function load($printQuery = false, $logQuery = false) { @@ -147,7 +147,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl /** * Joines subscribers information * - * @return \Magento\Newsletter\Model\Resource\Queue\Collection + * @return $this */ public function addSubscribersInfo() { @@ -160,8 +160,8 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl * to add specific filter or adds reguler filter * * @param string $field - * @param mixed $condition - * @return \Magento\Newsletter\Model\Resource\Queue\Collection + * @param null|string|array $condition + * @return $this */ public function addFieldToFilter($field, $condition = null) { @@ -177,7 +177,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl * Returns ids from queue_link table * * @param string $field - * @param mixed $condition + * @param null|string|array $condition * @return array */ protected function _getIdsFromLink($field, $condition) @@ -207,7 +207,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl * Set filter for queue by subscriber. * * @param int $subscriberId - * @return \Magento\Newsletter\Model\Resource\Queue\Collection + * @return $this */ public function addSubscriberFilter($subscriberId) { @@ -223,7 +223,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl /** * Add filter by only ready fot sending item * - * @return \Magento\Newsletter\Model\Resource\Queue\Collection + * @return $this */ public function addOnlyForSendingFilter() { @@ -239,7 +239,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl /** * Add filter by only not sent items * - * @return \Magento\Newsletter\Model\Resource\Queue\Collection + * @return $this */ public function addOnlyUnsentFilter() { @@ -261,8 +261,8 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl /** * Filter collection by specified store ids * - * @param array|int $storeIds - * @return \Magento\Newsletter\Model\Resource\Queue\Collection + * @param int[]|int $storeIds + * @return $this */ public function addStoreFilter($storeIds) { diff --git a/app/code/Magento/Newsletter/Model/Resource/Subscriber.php b/app/code/Magento/Newsletter/Model/Resource/Subscriber.php index cf4391478eeacda91ca780ab14e106832ea88630..a3785ec09894cd49e57eca5be6113ac5f0c553e4 100644 --- a/app/code/Magento/Newsletter/Model/Resource/Subscriber.php +++ b/app/code/Magento/Newsletter/Model/Resource/Subscriber.php @@ -110,6 +110,7 @@ class Subscriber extends \Magento\Core\Model\Resource\Db\AbstractDb * Set error messages scope * * @param string $scope + * @return void */ public function setMessagesScope($scope) { @@ -183,7 +184,7 @@ class Subscriber extends \Magento\Core\Model\Resource\Db\AbstractDb * * @param \Magento\Newsletter\Model\Subscriber $subscriber * @param \Magento\Newsletter\Model\Queue $queue - * @return \Magento\Newsletter\Model\Resource\Subscriber + * @return $this * @throws \Magento\Core\Exception */ public function received(\Magento\Newsletter\Model\Subscriber $subscriber, \Magento\Newsletter\Model\Queue $queue) diff --git a/app/code/Magento/Newsletter/Model/Resource/Subscriber/Collection.php b/app/code/Magento/Newsletter/Model/Resource/Subscriber/Collection.php index c36a1b1757da15fff0afdbd9cb3a216c2b95bb05..60f0f8cd43230e2caff5aeb2a542abbbfba1317f 100644 --- a/app/code/Magento/Newsletter/Model/Resource/Subscriber/Collection.php +++ b/app/code/Magento/Newsletter/Model/Resource/Subscriber/Collection.php @@ -34,6 +34,8 @@ */ namespace Magento\Newsletter\Model\Resource\Subscriber; +use Magento\Newsletter\Model\Queue as ModelQueue; + class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractCollection { @@ -85,7 +87,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\Customer\Model\CustomerFactory $customerFactory - * @param mixed $connection + * @param null|\Zend_Db_Adapter_Abstract $connection * @param \Magento\Core\Model\Resource\Db\AbstractDb $resource */ public function __construct( @@ -128,8 +130,8 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl /** * Set loading mode subscribers by queue * - * @param \Magento\Newsletter\Model\Queue $queue - * @return \Magento\Newsletter\Model\Resource\Subscriber\Collection + * @param ModelQueue $queue + * @return $this */ public function useQueue(\Magento\Newsletter\Model\Queue $queue) { @@ -143,7 +145,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl /** * Set using of links to only unsendet letter subscribers. * - * @return \Magento\Newsletter\Model\Resource\Subscriber\Collection + * @return $this */ public function useOnlyUnsent() { @@ -157,7 +159,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl /** * Adds customer info to select * - * @return \Magento\Newsletter\Model\Resource\Subscriber\Collection + * @return $this */ public function showCustomerInfo() { @@ -187,7 +189,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl /** * Add type field expression to select * - * @return \Magento\Newsletter\Model\Resource\Subscriber\Collection + * @return $this */ public function addSubscriberTypeField() { @@ -199,7 +201,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl /** * Sets flag for customer info loading on load * - * @return \Magento\Newsletter\Model\Resource\Subscriber\Collection + * @return $this */ public function showStoreInfo() { @@ -231,7 +233,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl /** * Load only subscribed customers * - * @return \Magento\Newsletter\Model\Resource\Subscriber\Collection + * @return $this */ public function useOnlyCustomers() { @@ -243,7 +245,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl /** * Show only with subscribed status * - * @return \Magento\Newsletter\Model\Resource\Subscriber\Collection + * @return $this */ public function useOnlySubscribed() { @@ -255,8 +257,8 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl /** * Filter collection by specified store ids * - * @param array|int $storeIds - * @return \Magento\Newsletter\Model\Resource\Subscriber\Collection + * @param int[]|int $storeIds + * @return $this */ public function addStoreFilter($storeIds) { diff --git a/app/code/Magento/Newsletter/Model/Session.php b/app/code/Magento/Newsletter/Model/Session.php index 3a27af51d89fbf65570e9f8f7f0104b7f006a29c..be622cced3f163b2f4b44f5d0a3aa2d64366b55e 100644 --- a/app/code/Magento/Newsletter/Model/Session.php +++ b/app/code/Magento/Newsletter/Model/Session.php @@ -31,18 +31,35 @@ namespace Magento\Newsletter\Model; */ class Session extends \Magento\Session\Generic { + /** + * Set error message + * + * @param string $message + * @return $this + */ public function addError($message) { $this->setErrorMessage($message); return $this; } + /** + * Set success message + * + * @param string $message + * @return $this + */ public function addSuccess($message) { $this->setSuccessMessage($message); return $this; } + /** + * Get error message + * + * @return string $message + */ public function getError() { $message = $this->getErrorMessage(); @@ -50,6 +67,11 @@ class Session extends \Magento\Session\Generic return $message; } + /** + * Get success message + * + * @return string $message + */ public function getSuccess() { $message = $this->getSuccessMessage(); diff --git a/app/code/Magento/Newsletter/Model/Subscriber.php b/app/code/Magento/Newsletter/Model/Subscriber.php index ec170f60b13c255de65018d48d97342aab796af9..88ed9e1b16e5b1aabac7edbfc2c1283efda0eea4 100644 --- a/app/code/Magento/Newsletter/Model/Subscriber.php +++ b/app/code/Magento/Newsletter/Model/Subscriber.php @@ -30,17 +30,17 @@ * @method \Magento\Newsletter\Model\Resource\Subscriber _getResource() * @method \Magento\Newsletter\Model\Resource\Subscriber getResource() * @method int getStoreId() - * @method \Magento\Newsletter\Model\Subscriber setStoreId(int $value) + * @method Subscriber setStoreId(int $value) * @method string getChangeStatusAt() - * @method \Magento\Newsletter\Model\Subscriber setChangeStatusAt(string $value) + * @method Subscriber setChangeStatusAt(string $value) * @method int getCustomerId() - * @method \Magento\Newsletter\Model\Subscriber setCustomerId(int $value) + * @method Subscriber setCustomerId(int $value) * @method string getSubscriberEmail() - * @method \Magento\Newsletter\Model\Subscriber setSubscriberEmail(string $value) + * @method Subscriber setSubscriberEmail(string $value) * @method int getSubscriberStatus() - * @method \Magento\Newsletter\Model\Subscriber setSubscriberStatus(int $value) + * @method Subscriber setSubscriberStatus(int $value) * @method string getSubscriberConfirmCode() - * @method \Magento\Newsletter\Model\Subscriber setSubscriberConfirmCode(string $value) + * @method Subscriber setSubscriberConfirmCode(string $value) * * @category Magento * @package Magento_Newsletter @@ -239,7 +239,7 @@ class Subscriber extends \Magento\Core\Model\AbstractModel * Alias for setSubscriberConfirmCode() * * @param string $value - * @return \Magento\Newsletter\Model\Subscriber + * @return $this */ public function setCode($value) { @@ -259,8 +259,8 @@ class Subscriber extends \Magento\Core\Model\AbstractModel /** * Alias for setSubscriberStatus() * - * @param int - * @return \Magento\Newsletter\Model\Subscriber + * @param int $value + * @return $this */ public function setStatus($value) { @@ -271,7 +271,7 @@ class Subscriber extends \Magento\Core\Model\AbstractModel * Set the error messages scope for subscription * * @param boolean $scope - * @return \Magento\Newsletter\Model\Subscriber + * @return Subscriber */ public function setMessagesScope($scope) @@ -294,7 +294,7 @@ class Subscriber extends \Magento\Core\Model\AbstractModel * Alias for setSubscriberEmail() * * @param string $value - * @return \Magento\Newsletter\Model\Subscriber + * @return $this */ public function setEmail($value) { @@ -341,7 +341,7 @@ class Subscriber extends \Magento\Core\Model\AbstractModel /** * Load subscriber data from resource model by email * - * @param $subscriberEmail + * @param string $subscriberEmail * @return $this */ public function loadByEmail($subscriberEmail) @@ -354,7 +354,7 @@ class Subscriber extends \Magento\Core\Model\AbstractModel * Load subscriber info by customer * * @param \Magento\Customer\Model\Customer $customer - * @return \Magento\Newsletter\Model\Subscriber + * @return $this */ public function loadByCustomer(\Magento\Customer\Model\Customer $customer) { @@ -460,8 +460,8 @@ class Subscriber extends \Magento\Core\Model\AbstractModel /** * Unsubscribes loaded subscription * - * @return \Magento\Newsletter\Model\Subscriber * @throws \Magento\Core\Exception + * @return $this */ public function unsubscribe() { @@ -479,7 +479,7 @@ class Subscriber extends \Magento\Core\Model\AbstractModel * Saving customer subscription status * * @param \Magento\Customer\Model\Customer $customer - * @return \Magento\Newsletter\Model\Subscriber + * @return $this */ public function subscribeCustomer($customer) { @@ -589,7 +589,7 @@ class Subscriber extends \Magento\Core\Model\AbstractModel /** * Sends out confirmation email * - * @return \Magento\Newsletter\Model\Subscriber + * @return $this */ public function sendConfirmationRequestEmail() { @@ -624,7 +624,7 @@ class Subscriber extends \Magento\Core\Model\AbstractModel /** * Sends out confirmation success email * - * @return \Magento\Newsletter\Model\Subscriber + * @return $this */ public function sendConfirmationSuccessEmail() { @@ -659,7 +659,7 @@ class Subscriber extends \Magento\Core\Model\AbstractModel /** * Sends out unsubsciption email * - * @return \Magento\Newsletter\Model\Subscriber + * @return $this */ public function sendUnsubscriptionEmail() { diff --git a/app/code/Magento/Newsletter/Model/Template/Filter.php b/app/code/Magento/Newsletter/Model/Template/Filter.php index fd9b7b164eebcf40cbc89ff5327acf343c28839d..c2e422c3cbd86489cff96208140da2f0cf379b68 100644 --- a/app/code/Magento/Newsletter/Model/Template/Filter.php +++ b/app/code/Magento/Newsletter/Model/Template/Filter.php @@ -38,7 +38,7 @@ class Filter extends \Magento\Widget\Model\Template\Filter /** * Generate widget HTML if template variables are assigned * - * @param array $construction + * @param string[] $construction * @return string */ public function widgetDirective($construction) diff --git a/app/code/Magento/Newsletter/etc/di.xml b/app/code/Magento/Newsletter/etc/di.xml index e9ae933643009d19be79ede3503d5b5b651cdb19..59bd57103172adfcd47fe8b2217db32274a0fa0d 100644 --- a/app/code/Magento/Newsletter/etc/di.xml +++ b/app/code/Magento/Newsletter/etc/di.xml @@ -26,9 +26,9 @@ <config> <type name="Magento\Module\Updater\SetupFactory"> <param name="resourceTypes"> - <value> - <newsletter_setup>Magento\Newsletter\Model\Resource\Setup</newsletter_setup> - </value> + <array> + <item key="newsletter_setup"><value>Magento\Newsletter\Model\Resource\Setup</value></item> + </array> </param> </type> <virtualType name="Magento\Newsletter\Model\Session\Storage" type="Magento\Session\Storage"> diff --git a/app/code/Magento/Newsletter/etc/frontend/di.xml b/app/code/Magento/Newsletter/etc/frontend/di.xml index 37c4aa5147194357dad9e95b93cbd8aaabf5de15..e008d19a0300e2059f88a552104a6d646da1a998 100644 --- a/app/code/Magento/Newsletter/etc/frontend/di.xml +++ b/app/code/Magento/Newsletter/etc/frontend/di.xml @@ -31,9 +31,9 @@ </type> <type name="Magento\Core\Model\Url\SecurityInfo"> <param name="secureUrlList"> - <value> - <newsletter_manage>/newsletter/manage/</newsletter_manage> - </value> + <array> + <item key="newsletter_manage"><value>/newsletter/manage/</value></item> + </array> </param> </type> </config> diff --git a/app/code/Magento/Newsletter/etc/module.xml b/app/code/Magento/Newsletter/etc/module.xml index ede53cc6925b595bcbc52b0786f2120cfc5eb1a8..a4fd5ee0b558bd88fe87833f5df0e4a3237f2afb 100755 --- a/app/code/Magento/Newsletter/etc/module.xml +++ b/app/code/Magento/Newsletter/etc/module.xml @@ -39,6 +39,7 @@ <module name="Magento_Cms"/> <module name="Magento_Email"/> <module name="Magento_Theme"/> + <module name="Magento_Cron"/> </depends> </module> </config> diff --git a/app/code/Magento/Ogone/Model/Config.php b/app/code/Magento/Ogone/Model/Config.php index 2cb25afea8a1fa64f34d7401ea06206a26f553f9..d868021c72c5ed5c44bbd62621bd8235b2bfae40 100644 --- a/app/code/Magento/Ogone/Model/Config.php +++ b/app/code/Magento/Ogone/Model/Config.php @@ -45,7 +45,7 @@ class Config extends \Magento\Payment\Model\Config /** * @param \Magento\Core\Model\Store\Config $coreStoreConfig - * @param \Magento\Core\Model\Config $coreConfig + * @param \Magento\App\ConfigInterface $coreConfig * @param \Magento\Payment\Model\Method\Factory $paymentMethodFactory * @param \Magento\Core\Model\LocaleInterface $locale * @param \Magento\Config\DataInterface $dataStorage @@ -54,7 +54,7 @@ class Config extends \Magento\Payment\Model\Config */ public function __construct( \Magento\Core\Model\Store\Config $coreStoreConfig, - \Magento\Core\Model\Config $coreConfig, + \Magento\App\ConfigInterface $coreConfig, \Magento\Payment\Model\Method\Factory $paymentMethodFactory, \Magento\Core\Model\LocaleInterface $locale, \Magento\Config\DataInterface $dataStorage, diff --git a/app/code/Magento/Ogone/etc/frontend/di.xml b/app/code/Magento/Ogone/etc/frontend/di.xml index 1dc28cc1d7c06dee391bc0d623512d8b3d68ef0c..ecab48a1d1040eb639142a1cfed23def4ecb7bfc 100644 --- a/app/code/Magento/Ogone/etc/frontend/di.xml +++ b/app/code/Magento/Ogone/etc/frontend/di.xml @@ -26,9 +26,9 @@ <config> <type name="Magento\Core\Model\Url\SecurityInfo"> <param name="secureUrlList"> - <value> - <ogone_api>/ogone/api</ogone_api> - </value> + <array> + <item key="ogone_api"><value>/ogone/api</value></item> + </array> </param> </type> </config> diff --git a/app/code/Magento/PageCache/Block/Javascript.php b/app/code/Magento/PageCache/Block/Javascript.php new file mode 100644 index 0000000000000000000000000000000000000000..1472c169e935e07f4442d570006f37f7eaa6cb25 --- /dev/null +++ b/app/code/Magento/PageCache/Block/Javascript.php @@ -0,0 +1,49 @@ +<?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_PageCache + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\PageCache\Block; + +/** + * Class Form + * @package Magento\PageCache\Block + */ +class Javascript extends \Magento\View\Element\Template +{ + /** + * Retrieve script options encoded to json + * + * @return string + */ + public function getScriptOptions() + { + $params = array( + 'url' => $this->getUrl('page_cache/block/render/'), + 'handles' => $this->getLayout()->getUpdate()->getHandles(), + 'versionCookieName' => \Magento\PageCache\Model\Version::COOKIE_NAME + ); + return json_encode($params); + } +} diff --git a/app/code/Magento/PageCache/Controller/Block.php b/app/code/Magento/PageCache/Controller/Block.php new file mode 100644 index 0000000000000000000000000000000000000000..785a8bc714440b2f0f7cf4694c3ef42b34f3e2da --- /dev/null +++ b/app/code/Magento/PageCache/Controller/Block.php @@ -0,0 +1,75 @@ +<?php +/** + * PageCache controller + * + * 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\PageCache\Controller; + +use Magento\PageCache\Helper\Data; + +class Block extends \Magento\App\Action\Action +{ + /** + * Returns block content depends on ajax request + */ + public function renderAction() + { + if (!$this->getRequest()->isAjax()) { + $this->_forward('noroute'); + return; + } + $blocks = $this->getRequest()->getParam('blocks', array()); + $handles = $this->getRequest()->getParam('handles', array()); + + if (!$handles || !$blocks) { + return; + } + $this->_view->loadLayout($handles); + $data = array(); + + foreach ($blocks as $blockName) { + $blockInstance = $this->_view->getLayout()->getBlock($blockName); + if (is_object($blockInstance)) { + $data[$blockName] = $blockInstance->toHtml(); + } + } + + $this->setPrivateHeaders(); + + $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/Helper/Data.php b/app/code/Magento/PageCache/Helper/Data.php index 777d68e72b5a8d6e9cdbc9a9e90d197812f45e97..068007b5fcef43af2e0984aa37c9c39ac8cb5a62 100644 --- a/app/code/Magento/PageCache/Helper/Data.php +++ b/app/code/Magento/PageCache/Helper/Data.php @@ -33,7 +33,42 @@ */ namespace Magento\PageCache\Helper; +/** + * Class Data + * @package Magento\PageCache\Helper + */ class Data extends \Magento\App\Helper\AbstractHelper { + /** + * Private caching time one year + */ + const PRIVATE_MAX_AGE_CACHE = 31536000; + + /** + * XML path to value for public max-age parameter + */ + const PUBLIC_MAX_AGE_PATH = 'system/headers/public-max-age'; + + /** + * @var \Magento\App\ConfigInterface + */ + protected $config; + + /** + * @param \Magento\App\Helper\Context $context + * @param \Magento\App\ConfigInterface $config + */ + public function __construct(\Magento\App\Helper\Context $context, \Magento\App\ConfigInterface $config) + { + parent::__construct($context); + $this->config = $config; + } + /** + * @return mixed + */ + public function getPublicMaxAgeCache() + { + return $this->config->getValue(self::PUBLIC_MAX_AGE_PATH); + } } diff --git a/app/code/Magento/PageCache/Model/App/FrontController/HeaderPlugin.php b/app/code/Magento/PageCache/Model/App/FrontController/HeaderPlugin.php index 70cf007729b7a5fde15d7c8fce52543f01e409a7..8a1d53e3e7abb96f1e29ad8a4df2d1de73891279 100644 --- a/app/code/Magento/PageCache/Model/App/FrontController/HeaderPlugin.php +++ b/app/code/Magento/PageCache/Model/App/FrontController/HeaderPlugin.php @@ -23,6 +23,8 @@ */ namespace Magento\PageCache\Model\App\FrontController; +use Magento\PageCache\Helper\Data; + /** * Class HeadPlugin */ @@ -34,22 +36,38 @@ class HeaderPlugin protected $layout; /** - * @var \Magento\Core\Model\ConfigInterface + * @var \Magento\App\ConfigInterface */ protected $config; + + /** + * @var \Magento\PageCache\Model\Version + */ + private $version; + + /** + * @var \Magento\PageCache\Helper\Data + */ + private $helper; /** * Constructor * * @param \Magento\Core\Model\Layout $layout - * @param \Magento\Core\Model\ConfigInterface $config + * @param \Magento\App\ConfigInterface $config + * @param \Magento\PageCache\Helper\Data + * @param \Magento\PageCache\Model\Version $version */ public function __construct( \Magento\Core\Model\Layout $layout, - \Magento\Core\Model\ConfigInterface $config + \Magento\App\ConfigInterface $config, + \Magento\PageCache\Helper\Data $helper, + \Magento\PageCache\Model\Version $version ){ $this->layout = $layout; + $this->helper = $helper; $this->config = $config; + $this->version = $version; } /** @@ -60,24 +78,43 @@ class HeaderPlugin */ public function afterDispatch(\Magento\App\Response\Http $response) { - $maxAge = $this->config->getValue('system/headers/max-age'); if ($this->layout->isCacheable()) { $response->setHeader('pragma', 'cache', true); - if($this->layout->isPrivate()) { - $response->setHeader('cache-control', 'private, max-age=' . $maxAge, true); - $response->setHeader('expires', - gmdate('D, d M Y H:i:s T', strtotime('+' . $maxAge . ' seconds')), true); - } else { - $response->setHeader('cache-control', 'public, max-age=' . $maxAge, true); - $response->setHeader('expires', - gmdate('D, d M Y H:i:s T', strtotime('+' . $maxAge . ' seconds')), true); + if(!$response->getHeader('cache-control')) { + $this->setPublicHeaders($response); } } else { - $response->setHeader('pragma', 'no-cache', true); - $response->setHeader('cache-control', 'no-store, no-cache, must-revalidate, max-age=0', true); - $response->setHeader('expires', - gmdate('D, d M Y H:i:s T', strtotime('-' . $maxAge . ' seconds')), true); + $this->setNocacheHeaders($response); } + $this->version->process(); return $response; } + + /** + * @param \Magento\App\Response\Http $response + */ + protected function setPublicHeaders(\Magento\App\Response\Http $response) + { + $maxAge = $this->helper->getPublicMaxAgeCache(); + $response->setHeader('cache-control', 'public, max-age=' . $maxAge, true); + $response->setHeader( + 'expires', + gmdate('D, d M Y H:i:s T', strtotime('+' . $maxAge . ' seconds')), + true + ); + } + + /** + * @param \Magento\App\Response\Http $response + */ + protected function setNocacheHeaders(\Magento\App\Response\Http $response) + { + $response->setHeader('pragma', 'no-cache', true); + $response->setHeader('cache-control', 'no-store, no-cache, must-revalidate, max-age=0', true); + $response->setHeader( + 'expires', + gmdate('D, d M Y H:i:s T', strtotime('-1 year')), + true + ); + } } diff --git a/app/code/Magento/PageCache/Model/Observer.php b/app/code/Magento/PageCache/Model/Observer.php new file mode 100644 index 0000000000000000000000000000000000000000..d190f82f0b3dcd73ac97b73a00da13999e5dcfbb --- /dev/null +++ b/app/code/Magento/PageCache/Model/Observer.php @@ -0,0 +1,56 @@ +<?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_PageCache + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\PageCache\Model; + +/** + * Class Observer + * @package Magento\PageCache\Model + */ +class Observer +{ + /** + * Add comment cache containers to private blocks + * Blocks are wrapped only if page is cacheable + * + * @param \Magento\Event\Observer $observer + */ + public function processLayoutRenderElement(\Magento\Event\Observer $observer) + { + /** @var \Magento\Core\Model\Layout $layout */ + $layout = $observer->getEvent()->getLayout(); + if ($layout->isCacheable()) { + $name = $observer->getEvent()->getElementName(); + $block = $layout->getBlock($name); + if ($block instanceof \Magento\View\Element\AbstractBlock && $block->isScopePrivate()) { + $transport = $observer->getEvent()->getTransport(); + $output = $transport->getData('output'); + $html = sprintf('<!-- BLOCK %1$s -->%2$s<!-- /BLOCK %1$s -->', $block->getNameInLayout(), $output); + $transport->setData('output', $html); + } + } + } +} diff --git a/app/code/Magento/PageCache/Model/Version.php b/app/code/Magento/PageCache/Model/Version.php new file mode 100644 index 0000000000000000000000000000000000000000..727fb8dfaa0aa55a3910c20f806c432febd0378d --- /dev/null +++ b/app/code/Magento/PageCache/Model/Version.php @@ -0,0 +1,97 @@ +<?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_PageCache + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\PageCache\Model; + +/** + * Class Version + * @package Magento\PageCache\Model + */ +class Version +{ + /** + * Name of cookie that holds private content version + */ + const COOKIE_NAME = 'private_content_version'; + + /** + * Ten years cookie period + */ + const COOKIE_PERIOD = 315360000; + + /** + * Cookie + * + * @var \Magento\Stdlib\Cookie + */ + private $cookie; + + /** + * Request + * + * @var \Magento\App\Request\Http + */ + private $request; + + public function __construct( + \Magento\Stdlib\Cookie $cookie, + \Magento\App\Request\Http $request + ) { + $this->cookie = $cookie; + $this->request = $request; + } + + /** + * Increment private content version cookie (for user to pull new private content) + */ + private function set() + { + $this->cookie->set(self::COOKIE_NAME, $this->generateValue(), self::COOKIE_PERIOD, '/'); + } + + /** + * Generate unique version identifier + * + * @return string + */ + private function generateValue() + { + return md5(rand() . time()); + } + + /** + * Handle private content version cookie + * Set cookie if it is not set. + * Increment version on post requests. + * In all other cases do nothing. + */ + public function process() + { + if ($this->request->isPost()) { + $this->set(); + } + } +} diff --git a/app/code/Magento/PageCache/etc/config.xml b/app/code/Magento/PageCache/etc/config.xml index 7f604fac8dc5b967f3617c2bfb3dc513d1ec213e..50809da39d5435b60c8d779acf442e934a921858 100644 --- a/app/code/Magento/PageCache/etc/config.xml +++ b/app/code/Magento/PageCache/etc/config.xml @@ -29,8 +29,8 @@ <default> <system> <headers> - <max-age>28800</max-age> + <public-max-age>0</public-max-age> </headers> </system> </default> -</config> +</config> \ No newline at end of file diff --git a/app/code/Magento/PageCache/etc/di.xml b/app/code/Magento/PageCache/etc/di.xml index 8a37a88079fc23cfae2c241ba9deeb6e4dfd4399..6dba77137b484dfe341c06e0abdb941bd42572a2 100644 --- a/app/code/Magento/PageCache/etc/di.xml +++ b/app/code/Magento/PageCache/etc/di.xml @@ -25,7 +25,6 @@ --> <config> <type name="Magento\App\FrontControllerInterface"> - <plugin name="front-controller-head" - type="Magento\PageCache\Model\App\FrontController\HeaderPlugin" disabled="true"/> + <plugin name="front-controller-head" type="Magento\PageCache\Model\App\FrontController\HeaderPlugin"/> </type> </config> diff --git a/app/code/Magento/PageCache/etc/events.xml b/app/code/Magento/PageCache/etc/events.xml new file mode 100644 index 0000000000000000000000000000000000000000..2de56ec9f5f129ecb0576ea585566fad7384354f --- /dev/null +++ b/app/code/Magento/PageCache/etc/events.xml @@ -0,0 +1,30 @@ +<?xml version="1.0"?> +<!-- +/** + * 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) + */ +--> +<config> + <event name="core_layout_render_element"> + <observer name="pagecache" instance="Magento\PageCache\Model\Observer" method="processLayoutRenderElement" /> + </event> +</config> diff --git a/app/code/Magento/PaypalUk/etc/frontend/routes.xml b/app/code/Magento/PageCache/etc/frontend/routes.xml similarity index 89% rename from app/code/Magento/PaypalUk/etc/frontend/routes.xml rename to app/code/Magento/PageCache/etc/frontend/routes.xml index be7f0ddb83e8d29b01605e8aaa304780794113bd..6cba7f7e55d343ba89977b5ae8e0428f15d4b522 100644 --- a/app/code/Magento/PaypalUk/etc/frontend/routes.xml +++ b/app/code/Magento/PageCache/etc/frontend/routes.xml @@ -25,8 +25,8 @@ --> <config> <router id="standard"> - <route id="paypaluk" frontName="paypaluk"> - <module name="Magento_PaypalUk" /> + <route id="magento_pagecache" frontName="page_cache"> + <module name="Magento_PageCache" /> </route> </router> -</config> \ No newline at end of file +</config> diff --git a/app/code/Magento/PageCache/etc/module.xml b/app/code/Magento/PageCache/etc/module.xml index 7b213139f7fb85840668fc86e02b8abafa9d94f9..bf7c69345b084a9af77c82d0990d8bb342c2ba30 100755 --- a/app/code/Magento/PageCache/etc/module.xml +++ b/app/code/Magento/PageCache/etc/module.xml @@ -30,6 +30,7 @@ </sequence> <depends> <module name="Magento_Core"/> + <module name="Magento_Theme"/> </depends> </module> </config> diff --git a/app/code/Magento/PageCache/view/frontend/javascript.phtml b/app/code/Magento/PageCache/view/frontend/javascript.phtml new file mode 100644 index 0000000000000000000000000000000000000000..dac67a9a75bbff26e164720b405d4ba519831383 --- /dev/null +++ b/app/code/Magento/PageCache/view/frontend/javascript.phtml @@ -0,0 +1,34 @@ +<?php +/** + * 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) + */ +?> +<?php /** @var \Magento\PageCache\Block\Javascript $this */ ?> +<script type="text/javascript"> + //<![CDATA[ + (function ($) { + head.js("<?php echo $this->getViewFileUrl('Magento_PageCache::js/page-cache.js')?>", function () { + $('body').pageCache(<?php echo $this->getScriptOptions(); ?>); + }); + })(jQuery); + //]]> +</script> \ No newline at end of file diff --git a/app/code/Magento/PageCache/view/frontend/js/comments.js b/app/code/Magento/PageCache/view/frontend/js/comments.js new file mode 100644 index 0000000000000000000000000000000000000000..957d391f620799bc12dbde6ccd59d2f46a940da2 --- /dev/null +++ b/app/code/Magento/PageCache/view/frontend/js/comments.js @@ -0,0 +1,42 @@ +/** + * Finds all comment elements + * + * 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) + */ +/*jshint browser:true jquery:true expr:true*/ +(function ($) { + "use strict"; + $.fn.comments = function () { + var elements = []; + var lookup = function (el) { + el.contents().each(function (i, el) { + if (el.nodeType == 8) { + elements.push(el); + } else if (el.nodeType == 1) { + lookup($(el)); + } + }); + }; + lookup(this); + return elements; + }; +})(jQuery); \ No newline at end of file diff --git a/app/code/Magento/PageCache/view/frontend/js/page-cache.js b/app/code/Magento/PageCache/view/frontend/js/page-cache.js new file mode 100644 index 0000000000000000000000000000000000000000..f306ada4af1546155675395f0b1676200ad51951 --- /dev/null +++ b/app/code/Magento/PageCache/view/frontend/js/page-cache.js @@ -0,0 +1,128 @@ +/** + * Handles additional ajax request for rendering user private content + * + * 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) + */ +/*jshint browser:true jquery:true expr:true*/ +(function ($) { + "use strict"; + $.widget('mage.pageCache', { + options: { + url: '/', + patternPlaceholderOpen: /^ BLOCK (.+) $/, + patternPlaceholderClose: /^ \/BLOCK (.+) $/, + versionCookieName: 'private_content_version', + handles: [] + }, + _create: function () { + var version = $.mage.cookies.get(this.options.versionCookieName); + if (!version) { + return ; + } + var placeholders = this._searchPlaceholders(this.element.comments()); + this._ajax(placeholders, version); + }, + _searchPlaceholders: function (elements) { + var placeholders = [], + tmp = {}; + for (var i = 0; i < elements.length; i++) { + var el = elements[i], + matches = this.options.patternPlaceholderOpen.exec(el.nodeValue), + name = null; + + if (matches) { + name = matches[1]; + tmp[name] = { + name: name, + openElement: el + }; + } else { + matches = this.options.patternPlaceholderClose.exec(el.nodeValue); + if (matches) { + name = matches[1]; + if (tmp[name]) { + tmp[name].closeElement = el; + placeholders.push(tmp[name]); + delete tmp[name]; + } + } + } + } + return placeholders; + }, + _replacePlaceholder: function(placeholder, html) { + var parent = $(placeholder.openElement).parent(), + contents = parent.contents(), + startReplacing = false, + prevSibling = null; + for (var y = 0; y < contents.length; y++) { + var element = contents[y]; + if (element == placeholder.openElement) { + startReplacing = true; + } + if (startReplacing) { + element.remove(); + } else if (element.nodeType != 8) { + //due to comment tag doesn't have siblings we try to find it manually + prevSibling = element; + } + if (element == placeholder.closeElement) { + break; + } + } + if (prevSibling) { + $(prevSibling).after(html); + } else { + $(parent).prepend(html); + } + }, + _ajax: function (placeholders, version) { + var data = { + blocks: [], + handles: this.options.handles, + version: version + }; + for (var i = 0; i < placeholders.length; i++) { + data.blocks.push(placeholders[i].name); + } + data.blocks.sort(); + data.handles.sort(); + $.ajax({ + url: this.options.url, + data: data, + type: 'GET', + cache: true, + dataType: 'json', + context: this, + success: function (response) { + for (var i = 0; i < placeholders.length; i++) { + var placeholder = placeholders[i]; + if (!response.hasOwnProperty(placeholder.name)) { + continue; + } + this._replacePlaceholder(placeholder, response[placeholder.name]); + } + } + }); + } + }); +})(jQuery); \ No newline at end of file diff --git a/app/code/Magento/PaypalUk/view/frontend/layout/default.xml b/app/code/Magento/PageCache/view/frontend/layout/default.xml similarity index 66% rename from app/code/Magento/PaypalUk/view/frontend/layout/default.xml rename to app/code/Magento/PageCache/view/frontend/layout/default.xml index 87713b75bf821af6d3bd0fc7a37ede4a2779bbe2..eba7a5e3faa0817dbb44b50b29c6ac4fd9dca341 100644 --- a/app/code/Magento/PaypalUk/view/frontend/layout/default.xml +++ b/app/code/Magento/PageCache/view/frontend/layout/default.xml @@ -24,8 +24,14 @@ */ --> <layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> - <referenceContainer name="cart_sidebar.extra_actions"> - <block class="Magento\PaypalUk\Block\Express\Shortcut" name="paypaluk.partner.cart_sidebar.shortcut" - template="Magento_Paypal::express/shortcut.phtml" cacheable="false"/> + <referenceBlock name="head"> + <block class="Magento\Theme\Block\Html\Head\Script" name="magento-pagecache-comments-js" after="jquery-jquery-js"> + <arguments> + <argument name="file" xsi:type="string">Magento_PageCache::js/comments.js</argument> + </arguments> + </block> + </referenceBlock> + <referenceContainer name="content"> + <block class="Magento\PageCache\Block\Javascript" template="Magento_PageCache::javascript.phtml" name="pageCache" as="pageCache"/> </referenceContainer> -</layout> +</layout> \ No newline at end of file diff --git a/app/code/Magento/Payment/Helper/Data.php b/app/code/Magento/Payment/Helper/Data.php index 1dbaf1064aa8b275589613d9b7dbc6b835e76029..7afe081b5ce937a4fb148a1851997c78431a7071 100644 --- a/app/code/Magento/Payment/Helper/Data.php +++ b/app/code/Magento/Payment/Helper/Data.php @@ -58,7 +58,7 @@ class Data extends \Magento\App\Helper\AbstractHelper /** * Config * - * @var \Magento\Core\Model\Config + * @var \Magento\App\ConfigInterface */ protected $_config; @@ -81,7 +81,7 @@ class Data extends \Magento\App\Helper\AbstractHelper * @param \Magento\Core\Model\Store\Config $coreStoreConfig * @param \Magento\View\LayoutInterface $layout * @param \Magento\Payment\Model\Method\Factory $paymentMethodFactory - * @param \Magento\Core\Model\Config $config + * @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 @@ -91,7 +91,7 @@ class Data extends \Magento\App\Helper\AbstractHelper \Magento\Core\Model\Store\Config $coreStoreConfig, \Magento\View\LayoutInterface $layout, \Magento\Payment\Model\Method\Factory $paymentMethodFactory, - \Magento\Core\Model\Config $config, + \Magento\App\ConfigInterface $config, \Magento\Core\Model\App\Emulation $appEmulation, \Magento\Payment\Model\Config $paymentConfig, \Magento\Core\Model\Config\Initial $initialConfig diff --git a/app/code/Magento/Payment/Model/Config.php b/app/code/Magento/Payment/Model/Config.php index bdf66d4b3f3ad2f51bb6494ea369533e628f7c6b..06f16f767f9e10e38c61dbaf79a09b0b070187b4 100644 --- a/app/code/Magento/Payment/Model/Config.php +++ b/app/code/Magento/Payment/Model/Config.php @@ -68,14 +68,14 @@ class Config * Construct * * @param \Magento\Core\Model\Store\Config $coreStoreConfig - * @param \Magento\Core\Model\Config $coreConfig + * @param \Magento\App\ConfigInterface $coreConfig * @param \Magento\Payment\Model\Method\Factory $paymentMethodFactory * @param \Magento\Core\Model\LocaleInterface $locale * @param \Magento\Config\DataInterface $dataStorage */ public function __construct( \Magento\Core\Model\Store\Config $coreStoreConfig, - \Magento\Core\Model\Config $coreConfig, + \Magento\App\ConfigInterface $coreConfig, \Magento\Payment\Model\Method\Factory $paymentMethodFactory, \Magento\Core\Model\LocaleInterface $locale, \Magento\Config\DataInterface $dataStorage diff --git a/app/code/Magento/Paypal/Block/Adminhtml/System/Config/Fieldset/Store.php b/app/code/Magento/Paypal/Block/Adminhtml/System/Config/Fieldset/Store.php index 3efa72c761520d2729cb54ae11567990d11e7659..2e94c2a91230165a5294d2d0fc2dc3543086aac5 100644 --- a/app/code/Magento/Paypal/Block/Adminhtml/System/Config/Fieldset/Store.php +++ b/app/code/Magento/Paypal/Block/Adminhtml/System/Config/Fieldset/Store.php @@ -43,18 +43,18 @@ class Store protected $_template = 'Magento_Paypal::system/config/fieldset/store.phtml'; /** - * @var \Magento\Core\Model\Config + * @var \Magento\App\ConfigInterface */ protected $_coreConfig; /** * @param \Magento\Backend\Block\Template\Context $context - * @param \Magento\Core\Model\Config $coreConfig + * @param \Magento\App\ConfigInterface $coreConfig * @param array $data */ public function __construct( \Magento\Backend\Block\Template\Context $context, - \Magento\Core\Model\Config $coreConfig, + \Magento\App\ConfigInterface $coreConfig, array $data = array() ) { parent::__construct($context, $data); @@ -85,9 +85,9 @@ class Store 'express' => 'payment/paypal_express/active', 'wps' => 'payment/paypal_standard/active', 'wpp' => 'payment/paypal_direct/active', - 'wpppe' => 'payment/paypaluk_direct/active', - 'verisign' => 'payment/verisign/active', - 'expresspe' => 'payment/paypaluk_express/active' + 'wpppe' => 'payment/payflow_direct/active', + 'payflowpro' => 'payment/payflowpro/active', + 'expresspe' => 'payment/payflow_express/active' ); // Retrieve a code of the current website $website = $this->getRequest()->getParam('website'); diff --git a/app/code/Magento/Paypal/Block/Express/Review.php b/app/code/Magento/Paypal/Block/Express/Review.php index b9c7e8c6ae976def2e86116a5b144db484561344..236a8ab7f13053148ca7a51541d317954c4e4c74 100644 --- a/app/code/Magento/Paypal/Block/Express/Review.php +++ b/app/code/Magento/Paypal/Block/Express/Review.php @@ -48,11 +48,11 @@ class Review extends \Magento\View\Element\Template protected $_currentShippingRate = null; /** - * Paypal action prefix + * Paypal controller path * * @var string */ - protected $_paypalActionPrefix = 'paypal'; + protected $_controllerPath = 'paypal/express'; /** * @var \Magento\Tax\Helper\Data @@ -187,11 +187,11 @@ class Review extends \Magento\View\Element\Template } /** - * Set paypal actions prefix + * Set controller path */ - public function setPaypalActionPrefix($prefix) + public function setControllerPath($prefix) { - $this->_paypalActionPrefix = $prefix; + $this->_controllerPath = $prefix; } /** @@ -233,8 +233,8 @@ class Review extends \Magento\View\Element\Template { $methodInstance = $this->_quote->getPayment()->getMethodInstance(); $this->setPaymentMethodTitle($methodInstance->getTitle()); - $this->setUpdateOrderSubmitUrl($this->getUrl("{$this->_paypalActionPrefix}/express/updateOrder")); - $this->setUpdateShippingMethodsUrl($this->getUrl("{$this->_paypalActionPrefix}/express/updateShippingMethods")); + $this->setUpdateOrderSubmitUrl($this->getUrl("{$this->_controllerPath}/updateOrder")); + $this->setUpdateShippingMethodsUrl($this->getUrl("{$this->_controllerPath}/updateShippingMethods")); $this->setShippingRateRequired(true); if ($this->_quote->getIsVirtual()) { @@ -257,14 +257,14 @@ class Review extends \Magento\View\Element\Template } // misc shipping parameters - $this->setShippingMethodSubmitUrl($this->getUrl("{$this->_paypalActionPrefix}/express/saveShippingMethod")) + $this->setShippingMethodSubmitUrl($this->getUrl("{$this->_controllerPath}/saveShippingMethod")) ->setCanEditShippingAddress($this->_quote->getMayEditShippingAddress()) ->setCanEditShippingMethod($this->_quote->getMayEditShippingMethod()) ; } - $this->setEditUrl($this->getUrl("{$this->_paypalActionPrefix}/express/edit")) - ->setPlaceOrderUrl($this->getUrl("{$this->_paypalActionPrefix}/express/placeOrder")); + $this->setEditUrl($this->getUrl("{$this->_controllerPath}/edit")) + ->setPlaceOrderUrl($this->getUrl("{$this->_controllerPath}/placeOrder")); return parent::_beforeToHtml(); } diff --git a/app/code/Magento/PaypalUk/Block/Express/Form.php b/app/code/Magento/Paypal/Block/PayflowExpress/Form.php similarity index 91% rename from app/code/Magento/PaypalUk/Block/Express/Form.php rename to app/code/Magento/Paypal/Block/PayflowExpress/Form.php index 8c41af04feb053c933aed1ae5b6ea4dc1b43ac8d..f6cf2bc63e289f6dcb0f944c56f2af8cd7225a7d 100644 --- a/app/code/Magento/PaypalUk/Block/Express/Form.php +++ b/app/code/Magento/Paypal/Block/PayflowExpress/Form.php @@ -18,14 +18,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_PaypalUk * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\PaypalUk\Block\Express; +namespace Magento\Paypal\Block\PayflowExpress; class Form extends \Magento\Paypal\Block\Express\Form { @@ -34,5 +32,4 @@ class Form extends \Magento\Paypal\Block\Express\Form * @var string */ protected $_methodCode = \Magento\Paypal\Model\Config::METHOD_WPP_PE_EXPRESS; - } diff --git a/app/code/Magento/PaypalUk/Block/Express/Shortcut.php b/app/code/Magento/Paypal/Block/PayflowExpress/Shortcut.php similarity index 85% rename from app/code/Magento/PaypalUk/Block/Express/Shortcut.php rename to app/code/Magento/Paypal/Block/PayflowExpress/Shortcut.php index a467df92060b277ec45a4b93c4a6e4ab4aede425..bc659ec1b76c3444f3dcdd1c1c22a6166816497b 100644 --- a/app/code/Magento/PaypalUk/Block/Express/Shortcut.php +++ b/app/code/Magento/Paypal/Block/PayflowExpress/Shortcut.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_PaypalUk * @copyright Copyright (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,7 +25,7 @@ /** * Paypal expess checkout shortcut link */ -namespace Magento\PaypalUk\Block\Express; +namespace Magento\Paypal\Block\PayflowExpress; class Shortcut extends \Magento\Paypal\Block\Express\Shortcut { @@ -43,12 +41,12 @@ class Shortcut extends \Magento\Paypal\Block\Express\Shortcut * * @var string */ - protected $_startAction = 'paypaluk/express/start'; + protected $_startAction = 'paypal/payflowexpress/start'; /** * Express checkout model factory name * * @var string */ - protected $_checkoutType = 'Magento\PaypalUk\Model\Express\Checkout'; + protected $_checkoutType = 'Magento\Paypal\Model\PayflowExpress\Checkout'; } diff --git a/app/code/Magento/PaypalUk/Controller/Express.php b/app/code/Magento/Paypal/Controller/Payflowexpress.php similarity index 84% rename from app/code/Magento/PaypalUk/Controller/Express.php rename to app/code/Magento/Paypal/Controller/Payflowexpress.php index 96a61fdfd65d862d6c5e0b5e2028cb2c37834aff..f12d71bf818c8890e1b241af90dd9c4ff0e49fa4 100644 --- a/app/code/Magento/PaypalUk/Controller/Express.php +++ b/app/code/Magento/Paypal/Controller/Payflowexpress.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_PaypalUk * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ @@ -28,9 +26,9 @@ * Express Checkout Controller */ -namespace Magento\PaypalUk\Controller; +namespace Magento\Paypal\Controller; -class Express extends \Magento\Paypal\Controller\Express\AbstractExpress +class Payflowexpress extends \Magento\Paypal\Controller\Express\AbstractExpress { /** * Config mode type @@ -51,5 +49,5 @@ class Express extends \Magento\Paypal\Controller\Express\AbstractExpress * * @var string */ - protected $_checkoutType = 'Magento\PaypalUk\Model\Express\Checkout'; + protected $_checkoutType = 'Magento\Paypal\Model\PayflowExpress\Checkout'; } diff --git a/app/code/Magento/PaypalUk/Model/Api/Nvp.php b/app/code/Magento/Paypal/Model/Api/PayflowNvp.php similarity index 96% rename from app/code/Magento/PaypalUk/Model/Api/Nvp.php rename to app/code/Magento/Paypal/Model/Api/PayflowNvp.php index 8ae8f0e31eddd15c5c7cbbd2bd51bc12e8699bd8..ee0f5fd805e85cedb660b78cc8f6a9249dce98be 100644 --- a/app/code/Magento/PaypalUk/Model/Api/Nvp.php +++ b/app/code/Magento/Paypal/Model/Api/PayflowNvp.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_PaypalUk * @copyright Copyright (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,9 +25,9 @@ /** * NVP API wrappers model */ -namespace Magento\PaypalUk\Model\Api; +namespace Magento\Paypal\Model\Api; -class Nvp extends \Magento\Paypal\Model\Api\Nvp +class PayflowNvp extends \Magento\Paypal\Model\Api\Nvp { /**#@+ * Transaction types declaration @@ -255,7 +253,7 @@ class Nvp extends \Magento\Paypal\Model\Api\Nvp 'SHIPTOSTREET' => 'street', 'SHIPTOSTREET2' => 'street2', 'SHIPTOZIP' => 'postcode', - 'SHIPTOPHONENUM' => 'telephone', // does not supported by PaypalUk + 'SHIPTOPHONENUM' => 'telephone', // does not supported by Payflow ); /** @@ -283,7 +281,7 @@ class Nvp extends \Magento\Paypal\Model\Api\Nvp ); /** - * Map for billing address to do request to PayPalUk + * Map for billing address to do request to Payflow * * @var array */ @@ -381,7 +379,7 @@ class Nvp extends \Magento\Paypal\Model\Api\Nvp } /** - * Return PaypalUk partner based on config data + * Return Payflow partner based on config data * * @return string */ @@ -391,7 +389,7 @@ class Nvp extends \Magento\Paypal\Model\Api\Nvp } /** - * Return PaypalUk user based on config data + * Return Payflow user based on config data * * @return string */ @@ -401,7 +399,7 @@ class Nvp extends \Magento\Paypal\Model\Api\Nvp } /** - * Return PaypalUk password based on config data + * Return Payflow password based on config data * * @return string */ @@ -411,7 +409,7 @@ class Nvp extends \Magento\Paypal\Model\Api\Nvp } /** - * Return PaypalUk vendor based on config data + * Return Payflow vendor based on config data * * @return string */ @@ -421,7 +419,7 @@ class Nvp extends \Magento\Paypal\Model\Api\Nvp } /** - * Return PaypalUk tender based on config data + * Return Payflow tender based on config data * * @return string */ @@ -456,8 +454,8 @@ class Nvp extends \Magento\Paypal\Model\Api\Nvp protected function _addMethodToRequest($methodName, $request) { $request['TRXTYPE'] = $this->_mapPaypalMethodName($methodName); - if (!is_null($this->_getPaypalUkActionName($methodName))) { - $request['ACTION'] = $this->_getPaypalUkActionName($methodName); + if (!is_null($this->_getPayflowActionName($methodName))) { + $request['ACTION'] = $this->_getPayflowActionName($methodName); } return $request; } @@ -468,7 +466,7 @@ class Nvp extends \Magento\Paypal\Model\Api\Nvp * @param string * @return string | null */ - protected function _getPaypalUkActionName($methodName) + protected function _getPayflowActionName($methodName) { switch($methodName) { case \Magento\Paypal\Model\Api\Nvp::SET_EXPRESS_CHECKOUT: @@ -567,7 +565,7 @@ class Nvp extends \Magento\Paypal\Model\Api\Nvp } /** - * "GetTransactionDetails" method does not exists in PaypalUK + * "GetTransactionDetails" method does not exists in Payflow */ public function callGetTransactionDetails() { diff --git a/app/code/Magento/Paypal/Model/Config.php b/app/code/Magento/Paypal/Model/Config.php index 94514f0ca378f2c34fb4c093e3be9e2f56ba23b4..dacf58046d6eefda165cf737546731a25a462c48 100644 --- a/app/code/Magento/Paypal/Model/Config.php +++ b/app/code/Magento/Paypal/Model/Config.php @@ -50,17 +50,17 @@ class Config /** * Direct Payments (Payflow Edition) */ - const METHOD_WPP_PE_DIRECT = 'paypaluk_direct'; + const METHOD_WPP_PE_DIRECT = 'payflow_direct'; /** * Express Checkout (Payflow Edition) */ - const METHOD_WPP_PE_EXPRESS = 'paypaluk_express'; + const METHOD_WPP_PE_EXPRESS = 'payflow_express'; /** * Payflow Pro Gateway */ - const METHOD_PAYFLOWPRO = 'verisign'; + const METHOD_PAYFLOWPRO = 'payflowpro'; const METHOD_PAYFLOWLINK = 'payflow_link'; const METHOD_PAYFLOWADVANCED = 'payflow_advanced'; @@ -177,8 +177,8 @@ class Config 'paypal_standard' => 'WPS', 'paypal_express' => 'EC', 'paypal_direct' => 'DP', - 'paypaluk_express' => 'EC', - 'paypaluk_direct' => 'DP', + 'payflow_express' => 'EC', + 'payflow_direct' => 'DP', ); /** @@ -1350,7 +1350,6 @@ class Config protected function _mapWpukFieldset($fieldName) { $pathPrefix = 'paypal/wpuk'; - // Use PUMP credentials from Verisign for EC when Direct Payments are unavailable if ($this->_methodCode == self::METHOD_WPP_PE_EXPRESS && $this->isMethodAvailable(self::METHOD_PAYFLOWLINK) ) { @@ -1362,7 +1361,7 @@ class Config } elseif ($this->_methodCode == self::METHOD_WPP_PE_EXPRESS && !$this->isMethodAvailable(self::METHOD_WPP_PE_DIRECT) ) { - $pathPrefix = 'payment/verisign'; + $pathPrefix = 'payment/payflowpro'; } elseif ($this->_methodCode == self::METHOD_PAYFLOWADVANCED || $this->_methodCode == self::METHOD_PAYFLOWLINK ) { diff --git a/app/code/Magento/Paypal/Model/Express/Checkout.php b/app/code/Magento/Paypal/Model/Express/Checkout.php index dd7c63606233bce3b0916e18e52608a15d6f0f9b..52d4ee2b5d65cbbc39bd7cc353ead08c99ececc2 100644 --- a/app/code/Magento/Paypal/Model/Express/Checkout.php +++ b/app/code/Magento/Paypal/Model/Express/Checkout.php @@ -185,7 +185,7 @@ class Checkout protected $_storeManager; /** - * @var \Magento\Core\Model\Url + * @var \Magento\UrlInterface */ protected $_coreUrl; @@ -236,7 +236,7 @@ class Checkout * @param \Magento\Core\Model\LocaleInterface $locale * @param \Magento\Paypal\Model\Info $paypalInfo * @param \Magento\Core\Model\StoreManagerInterface $storeManager - * @param \Magento\Core\Model\Url $coreUrl + * @param \Magento\UrlInterface $coreUrl * @param \Magento\Paypal\Model\CartFactory $cartFactory * @param \Magento\Core\Model\Log\AdapterFactory $logFactory * @param \Magento\Checkout\Model\Type\OnepageFactory $onepageFactory @@ -257,7 +257,7 @@ class Checkout \Magento\Core\Model\LocaleInterface $locale, \Magento\Paypal\Model\Info $paypalInfo, \Magento\Core\Model\StoreManagerInterface $storeManager, - \Magento\Core\Model\Url $coreUrl, + \Magento\UrlInterface $coreUrl, \Magento\Paypal\Model\CartFactory $cartFactory, \Magento\Core\Model\Log\AdapterFactory $logFactory, \Magento\Checkout\Model\Type\OnepageFactory $onepageFactory, diff --git a/app/code/Magento/PaypalUk/Model/Pro.php b/app/code/Magento/Paypal/Model/Payflow/Pro.php similarity index 90% rename from app/code/Magento/PaypalUk/Model/Pro.php rename to app/code/Magento/Paypal/Model/Payflow/Pro.php index e926687c7ebfd390cc9d9f762934c687ac84239e..ae336bb38c21cc7a5d736753141c2191c2bd5617 100644 --- a/app/code/Magento/PaypalUk/Model/Pro.php +++ b/app/code/Magento/Paypal/Model/Payflow/Pro.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_PaypalUk * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ @@ -29,7 +27,7 @@ * This model was created because right now PayPal Direct and PayPal Express payment * (Payflow Edition) methods cannot have same abstract */ -namespace Magento\PaypalUk\Model; +namespace Magento\Paypal\Model\Payflow; class Pro extends \Magento\Paypal\Model\Pro { @@ -38,7 +36,7 @@ class Pro extends \Magento\Paypal\Model\Pro * * @var string */ - protected $_apiType = 'Magento\PaypalUk\Model\Api\Nvp'; + protected $_apiType = 'Magento\Paypal\Model\Api\PayflowNvp'; /** * Config model type @@ -88,7 +86,7 @@ class Pro extends \Magento\Paypal\Model\Pro { if ($payment->getParentTransactionId()) { return $payment->getTransaction($payment->getParentTransactionId()) - ->getAdditionalInformation(\Magento\PaypalUk\Model\Pro::TRANSPORT_PAYFLOW_TXN_ID); + ->getAdditionalInformation(self::TRANSPORT_PAYFLOW_TXN_ID); } return $payment->getParentTransactionId(); } @@ -104,7 +102,7 @@ class Pro extends \Magento\Paypal\Model\Pro $payment->setTransactionId($api->getPaypalTransactionId()) ->setIsTransactionClosed(false) ->setTransactionAdditionalInfo( - \Magento\PaypalUk\Model\Pro::TRANSPORT_PAYFLOW_TXN_ID, + self::TRANSPORT_PAYFLOW_TXN_ID, $api->getTransactionId() ); $payment->setPreparedMessage(__('Payflow PNREF: #%1.', $api->getTransactionId())); @@ -112,7 +110,7 @@ class Pro extends \Magento\Paypal\Model\Pro } /** - * Fetch transaction details info method does not exists in PaypalUK + * Fetch transaction details info method does not exists in Payflow * * @param \Magento\Payment\Model\Info $payment * @param string $transactionId @@ -121,7 +119,7 @@ class Pro extends \Magento\Paypal\Model\Pro */ public function fetchTransactionInfo(\Magento\Payment\Model\Info $payment, $transactionId) { - throw new \Magento\Core\Exception(__('Fetch transaction details method does not exists in PaypalUK')); + throw new \Magento\Core\Exception(__('Fetch transaction details method does not exists in Payflow')); } /** @@ -137,7 +135,7 @@ class Pro extends \Magento\Paypal\Model\Pro ->setIsTransactionClosed(1) // refund initiated by merchant ->setShouldCloseParentTransaction(!$canRefundMore) ->setTransactionAdditionalInfo( - \Magento\PaypalUk\Model\Pro::TRANSPORT_PAYFLOW_TXN_ID, + self::TRANSPORT_PAYFLOW_TXN_ID, $api->getTransactionId() ); $payment->setPreparedMessage(__('Payflow PNREF: #%1.', $api->getTransactionId())); diff --git a/app/code/Magento/PaypalUk/Model/Direct.php b/app/code/Magento/Paypal/Model/PayflowDirect.php similarity index 90% rename from app/code/Magento/PaypalUk/Model/Direct.php rename to app/code/Magento/Paypal/Model/PayflowDirect.php index d12e147a24a4e0e6c754feb14754b4e5d2a1ab10..1c30e094b202eb26d13ff8456a50303b7ce5b6ce 100644 --- a/app/code/Magento/PaypalUk/Model/Direct.php +++ b/app/code/Magento/Paypal/Model/PayflowDirect.php @@ -18,18 +18,13 @@ * 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_PaypalUk * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -/** - * PayPalUk Direct Module - */ -namespace Magento\PaypalUk\Model; +namespace Magento\Paypal\Model; -class Direct extends \Magento\Paypal\Model\Direct +class PayflowDirect extends \Magento\Paypal\Model\Direct { protected $_code = \Magento\Paypal\Model\Config::METHOD_WPP_PE_DIRECT; @@ -38,7 +33,7 @@ class Direct extends \Magento\Paypal\Model\Direct * * @var string */ - protected $_proType = 'Magento\PaypalUk\Model\Pro'; + protected $_proType = 'Magento\Paypal\Model\Payflow\Pro'; /** * Return available CC types for gateway based on merchant country @@ -78,7 +73,7 @@ class Direct extends \Magento\Paypal\Model\Direct $payment->setTransactionId($api->getPaypalTransactionId())->setIsTransactionClosed(0) ->setIsTransactionPending($api->getIsPaymentPending()) ->setTransactionAdditionalInfo( - \Magento\PaypalUk\Model\Pro::TRANSPORT_PAYFLOW_TXN_ID, + \Magento\Paypal\Model\Payflow\Pro::TRANSPORT_PAYFLOW_TXN_ID, $api->getTransactionId() ); $payment->setPreparedMessage(__('Payflow PNREF: #%1.', $api->getTransactionId())); diff --git a/app/code/Magento/PaypalUk/Model/Express.php b/app/code/Magento/Paypal/Model/PayflowExpress.php similarity index 91% rename from app/code/Magento/PaypalUk/Model/Express.php rename to app/code/Magento/Paypal/Model/PayflowExpress.php index f3532a0929b258cc73b71112131ac43e45771757..cceebc35964e8d9ff138d4a07576426073684309 100644 --- a/app/code/Magento/PaypalUk/Model/Express.php +++ b/app/code/Magento/Paypal/Model/PayflowExpress.php @@ -18,21 +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_PaypalUk * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -/** - * PayPalUk Express Module - */ -namespace Magento\PaypalUk\Model; +namespace Magento\Paypal\Model; -class Express extends \Magento\Paypal\Model\Express +class PayflowExpress extends \Magento\Paypal\Model\Express { protected $_code = \Magento\Paypal\Model\Config::METHOD_WPP_PE_EXPRESS; - protected $_formBlockType = 'Magento\PaypalUk\Block\Express\Form'; + protected $_formBlockType = 'Magento\Paypal\Block\PayflowExpress\Form'; protected $_canCreateBillingAgreement = false; protected $_canManageRecurringProfiles = false; @@ -41,7 +36,7 @@ class Express extends \Magento\Paypal\Model\Express * * @var $_proType string */ - protected $_proType = 'Magento\PaypalUk\Model\Pro'; + protected $_proType = 'Magento\Paypal\Model\Payflow\Pro'; /** * Express Checkout payment method instance @@ -127,7 +122,7 @@ class Express extends \Magento\Paypal\Model\Express $api->getRedirectRequired() || $api->getRedirectRequested() ) ->setIsTransactionPending($api->getIsPaymentPending()) - ->setTransactionAdditionalInfo(\Magento\PaypalUk\Model\Pro::TRANSPORT_PAYFLOW_TXN_ID, + ->setTransactionAdditionalInfo(\Magento\Paypal\Model\Payflow\Pro::TRANSPORT_PAYFLOW_TXN_ID, $api->getTransactionId()) ; $payment->setPreparedMessage(__('Payflow PNREF: #%1.', $api->getTransactionId())); @@ -143,6 +138,6 @@ class Express extends \Magento\Paypal\Model\Express */ public function getCheckoutRedirectUrl() { - return $this->_urlBuilder->getUrl('paypaluk/express/start'); + return $this->_urlBuilder->getUrl('paypal/payflowexpress/start'); } } diff --git a/app/code/Magento/PaypalUk/Model/Express/Checkout.php b/app/code/Magento/Paypal/Model/PayflowExpress/Checkout.php similarity index 90% rename from app/code/Magento/PaypalUk/Model/Express/Checkout.php rename to app/code/Magento/Paypal/Model/PayflowExpress/Checkout.php index 5edd5ce35d4ccbeec216dfba9f1ec71444eb71b9..5b7f1ae5877a4724b43efe0d9f0b1b69c6a4280e 100644 --- a/app/code/Magento/PaypalUk/Model/Express/Checkout.php +++ b/app/code/Magento/Paypal/Model/PayflowExpress/Checkout.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_PaypalUk * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ @@ -28,7 +26,7 @@ * Wrapper that performs Paypal Express and Checkout communication * Use current Paypal Express method instance */ -namespace Magento\PaypalUk\Model\Express; +namespace Magento\Paypal\Model\PayflowExpress; class Checkout extends \Magento\Paypal\Model\Express\Checkout { @@ -37,7 +35,7 @@ class Checkout extends \Magento\Paypal\Model\Express\Checkout * * @var string */ - protected $_apiType = 'Magento\PaypalUk\Model\Api\Nvp'; + protected $_apiType = 'Magento\Paypal\Model\Api\PayflowNvp'; /** * Payment method type diff --git a/app/code/Magento/Paypal/Model/Payflowlink.php b/app/code/Magento/Paypal/Model/Payflowlink.php index c0ba12f013d6f70f7011b5c7189da068ef743cd8..889ef28538263a945d1a83b65cad9709b14b5d81 100644 --- a/app/code/Magento/Paypal/Model/Payflowlink.php +++ b/app/code/Magento/Paypal/Model/Payflowlink.php @@ -741,7 +741,7 @@ class Payflowlink extends \Magento\Paypal\Model\Payflowpro /** @var $website \Magento\Core\Model\Website */ $website = $this->_websiteFactory->create()->load($this->_requestHttp->getParam('website')); $secure = $this->_coreStoreConfig->getConfigFlag( - \Magento\Core\Model\Url::XML_PATH_SECURE_IN_FRONT, + \Magento\Core\Model\Store::XML_PATH_SECURE_IN_FRONTEND, $website->getDefaultStore() ); $path = $secure @@ -749,9 +749,9 @@ class Payflowlink extends \Magento\Paypal\Model\Payflowpro : \Magento\Core\Model\Store::XML_PATH_UNSECURE_BASE_LINK_URL; $websiteUrl = $this->_coreStoreConfig->getConfig($path, $website->getDefaultStore()); } else { - $secure = $this->_coreStoreConfig->getConfigFlag(\Magento\Core\Model\Url::XML_PATH_SECURE_IN_FRONT); + $secure = $this->_coreStoreConfig->getConfigFlag(\Magento\Core\Model\Store::XML_PATH_SECURE_IN_FRONTEND); $websiteUrl = $this->_storeManager->getStore() - ->getBaseUrl(\Magento\Core\Model\Store::URL_TYPE_LINK, $secure); + ->getBaseUrl(\Magento\UrlInterface::URL_TYPE_LINK, $secure); } return $websiteUrl . 'paypal/' . $this->getCallbackController() . '/' . $actionName; diff --git a/app/code/Magento/Paypal/Model/System/Config/Backend/Cert.php b/app/code/Magento/Paypal/Model/System/Config/Backend/Cert.php index 7795617eac352fddf3d3b1881b41dc187ad1b82d..65a5e8e16b14fb5f4b70dfb207905e389849d346 100644 --- a/app/code/Magento/Paypal/Model/System/Config/Backend/Cert.php +++ b/app/code/Magento/Paypal/Model/System/Config/Backend/Cert.php @@ -50,7 +50,7 @@ class Cert extends \Magento\Core\Model\Config\Value * @param \Magento\Core\Model\Context $context * @param \Magento\Core\Model\Registry $registry * @param \Magento\Core\Model\StoreManagerInterface $storeManager - * @param \Magento\Core\Model\Config $config + * @param \Magento\App\ConfigInterface $config * @param \Magento\Paypal\Model\CertFactory $certFactory * @param \Magento\Encryption\EncryptorInterface $encryptor * @param \Magento\App\Filesystem $filesystem @@ -62,7 +62,7 @@ class Cert extends \Magento\Core\Model\Config\Value \Magento\Core\Model\Context $context, \Magento\Core\Model\Registry $registry, \Magento\Core\Model\StoreManagerInterface $storeManager, - \Magento\Core\Model\Config $config, + \Magento\App\ConfigInterface $config, \Magento\Paypal\Model\CertFactory $certFactory, \Magento\Encryption\EncryptorInterface $encryptor, \Magento\App\Filesystem $filesystem, diff --git a/app/code/Magento/Paypal/Model/System/Config/Backend/Cron.php b/app/code/Magento/Paypal/Model/System/Config/Backend/Cron.php index b29d051f14751633cc8b0fb820d3c39b919867c8..704a7cf08b0cddc6955ccafdc193f6a8bddfef3c 100644 --- a/app/code/Magento/Paypal/Model/System/Config/Backend/Cron.php +++ b/app/code/Magento/Paypal/Model/System/Config/Backend/Cron.php @@ -40,7 +40,7 @@ class Cron extends \Magento\Core\Model\Config\Value * @param \Magento\Core\Model\Context $context * @param \Magento\Core\Model\Registry $registry * @param \Magento\Core\Model\StoreManagerInterface $storeManager - * @param \Magento\Core\Model\Config $config + * @param \Magento\App\ConfigInterface $config * @param \Magento\Core\Model\Config\ValueFactory $configValueFactory * @param \Magento\Core\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection @@ -50,7 +50,7 @@ class Cron extends \Magento\Core\Model\Config\Value \Magento\Core\Model\Context $context, \Magento\Core\Model\Registry $registry, \Magento\Core\Model\StoreManagerInterface $storeManager, - \Magento\Core\Model\Config $config, + \Magento\App\ConfigInterface $config, \Magento\Core\Model\Config\ValueFactory $configValueFactory, \Magento\Core\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, diff --git a/app/code/Magento/Paypal/Model/System/Config/Backend/MerchantCountry.php b/app/code/Magento/Paypal/Model/System/Config/Backend/MerchantCountry.php index c94e0d56c97e8a35db40cef214e9f72f4cb1461a..326b780a9e3ecdbe67192fc2ae9e47eb77f73819 100644 --- a/app/code/Magento/Paypal/Model/System/Config/Backend/MerchantCountry.php +++ b/app/code/Magento/Paypal/Model/System/Config/Backend/MerchantCountry.php @@ -42,7 +42,7 @@ class MerchantCountry extends \Magento\Core\Model\Config\Value * @param \Magento\Core\Model\Context $context * @param \Magento\Core\Model\Registry $registry * @param \Magento\Core\Model\StoreManagerInterface $storeManager - * @param \Magento\Core\Model\Config $config + * @param \Magento\App\ConfigInterface $config * @param \Magento\Core\Helper\Data $coreData * @param \Magento\Core\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection @@ -52,7 +52,7 @@ class MerchantCountry extends \Magento\Core\Model\Config\Value \Magento\Core\Model\Context $context, \Magento\Core\Model\Registry $registry, \Magento\Core\Model\StoreManagerInterface $storeManager, - \Magento\Core\Model\Config $config, + \Magento\App\ConfigInterface $config, \Magento\Core\Helper\Data $coreData, \Magento\Core\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, diff --git a/app/code/Magento/Paypal/etc/adminhtml/di.xml b/app/code/Magento/Paypal/etc/adminhtml/di.xml index 91084386edc1eded7455618677d40565ffe844f3..ab03f77ce1d279a7e38c0847f7dfc84d2ddc263a 100644 --- a/app/code/Magento/Paypal/etc/adminhtml/di.xml +++ b/app/code/Magento/Paypal/etc/adminhtml/di.xml @@ -37,6 +37,19 @@ <value>adminhtml</value> </param> </virtualType> + <virtualType name="Magento\Paypal\Model\PayflowSession\Storage" type="Magento\Session\Storage"> + <param name="namespace"> + <value>paypal_payflow</value> + </param> + </virtualType> + <virtualType name="Magento\Paypal\Model\PayflowSession" type="Magento\Session\Generic"> + <param name="storage"> + <instance type="Magento\Paypal\Model\PayflowSession\Storage" /> + </param> + <param name="sessionName"> + <value>adminhtml</value> + </param> + </virtualType> <type name="Magento\Session\Generic"> <param name="sessionName"> <value>adminhtml</value> diff --git a/app/code/Magento/Paypal/etc/adminhtml/system.xml b/app/code/Magento/Paypal/etc/adminhtml/system.xml index 1cca5c8a2428b9a0093389f6a8d33e27ef3c4b21..4a389aaff6727aa72ed2cad5b09e7f0ec3cc51a5 100644 --- a/app/code/Magento/Paypal/etc/adminhtml/system.xml +++ b/app/code/Magento/Paypal/etc/adminhtml/system.xml @@ -70,7 +70,7 @@ <comment>Process payments using your own internet merchant account.</comment> <help_url>https://merchant.paypal.com/cgi-bin/marketingweb?cmd=_render-content</help_url> <group id="payflow_link_us" extends="*/paypal_payments/payflow_link" /> - <group id="paypal_verisign_with_express_checkout_us" extends="*/paypal_payments/paypal_verisign_with_express_checkout"> + <group id="paypal_payflowpro_with_express_checkout_us" extends="*/paypal_payments/paypal_payflowpro_with_express_checkout"> <group id="paypal_payflow_required"> <field id="enable_paypal_payflow"> <frontend_class>paypal-enabler paypal-ec-pe</frontend_class> @@ -172,7 +172,7 @@ <attribute type="shared">1</attribute> </field> <field id="enable_express_checkout" translate="label" type="select" sortOrder="40" showInDefault="1" showInWebsite="1"> - <config_path>payment/paypaluk_express/active</config_path> + <config_path>payment/payflow_express/active</config_path> <frontend_model>Magento\Paypal\Block\Adminhtml\System\Config\Field\Hidden</frontend_model> <source_model>Magento\Backend\Model\Config\Source\Yesno</source_model> <frontend_class>paypal-ec-payflow-enabler</frontend_class> @@ -288,12 +288,12 @@ <group id="settings_express_checkout" type="text" translate="label" showInDefault="1" showInWebsite="1" showInStore="1" sortOrder="30"> <label>Basic Settings - PayPal Express Checkout</label> <frontend_model>Magento\Paypal\Block\Adminhtml\System\Config\Fieldset\Expanded</frontend_model> - <field id="title" extends="payment/paypal_payments/paypal_verisign_with_express_checkout/paypal_payflow_express_checkout/title" /> - <field id="sort_order" extends="payment/paypal_payments/paypal_verisign_with_express_checkout/paypal_payflow_express_checkout/sort_order" /> - <field id="payment_action" extends="payment/paypal_payments/paypal_verisign_with_express_checkout/paypal_payflow_express_checkout/payment_action" /> - <field id="visible_on_cart" extends="payment/paypal_payments/paypal_verisign_with_express_checkout/paypal_payflow_express_checkout/visible_on_cart" /> - <field id="visible_on_product" extends="payment/paypal_payments/paypal_verisign_with_express_checkout/paypal_payflow_express_checkout/visible_on_product" /> - <group id="settings_express_checkout_advanced" type="group" extends="payment/paypal_payments/paypal_verisign_with_express_checkout/paypal_payflow_express_checkout/paypal_payflow_express_checkout_advanced"/> + <field id="title" extends="payment/paypal_payments/paypal_payflowpro_with_express_checkout/paypal_payflow_express_checkout/title" /> + <field id="sort_order" extends="payment/paypal_payments/paypal_payflowpro_with_express_checkout/paypal_payflow_express_checkout/sort_order" /> + <field id="payment_action" extends="payment/paypal_payments/paypal_payflowpro_with_express_checkout/paypal_payflow_express_checkout/payment_action" /> + <field id="visible_on_cart" extends="payment/paypal_payments/paypal_payflowpro_with_express_checkout/paypal_payflow_express_checkout/visible_on_cart" /> + <field id="visible_on_product" extends="payment/paypal_payments/paypal_payflowpro_with_express_checkout/paypal_payflow_express_checkout/visible_on_product" /> + <group id="settings_express_checkout_advanced" type="group" extends="payment/paypal_payments/paypal_payflowpro_with_express_checkout/paypal_payflow_express_checkout/paypal_payflow_express_checkout_advanced"/> </group> </group> <group id="wpp" type="text" translate="label comment" showInDefault="1" showInWebsite="1" showInStore="1" sortOrder="40"> @@ -602,12 +602,12 @@ </group> </group> </group> - <group id="paypal_verisign" type="text" translate="label comment" showInDefault="1" showInWebsite="1" showInStore="1" sortOrder="10"> + <group id="paypal_payflowpro" type="text" translate="label comment" showInDefault="1" showInWebsite="1" showInStore="1" sortOrder="10"> <label>Payflow Pro</label> <frontend_model>Magento\Paypal\Block\Adminhtml\System\Config\Fieldset\Payment</frontend_model> <fieldset_css>pp-method-payflow</fieldset_css> <comment>Connect your merchant account with a fully customizable gateway that lets customers pay without leaving your site.</comment> - <attribute type="activity_path">payment/verisign/active</attribute> + <attribute type="activity_path">payment/payflowpro/active</attribute> <more_url>https://www.paypal.com/webapps/mpp/referral/paypal-payflow-pro?partner_id=NB9WWHYEMVUMS</more_url> <attribute type="paypal_ec_separate">1</attribute> <group id="paypal_payflow_required" type="text" translate="label" showInDefault="1" showInWebsite="1" sortOrder="10"> @@ -618,41 +618,41 @@ <frontend_model>Magento\Paypal\Block\Adminhtml\System\Config\Fieldset\Expanded</frontend_model> <field id="partner" translate="label" type="text" sortOrder="20" showInDefault="1" showInWebsite="1"> <label>Partner</label> - <config_path>payment/verisign/partner</config_path> + <config_path>payment/payflowpro/partner</config_path> <attribute type="shared">1</attribute> </field> <field id="user" translate="label" type="obscure" sortOrder="30" showInDefault="1" showInWebsite="1"> <label>User</label> - <config_path>payment/verisign/user</config_path> + <config_path>payment/payflowpro/user</config_path> <backend_model>Magento\Backend\Model\Config\Backend\Encrypted</backend_model> <attribute type="shared">1</attribute> </field> <field id="vendor" translate="label" type="text" sortOrder="40" showInDefault="1" showInWebsite="1"> <label>Vendor</label> - <config_path>payment/verisign/vendor</config_path> + <config_path>payment/payflowpro/vendor</config_path> <attribute type="shared">1</attribute> </field> <field id="pwd" translate="label" type="obscure" sortOrder="50" showInDefault="1" showInWebsite="1"> <label>Password</label> - <config_path>payment/verisign/pwd</config_path> + <config_path>payment/payflowpro/pwd</config_path> <backend_model>Magento\Backend\Model\Config\Backend\Encrypted</backend_model> <attribute type="shared">1</attribute> </field> <field id="sandbox_flag" translate="label" type="select" sortOrder="60" showInDefault="1" showInWebsite="1"> <label>Test Mode</label> - <config_path>payment/verisign/sandbox_flag</config_path> + <config_path>payment/payflowpro/sandbox_flag</config_path> <source_model>Magento\Backend\Model\Config\Source\Yesno</source_model> <attribute type="shared">1</attribute> </field> <field id="use_proxy" translate="label" type="select" sortOrder="70" showInDefault="1" showInWebsite="1"> <label>Use Proxy</label> - <config_path>payment/verisign/use_proxy</config_path> + <config_path>payment/payflowpro/use_proxy</config_path> <source_model>Magento\Backend\Model\Config\Source\Yesno</source_model> <attribute type="shared">1</attribute> </field> <field id="proxy_host" translate="label" type="text" sortOrder="80" showInDefault="1" showInWebsite="1"> <label>Proxy Host</label> - <config_path>payment/verisign/proxy_host</config_path> + <config_path>payment/payflowpro/proxy_host</config_path> <depends> <field id="use_proxy">1</field> </depends> @@ -660,7 +660,7 @@ </field> <field id="proxy_port" translate="label" type="text" sortOrder="90" showInDefault="1" showInWebsite="1"> <label>Proxy Port</label> - <config_path>payment/verisign/proxy_port</config_path> + <config_path>payment/payflowpro/proxy_port</config_path> <depends> <field id="use_proxy">1</field> </depends> @@ -669,7 +669,7 @@ </group> <field id="enable_paypal_payflow" translate="label" type="select" sortOrder="20" showInDefault="1" showInWebsite="1"> <label>Enable this Solution</label> - <config_path>payment/verisign/active</config_path> + <config_path>payment/payflowpro/active</config_path> <source_model>Magento\Backend\Model\Config\Source\Yesno</source_model> <requires> <group id="paypal_payflow_api_settings"/> @@ -684,18 +684,18 @@ <field id="title" translate="label comment" type="text" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1"> <label>Title</label> <comment>It is recommended to set this value to "Debit or Credit Card" per store views.</comment> - <config_path>payment/verisign/title</config_path> + <config_path>payment/payflowpro/title</config_path> <attribute type="shared">1</attribute> </field> <field id="sort_order" translate="label" type="text" sortOrder="20" showInDefault="1" showInWebsite="1" showInStore="1"> <label>Sort Order</label> - <config_path>payment/verisign/sort_order</config_path> + <config_path>payment/payflowpro/sort_order</config_path> <frontend_class>validate-number</frontend_class> <attribute type="shared">1</attribute> </field> <field id="payment_action" translate="label" type="select" sortOrder="30" showInDefault="1" showInWebsite="1"> <label>Payment Action</label> - <config_path>payment/verisign/payment_action</config_path> + <config_path>payment/payflowpro/payment_action</config_path> <source_model>Magento\Paypal\Model\System\Config\Source\PaymentActions</source_model> <attribute type="shared">1</attribute> </field> @@ -709,7 +709,7 @@ <comment> <![CDATA[Supporting of American Express cards require additional agreement. Learn more at <a href="http://www.paypal.com/amexupdate">http://www.paypal.com/amexupdate</a>.]]> </comment> - <config_path>payment/verisign/cctypes</config_path> + <config_path>payment/payflowpro/cctypes</config_path> <source_model>Magento\Paypal\Model\Config::getPayflowproCcTypesAsOptionArray</source_model> <attribute type="shared">1</attribute> </field> @@ -718,13 +718,13 @@ <fieldset_css>config-advanced</fieldset_css> <field id="allowspecific" translate="label" type="select" sortOrder="10" showInDefault="1" showInWebsite="1"> <label>Payment Applicable From</label> - <config_path>payment/verisign/allowspecific</config_path> + <config_path>payment/payflowpro/allowspecific</config_path> <source_model>Magento\Payment\Model\Config\Source\Allspecificcountries</source_model> <attribute type="shared">1</attribute> </field> <field id="specificcountry" translate="label" type="multiselect" sortOrder="20" showInDefault="1" showInWebsite="1"> <label>Countries Payment Applicable From</label> - <config_path>payment/verisign/specificcountry</config_path> + <config_path>payment/payflowpro/specificcountry</config_path> <source_model>Magento\Paypal\Model\System\Config\Source\BuyerCountry</source_model> <depends> <field id="allowspecific">1</field> @@ -733,19 +733,19 @@ </field> <field id="debug" translate="label" type="select" sortOrder="30" showInDefault="1" showInWebsite="1"> <label>Debug Mode</label> - <config_path>payment/verisign/debug</config_path> + <config_path>payment/payflowpro/debug</config_path> <source_model>Magento\Backend\Model\Config\Source\Yesno</source_model> <attribute type="shared">1</attribute> </field> <field id="verify_peer" translate="label" type="select" sortOrder="35" showInDefault="1" showInWebsite="1"> <label>Enable SSL verification</label> - <config_path>payment/verisign/verify_peer</config_path> + <config_path>payment/payflowpro/verify_peer</config_path> <source_model>Magento\Backend\Model\Config\Source\Yesno</source_model> <attribute type="shared">1</attribute> </field> <field id="useccv" translate="label" type="select" sortOrder="40" showInDefault="1" showInWebsite="1"> <label>Require CVV Entry</label> - <config_path>payment/verisign/useccv</config_path> + <config_path>payment/payflowpro/useccv</config_path> <source_model>Magento\Backend\Model\Config\Source\Yesno</source_model> <attribute type="shared">1</attribute> </field> @@ -756,13 +756,13 @@ </field> <field id="centinel" translate="label" type="select" sortOrder="60" showInDefault="1" showInWebsite="1"> <label>3D Secure Card Validation</label> - <config_path>payment/verisign/centinel</config_path> + <config_path>payment/payflowpro/centinel</config_path> <source_model>Magento\Backend\Model\Config\Source\Yesno</source_model> <attribute type="shared">1</attribute> </field> <field id="centinel_is_mode_strict" translate="label comment" type="select" sortOrder="70" showInDefault="1" showInWebsite="1"> <label>Severe 3D Secure Card Validation</label> - <config_path>payment/verisign/centinel_is_mode_strict</config_path> + <config_path>payment/payflowpro/centinel_is_mode_strict</config_path> <comment>Severe validation removes chargeback liability on merchant.</comment> <source_model>Magento\Backend\Model\Config\Source\Yesno</source_model> <depends> @@ -772,7 +772,7 @@ </field> <field id="centinel_api_url" translate="label comment" type="text" sortOrder="80" showInDefault="1" showInWebsite="1"> <label>Centinel API URL</label> - <config_path>payment/verisign/centinel_api_url</config_path> + <config_path>payment/payflowpro/centinel_api_url</config_path> <comment>A value is required for live mode. Refer to your CardinalCommerce agreement.</comment> <source_model>Magento\Backend\Model\Config\Source\Yesno</source_model> <depends> @@ -796,7 +796,7 @@ </group> </group> </group> - <group id="paypal_verisign_with_express_checkout" type="group" translate="label comment" extends="payment/paypal_payments/paypal_verisign"> + <group id="paypal_payflowpro_with_express_checkout" type="group" translate="label comment" extends="payment/paypal_payments/paypal_payflowpro"> <label>Payflow Pro (Includes Express Checkout)</label> <attribute type="paypal_ec_separate">0</attribute> <group id="paypal_payflow_required" type="text" translate="label" showInDefault="1" showInWebsite="1" sortOrder="10"> @@ -829,31 +829,31 @@ <frontend_model>Magento\Paypal\Block\Adminhtml\System\Config\Fieldset\Expanded</frontend_model> <field id="title" translate="label" type="text" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1"> <label>Title</label> - <config_path>payment/paypaluk_express/title</config_path> + <config_path>payment/payflow_express/title</config_path> <attribute type="shared">1</attribute> </field> <field id="sort_order" translate="label" type="text" sortOrder="20" showInDefault="1" showInWebsite="1" showInStore="1"> <label>Sort Order</label> - <config_path>payment/paypaluk_express/sort_order</config_path> + <config_path>payment/payflow_express/sort_order</config_path> <frontend_class>validate-number</frontend_class> <attribute type="shared">1</attribute> </field> <field id="payment_action" translate="label" type="select" sortOrder="30" showInDefault="1" showInWebsite="1"> <label>Payment Action</label> - <config_path>payment/paypaluk_express/payment_action</config_path> + <config_path>payment/payflow_express/payment_action</config_path> <source_model>Magento\Paypal\Model\System\Config\Source\PaymentActions</source_model> <attribute type="shared">1</attribute> </field> <field id="visible_on_cart" translate="label comment" type="select" sortOrder="40" showInDefault="1" showInWebsite="1" showInStore="1"> <label>Shortcut on Shopping Cart</label> <comment>Also affects mini-shopping cart.</comment> - <config_path>payment/paypaluk_express/visible_on_cart</config_path> + <config_path>payment/payflow_express/visible_on_cart</config_path> <source_model>Magento\Backend\Model\Config\Source\Yesno</source_model> <attribute type="shared">1</attribute> </field> <field id="visible_on_product" translate="label" type="select" sortOrder="50" showInDefault="1" showInWebsite="1" showInStore="1"> <label>Shortcut on Product View</label> - <config_path>payment/paypaluk_express/visible_on_product</config_path> + <config_path>payment/payflow_express/visible_on_product</config_path> <source_model>Magento\Backend\Model\Config\Source\Yesno</source_model> <attribute type="shared">1</attribute> </field> @@ -862,13 +862,13 @@ <fieldset_css>config-advanced</fieldset_css> <field id="allowspecific" translate="label" type="select" sortOrder="10" showInDefault="1" showInWebsite="1"> <label>Payment Applicable From</label> - <config_path>payment/paypaluk_express/allowspecific</config_path> + <config_path>payment/payflow_express/allowspecific</config_path> <source_model>Magento\Payment\Model\Config\Source\Allspecificcountries</source_model> <attribute type="shared">1</attribute> </field> <field id="specificcountry" translate="label" type="multiselect" sortOrder="20" showInDefault="1" showInWebsite="1"> <label>Countries Payment Applicable From</label> - <config_path>payment/paypaluk_express/specificcountry</config_path> + <config_path>payment/payflow_express/specificcountry</config_path> <source_model>Magento\Paypal\Model\System\Config\Source\BuyerCountry</source_model> <depends> <field id="allowspecific">1</field> @@ -877,19 +877,19 @@ </field> <field id="debug" translate="label" type="select" sortOrder="30" showInDefault="1" showInWebsite="1"> <label>Debug Mode</label> - <config_path>payment/paypaluk_express/debug</config_path> + <config_path>payment/payflow_express/debug</config_path> <source_model>Magento\Backend\Model\Config\Source\Yesno</source_model> <attribute type="shared">1</attribute> </field> <field id="verify_peer" translate="label" type="select" sortOrder="35" showInDefault="1" showInWebsite="1"> <label>Enable SSL verification</label> - <config_path>payment/paypaluk_express/verify_peer</config_path> + <config_path>payment/payflow_express/verify_peer</config_path> <source_model>Magento\Backend\Model\Config\Source\Yesno</source_model> <attribute type="shared">1</attribute> </field> <field id="line_items_enabled" translate="label" type="select" sortOrder="40" showInDefault="1" showInWebsite="1"> <label>Transfer Cart Line Items</label> - <config_path>payment/paypaluk_express/line_items_enabled</config_path> + <config_path>payment/payflow_express/line_items_enabled</config_path> <source_model>Magento\Backend\Model\Config\Source\Yesno</source_model> <attribute type="shared">1</attribute> </field> @@ -981,7 +981,7 @@ </field> <field id="enable_express_checkout" translate="label" type="select" sortOrder="40" showInDefault="1" showInWebsite="1"> <label>Enable Express Checkout</label> - <config_path>payment/paypaluk_express/active</config_path> + <config_path>payment/payflow_express/active</config_path> <source_model>Magento\Backend\Model\Config\Source\Yesno</source_model> <frontend_class>paypal-ec-payflow-enabler</frontend_class> <attribute type="shared">1</attribute> @@ -1096,12 +1096,12 @@ <group id="settings_payflow_link_express_checkout" type="text" translate="label" showInDefault="1" showInWebsite="1" showInStore="1" sortOrder="30"> <label>Basic Settings - PayPal Express Checkout</label> <frontend_model>Magento\Paypal\Block\Adminhtml\System\Config\Fieldset\Expanded</frontend_model> - <field id="title" extends="payment/paypal_payments/paypal_verisign_with_express_checkout/paypal_payflow_express_checkout/title" /> - <field id="sort_order" extends="payment/paypal_payments/paypal_verisign_with_express_checkout/paypal_payflow_express_checkout/sort_order" /> - <field id="payment_action" extends="payment/paypal_payments/paypal_verisign_with_express_checkout/paypal_payflow_express_checkout/payment_action" /> - <field id="visible_on_cart" extends="payment/paypal_payments/paypal_verisign_with_express_checkout/paypal_payflow_express_checkout/visible_on_cart" /> - <field id="visible_on_product" extends="payment/paypal_payments/paypal_verisign_with_express_checkout/paypal_payflow_express_checkout/visible_on_product" /> - <group id="settings_payflow_link_express_checkout_advanced" type="group" extends="payment/paypal_payments/paypal_verisign_with_express_checkout/paypal_payflow_express_checkout/paypal_payflow_express_checkout_advanced"/> + <field id="title" extends="payment/paypal_payments/paypal_payflowpro_with_express_checkout/paypal_payflow_express_checkout/title" /> + <field id="sort_order" extends="payment/paypal_payments/paypal_payflowpro_with_express_checkout/paypal_payflow_express_checkout/sort_order" /> + <field id="payment_action" extends="payment/paypal_payments/paypal_payflowpro_with_express_checkout/paypal_payflow_express_checkout/payment_action" /> + <field id="visible_on_cart" extends="payment/paypal_payments/paypal_payflowpro_with_express_checkout/paypal_payflow_express_checkout/visible_on_cart" /> + <field id="visible_on_product" extends="payment/paypal_payments/paypal_payflowpro_with_express_checkout/paypal_payflow_express_checkout/visible_on_product" /> + <group id="settings_payflow_link_express_checkout_advanced" type="group" extends="payment/paypal_payments/paypal_payflowpro_with_express_checkout/paypal_payflow_express_checkout/paypal_payflow_express_checkout_advanced"/> </group> </group> <group id="express_checkout" type="text" translate="label comment" showInDefault="1" showInWebsite="1" showInStore="1" sortOrder="60"> diff --git a/app/code/Magento/Paypal/etc/config.xml b/app/code/Magento/Paypal/etc/config.xml index a9d8bf8375fbfe565a7e05433e9d6293f6b89120..1329049a0f816b85392989eb41fd32bdaf40e4be 100644 --- a/app/code/Magento/Paypal/etc/config.xml +++ b/app/code/Magento/Paypal/etc/config.xml @@ -81,7 +81,7 @@ <group>paypal</group> <verify_peer>1</verify_peer> </paypal_standard> - <paypaluk_express> + <payflow_express> <title>PayPal Express Checkout Payflow Edition</title> <payment_action>Authorization</payment_action> <line_items_enabled>1</line_items_enabled> @@ -89,16 +89,18 @@ <visible_on_product>1</visible_on_product> <group>paypal</group> <verify_peer>1</verify_peer> - </paypaluk_express> - <paypaluk_direct> + <model>Magento\Paypal\Model\PayflowExpress</model> + </payflow_express> + <payflow_direct> <title>PayPal Direct Payment Payflow Edition</title> <payment_action>Authorization</payment_action> <cctypes>VI,MC,AE</cctypes> <useccv>1</useccv> <group>paypal</group> <verify_peer>1</verify_peer> - </paypaluk_direct> - <verisign> + <model>Magento\Paypal\Model\PayflowDirect</model> + </payflow_direct> + <payflowpro> <model>Magento\Paypal\Model\Payflowpro</model> <title>Payflow Pro</title> <payment_action>Authorization</payment_action> @@ -110,7 +112,7 @@ <pwd backend_model="Magento\Backend\Model\Config\Backend\Encrypted" /> <group>paypal</group> <verify_peer>1</verify_peer> - </verisign> + </payflowpro> <paypal_billing_agreement> <active>1</active> <allow_billing_agreement_wizard>1</allow_billing_agreement_wizard> diff --git a/app/code/Magento/Paypal/etc/di.xml b/app/code/Magento/Paypal/etc/di.xml index f2f6f36342569b92f64bd4c673cb368bfab3d933..b8dfd1cb8c7239c5ebe68b9913c913ed3d50d6a9 100644 --- a/app/code/Magento/Paypal/etc/di.xml +++ b/app/code/Magento/Paypal/etc/di.xml @@ -26,9 +26,9 @@ <config> <type name="Magento\Module\Updater\SetupFactory"> <param name="resourceTypes"> - <value> - <paypal_setup>Magento\Sales\Model\Resource\Setup</paypal_setup> - </value> + <array> + <item key="paypal_setup"><value>Magento\Sales\Model\Resource\Setup</value></item> + </array> </param> </type> </config> diff --git a/app/code/Magento/Paypal/etc/frontend/di.xml b/app/code/Magento/Paypal/etc/frontend/di.xml index 0e7b099c3a7ccaae4e745eccdf785989034b51b4..6e1eb584d9d7b417d7af0995368b3c63cc0ccbed 100644 --- a/app/code/Magento/Paypal/etc/frontend/di.xml +++ b/app/code/Magento/Paypal/etc/frontend/di.xml @@ -37,6 +37,19 @@ <value>frontend</value> </param> </virtualType> + <virtualType name="Magento\Paypal\Model\PayflowSession\Storage" type="Magento\Session\Storage"> + <param name="namespace"> + <value>paypal_payflow</value> + </param> + </virtualType> + <virtualType name="Magento\Paypal\Model\PayflowSession" type="Magento\Session\Generic"> + <param name="storage"> + <instance type="Magento\Paypal\Model\PayflowSession\Storage" /> + </param> + <param name="sessionName"> + <value>frontend</value> + </param> + </virtualType> <type name="Magento\Session\Generic"> <param name="sessionName"> <value>frontend</value> @@ -44,11 +57,12 @@ </type> <type name="Magento\Core\Model\Url\SecurityInfo"> <param name="secureUrlList"> - <value> - <paypal_express>/paypal/express</paypal_express> - <paypal_standard>/paypal/standard</paypal_standard> - <paypal_express_callbackshippingoptions>paypal/express/callbackshippingoptions</paypal_express_callbackshippingoptions> - </value> + <array> + <item key="paypal_express"><value>/paypal/express</value></item> + <item key="paypal_payflowexpress"><value>/paypal/payflowexpress</value></item> + <item key="paypal_standard"><value>/paypal/standard</value></item> + <item key="paypal_express_callbackshippingoptions"><value>paypal/express/callbackshippingoptions</value></item> + </array> </param> </type> </config> diff --git a/app/code/Magento/Paypal/etc/frontend/page_types.xml b/app/code/Magento/Paypal/etc/frontend/page_types.xml index bf5ae85d80754ef20200803f6fb5d03a25e90c4e..44dfffd644bf8350e84e93669ed0558a6963f37e 100644 --- a/app/code/Magento/Paypal/etc/frontend/page_types.xml +++ b/app/code/Magento/Paypal/etc/frontend/page_types.xml @@ -32,4 +32,5 @@ <type id="paypal_payflowadvanced_cancelpayment" label="Paypal Payflow Advanced Cancel Payment"/> <type id="paypal_payflowadvanced_form" label="Paypal Payflow Advanced Form"/> <type id="paypal_payflowadvanced_returnurl" label="Paypal Payflow Advanced Return URL"/> + <type id="paypal_payflowexpress_review" label="PayPal Express Order Review Form"/> </page_types> diff --git a/app/code/Magento/Paypal/i18n/de_DE.csv b/app/code/Magento/Paypal/i18n/de_DE.csv index c64fb741735af1cd03d82f62944951cd3150c54c..6a376dc6ed657093e5921daf185cf0810ecf8e8a 100644 --- a/app/code/Magento/Paypal/i18n/de_DE.csv +++ b/app/code/Magento/Paypal/i18n/de_DE.csv @@ -265,8 +265,10 @@ "PayPal Buyer Warranty Bonus","PayPal Käufer Garantiebonus" "PayPal Debit Card Cash Advance","PayPal Debitkarte Barvorschuss" "PayPal Debit Card Withdrawal from ATM","PayPal Debitkarte Abhebung von ATM" +"PayPal Express Checkout (Payflow Edition) Shortcut Wrapper","PayPal Express Checkout (Payflow Edition) Shortcut Wrapper" "PayPal Express Checkout Shortcut Wrapper","PayPal Express Checkout Shortcut Wrapper" "PayPal Express Checkout Token does not exist.","PayPal Express-Checkout Token existiert nicht." +"PayPal Express Order Review Form","PayPal Express Bestellübersichtsformular" "PayPal Express Order Review Form","PayPal Express Ansicht Bestellformular" "PayPal Fee Information","PayPal Gebühren-Information" "PayPal Merchant Pages Style","PayPal Händlerseiten Design" @@ -309,6 +311,7 @@ "Payments by cards + seller protection - <strong style=""color:red"">Contact PayPal before activating</strong>","Kartenzahlungen + Verkäuferschutz - <strong style=""color:red"">Kontaktieren Sie PayPal vor der Aktivierung</strong>" "Paypal Billing Agreement Settings","PayPal Rechnungsvereinbarung Einstellungen" "Pending PayPal","PayPal ausstehend" +"Phone","Telefon" "Place Order","Erteilen Sie den Auftrag" "Please agree to all the terms and conditions before placing the order.","Bitte stimmen Sie den Allgemeinen Geschäftsbedingungen zu, bevor Sie die Bestellung aufgeben." "Please contact PayPal Customer Service.","Bitte benachrichtigen Sie den PayPal Kundenservice." @@ -387,7 +390,6 @@ "Summary Text for Aggregated Cart","Zusammenfassung des gesamten Korbs" "Supporting of American Express cards require additional agreement. Learn more at <a href=""http://www.paypal.com/amexupdate"">http://www.paypal.com/amexupdate</a>.","Für die Unterstützung von American Express Karten ist eine gesonderte Vereinbarung erforderlich. Erfahren Sie mehr unter at <a href=""http://www.paypal.com/amexupdate"">http://www.paypal.com/amexupdate</a>." "Switch/Maestro","Switch/ Maestro" -"Phone","Telefon" "Test Mode","Testmodus" "The background color for the checkout page around the header and payment form.","Die Hintergrundfarbe für die Checkout-Seite, um die Überschrift und Zahlungsart herum." "The background color for the header of the checkout page. Case-insensitive six-character HTML hexadecimal color code in ASCII.","Die Hintergrundfarbe für die Kopfzeile der Abmeldeseite. Groβ- und Kleinschreibung sechs Buchstaben HTML hexadezimal farbcode in ASII." diff --git a/app/code/Magento/Paypal/i18n/en_US.csv b/app/code/Magento/Paypal/i18n/en_US.csv index e49ace98a3b1d5edcf092284bcf0f30e522961dc..f01e1a3be161494a1e32cbd243628290a1160a8e 100644 --- a/app/code/Magento/Paypal/i18n/en_US.csv +++ b/app/code/Magento/Paypal/i18n/en_US.csv @@ -265,6 +265,7 @@ "PayPal Buyer Warranty Bonus","PayPal Buyer Warranty Bonus" "PayPal Debit Card Cash Advance","PayPal Debit Card Cash Advance" "PayPal Debit Card Withdrawal from ATM","PayPal Debit Card Withdrawal from ATM" +"PayPal Express Checkout (Payflow Edition) Shortcut Wrapper","PayPal Express Checkout (Payflow Edition) Shortcut Wrapper" "PayPal Express Checkout Shortcut Wrapper","PayPal Express Checkout Shortcut Wrapper" "PayPal Express Checkout Token does not exist.","PayPal Express Checkout Token does not exist." "PayPal Express Order Review Form","PayPal Express Order Review Form" @@ -309,6 +310,7 @@ "Payments by cards + seller protection - <strong style=""color:red"">Contact PayPal before activating</strong>","Payments by cards + seller protection - <strong style=""color:red"">Contact PayPal before activating</strong>" "Paypal Billing Agreement Settings","Paypal Billing Agreement Settings" "Pending PayPal","Pending PayPal" +"Phone","Phone" "Place Order","Place Order" "Please agree to all the terms and conditions before placing the order.","Please agree to all the terms and conditions before placing the order." "Please contact PayPal Customer Service.","Please contact PayPal Customer Service." @@ -387,7 +389,6 @@ "Summary Text for Aggregated Cart","Summary Text for Aggregated Cart" "Supporting of American Express cards require additional agreement. Learn more at <a href=""http://www.paypal.com/amexupdate"">http://www.paypal.com/amexupdate</a>.","Supporting of American Express cards require additional agreement. Learn more at <a href=""http://www.paypal.com/amexupdate"">http://www.paypal.com/amexupdate</a>." "Switch/Maestro","Switch/Maestro" -"Phone","Phone" "Test Mode","Test Mode" "The background color for the checkout page around the header and payment form.","The background color for the checkout page around the header and payment form." "The background color for the header of the checkout page. Case-insensitive six-character HTML hexadecimal color code in ASCII.","The background color for the header of the checkout page. Case-insensitive six-character HTML hexadecimal color code in ASCII." diff --git a/app/code/Magento/Paypal/i18n/es_ES.csv b/app/code/Magento/Paypal/i18n/es_ES.csv index e61b0062eb0fb97e360c68d9691d701b7d7ab013..842818ce40a230dac3bed3630fa8f4970a5beacb 100644 --- a/app/code/Magento/Paypal/i18n/es_ES.csv +++ b/app/code/Magento/Paypal/i18n/es_ES.csv @@ -265,8 +265,10 @@ "PayPal Buyer Warranty Bonus","Bonificación de garantÃa del comprador en PayPal" "PayPal Debit Card Cash Advance","Adelanto de efectivo de una tarjeta de débito en PayPal" "PayPal Debit Card Withdrawal from ATM","Retiro de dinero de tarjeta de débido de PayPal desde un cajero automático" +"PayPal Express Checkout (Payflow Edition) Shortcut Wrapper","Contenedor de acceso directo a Pago Express de PayPal (Edición de Flujo de Pago)" "PayPal Express Checkout Shortcut Wrapper","Acceso directo al check-out exprés de PayPal" "PayPal Express Checkout Token does not exist.","El sÃmbolo para la Salida Express con Paypal no existe." +"PayPal Express Order Review Form","Formulario para revisar el pedido express de Paypal" "PayPal Express Order Review Form","Formulario de revisión de compra por PayPal Express" "PayPal Fee Information","Información de tarifa de PayPal" "PayPal Merchant Pages Style","Estilo de la página de la tienda en PayPal" @@ -309,6 +311,7 @@ "Payments by cards + seller protection - <strong style=""color:red"">Contact PayPal before activating</strong>","Pagos mediante tarjetas + protección de vendedor - <strong style=""color:red"">Contacte con PayPal antes de su activación</strong>" "Paypal Billing Agreement Settings","Ajustes del Acuerdo de Facturación de PayPal" "Pending PayPal","Pendiente de pago en PayPal" +"Phone","Teléfono" "Place Order","Hacer pedido" "Please agree to all the terms and conditions before placing the order.","Por favor, acepta todos los términos y condiciones antes de realizar el pedido." "Please contact PayPal Customer Service.","Por favor, póngase en contacto con el Servicio de Atención al Cliente de PayPal." @@ -387,7 +390,6 @@ "Summary Text for Aggregated Cart","Texto de Resumen para el Carro Añadido" "Supporting of American Express cards require additional agreement. Learn more at <a href=""http://www.paypal.com/amexupdate"">http://www.paypal.com/amexupdate</a>.","La admisión de tarjetas American Express requiere de un acuerdo adicional. Consulte los requisitios en <a href=""http://www.paypal.com/amexupdate"">http://www.paypal.com/amexupdate</a>." "Switch/Maestro","Cambiar/Maestro" -"Phone","Teléfono" "Test Mode","Modo de prueba" "The background color for the checkout page around the header and payment form.","El color de fondo de la página de reembolso de la cabecera y formulario de pago." "The background color for the header of the checkout page. Case-insensitive six-character HTML hexadecimal color code in ASCII.","Color de fondo para la cabecera de la página de pago. Código ASCII de color hexadecimal HTML de seis caracteres sin diferencias mayúsculas o minúsculas." diff --git a/app/code/Magento/Paypal/i18n/fr_FR.csv b/app/code/Magento/Paypal/i18n/fr_FR.csv index ff3a20ee83329cb2b03f4500bba17a0fa3b37081..8b7275750411c5eab4a1db409607b5de7f99f662 100644 --- a/app/code/Magento/Paypal/i18n/fr_FR.csv +++ b/app/code/Magento/Paypal/i18n/fr_FR.csv @@ -265,8 +265,10 @@ "PayPal Buyer Warranty Bonus","Bonus Garantie Acheteur PayPal" "PayPal Debit Card Cash Advance","Avance de fonds carte de débit PayPal" "PayPal Debit Card Withdrawal from ATM","Retrait depuis distributeur automatique à partir d'une carte de débit Paypal" +"PayPal Express Checkout (Payflow Edition) Shortcut Wrapper","Paiement express Paypal (Edition Payflow) Shortcut Wrapper" "PayPal Express Checkout Shortcut Wrapper","PayPal Express Checkout Shortcut Wrapper" "PayPal Express Checkout Token does not exist.","Le mot de vérification du paiement express via Paypal n'existe pas." +"PayPal Express Order Review Form","Formulaire de vérification du paiement express via Paypal." "PayPal Express Order Review Form","PayPal Express Order Review Form" "PayPal Fee Information","Informations des frais Paypal" "PayPal Merchant Pages Style","Style de pages marchants PayPal" @@ -309,6 +311,7 @@ "Payments by cards + seller protection - <strong style=""color:red"">Contact PayPal before activating</strong>","Paiements par cartes + protection vendeur - <strong style=""color:red"">Contacter PayPal avant l'activation</strong>" "Paypal Billing Agreement Settings","Réglages de l'accord de facturation PayPal" "Pending PayPal","PayPal en attente" +"Phone","Téléphone" "Place Order","Placer une commande" "Please agree to all the terms and conditions before placing the order.","Veuillez accepter toutes les conditions générales avant de passer la commande." "Please contact PayPal Customer Service.","Veuillez contacter le service clients de Paypal." @@ -387,7 +390,6 @@ "Summary Text for Aggregated Cart","Texte résumant pour les paniers agrégés" "Supporting of American Express cards require additional agreement. Learn more at <a href=""http://www.paypal.com/amexupdate"">http://www.paypal.com/amexupdate</a>.","La prise en charge des cartes American Express nécessite un accord supplémentaire. En savoir plus : <a href=""http://www.paypal.com/amexupdate"">http://www.paypal.com/amexupdate</a>." "Switch/Maestro","Switch/Maestro" -"Phone","Téléphone" "Test Mode","Mode test." "The background color for the checkout page around the header and payment form.","Couleur de fond pour la page de paiement autour du haut de page et du formulaire de paiement." "The background color for the header of the checkout page. Case-insensitive six-character HTML hexadecimal color code in ASCII.","La couleur de fond de l'entête de la page de paiement. Code HTML hexadécimal en ASCII de six caractères, non sensible à la case." diff --git a/app/code/Magento/Paypal/i18n/nl_NL.csv b/app/code/Magento/Paypal/i18n/nl_NL.csv index fd3a3248db926f4d4b83fff9a5c1588f103e3236..ab100416c4045ca32392ae3241697232bb9ed814 100644 --- a/app/code/Magento/Paypal/i18n/nl_NL.csv +++ b/app/code/Magento/Paypal/i18n/nl_NL.csv @@ -265,6 +265,7 @@ "PayPal Buyer Warranty Bonus","PayPal koper garantie bonus" "PayPal Debit Card Cash Advance","PayPal betaalkaart kas voorschot" "PayPal Debit Card Withdrawal from ATM","PayPal betaalkaart geld pinnen" +"PayPal Express Checkout (Payflow Edition) Shortcut Wrapper","PayPal Express Checkout (Payflow Edition) Shortcut Wrapper" "PayPal Express Checkout Shortcut Wrapper","PayPal Express Checkout Shortcut Wrapper" "PayPal Express Checkout Token does not exist.","PayPal Express Afrekenen Teken bestaan niet." "PayPal Express Order Review Form","PayPal Express Bestelling Terugzien Formulier" @@ -309,6 +310,7 @@ "Payments by cards + seller protection - <strong style=""color:red"">Contact PayPal before activating</strong>","Betaling met kaarten + bescherming van verkoper - <strong style=""color:red"">neem contact op met PayPal alvorens dit te activeren</strong>" "Paypal Billing Agreement Settings","Paypal Facturering Overeenkomst Instellingen" "Pending PayPal","In afwachting van PayPal" +"Phone","Telefoon" "Place Order","Bestelling plaatsen" "Please agree to all the terms and conditions before placing the order.","Ga alstublieft akkoord met alle voorwaarden voor het plaatsen van de bestelling." "Please contact PayPal Customer Service.","Neem alstublieft contact op met Paypal Klantenservice." @@ -387,7 +389,6 @@ "Summary Text for Aggregated Cart","Samenvatting tekst voor samengesteld winkelmandje" "Supporting of American Express cards require additional agreement. Learn more at <a href=""http://www.paypal.com/amexupdate"">http://www.paypal.com/amexupdate</a>.","Ondersteuning van American Express kaarten vereist een additionele overeenkomst. Leer meer op <a href=""http://www.paypal.com/amexupdate"">http://www.paypal.com/amexupdate</a>" "Switch/Maestro","Switch/Maestro" -"Phone","Telefoon" "Test Mode","Test modus" "The background color for the checkout page around the header and payment form.","De achtergrondkleur voor de afrekenpagina rond de header en het betalingsformulier." "The background color for the header of the checkout page. Case-insensitive six-character HTML hexadecimal color code in ASCII.","De achtergrondkleur voor de header van de afrekenpagina. Niet hoofdlettergevoelige zes-letterteken HTML hexadecimale kleurcode in ASCII." diff --git a/app/code/Magento/Paypal/i18n/pt_BR.csv b/app/code/Magento/Paypal/i18n/pt_BR.csv index 8029349193573a19b48dd45bd5981c1a1c7288ad..aa7f79d0afa4a8e16daacba69768f44e08a77ddf 100644 --- a/app/code/Magento/Paypal/i18n/pt_BR.csv +++ b/app/code/Magento/Paypal/i18n/pt_BR.csv @@ -265,6 +265,7 @@ "PayPal Buyer Warranty Bonus","Garantia Bonus de Comprador PayPal" "PayPal Debit Card Cash Advance","Adiantamento de Dinheiro com Cartão de Débito PayPal" "PayPal Debit Card Withdrawal from ATM","Levantamento de ATM com Cartão de Débito PayPal" +"PayPal Express Checkout (Payflow Edition) Shortcut Wrapper","Fechar Pedido com PayPal Express (Edição Payflow): Wrapper Simplificado" "PayPal Express Checkout Shortcut Wrapper","Atalho Envoltório PayPal de Checkout Expresso" "PayPal Express Checkout Token does not exist.","Fechar Pedido com PayPal Express: Token não existe" "PayPal Express Order Review Form","PayPal Express: Revisar Pedido" @@ -309,6 +310,7 @@ "Payments by cards + seller protection - <strong style=""color:red"">Contact PayPal before activating</strong>","Pagamentos com cartões + proteção do vendedor - <strong style=""color:red"">Contactar o PayPal antes de ativar</strong>" "Paypal Billing Agreement Settings","Configurações do Contrato de Faturamento do PayPal" "Pending PayPal","Pendência com PayPal" +"Phone","Telefone" "Place Order","Colocar Ordem" "Please agree to all the terms and conditions before placing the order.","Por favor concorde com todos os Termos e Condições antes de colocar a ordem." "Please contact PayPal Customer Service.","Entre em contato com o Atendimento ao Cliente PayPal." @@ -387,7 +389,6 @@ "Summary Text for Aggregated Cart","Texto Resumo para Carrinho Agregado" "Supporting of American Express cards require additional agreement. Learn more at <a href=""http://www.paypal.com/amexupdate"">http://www.paypal.com/amexupdate</a>.","Apoio de cartões American Express exige um acordo adicional. Saiba mais em <a href=""http://www.paypal.com/amexupdate"">http://www.paypal.com/amexupdate</a>." "Switch/Maestro","Switch/Maestro" -"Phone","Telefone" "Test Mode","Modo de Teste" "The background color for the checkout page around the header and payment form.","A cor de fundo para a página de compra à volta do cabeçalho e formulário de pagamento." "The background color for the header of the checkout page. Case-insensitive six-character HTML hexadecimal color code in ASCII.","A cor de fundo para o cabeçalho da página de compra. Código de seis caracteres, sem diferença de minúsculas e maiúsculas, de cor hexadecimal HTML em ASCII." diff --git a/app/code/Magento/Paypal/i18n/zh_CN.csv b/app/code/Magento/Paypal/i18n/zh_CN.csv index efa09e24d2758721a96566167da28134581d9d80..e263d254469bd0e8f94510fba2655c5a436d87a0 100644 --- a/app/code/Magento/Paypal/i18n/zh_CN.csv +++ b/app/code/Magento/Paypal/i18n/zh_CN.csv @@ -265,6 +265,7 @@ "PayPal Buyer Warranty Bonus","PayPalä¹°å®¶æ‹…ä¿æ´¥è´´" "PayPal Debit Card Cash Advance","PayPal借记å¡é¢„付现金" "PayPal Debit Card Withdrawal from ATM","从ATM进行PayPalå€Ÿè®°å¡æ’¤é”€" +"PayPal Express Checkout (Payflow Edition) Shortcut Wrapper","PayPal快速结账(Payflowç‰ˆï¼‰å¿«æ·æ–¹å¼åŒ…装" "PayPal Express Checkout Shortcut Wrapper","PayPal Express Checkout å¿«æ·æ–¹å¼ä¿æŠ¤" "PayPal Express Checkout Token does not exist.","PayPal快速结账令牌ä¸å˜åœ¨ã€‚" "PayPal Express Order Review Form","PayPal快速订å•审查表å•" @@ -309,6 +310,7 @@ "Payments by cards + seller protection - <strong style=""color:red"">Contact PayPal before activating</strong>","通过å¡ç‰‡æ”¯ä»˜ + å–å®¶ä¿æŠ¤ - <strong style=""color:red"">激活å‰è”ç³»PayPal</strong>" "Paypal Billing Agreement Settings","PayPalè®°è´¦å议设置" "Pending PayPal","挂起的PayPal" +"Phone","电è¯" "Place Order","下订å•" "Please agree to all the terms and conditions before placing the order.","请在下订å•å‰åŒæ„æ‰€æœ‰çš„æ¡æ¬¾å’Œæ¡ä»¶ã€‚" "Please contact PayPal Customer Service.","请è”ç³»PayPal客æœã€‚" @@ -387,7 +389,6 @@ "Summary Text for Aggregated Cart","èšåˆè´ç‰©è½¦çš„æ‘˜è¦æ–‡å—" "Supporting of American Express cards require additional agreement. Learn more at <a href=""http://www.paypal.com/amexupdate"">http://www.paypal.com/amexupdate</a>.","对美国è¿é€šå¡çš„æ”¯æŒè¦æ±‚é¢å¤–çš„å议。欲知详情请访问 <a href=""http://www.paypal.com/amexupdate"">http://www.paypal.com/amexupdate</a>。" "Switch/Maestro","Switch/Maestro" -"Phone","电è¯" "Test Mode","测试模å¼" "The background color for the checkout page around the header and payment form.","付款页é¢ä¸Šå¤´éƒ¨å’Œæ”¯ä»˜è¡¨å•周围的背景色。" "The background color for the header of the checkout page. Case-insensitive six-character HTML hexadecimal color code in ASCII.","付款页é¢ä¸Šå¤´éƒ¨çš„背景色。请用ASCIIç æ–¹å¼è¾“入大å°å†™æ•感的å…ä½ä»£è¡¨HTMLåå…进制颜色代ç çš„å—符。" diff --git a/app/code/Magento/Paypal/view/adminhtml/system/config/fieldset/store.phtml b/app/code/Magento/Paypal/view/adminhtml/system/config/fieldset/store.phtml index 5eda328e37bb6cf2023733a8681c376430b1f610..fec0e7b3e339de0f77e42aae8bdd6f996780ebe7 100644 --- a/app/code/Magento/Paypal/view/adminhtml/system/config/fieldset/store.phtml +++ b/app/code/Magento/Paypal/view/adminhtml/system/config/fieldset/store.phtml @@ -46,7 +46,7 @@ PaypalConfigDisabler.prototype = { wpp: $H({fieldset: 'wpp'}), wpppe: $H({fieldset: 'wpp_pe'}), expresspe: $H({fieldset: 'express_pe'}), - verisign: $H({fieldset: 'verisign'}), + payflowpro: $H({fieldset: 'payflowpro'}), wpppl: $H({fieldset: 'payflow_link'}), hosted_pro: $H({fieldset: 'hosted_pro'}) }); diff --git a/app/code/Magento/Paypal/view/frontend/layout/SHORTCUT_popup.xml b/app/code/Magento/Paypal/view/frontend/layout/SHORTCUT_popup.xml index b1f43c9dcdf0030afc51234eaa6b1638dcbc7dce..6abd619074b566ca44569315eb93c7e74a2ebdd3 100644 --- a/app/code/Magento/Paypal/view/frontend/layout/SHORTCUT_popup.xml +++ b/app/code/Magento/Paypal/view/frontend/layout/SHORTCUT_popup.xml @@ -37,5 +37,17 @@ </action> </block> </container> + <container name="product.info.addtocart.payflow.wrapper" + label="PayPal Express Checkout (Payflow Edition) Shortcut Wrapper" htmlTag="div"> + <block class="Magento\Paypal\Block\PayflowExpress\Shortcut" name="product.info.addtocart.payflow" + template="express/shortcut.phtml" cacheable="false"> + <action method="setIsInCatalogProduct"> + <argument name="value" xsi:type="string">1</argument> + </action> + <action method="setShowOrPosition"> + <argument name="value" xsi:type="string">after</argument> + </action> + </block> + </container> </referenceBlock> </layout> diff --git a/app/code/Magento/Paypal/view/frontend/layout/catalog_product_view.xml b/app/code/Magento/Paypal/view/frontend/layout/catalog_product_view.xml index 24a261a22888c758faa01058117ba1a023289a01..df80c2c2a454141be3ee0eef992f76496c02d397 100644 --- a/app/code/Magento/Paypal/view/frontend/layout/catalog_product_view.xml +++ b/app/code/Magento/Paypal/view/frontend/layout/catalog_product_view.xml @@ -33,6 +33,16 @@ </action> </block> </container> + <container name="product.info.addtocart.payflow.wrapper" + label="PayPal Express Checkout (Payflow Edition) Shortcut Wrapper" htmlTag="p" + htmlClass="paypal-logo"> + <block class="Magento\Paypal\Block\PayflowExpress\Shortcut" name="product.info.addtocart.payflow" + template="express/shortcut.phtml"> + <action method="setIsInCatalogProduct"> + <argument name="value" xsi:type="string">1</argument> + </action> + </block> + </container> </referenceBlock> <update handle="SHORTCUT_popup"/> <referenceContainer name="right"> diff --git a/app/code/Magento/Paypal/view/frontend/layout/checkout_cart_index.xml b/app/code/Magento/Paypal/view/frontend/layout/checkout_cart_index.xml index 53deb726ad05481be4f5f273d8ac7675ae398a01..406bf753fa84bf1675cd50aeb52123798daf1727 100644 --- a/app/code/Magento/Paypal/view/frontend/layout/checkout_cart_index.xml +++ b/app/code/Magento/Paypal/view/frontend/layout/checkout_cart_index.xml @@ -31,6 +31,12 @@ <argument name="value" xsi:type="string">1</argument> </action> </block> + <block class="Magento\Paypal\Block\PayflowExpress\Shortcut" name="checkout.cart.methods.payflow_express.top" + before="-" template="express/shortcut.phtml" cacheable="false"> + <action method="setIsQuoteAllowed"> + <argument name="value" xsi:type="string">1</argument> + </action> + </block> </referenceContainer> <referenceContainer name="checkout.cart.methods"> <block class="Magento\Paypal\Block\Express\Shortcut" name="checkout.cart.methods.paypal_express.bottom" @@ -39,6 +45,12 @@ <argument name="value" xsi:type="string">1</argument> </action> </block> + <block class="Magento\Paypal\Block\PayflowExpress\Shortcut" name="checkout.cart.methods.payflow_express.bottom" + before="-" template="express/shortcut.phtml" cacheable="false"> + <action method="setIsQuoteAllowed"> + <argument name="value" xsi:type="string">1</argument> + </action> + </block> </referenceContainer> <update handle="SHORTCUT_popup"/> </layout> diff --git a/app/code/Magento/Paypal/view/frontend/layout/default.xml b/app/code/Magento/Paypal/view/frontend/layout/default.xml index 2bb674915d0e52c496769708c03a8a48406aecb3..c5d6aeafa3752a78a181cddc9c42bbd1f547e66b 100644 --- a/app/code/Magento/Paypal/view/frontend/layout/default.xml +++ b/app/code/Magento/Paypal/view/frontend/layout/default.xml @@ -27,9 +27,13 @@ <referenceContainer name="topCart.extra_actions"> <block class="Magento\Paypal\Block\Express\Shortcut" name="paypal.partner.top_cart.shortcut" template="express/shortcut.phtml" cacheable="false"/> + <block class="Magento\Paypal\Block\PayflowExpress\Shortcut" name="payflow.partner.top_cart.shortcut" + template="express/shortcut.phtml" cacheable="false"/> </referenceContainer> <referenceContainer name="cart_sidebar.extra_actions"> <block class="Magento\Paypal\Block\Express\Shortcut" name="paypal.partner.cart_sidebar.shortcut" template="express/shortcut.phtml" cacheable="false"/> + <block class="Magento\Paypal\Block\PayflowExpress\Shortcut" name="payflow.partner.cart_sidebar.shortcut" + template="express/shortcut.phtml" cacheable="false"/> </referenceContainer> </layout> diff --git a/app/code/Magento/Paypal/view/frontend/layout/paypal_express_review.xml b/app/code/Magento/Paypal/view/frontend/layout/paypal_express_review.xml index a5957665188f1180c1a937c0a24e440b60e9cafe..d9bb4cf14d20dda6729e0f696af1a25f265dda35 100644 --- a/app/code/Magento/Paypal/view/frontend/layout/paypal_express_review.xml +++ b/app/code/Magento/Paypal/view/frontend/layout/paypal_express_review.xml @@ -24,6 +24,7 @@ */ --> <layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <update handle="checkout_onepage_review_item_renderers" /> <referenceBlock name="root"> <action method="setTemplate"> <argument name="template" xsi:type="string">1column.phtml</argument> @@ -39,12 +40,7 @@ as="shipping_method" template="express/review/shipping/method.phtml"/> <block class="Magento\Paypal\Block\Express\Review\Details" name="paypal.express.review.details" as="details" template="express/review/details.phtml"> - <block class="Magento\Checkout\Block\Cart\Item\Renderer" as="default" - template="onepage/review/item.phtml" cacheable="false"/> - <block class="Magento\Checkout\Block\Cart\Item\Renderer\Grouped" as="grouped" - template="onepage/review/item.phtml" cacheable="false"/> - <block class="Magento\Checkout\Block\Cart\Item\Renderer\Configurable" as="configurable" - template="onepage/review/item.phtml" cacheable="false"/> + <block class="Magento\View\Element\RendererList" name="checkout.onepage.review.item.renderers" as="renderer.list"/> <block class="Magento\Checkout\Block\Cart\Totals" name="paypal.express.review.details.totals" as="totals" template="onepage/review/totals.phtml" cacheable="false"/> </block> diff --git a/app/code/Magento/Paypal/view/frontend/layout/paypal_express_review_details.xml b/app/code/Magento/Paypal/view/frontend/layout/paypal_express_review_details.xml index f0ed14376cf6fe222ee7cc0ec20f882d9e62b2ab..5407774f232e5c5a60c10b43880d76fba199c804 100644 --- a/app/code/Magento/Paypal/view/frontend/layout/paypal_express_review_details.xml +++ b/app/code/Magento/Paypal/view/frontend/layout/paypal_express_review_details.xml @@ -24,10 +24,9 @@ */ --> <layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <update handle="checkout_onepage_review_item_renderers" /> <block class="Magento\Paypal\Block\Express\Review\Details" output="1" name="root" template="express/review/details.phtml"> - <block class="Magento\Checkout\Block\Cart\Item\Renderer" as="default" template="onepage/review/item.phtml" cacheable="false"/> - <block class="Magento\Checkout\Block\Cart\Item\Renderer\Grouped" as="grouped" template="onepage/review/item.phtml" cacheable="false"/> - <block class="Magento\Checkout\Block\Cart\Item\Renderer\Configurable" as="configurable" template="onepage/review/item.phtml" cacheable="false"/> + <block class="Magento\View\Element\RendererList" name="checkout.onepage.review.item.renderers" as="renderer.list"/> <block class="Magento\Checkout\Block\Cart\Totals" name="paypal.express.review.details.totals" as="totals" template="onepage/review/totals.phtml" cacheable="false"/> </block> </layout> diff --git a/app/code/Magento/PaypalUk/view/frontend/layout/paypaluk_express_review.xml b/app/code/Magento/Paypal/view/frontend/layout/paypal_payflowexpress_review.xml similarity index 75% rename from app/code/Magento/PaypalUk/view/frontend/layout/paypaluk_express_review.xml rename to app/code/Magento/Paypal/view/frontend/layout/paypal_payflowexpress_review.xml index 17b595fd69733b9004eb5d33a6ce01be467b9a14..5cdaf6ca42ce7a04aed5080c39b15d635ecdf6e6 100644 --- a/app/code/Magento/PaypalUk/view/frontend/layout/paypaluk_express_review.xml +++ b/app/code/Magento/Paypal/view/frontend/layout/paypal_payflowexpress_review.xml @@ -24,6 +24,7 @@ */ --> <layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <update handle="checkout_onepage_review_item_renderers" /> <referenceBlock name="root"> <action method="setTemplate"> <argument name="template" xsi:type="string">1column.phtml</argument> @@ -31,18 +32,13 @@ </referenceBlock> <referenceContainer name="content"> <block class="Magento\Paypal\Block\Express\Review" name="paypal.express.review" - template="Magento_PaypalUk::express/review.phtml"> - <action method="setPaypalActionPrefix"> - <argument name="prefix" xsi:type="string">paypaluk</argument> + template="payflowexpress/review.phtml"> + <action method="setControllerPath"> + <argument name="prefix" xsi:type="string">paypal/payflowexpress</argument> </action> <block class="Magento\Paypal\Block\Express\Review\Details" name="paypal.express.review.details" as="details" template="express/review/details.phtml"> - <block class="Magento\Checkout\Block\Cart\Item\Renderer" as="default" - template="onepage/review/item.phtml" cacheable="false"/> - <block class="Magento\Checkout\Block\Cart\Item\Renderer\Grouped" as="grouped" - template="onepage/review/item.phtml" cacheable="false"/> - <block class="Magento\Checkout\Block\Cart\Item\Renderer\Configurable" as="configurable" - template="onepage/review/item.phtml" cacheable="false"/> + <block class="Magento\View\Element\RendererList" name="checkout.onepage.review.item.renderers" as="renderer.list" /> <block class="Magento\Checkout\Block\Cart\Totals" name="paypal.express.review.details.totals" as="totals" template="onepage/review/totals.phtml" cacheable="false"/> </block> diff --git a/app/code/Magento/PaypalUk/view/frontend/express/review.phtml b/app/code/Magento/Paypal/view/frontend/payflowexpress/review.phtml similarity index 100% rename from app/code/Magento/PaypalUk/view/frontend/express/review.phtml rename to app/code/Magento/Paypal/view/frontend/payflowexpress/review.phtml diff --git a/app/code/Magento/PaypalUk/i18n/de_DE.csv b/app/code/Magento/PaypalUk/i18n/de_DE.csv deleted file mode 100644 index dff193d6cb66f30c05c2c2c2c303a636eacce14c..0000000000000000000000000000000000000000 --- a/app/code/Magento/PaypalUk/i18n/de_DE.csv +++ /dev/null @@ -1,2 +0,0 @@ -"PayPal Express Checkout (Payflow Edition) Shortcut Wrapper","PayPal Express Checkout (Payflow Edition) Shortcut Wrapper" -"PayPal Express Order Review Form","PayPal Express Bestellübersichtsformular" diff --git a/app/code/Magento/PaypalUk/i18n/en_US.csv b/app/code/Magento/PaypalUk/i18n/en_US.csv deleted file mode 100644 index 94085b297f0a39dedff1cde7b7befb5ff8a4ceb3..0000000000000000000000000000000000000000 --- a/app/code/Magento/PaypalUk/i18n/en_US.csv +++ /dev/null @@ -1,2 +0,0 @@ -"PayPal Express Checkout (Payflow Edition) Shortcut Wrapper","PayPal Express Checkout (Payflow Edition) Shortcut Wrapper" -"PayPal Express Order Review Form","PayPal Express Order Review Form" diff --git a/app/code/Magento/PaypalUk/i18n/es_ES.csv b/app/code/Magento/PaypalUk/i18n/es_ES.csv deleted file mode 100644 index d50b06868ab77a67474a95588abd7b35d4b74fe9..0000000000000000000000000000000000000000 --- a/app/code/Magento/PaypalUk/i18n/es_ES.csv +++ /dev/null @@ -1,2 +0,0 @@ -"PayPal Express Checkout (Payflow Edition) Shortcut Wrapper","Contenedor de acceso directo a Pago Express de PayPal (Edición de Flujo de Pago)" -"PayPal Express Order Review Form","Formulario para revisar el pedido express de Paypal" diff --git a/app/code/Magento/PaypalUk/i18n/fr_FR.csv b/app/code/Magento/PaypalUk/i18n/fr_FR.csv deleted file mode 100644 index eee5aec03eb5311417474ea512cf86df1ea22861..0000000000000000000000000000000000000000 --- a/app/code/Magento/PaypalUk/i18n/fr_FR.csv +++ /dev/null @@ -1,2 +0,0 @@ -"PayPal Express Checkout (Payflow Edition) Shortcut Wrapper","Paiement express Paypal (Edition Payflow) Shortcut Wrapper" -"PayPal Express Order Review Form","Formulaire de vérification du paiement express via Paypal." diff --git a/app/code/Magento/PaypalUk/i18n/nl_NL.csv b/app/code/Magento/PaypalUk/i18n/nl_NL.csv deleted file mode 100644 index c260cba00ac6be48e786e9daf8df20324235f5af..0000000000000000000000000000000000000000 --- a/app/code/Magento/PaypalUk/i18n/nl_NL.csv +++ /dev/null @@ -1,2 +0,0 @@ -"PayPal Express Checkout (Payflow Edition) Shortcut Wrapper","PayPal Express Checkout (Payflow Edition) Shortcut Wrapper" -"PayPal Express Order Review Form","PayPal Express Bestelling Terugzien Formulier" diff --git a/app/code/Magento/PaypalUk/i18n/pt_BR.csv b/app/code/Magento/PaypalUk/i18n/pt_BR.csv deleted file mode 100644 index 2b6cee81fc3f56b6aa0c5a0753d33a3153622608..0000000000000000000000000000000000000000 --- a/app/code/Magento/PaypalUk/i18n/pt_BR.csv +++ /dev/null @@ -1,2 +0,0 @@ -"PayPal Express Checkout (Payflow Edition) Shortcut Wrapper","Fechar Pedido com PayPal Express (Edição Payflow): Wrapper Simplificado" -"PayPal Express Order Review Form","PayPal Express: Revisar Pedido" diff --git a/app/code/Magento/PaypalUk/i18n/zh_CN.csv b/app/code/Magento/PaypalUk/i18n/zh_CN.csv deleted file mode 100644 index e899368134f93f109a3b0b1019fcb2601eb50ef7..0000000000000000000000000000000000000000 --- a/app/code/Magento/PaypalUk/i18n/zh_CN.csv +++ /dev/null @@ -1,2 +0,0 @@ -"PayPal Express Checkout (Payflow Edition) Shortcut Wrapper","PayPal快速结账(Payflowç‰ˆï¼‰å¿«æ·æ–¹å¼åŒ…装" -"PayPal Express Order Review Form","PayPal快速订å•审查表å•" diff --git a/app/code/Magento/PaypalUk/view/frontend/layout/SHORTCUT_uk_popup.xml b/app/code/Magento/PaypalUk/view/frontend/layout/SHORTCUT_uk_popup.xml deleted file mode 100644 index 5e340be4acfa9e25ca3c9cde14d1255d99de43d9..0000000000000000000000000000000000000000 --- a/app/code/Magento/PaypalUk/view/frontend/layout/SHORTCUT_uk_popup.xml +++ /dev/null @@ -1,41 +0,0 @@ -<?xml version="1.0"?> -<!-- -/** - * 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) - */ ---> -<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> - <referenceBlock name="product.tooltip"> - <container name="product.info.addtocart.paypaluk.wrapper" - label="PayPal Express Checkout (Payflow Edition) Shortcut Wrapper" htmlTag="div"> - <block class="Magento\PaypalUk\Block\Express\Shortcut" name="product.info.addtocart.paypaluk" - template="Magento_Paypal::express/shortcut.phtml" cacheable="false"> - <action method="setIsInCatalogProduct"> - <argument name="value" xsi:type="string">1</argument> - </action> - <action method="setShowOrPosition"> - <argument name="value" xsi:type="string">after</argument> - </action> - </block> - </container> - </referenceBlock> -</layout> diff --git a/app/code/Magento/PaypalUk/view/frontend/layout/catalog_product_view.xml b/app/code/Magento/PaypalUk/view/frontend/layout/catalog_product_view.xml deleted file mode 100644 index daf2f151f4b46078ca4401f41dfd0f7d1dc25f0a..0000000000000000000000000000000000000000 --- a/app/code/Magento/PaypalUk/view/frontend/layout/catalog_product_view.xml +++ /dev/null @@ -1,40 +0,0 @@ -<?xml version="1.0"?> -<!-- -/** - * 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) - */ ---> -<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> - <referenceBlock name="product.info.addtocart"> - <container name="product.info.addtocart.paypaluk.wrapper" - label="PayPal Express Checkout (Payflow Edition) Shortcut Wrapper" htmlTag="p" - htmlClass="paypal-logo"> - <block class="Magento\PaypalUk\Block\Express\Shortcut" name="product.info.addtocart.paypaluk" - template="Magento_Paypal::express/shortcut.phtml"> - <action method="setIsInCatalogProduct"> - <argument name="value" xsi:type="string">1</argument> - </action> - </block> - </container> - </referenceBlock> - <update handle="SHORTCUT_uk_popup"/> -</layout> diff --git a/app/code/Magento/PaypalUk/view/frontend/layout/catalogsearch_result_index.xml b/app/code/Magento/PaypalUk/view/frontend/layout/catalogsearch_result_index.xml deleted file mode 100644 index 40668f6fc4bdb5a327cbd5c2ec348b2ef6af9d60..0000000000000000000000000000000000000000 --- a/app/code/Magento/PaypalUk/view/frontend/layout/catalogsearch_result_index.xml +++ /dev/null @@ -1,28 +0,0 @@ -<?xml version="1.0"?> -<!-- -/** - * 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) - */ ---> -<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> - <update handle="SHORTCUT_uk_popup"/> -</layout> diff --git a/app/code/Magento/PaypalUk/view/frontend/layout/checkout_cart_index.xml b/app/code/Magento/PaypalUk/view/frontend/layout/checkout_cart_index.xml deleted file mode 100644 index 87b1ed17124fcb405f6d7c9e39527e948c18915d..0000000000000000000000000000000000000000 --- a/app/code/Magento/PaypalUk/view/frontend/layout/checkout_cart_index.xml +++ /dev/null @@ -1,44 +0,0 @@ -<?xml version="1.0"?> -<!-- -/** - * 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) - */ ---> -<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> - <referenceContainer name="checkout.cart.top_methods"> - <block class="Magento\PaypalUk\Block\Express\Shortcut" name="checkout.cart.methods.paypaluk_express.top" - before="-" template="Magento_Paypal::express/shortcut.phtml" cacheable="false"> - <action method="setIsQuoteAllowed"> - <argument name="value" xsi:type="string">1</argument> - </action> - </block> - </referenceContainer> - <referenceContainer name="checkout.cart.methods"> - <block class="Magento\PaypalUk\Block\Express\Shortcut" name="checkout.cart.methods.paypaluk_express.bottom" - before="-" template="Magento_Paypal::express/shortcut.phtml" cacheable="false"> - <action method="setIsQuoteAllowed"> - <argument name="value" xsi:type="string">1</argument> - </action> - </block> - </referenceContainer> - <update handle="SHORTCUT_uk_popup"/> -</layout> diff --git a/app/code/Magento/PaypalUk/view/frontend/layout/checkout_onepage_failure.xml b/app/code/Magento/PaypalUk/view/frontend/layout/checkout_onepage_failure.xml deleted file mode 100644 index 40668f6fc4bdb5a327cbd5c2ec348b2ef6af9d60..0000000000000000000000000000000000000000 --- a/app/code/Magento/PaypalUk/view/frontend/layout/checkout_onepage_failure.xml +++ /dev/null @@ -1,28 +0,0 @@ -<?xml version="1.0"?> -<!-- -/** - * 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) - */ ---> -<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> - <update handle="SHORTCUT_uk_popup"/> -</layout> diff --git a/app/code/Magento/PaypalUk/view/frontend/layout/checkout_onepage_success.xml b/app/code/Magento/PaypalUk/view/frontend/layout/checkout_onepage_success.xml deleted file mode 100644 index 40668f6fc4bdb5a327cbd5c2ec348b2ef6af9d60..0000000000000000000000000000000000000000 --- a/app/code/Magento/PaypalUk/view/frontend/layout/checkout_onepage_success.xml +++ /dev/null @@ -1,28 +0,0 @@ -<?xml version="1.0"?> -<!-- -/** - * 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) - */ ---> -<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> - <update handle="SHORTCUT_uk_popup"/> -</layout> diff --git a/app/code/Magento/PaypalUk/view/frontend/layout/review_product_list.xml b/app/code/Magento/PaypalUk/view/frontend/layout/review_product_list.xml deleted file mode 100644 index 40668f6fc4bdb5a327cbd5c2ec348b2ef6af9d60..0000000000000000000000000000000000000000 --- a/app/code/Magento/PaypalUk/view/frontend/layout/review_product_list.xml +++ /dev/null @@ -1,28 +0,0 @@ -<?xml version="1.0"?> -<!-- -/** - * 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) - */ ---> -<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> - <update handle="SHORTCUT_uk_popup"/> -</layout> diff --git a/app/code/Magento/PaypalUk/view/frontend/layout/tag_customer_view.xml b/app/code/Magento/PaypalUk/view/frontend/layout/tag_customer_view.xml deleted file mode 100644 index 40668f6fc4bdb5a327cbd5c2ec348b2ef6af9d60..0000000000000000000000000000000000000000 --- a/app/code/Magento/PaypalUk/view/frontend/layout/tag_customer_view.xml +++ /dev/null @@ -1,28 +0,0 @@ -<?xml version="1.0"?> -<!-- -/** - * 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) - */ ---> -<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> - <update handle="SHORTCUT_uk_popup"/> -</layout> diff --git a/app/code/Magento/PaypalUk/view/frontend/layout/tag_product_list.xml b/app/code/Magento/PaypalUk/view/frontend/layout/tag_product_list.xml deleted file mode 100644 index 40668f6fc4bdb5a327cbd5c2ec348b2ef6af9d60..0000000000000000000000000000000000000000 --- a/app/code/Magento/PaypalUk/view/frontend/layout/tag_product_list.xml +++ /dev/null @@ -1,28 +0,0 @@ -<?xml version="1.0"?> -<!-- -/** - * 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) - */ ---> -<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> - <update handle="SHORTCUT_uk_popup"/> -</layout> diff --git a/app/code/Magento/PaypalUk/view/frontend/layout/wishlist_index_index.xml b/app/code/Magento/PaypalUk/view/frontend/layout/wishlist_index_index.xml deleted file mode 100644 index 40668f6fc4bdb5a327cbd5c2ec348b2ef6af9d60..0000000000000000000000000000000000000000 --- a/app/code/Magento/PaypalUk/view/frontend/layout/wishlist_index_index.xml +++ /dev/null @@ -1,28 +0,0 @@ -<?xml version="1.0"?> -<!-- -/** - * 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) - */ ---> -<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> - <update handle="SHORTCUT_uk_popup"/> -</layout> diff --git a/app/code/Magento/Persistent/Model/Session.php b/app/code/Magento/Persistent/Model/Session.php index 56e94d4e26ad8b4fa3625a2a6313ad6259fa43de..3b9900655cad3113394a9715afe6345bd19db351 100644 --- a/app/code/Magento/Persistent/Model/Session.php +++ b/app/code/Magento/Persistent/Model/Session.php @@ -70,7 +70,7 @@ class Session extends \Magento\Core\Model\AbstractModel protected $_coreData; /** - * @var \Magento\Core\Model\Config + * @var \Magento\App\ConfigInterface */ protected $_coreConfig; @@ -103,7 +103,7 @@ class Session extends \Magento\Core\Model\AbstractModel * * @param \Magento\Core\Model\Context $context * @param \Magento\Core\Model\Registry $registry - * @param \Magento\Core\Model\Config $coreConfig + * @param \Magento\App\ConfigInterface $coreConfig * @param \Magento\Core\Helper\Data $coreData * @param \Magento\Persistent\Helper\Data $persistentData * @param \Magento\Stdlib\Cookie $cookie @@ -117,7 +117,7 @@ class Session extends \Magento\Core\Model\AbstractModel public function __construct( \Magento\Core\Model\Context $context, \Magento\Core\Model\Registry $registry, - \Magento\Core\Model\Config $coreConfig, + \Magento\App\ConfigInterface $coreConfig, \Magento\Core\Helper\Data $coreData, \Magento\Persistent\Helper\Data $persistentData, \Magento\Stdlib\Cookie $cookie, diff --git a/app/code/Magento/Persistent/etc/frontend/di.xml b/app/code/Magento/Persistent/etc/frontend/di.xml index 59fec0ddd696a0969f990eddf0a2b62f8f98d951..8a467c2a49cd044dbbf0f38c8bb789795ac8d6a7 100644 --- a/app/code/Magento/Persistent/etc/frontend/di.xml +++ b/app/code/Magento/Persistent/etc/frontend/di.xml @@ -26,9 +26,9 @@ <config> <type name="Magento\Core\Model\Url\SecurityInfo"> <param name="secureUrlList"> - <value> - <persistent_onepage_register>/persistent/index/saveMethod</persistent_onepage_register> - </value> + <array> + <item key="persistent_onepage_register"><value>/persistent/index/saveMethod</value></item> + </array> </param> </type> </config> diff --git a/app/code/Magento/Persistent/etc/frontend/events.xml b/app/code/Magento/Persistent/etc/frontend/events.xml index ce099785c6afca6bb807a300cc370b18319bae46..926499b7bc95282ada14c3d0696bd385eef691e1 100644 --- a/app/code/Magento/Persistent/etc/frontend/events.xml +++ b/app/code/Magento/Persistent/etc/frontend/events.xml @@ -76,7 +76,7 @@ <event name="controller_action_predispatch_paypal_express_start"> <observer name="persistent" instance="Magento\Persistent\Model\Observer" method="preventExpressCheckout" /> </event> - <event name="controller_action_predispatch_paypaluk_express_start"> + <event name="controller_action_predispatch_paypal_payflowexpress_start"> <observer name="persistent" instance="Magento\Persistent\Model\Observer" method="preventExpressCheckout" /> </event> <event name="controller_action_predispatch_googlecheckout_redirect_checkout"> diff --git a/app/code/Magento/ProductAlert/Block/Email/AbstractEmail.php b/app/code/Magento/ProductAlert/Block/Email/AbstractEmail.php index d8a4ae38ad81ff716cea23d546d0b552f246ed38..d698531ef0af67df3ea7a94b4e3b1ee8d8cdc9ee 100644 --- a/app/code/Magento/ProductAlert/Block/Email/AbstractEmail.php +++ b/app/code/Magento/ProductAlert/Block/Email/AbstractEmail.php @@ -132,8 +132,8 @@ abstract class AbstractEmail extends \Magento\View\Element\Template protected function _getUrlParams() { return array( - '_store' => $this->getStore(), - '_store_to_url' => true + '_scope' => $this->getStore(), + '_scope_to_url' => true ); } } diff --git a/app/code/Magento/Reports/Block/Adminhtml/Grid/AbstractGrid.php b/app/code/Magento/Reports/Block/Adminhtml/Grid/AbstractGrid.php index 460b4bfecca9e7027ed80b8bf73b478ce5b1f83b..f4e7c602b3011e1b84622b47206879e06002216c 100644 --- a/app/code/Magento/Reports/Block/Adminhtml/Grid/AbstractGrid.php +++ b/app/code/Magento/Reports/Block/Adminhtml/Grid/AbstractGrid.php @@ -57,7 +57,6 @@ class AbstractGrid extends \Magento\Backend\Block\Widget\Grid\Extended /** * @param \Magento\Backend\Block\Template\Context $context - * @param \Magento\Core\Model\Url $urlModel * @param \Magento\Backend\Helper\Data $backendHelper * @param \Magento\Reports\Model\Resource\Report\Collection\Factory $resourceFactory * @param \Magento\Reports\Model\Grouped\CollectionFactory $collectionFactory @@ -66,7 +65,6 @@ class AbstractGrid extends \Magento\Backend\Block\Widget\Grid\Extended */ public function __construct( \Magento\Backend\Block\Template\Context $context, - \Magento\Core\Model\Url $urlModel, \Magento\Backend\Helper\Data $backendHelper, \Magento\Reports\Model\Resource\Report\Collection\Factory $resourceFactory, \Magento\Reports\Model\Grouped\CollectionFactory $collectionFactory, @@ -76,7 +74,7 @@ class AbstractGrid extends \Magento\Backend\Block\Widget\Grid\Extended $this->_resourceFactory = $resourceFactory; $this->_collectionFactory = $collectionFactory; $this->_reportsData = $reportsData; - parent::__construct($context, $urlModel, $backendHelper, $data); + parent::__construct($context, $backendHelper, $data); } protected function _construct() 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 d3ecb6ffc3a966bb20472ec7bcd2168bc8910b27..37fc636f6e7a4b44301ae18ae02926e0320509ed 100644 --- a/app/code/Magento/Reports/Block/Adminhtml/Product/Downloads/Grid.php +++ b/app/code/Magento/Reports/Block/Adminhtml/Product/Downloads/Grid.php @@ -42,20 +42,18 @@ class Grid extends \Magento\Backend\Block\Widget\Grid\Extended /** * @param \Magento\Backend\Block\Template\Context $context - * @param \Magento\Core\Model\Url $urlModel * @param \Magento\Backend\Helper\Data $backendHelper * @param \Magento\Reports\Model\Resource\Product\Downloads\CollectionFactory $downloadsFactory * @param array $data */ public function __construct( \Magento\Backend\Block\Template\Context $context, - \Magento\Core\Model\Url $urlModel, \Magento\Backend\Helper\Data $backendHelper, \Magento\Reports\Model\Resource\Product\Downloads\CollectionFactory $downloadsFactory, array $data = array() ) { $this->_downloadsFactory = $downloadsFactory; - parent::__construct($context, $urlModel, $backendHelper, $data); + parent::__construct($context, $backendHelper, $data); } protected function _construct() diff --git a/app/code/Magento/Reports/Block/Adminhtml/Product/Grid.php b/app/code/Magento/Reports/Block/Adminhtml/Product/Grid.php index 3da2162f068342c301097f6f2b0331c3376ab726..185294d94033bd65596b32c25dda39cb070d9f4c 100644 --- a/app/code/Magento/Reports/Block/Adminhtml/Product/Grid.php +++ b/app/code/Magento/Reports/Block/Adminhtml/Product/Grid.php @@ -42,20 +42,18 @@ class Grid extends \Magento\Backend\Block\Widget\Grid\Extended /** * @param \Magento\Backend\Block\Template\Context $context - * @param \Magento\Core\Model\Url $urlModel * @param \Magento\Backend\Helper\Data $backendHelper * @param \Magento\Reports\Model\Resource\Product\CollectionFactory $collectionFactory * @param array $data */ public function __construct( \Magento\Backend\Block\Template\Context $context, - \Magento\Core\Model\Url $urlModel, \Magento\Backend\Helper\Data $backendHelper, \Magento\Reports\Model\Resource\Product\CollectionFactory $collectionFactory, array $data = array() ) { $this->_collectionFactory = $collectionFactory; - parent::__construct($context, $urlModel, $backendHelper, $data); + parent::__construct($context, $backendHelper, $data); } protected function _construct() 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 0975c8efc3347a7e2868dac479063e2f25e34fcc..2de893c3cabf7db14fbbf34b56501cacef28c7c7 100644 --- a/app/code/Magento/Reports/Block/Adminhtml/Product/Lowstock/Grid.php +++ b/app/code/Magento/Reports/Block/Adminhtml/Product/Lowstock/Grid.php @@ -42,20 +42,18 @@ class Grid extends \Magento\Backend\Block\Widget\Grid /** * @param \Magento\Backend\Block\Template\Context $context - * @param \Magento\Core\Model\Url $urlModel * @param \Magento\Backend\Helper\Data $backendHelper * @param \Magento\Reports\Model\Resource\Product\Lowstock\CollectionFactory $lowstocksFactory * @param array $data */ public function __construct( \Magento\Backend\Block\Template\Context $context, - \Magento\Core\Model\Url $urlModel, \Magento\Backend\Helper\Data $backendHelper, \Magento\Reports\Model\Resource\Product\Lowstock\CollectionFactory $lowstocksFactory, array $data = array() ) { $this->_lowstocksFactory = $lowstocksFactory; - parent::__construct($context, $urlModel, $backendHelper, $data); + parent::__construct($context, $backendHelper, $data); } /** 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 bac69719883b29e6e4099b0550472f9d25be067b..d28086d5d6e7255657c6b3638e558084dc681898 100644 --- a/app/code/Magento/Reports/Block/Adminhtml/Review/Detail/Grid.php +++ b/app/code/Magento/Reports/Block/Adminhtml/Review/Detail/Grid.php @@ -42,20 +42,18 @@ class Grid extends \Magento\Backend\Block\Widget\Grid\Extended /** * @param \Magento\Backend\Block\Template\Context $context - * @param \Magento\Core\Model\Url $urlModel * @param \Magento\Backend\Helper\Data $backendHelper * @param \Magento\Reports\Model\Resource\Review\CollectionFactory $reviewsFactory * @param array $data */ public function __construct( \Magento\Backend\Block\Template\Context $context, - \Magento\Core\Model\Url $urlModel, \Magento\Backend\Helper\Data $backendHelper, \Magento\Reports\Model\Resource\Review\CollectionFactory $reviewsFactory, array $data = array() ) { $this->_reviewsFactory = $reviewsFactory; - parent::__construct($context, $urlModel, $backendHelper, $data); + parent::__construct($context, $backendHelper, $data); } protected function _construct() 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 aed5ce92b1737f064f1bebd115a11467b79a5937..44adfe5e890f45ac40d16c67bcf72663f97bc96f 100644 --- a/app/code/Magento/Reports/Block/Adminhtml/Sales/Tax/Grid.php +++ b/app/code/Magento/Reports/Block/Adminhtml/Sales/Tax/Grid.php @@ -44,7 +44,6 @@ class Grid extends \Magento\Reports\Block\Adminhtml\Grid\AbstractGrid /** * @param \Magento\Backend\Block\Template\Context $context - * @param \Magento\Core\Model\Url $urlModel * @param \Magento\Backend\Helper\Data $backendHelper * @param \Magento\Reports\Model\Resource\Report\Collection\Factory $resourceFactory * @param \Magento\Reports\Model\Grouped\CollectionFactory $collectionFactory @@ -54,7 +53,6 @@ class Grid extends \Magento\Reports\Block\Adminhtml\Grid\AbstractGrid */ public function __construct( \Magento\Backend\Block\Template\Context $context, - \Magento\Core\Model\Url $urlModel, \Magento\Backend\Helper\Data $backendHelper, \Magento\Reports\Model\Resource\Report\Collection\Factory $resourceFactory, \Magento\Reports\Model\Grouped\CollectionFactory $collectionFactory, @@ -65,7 +63,6 @@ class Grid extends \Magento\Reports\Block\Adminhtml\Grid\AbstractGrid $this->_configFactory = $configFactory; parent::__construct( $context, - $urlModel, $backendHelper, $resourceFactory, $collectionFactory, 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 db70f4963208e69d79b066983621dac513688b1e..ff7f09092ab171a262dca979a5e982ee1f1fd7d3 100644 --- a/app/code/Magento/Reports/Block/Adminhtml/Shopcart/Abandoned/Grid.php +++ b/app/code/Magento/Reports/Block/Adminhtml/Shopcart/Abandoned/Grid.php @@ -42,20 +42,18 @@ class Grid extends \Magento\Reports\Block\Adminhtml\Grid\Shopcart /** * @param \Magento\Backend\Block\Template\Context $context - * @param \Magento\Core\Model\Url $urlModel * @param \Magento\Backend\Helper\Data $backendHelper * @param \Magento\Reports\Model\Resource\Quote\CollectionFactory $quotesFactory * @param array $data */ public function __construct( \Magento\Backend\Block\Template\Context $context, - \Magento\Core\Model\Url $urlModel, \Magento\Backend\Helper\Data $backendHelper, \Magento\Reports\Model\Resource\Quote\CollectionFactory $quotesFactory, array $data = array() ) { $this->_quotesFactory = $quotesFactory; - parent::__construct($context, $urlModel, $backendHelper, $data); + parent::__construct($context, $backendHelper, $data); } protected function _construct() 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 9ea648a0be0d60176abacfad8881e832951cd598..0505ca3af83c8ea71f0508117e1dd563207ff5ae 100644 --- a/app/code/Magento/Reports/Block/Adminhtml/Shopcart/Customer/Grid.php +++ b/app/code/Magento/Reports/Block/Adminhtml/Shopcart/Customer/Grid.php @@ -42,20 +42,18 @@ class Grid extends \Magento\Reports\Block\Adminhtml\Grid\Shopcart /** * @param \Magento\Backend\Block\Template\Context $context - * @param \Magento\Core\Model\Url $urlModel * @param \Magento\Backend\Helper\Data $backendHelper * @param \Magento\Reports\Model\Resource\Customer\CollectionFactory $customersFactory * @param array $data */ public function __construct( \Magento\Backend\Block\Template\Context $context, - \Magento\Core\Model\Url $urlModel, \Magento\Backend\Helper\Data $backendHelper, \Magento\Reports\Model\Resource\Customer\CollectionFactory $customersFactory, array $data = array() ) { $this->_customersFactory = $customersFactory; - parent::__construct($context, $urlModel, $backendHelper, $data); + parent::__construct($context, $backendHelper, $data); } protected function _construct() 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 6cd417d299c1437e26047ebe35fcb9d00af87754..a90e69386d318784a5d9bd929c432e794fc287b9 100644 --- a/app/code/Magento/Reports/Block/Adminhtml/Shopcart/Product/Grid.php +++ b/app/code/Magento/Reports/Block/Adminhtml/Shopcart/Product/Grid.php @@ -42,20 +42,18 @@ class Grid extends \Magento\Reports\Block\Adminhtml\Grid\Shopcart /** * @param \Magento\Backend\Block\Template\Context $context - * @param \Magento\Core\Model\Url $urlModel * @param \Magento\Backend\Helper\Data $backendHelper * @param \Magento\Reports\Model\Resource\Quote\CollectionFactory $quotesFactory * @param array $data */ public function __construct( \Magento\Backend\Block\Template\Context $context, - \Magento\Core\Model\Url $urlModel, \Magento\Backend\Helper\Data $backendHelper, \Magento\Reports\Model\Resource\Quote\CollectionFactory $quotesFactory, array $data = array() ) { $this->_quotesFactory = $quotesFactory; - parent::__construct($context, $urlModel, $backendHelper, $data); + parent::__construct($context, $backendHelper, $data); } protected function _construct() diff --git a/app/code/Magento/Reports/Block/Adminhtml/Wishlist/Grid.php b/app/code/Magento/Reports/Block/Adminhtml/Wishlist/Grid.php index 304db730dee463aee7ea1cf6f18dbc4b254b3f71..e51e4034265e992128cae58ae0422e2dde3121a5 100644 --- a/app/code/Magento/Reports/Block/Adminhtml/Wishlist/Grid.php +++ b/app/code/Magento/Reports/Block/Adminhtml/Wishlist/Grid.php @@ -42,20 +42,18 @@ class Grid extends \Magento\Backend\Block\Widget\Grid\Extended /** * @param \Magento\Backend\Block\Template\Context $context - * @param \Magento\Core\Model\Url $urlModel * @param \Magento\Backend\Helper\Data $backendHelper * @param \Magento\Reports\Model\Resource\Wishlist\Product\CollectionFactory $productsFactory * @param array $data */ public function __construct( \Magento\Backend\Block\Template\Context $context, - \Magento\Core\Model\Url $urlModel, \Magento\Backend\Helper\Data $backendHelper, \Magento\Reports\Model\Resource\Wishlist\Product\CollectionFactory $productsFactory, array $data = array() ) { $this->_productsFactory = $productsFactory; - parent::__construct($context, $urlModel, $backendHelper, $data); + parent::__construct($context, $backendHelper, $data); } protected function _construct() diff --git a/app/code/Magento/Reports/etc/di.xml b/app/code/Magento/Reports/etc/di.xml index e0b2110c9146c92cbcb2ee37f22a6bf97da1214f..cc274db9d331eff06d9239a4a934b2294ad31a37 100644 --- a/app/code/Magento/Reports/etc/di.xml +++ b/app/code/Magento/Reports/etc/di.xml @@ -29,9 +29,9 @@ </type> <type name="Magento\Module\Updater\SetupFactory"> <param name="resourceTypes"> - <value> - <reports_setup>Magento\Reports\Model\Resource\Setup</reports_setup> - </value> + <array> + <item key="reports_setup"><value>Magento\Reports\Model\Resource\Setup</value></item> + </array> </param> </type> <virtualType name="Magento\Reports\Model\Session\Storage" type="Magento\Session\Storage"> diff --git a/app/code/Magento/Review/Block/Adminhtml/Add.php b/app/code/Magento/Review/Block/Adminhtml/Add.php index 136b520c6f4a75e5e2d0fe1fe7ea4441ede2734c..7bcf2e85007b763b6ef483774bf27cfe1de861ef 100644 --- a/app/code/Magento/Review/Block/Adminhtml/Add.php +++ b/app/code/Magento/Review/Block/Adminhtml/Add.php @@ -24,6 +24,8 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Review\Block\Adminhtml; + /** * Adminhtml add Review main block * @@ -31,9 +33,6 @@ * @package Magento_Review * @author Magento Core Team <core@magentocommerce.com> */ - -namespace Magento\Review\Block\Adminhtml; - class Add extends \Magento\Backend\Block\Widget\Form\Container { protected function _construct() @@ -119,6 +118,9 @@ class Add extends \Magento\Backend\Block\Widget\Form\Container '; } + /** + * @return string + */ public function getHeaderText() { return __('Add New Review'); diff --git a/app/code/Magento/Review/Block/Adminhtml/Add/Form.php b/app/code/Magento/Review/Block/Adminhtml/Add/Form.php index 710f4fd2a21e73181643e4a00c43b1a64e12cbbe..35371248f652b2e14ad0e54db4a868273234834d 100644 --- a/app/code/Magento/Review/Block/Adminhtml/Add/Form.php +++ b/app/code/Magento/Review/Block/Adminhtml/Add/Form.php @@ -69,6 +69,9 @@ class Form extends \Magento\Backend\Block\Widget\Form\Generic parent::__construct($context, $registry, $formFactory, $data); } + /** + * @return void + */ protected function _prepareForm() { /** @var \Magento\Data\Form $form */ diff --git a/app/code/Magento/Review/Block/Adminhtml/Edit.php b/app/code/Magento/Review/Block/Adminhtml/Edit.php index 52b2840b8ad644176fb3622be07c296238031d09..23ff1302b99a17fa6baba52d32d6e5696eb273b7 100644 --- a/app/code/Magento/Review/Block/Adminhtml/Edit.php +++ b/app/code/Magento/Review/Block/Adminhtml/Edit.php @@ -24,11 +24,11 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Review\Block\Adminhtml; + /** * Review edit form */ -namespace Magento\Review\Block\Adminhtml; - class Edit extends \Magento\Backend\Block\Widget\Form\Container { /** @@ -213,6 +213,9 @@ class Edit extends \Magento\Backend\Block\Widget\Form\Container '; } + /** + * @return string + */ public function getHeaderText() { $reviewData = $this->_coreRegistry->registry('review_data'); diff --git a/app/code/Magento/Review/Block/Adminhtml/Edit/Form.php b/app/code/Magento/Review/Block/Adminhtml/Edit/Form.php index 0ac0acf6ebc28b9d95c849075a802245df24d101..e429057dabfb460a88517f6a242e3fe7037234d4 100644 --- a/app/code/Magento/Review/Block/Adminhtml/Edit/Form.php +++ b/app/code/Magento/Review/Block/Adminhtml/Edit/Form.php @@ -80,6 +80,9 @@ class Form extends \Magento\Backend\Block\Widget\Form\Generic parent::__construct($context, $registry, $formFactory, $data); } + /** + * @return $this + */ protected function _prepareForm() { $review = $this->_coreRegistry->registry('review_data'); diff --git a/app/code/Magento/Review/Block/Adminhtml/Grid.php b/app/code/Magento/Review/Block/Adminhtml/Grid.php index 671b81f9ae6e8041dd0b4e3212ba12f64fefd710..a954bc7dfa9493097ef9a809f7f7791f3fb49d29 100644 --- a/app/code/Magento/Review/Block/Adminhtml/Grid.php +++ b/app/code/Magento/Review/Block/Adminhtml/Grid.php @@ -74,7 +74,6 @@ class Grid extends \Magento\Backend\Block\Widget\Grid\Extended /** * @param \Magento\Backend\Block\Template\Context $context - * @param \Magento\Core\Model\Url $urlModel * @param \Magento\Backend\Helper\Data $backendHelper * @param \Magento\Review\Model\ReviewFactory $reviewFactory * @param \Magento\Review\Model\Resource\Review\Product\CollectionFactory $productsFactory @@ -85,7 +84,6 @@ class Grid extends \Magento\Backend\Block\Widget\Grid\Extended */ public function __construct( \Magento\Backend\Block\Template\Context $context, - \Magento\Core\Model\Url $urlModel, \Magento\Backend\Helper\Data $backendHelper, \Magento\Review\Model\ReviewFactory $reviewFactory, \Magento\Review\Model\Resource\Review\Product\CollectionFactory $productsFactory, @@ -99,7 +97,7 @@ class Grid extends \Magento\Backend\Block\Widget\Grid\Extended $this->_reviewData = $reviewData; $this->_reviewActionPager = $reviewActionPager; $this->_reviewFactory = $reviewFactory; - parent::__construct($context, $urlModel, $backendHelper, $data); + parent::__construct($context, $backendHelper, $data); } /** @@ -305,7 +303,7 @@ class Grid extends \Magento\Backend\Block\Widget\Grid\Extended /** * Prepare grid mass actions * - * @return \Magento\Backend\Block\Widget\Grid|void + * @return void */ protected function _prepareMassaction() { diff --git a/app/code/Magento/Review/Block/Adminhtml/Grid/Filter/Type.php b/app/code/Magento/Review/Block/Adminhtml/Grid/Filter/Type.php index 132b4cedecedf7de0461ac8ec5d712dd098a9a42..8d8721e2e5979e3acbcc58e17a3b4265e9fbe15e 100644 --- a/app/code/Magento/Review/Block/Adminhtml/Grid/Filter/Type.php +++ b/app/code/Magento/Review/Block/Adminhtml/Grid/Filter/Type.php @@ -24,6 +24,8 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Review\Block\Adminhtml\Grid\Filter; + /** * Adminhtml review grid filter by type * @@ -31,11 +33,11 @@ * @package Magento_Review * @author Magento Core Team <core@magentocommerce.com> */ - -namespace Magento\Review\Block\Adminhtml\Grid\Filter; - class Type extends \Magento\Backend\Block\Widget\Grid\Column\Filter\Select { + /** + * @return array + */ protected function _getOptions() { return array( @@ -46,6 +48,9 @@ class Type extends \Magento\Backend\Block\Widget\Grid\Column\Filter\Select ); } + /** + * @return int + */ public function getCondition() { if ($this->getValue() == 1) { diff --git a/app/code/Magento/Review/Block/Adminhtml/Grid/Renderer/Type.php b/app/code/Magento/Review/Block/Adminhtml/Grid/Renderer/Type.php index 8745462be1088078268215336c1c14eccc01aef9..67ebcececcc40520d7ccd600cc2bbff51d8d5a0a 100644 --- a/app/code/Magento/Review/Block/Adminhtml/Grid/Renderer/Type.php +++ b/app/code/Magento/Review/Block/Adminhtml/Grid/Renderer/Type.php @@ -24,6 +24,8 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Review\Block\Adminhtml\Grid\Renderer; + /** * Adminhtml review grid item renderer for item type * @@ -31,11 +33,11 @@ * @package Magento_Review * @author Magento Core Team <core@magentocommerce.com> */ - -namespace Magento\Review\Block\Adminhtml\Grid\Renderer; - class Type extends \Magento\Backend\Block\Widget\Grid\Column\Renderer\AbstractRenderer { + /** + * @return string + */ public function render(\Magento\Object $row) { diff --git a/app/code/Magento/Review/Block/Adminhtml/Product/Grid.php b/app/code/Magento/Review/Block/Adminhtml/Product/Grid.php index 8c29fbee23484ad90e7781880c3234d725ae2cfc..8cda7a1478d53298f4d3034244f1ed1c2539eff6 100644 --- a/app/code/Magento/Review/Block/Adminhtml/Product/Grid.php +++ b/app/code/Magento/Review/Block/Adminhtml/Product/Grid.php @@ -42,7 +42,6 @@ class Grid extends \Magento\Catalog\Block\Adminhtml\Product\Grid /** * @param \Magento\Backend\Block\Template\Context $context - * @param \Magento\Core\Model\Url $urlModel * @param \Magento\Backend\Helper\Data $backendHelper * @param \Magento\Core\Model\WebsiteFactory $websiteFactory * @param \Magento\Eav\Model\Resource\Entity\Attribute\Set\CollectionFactory $setsFactory @@ -58,7 +57,6 @@ class Grid extends \Magento\Catalog\Block\Adminhtml\Product\Grid */ public function __construct( \Magento\Backend\Block\Template\Context $context, - \Magento\Core\Model\Url $urlModel, \Magento\Backend\Helper\Data $backendHelper, \Magento\Core\Model\WebsiteFactory $websiteFactory, \Magento\Eav\Model\Resource\Entity\Attribute\Set\CollectionFactory $setsFactory, @@ -73,7 +71,6 @@ class Grid extends \Magento\Catalog\Block\Adminhtml\Product\Grid $this->_websitesFactory = $websitesFactory; parent::__construct( $context, - $urlModel, $backendHelper, $websiteFactory, $setsFactory, @@ -93,6 +90,9 @@ class Grid extends \Magento\Catalog\Block\Adminhtml\Product\Grid $this->setUseAjax(true); } + /** + * @return void + */ protected function _prepareColumns() { $this->addColumn('entity_id', array( @@ -157,16 +157,25 @@ class Grid extends \Magento\Catalog\Block\Adminhtml\Product\Grid } } + /** + * @return string + */ public function getGridUrl() { return $this->getUrl('catalog/*/productGrid', array('_current'=>true)); } + /** + * @return string + */ public function getRowUrl($row) { return $this->getUrl('catalog/*/jsonProductInfo', array('id' => $row->getId())); } + /** + * @return $this + */ protected function _prepareMassaction() { return $this; diff --git a/app/code/Magento/Review/Block/Adminhtml/Rating/Detailed.php b/app/code/Magento/Review/Block/Adminhtml/Rating/Detailed.php index c5eda0804c5db8b0c9731bad3aba26177afad35c..db12de01600d88feacc52213f2e72776bc1ca9cf 100644 --- a/app/code/Magento/Review/Block/Adminhtml/Rating/Detailed.php +++ b/app/code/Magento/Review/Block/Adminhtml/Rating/Detailed.php @@ -23,16 +23,26 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Review\Block\Adminhtml\Rating; + +use Magento\Rating\Model\Rating; +use Magento\Rating\Model\Rating\Option; +use Magento\Rating\Model\Resource\Rating\Collection as RatingCollection; +use Magento\Rating\Model\Resource\Rating\Option\Vote\Collection as VoteCollection; /** * Adminhtml detailed rating stars */ -namespace Magento\Review\Block\Adminhtml\Rating; - class Detailed extends \Magento\Backend\Block\Template { + /** + * @var VoteCollection + */ protected $_voteCollection = false; + /** + * @var string + */ protected $_template = 'Magento_Rating::rating/detailed.phtml'; /** @@ -81,6 +91,9 @@ class Detailed extends \Magento\Backend\Block\Template } } + /** + * @return RatingCollection + */ public function getRating() { if (!$this->getRatingCollection()) { @@ -131,12 +144,20 @@ class Detailed extends \Magento\Backend\Block\Template return $this->getRatingCollection(); } + /** + * @return $this + */ public function setIndependentMode() { $this->setIsIndependentMode(true); return $this; } + /** + * @param Option $option + * @param Rating $rating + * @return bool + */ public function isSelected($option, $rating) { if ($this->getIsIndependentMode()) { diff --git a/app/code/Magento/Review/Block/Adminhtml/Rating/Summary.php b/app/code/Magento/Review/Block/Adminhtml/Rating/Summary.php index f1b4eda9b0565d76b764f107d048d4a33521465c..11abe14d21f447c5286ec4e17db9cf955d86e03f 100644 --- a/app/code/Magento/Review/Block/Adminhtml/Rating/Summary.php +++ b/app/code/Magento/Review/Block/Adminhtml/Rating/Summary.php @@ -24,13 +24,18 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Review\Block\Adminhtml\Rating; + +use Magento\Rating\Model\Resource\Rating\Collection as RatingCollection; + /** * Adminhtml summary rating stars */ -namespace Magento\Review\Block\Adminhtml\Rating; - class Summary extends \Magento\Backend\Block\Template { + /** + * @var string + */ protected $_template = 'Magento_Rating::rating/stars/summary.phtml'; /** @@ -77,6 +82,9 @@ class Summary extends \Magento\Backend\Block\Template } } + /** + * @return RatingCollection + */ public function getRating() { if (!$this->getRatingCollection()) { @@ -89,6 +97,9 @@ class Summary extends \Magento\Backend\Block\Template return $this->getRatingCollection(); } + /** + * @return string + */ public function getRatingSummary() { if (!$this->getRatingSummaryCache()) { diff --git a/app/code/Magento/Review/Block/Customer/ListCustomer.php b/app/code/Magento/Review/Block/Customer/ListCustomer.php index ce91b039562c58991e32853a4c783f0abd338cbe..e2a46d8c5b729782063ed98b638184a645e8212a 100644 --- a/app/code/Magento/Review/Block/Customer/ListCustomer.php +++ b/app/code/Magento/Review/Block/Customer/ListCustomer.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\Review\Block\Customer; /** * Customer Reviews list block @@ -32,8 +32,6 @@ * @package Magento_Review * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\Review\Block\Customer; - class ListCustomer extends \Magento\Customer\Block\Account\Dashboard { /** @@ -67,6 +65,9 @@ class ListCustomer extends \Magento\Customer\Block\Account\Dashboard $this->_isScopePrivate = true; } + /** + * @return $this + */ protected function _initCollection() { $this->_collection = $this->_collectionFactory->create(); @@ -157,7 +158,7 @@ class ListCustomer extends \Magento\Customer\Block\Account\Dashboard /** * Format date in short format * - * @param $date + * @param string $date * @return string */ public function dateFormat($date) diff --git a/app/code/Magento/Review/Block/Customer/Recent.php b/app/code/Magento/Review/Block/Customer/Recent.php index 3e2ea6e2bb482dde1a1c4088e6cd0834295fa3a8..c2d11019f5c73325ec88bcb390b1c6a5dbad58f5 100644 --- a/app/code/Magento/Review/Block/Customer/Recent.php +++ b/app/code/Magento/Review/Block/Customer/Recent.php @@ -26,6 +26,8 @@ namespace Magento\Review\Block\Customer; +use Magento\Review\Model\Resource\Review\Product\Collection; + /** * Recent Customer Reviews Block */ @@ -39,7 +41,7 @@ class Recent extends \Magento\View\Element\Template /** * Product reviews collection * - * @var \Magento\Review\Model\Resource\Review\Product\Collection + * @var Collection */ protected $_collection; @@ -91,6 +93,9 @@ class Recent extends \Magento\View\Element\Template )); } + /** + * @return $this + */ protected function _initCollection() { $this->_collection = $this->_collectionFactory->create(); @@ -104,11 +109,17 @@ class Recent extends \Magento\View\Element\Template return $this; } + /** + * @return int + */ public function count() { return $this->_getCollection()->getSize(); } + /** + * @return Collection + */ protected function _getCollection() { if (!$this->_collection) { @@ -117,31 +128,49 @@ class Recent extends \Magento\View\Element\Template return $this->_collection; } + /** + * @return Collection + */ public function getCollection() { return $this->_getCollection(); } + /** + * @return string + */ public function getReviewLink() { return $this->getUrl('review/customer/view/'); } + /** + * @return string + */ public function getProductLink() { return $this->getUrl('catalog/product/view/'); } + /** + * @return string + */ public function dateFormat($date) { return $this->formatDate($date, \Magento\Core\Model\LocaleInterface::FORMAT_TYPE_SHORT); } + /** + * @return string + */ public function getAllReviewsUrl() { return $this->getUrl('review/customer'); } + /** + * @return string + */ public function getReviewUrl($id) { return $this->getUrl('review/customer/view', array('id' => $id)); diff --git a/app/code/Magento/Review/Block/Customer/View.php b/app/code/Magento/Review/Block/Customer/View.php index f2514ef107a534ae04928e800fb871f2eeb11e79..b41a95cb478962a90bebe834e265dba127e3154a 100644 --- a/app/code/Magento/Review/Block/Customer/View.php +++ b/app/code/Magento/Review/Block/Customer/View.php @@ -34,6 +34,10 @@ namespace Magento\Review\Block\Customer; +use Magento\Catalog\Model\Product as Product; +use Magento\Rating\Model\Rating\Option\Vote\Collection as VoteCollection; +use Magento\Review\Model\Review as Review; + class View extends \Magento\Catalog\Block\Product\AbstractProduct { protected $_template = 'customer/view.phtml'; @@ -136,6 +140,9 @@ class View extends \Magento\Catalog\Block\Product\AbstractProduct $this->setReviewId($this->getRequest()->getParam('id', false)); } + /** + * @return Product + */ public function getProductData() { if( $this->getReviewId() && !$this->getProductCacheData() ) { @@ -147,6 +154,9 @@ class View extends \Magento\Catalog\Block\Product\AbstractProduct return $this->getProductCacheData(); } + /** + * @return Review + */ public function getReviewData() { if( $this->getReviewId() && !$this->getReviewCachedData() ) { @@ -155,11 +165,17 @@ class View extends \Magento\Catalog\Block\Product\AbstractProduct return $this->getReviewCachedData(); } + /** + * @return string + */ public function getBackUrl() { return $this->getUrl('review/customer'); } + /** + * @return VoteCollection + */ public function getRating() { if( !$this->getRatingCollection() ) { @@ -176,6 +192,9 @@ class View extends \Magento\Catalog\Block\Product\AbstractProduct return $this->getRatingCollection(); } + /** + * @return array + */ public function getRatingSummary() { if( !$this->getRatingSummaryCache() ) { @@ -184,6 +203,9 @@ class View extends \Magento\Catalog\Block\Product\AbstractProduct return $this->getRatingSummaryCache(); } + /** + * @return int + */ public function getTotalReviews() { if( !$this->getTotalReviewsCache() ) { @@ -192,6 +214,9 @@ class View extends \Magento\Catalog\Block\Product\AbstractProduct return $this->getTotalReviewsCache(); } + /** + * @return string + */ public function dateFormat($date) { return $this->formatDate($date, \Magento\Core\Model\LocaleInterface::FORMAT_TYPE_LONG); @@ -200,7 +225,7 @@ class View extends \Magento\Catalog\Block\Product\AbstractProduct /** * Check whether current customer is review owner * - * @return boolean + * @return bool */ public function isReviewOwner() { diff --git a/app/code/Magento/Review/Block/Form.php b/app/code/Magento/Review/Block/Form.php index 31361997ee1b7fb7a4e401b75e1c7e035f15c63b..10ab8e13a75dd6af647550503562d004bc46ffdf 100644 --- a/app/code/Magento/Review/Block/Form.php +++ b/app/code/Magento/Review/Block/Form.php @@ -33,6 +33,9 @@ */ namespace Magento\Review\Block; +use Magento\Catalog\Model\Product; +use Magento\Rating\Model\Resource\Rating\Collection as RatingCollection; + class Form extends \Magento\View\Element\Template { /** @@ -139,18 +142,27 @@ class Form extends \Magento\View\Element\Template ->assign('messages', $this->messageManager->getMessages(true)); } + /** + * @return Product + */ public function getProductInfo() { $product = $this->_productFactory->create(); return $product->load($this->getRequest()->getParam('id')); } + /** + * @return string + */ public function getAction() { $productId = $this->getRequest()->getParam('id', false); return $this->getUrl('review/product/post', array('id' => $productId)); } + /** + * @return RatingCollection + */ public function getRatings() { return $this->_ratingFactory->create() diff --git a/app/code/Magento/Review/Block/Helper.php b/app/code/Magento/Review/Block/Helper.php index a92e36adddc2f1f422ce5c4e9817be525386c3a8..98c04a9a85a1cae1667014416d78c2c3c2b8c88f 100644 --- a/app/code/Magento/Review/Block/Helper.php +++ b/app/code/Magento/Review/Block/Helper.php @@ -24,6 +24,10 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Review\Block; + +use Magento\Catalog\Model\Product; + /** * Review helper * @@ -31,10 +35,11 @@ * @package Magento_Review * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\Review\Block; - class Helper extends \Magento\View\Element\Template { + /** + * @var array + */ protected $_availableTemplates = array( 'default' => 'helper/summary.phtml', 'short' => 'helper/summary_short.phtml' @@ -59,6 +64,12 @@ class Helper extends \Magento\View\Element\Template parent::__construct($context, $data); } + /** + * @param Product $product + * @param string $templateType + * @param bool $displayIfNoReviews + * @return string + */ public function getSummaryHtml($product, $templateType, $displayIfNoReviews) { // pick template among available @@ -77,16 +88,25 @@ class Helper extends \Magento\View\Element\Template return $this->toHtml(); } + /** + * @return string + */ public function getRatingSummary() { return $this->getProduct()->getRatingSummary()->getRatingSummary(); } + /** + * @return int + */ public function getReviewsCount() { return $this->getProduct()->getRatingSummary()->getReviewsCount(); } + /** + * @return string + */ public function getReviewsUrl() { return $this->getUrl('review/product/list', array( @@ -102,6 +122,7 @@ class Helper extends \Magento\View\Element\Template * * @param string $type * @param string $template + * @return void */ public function addTemplate($type, $template) { diff --git a/app/code/Magento/Review/Block/Product/View.php b/app/code/Magento/Review/Block/Product/View.php index 9ad39b65b6a2667037427cdf3abcb76be9b8f4cc..93c8ed0d785801460c545be40da3ab59545ad39e 100644 --- a/app/code/Magento/Review/Block/Product/View.php +++ b/app/code/Magento/Review/Block/Product/View.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\Review\Block\Product; + +use Magento\Review\Model\Resource\Review\Collection as ReviewCollection; /** * Product Reviews Page @@ -31,12 +34,10 @@ * @package Magento_Review * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\Review\Block\Product; - class View extends \Magento\Catalog\Block\Product\View { /** - * @var \Magento\Review\Model\Resource\Review\Collection + * @var ReviewCollection */ protected $_reviewsCollection; @@ -155,6 +156,9 @@ class View extends \Magento\Catalog\Block\Product\View ; } + /** + * @return ReviewCollection + */ public function getReviewsCollection() { if (null === $this->_reviewsCollection) { diff --git a/app/code/Magento/Review/Block/Product/View/ListView.php b/app/code/Magento/Review/Block/Product/View/ListView.php index 09e1dfc70a59b0d8b48b5aeed81567b50fb1d763..a7f419253c757ac0c7ef0f620d2eece3626eaed6 100644 --- a/app/code/Magento/Review/Block/Product/View/ListView.php +++ b/app/code/Magento/Review/Block/Product/View/ListView.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\Review\Block\Product\View; /** * Detailed Product Reviews @@ -31,17 +32,24 @@ * @package Magento_Review * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\Review\Block\Product\View; - class ListView extends \Magento\Review\Block\Product\View { + /** + * @var false + */ protected $_forceHasOptions = false; + /** + * @return int + */ public function getProductId() { return $this->_coreRegistry->registry('product')->getId(); } + /** + * @return $this + */ protected function _prepareLayout() { parent::_prepareLayout(); @@ -54,6 +62,9 @@ class ListView extends \Magento\Review\Block\Product\View return $this; } + /** + * @return $this + */ protected function _beforeToHtml() { $this->getReviewsCollection() @@ -62,6 +73,9 @@ class ListView extends \Magento\Review\Block\Product\View return parent::_beforeToHtml(); } + /** + * @return string + */ public function getReviewUrl($id) { return $this->getUrl('*/*/view', array('id' => $id)); diff --git a/app/code/Magento/Review/Block/Product/View/Other.php b/app/code/Magento/Review/Block/Product/View/Other.php index 2f204470c5cda5941b7c82acd15452dd7239284c..e4e6d04c2384da2ae138717e8718251903af2949 100644 --- a/app/code/Magento/Review/Block/Product/View/Other.php +++ b/app/code/Magento/Review/Block/Product/View/Other.php @@ -24,11 +24,11 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Review\Block\Product\View; + /** * Product view other block */ -namespace Magento\Review\Block\Product\View; - class Other extends \Magento\View\Element\Template { /** diff --git a/app/code/Magento/Review/Block/View.php b/app/code/Magento/Review/Block/View.php index b66af65dd345053f8011e97da5af37895a24b7da..080ecb97caf57b204e38c7e28e17345fe10b9039 100644 --- a/app/code/Magento/Review/Block/View.php +++ b/app/code/Magento/Review/Block/View.php @@ -36,6 +36,9 @@ namespace Magento\Review\Block; class View extends \Magento\Catalog\Block\Product\AbstractProduct { + /** + * @var string + */ protected $_template = 'view.phtml'; /** diff --git a/app/code/Magento/Review/Controller/Customer.php b/app/code/Magento/Review/Controller/Customer.php index 791ab0b6d1848c3a755e9efa31cdc0fde4aec79e..6b557555a7d8ca329e1433977a91279274125759 100644 --- a/app/code/Magento/Review/Controller/Customer.php +++ b/app/code/Magento/Review/Controller/Customer.php @@ -70,6 +70,9 @@ class Customer extends \Magento\App\Action\Action return parent::dispatch($request); } + /** + * @return void + */ public function indexAction() { $this->_view->loadLayout(); @@ -87,6 +90,9 @@ class Customer extends \Magento\App\Action\Action $this->_view->renderLayout(); } + /** + * @return void + */ public function viewAction() { $this->_view->loadLayout(); diff --git a/app/code/Magento/Review/Controller/Product.php b/app/code/Magento/Review/Controller/Product.php index ab4f2ff63799ddcd4e838f9e309416b3d8dda89b..a90661fa3e9db952b77e5b4a629ab0bde3b5bf99 100644 --- a/app/code/Magento/Review/Controller/Product.php +++ b/app/code/Magento/Review/Controller/Product.php @@ -35,6 +35,7 @@ namespace Magento\Review\Controller; use Magento\App\Action\NotFoundException; use Magento\App\RequestInterface; +use Magento\Review\Model\Review; class Product extends \Magento\App\Action\Action { @@ -241,8 +242,8 @@ class Product extends \Magento\App\Action\Action * Load review model with data by passed id. * Return false if review was not loaded or review is not approved. * - * @param $reviewId - * @return bool|\Magento\Review\Model\Review + * @param int $reviewId + * @return bool|Review */ protected function _loadReview($reviewId) { @@ -251,7 +252,7 @@ class Product extends \Magento\App\Action\Action } $review = $this->_reviewFactory->create()->load($reviewId); - /* @var $review \Magento\Review\Model\Review */ + /* @var $review Review */ if (!$review->getId() || !$review->isApproved() || !$review->isAvailableOnStore($this->_storeManager->getStore()) @@ -266,6 +267,8 @@ class Product extends \Magento\App\Action\Action /** * Submit new review action + * + * @return void */ public function postAction() { @@ -289,14 +292,14 @@ class Product extends \Magento\App\Action\Action $session = $this->_session; /* @var $session \Magento\Core\Model\Session */ $review = $this->_reviewFactory->create()->setData($data); - /* @var $review \Magento\Review\Model\Review */ + /* @var $review Review */ $validate = $review->validate(); if ($validate === true) { try { - $review->setEntityId($review->getEntityIdByCode(\Magento\Review\Model\Review::ENTITY_PRODUCT_CODE)) + $review->setEntityId($review->getEntityIdByCode(Review::ENTITY_PRODUCT_CODE)) ->setEntityPkValue($product->getId()) - ->setStatusId(\Magento\Review\Model\Review::STATUS_PENDING) + ->setStatusId(Review::STATUS_PENDING) ->setCustomerId($this->_customerSession->getCustomerId()) ->setStoreId($this->_storeManager->getStore()->getId()) ->setStores(array($this->_storeManager->getStore()->getId())) @@ -339,6 +342,7 @@ class Product extends \Magento\App\Action\Action /** * Show list of product's reviews * + * @return void */ public function listAction() { @@ -373,6 +377,7 @@ class Product extends \Magento\App\Action\Action /** * Show details of one review * + * @return void */ public function viewAction() { @@ -396,6 +401,7 @@ class Product extends \Magento\App\Action\Action /** * Load specific layout handles by product type id * + * @return void */ protected function _initProductLayout($product) { diff --git a/app/code/Magento/Review/Helper/Action/Pager.php b/app/code/Magento/Review/Helper/Action/Pager.php index 651b24717bb1d53e404303465a9413c8eb9745c6..94321d412917b2b8bc46ab1004fe7e50f43c1f5f 100644 --- a/app/code/Magento/Review/Helper/Action/Pager.php +++ b/app/code/Magento/Review/Helper/Action/Pager.php @@ -66,6 +66,7 @@ class Pager extends \Magento\App\Helper\AbstractHelper * Set storage id * * @param $storageId + * @return void */ public function setStorageId($storageId) { @@ -76,7 +77,7 @@ class Pager extends \Magento\App\Helper\AbstractHelper * Set items to storage * * @param array $items - * @return \Magento\Review\Helper\Action\Pager + * @return $this */ public function setItems(array $items) { @@ -88,6 +89,8 @@ class Pager extends \Magento\App\Helper\AbstractHelper /** * Load stored items + * + * @return void */ protected function _loadItems() { @@ -129,7 +132,6 @@ class Pager extends \Magento\App\Helper\AbstractHelper } /** - * * * @param mixed $value * @return int|bool diff --git a/app/code/Magento/Review/Model/Resource/Review.php b/app/code/Magento/Review/Model/Resource/Review.php index 2010a0ac73f7a95c187c328f0ff4f8a07f54c5d1..a738d34a5134dd4189ac1f6a44034a2cbc79d294 100644 --- a/app/code/Magento/Review/Model/Resource/Review.php +++ b/app/code/Magento/Review/Model/Resource/Review.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\Review\Model\Resource; +use Magento\Core\Model\AbstractModel; /** * Review resource model @@ -32,8 +34,6 @@ * @package Magento_Review * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\Review\Model\Resource; - class Review extends \Magento\Core\Model\Resource\Db\AbstractDb { /** @@ -147,7 +147,7 @@ class Review extends \Magento\Core\Model\Resource\Db\AbstractDb * * @param string $field * @param mixed $value - * @param unknown_type $object + * @param AbstractModel $object * @return \Zend_Db_Select */ protected function _getLoadSelect($field, $value, $object) @@ -163,10 +163,10 @@ class Review extends \Magento\Core\Model\Resource\Db\AbstractDb /** * Perform actions before object save * - * @param \Magento\Core\Model\AbstractModel $object - * @return $this|\Magento\Core\Model\Resource\Db\AbstractDb + * @param AbstractModel $object + * @return $this */ - protected function _beforeSave(\Magento\Core\Model\AbstractModel $object) + protected function _beforeSave(AbstractModel $object) { if (!$object->getId()) { $object->setCreatedAt($this->_date->gmtDate()); @@ -184,10 +184,10 @@ class Review extends \Magento\Core\Model\Resource\Db\AbstractDb /** * Perform actions after object save * - * @param \Magento\Object $object - * @return \Magento\Review\Model\Resource\Review + * @param AbstractModel $object + * @return $this */ - protected function _afterSave(\Magento\Core\Model\AbstractModel $object) + protected function _afterSave(AbstractModel $object) { $adapter = $this->_getWriteAdapter(); /** @@ -249,10 +249,10 @@ class Review extends \Magento\Core\Model\Resource\Db\AbstractDb /** * Perform actions after object load * - * @param \Magento\Object $object - * @return \Magento\Review\Model\Resource\Review + * @param AbstractModel $object + * @return $this */ - protected function _afterLoad(\Magento\Core\Model\AbstractModel $object) + protected function _afterLoad(AbstractModel $object) { $adapter = $this->_getReadAdapter(); $select = $adapter->select() @@ -270,10 +270,10 @@ class Review extends \Magento\Core\Model\Resource\Db\AbstractDb /** * Action before delete * - * @param \Magento\Core\Model\AbstractModel $object - * @return \Magento\Review\Model\Resource\Review + * @param AbstractModel $object + * @return $this */ - protected function _beforeDelete(\Magento\Core\Model\AbstractModel $object) + protected function _beforeDelete(AbstractModel $object) { // prepare rating ids, that depend on review $this->_deleteCache = array( @@ -286,10 +286,10 @@ class Review extends \Magento\Core\Model\Resource\Db\AbstractDb /** * Perform actions after object delete * - * @param \Magento\Core\Model\AbstractModel $object - * @return \Magento\Review\Model\Resource\Review + * @param AbstractModel $object + * @return $this */ - public function afterDeleteCommit(\Magento\Core\Model\AbstractModel $object) + public function afterDeleteCommit(AbstractModel $object) { $this->aggregate($object); @@ -337,7 +337,8 @@ class Review extends \Magento\Core\Model\Resource\Db\AbstractDb /** * Aggregate * - * @param \Magento\Core\Model\AbstractModel $object + * @param AbstractModel $object + * @return void */ public function aggregate($object) { @@ -420,9 +421,9 @@ class Review extends \Magento\Core\Model\Resource\Db\AbstractDb * Aggregate this review's ratings. * Useful, when changing the review. * - * @param array $ratingIds + * @param int[] $ratingIds * @param int $entityPkValue - * @return \Magento\Review\Model\Resource\Review + * @return $this */ protected function _aggregateRatings($ratingIds, $entityPkValue) { @@ -442,6 +443,7 @@ class Review extends \Magento\Core\Model\Resource\Db\AbstractDb * * @param int $reviewId * @param int $entityPkValue + * @return void */ public function reAggregateReview($reviewId, $entityPkValue) { diff --git a/app/code/Magento/Review/Model/Resource/Review/Collection.php b/app/code/Magento/Review/Model/Resource/Review/Collection.php index ba06eae13fdd06078428c8237773415a53082bb9..0ccbe91e17361d042d5b2afab4f64aa42606d53f 100644 --- a/app/code/Magento/Review/Model/Resource/Review/Collection.php +++ b/app/code/Magento/Review/Model/Resource/Review/Collection.php @@ -140,7 +140,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl /** * init select * - * @return \Magento\Review\Model\Resource\Review\Product\Collection + * @return $this */ protected function _initSelect() { @@ -154,7 +154,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl /** * @param int|string $customerId - * @return \Magento\Review\Model\Resource\Review\Collection + * @return $this */ public function addCustomerFilter($customerId) { @@ -167,8 +167,8 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl /** * Add store filter * - * @param int|array $storeId - * @return \Magento\Review\Model\Resource\Review\Collection + * @param int|int[] $storeId + * @return $this */ public function addStoreFilter($storeId) { @@ -183,7 +183,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl /** * Add stores data * - * @return \Magento\Review\Model\Resource\Review\Collection + * @return $this */ public function addStoreData() { @@ -196,7 +196,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl * * @param int|string $entity * @param int $pkValue - * @return \Magento\Review\Model\Resource\Review\Collection + * @return $this */ public function addEntityFilter($entity, $pkValue) { @@ -225,7 +225,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl * Add status filter * * @param int|string $status - * @return \Magento\Review\Model\Resource\Review\Collection + * @return $this */ public function addStatusFilter($status) { @@ -245,7 +245,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl * Set date order * * @param string $dir - * @return \Magento\Review\Model\Resource\Review\Collection + * @return $this */ public function setDateOrder($dir = 'DESC') { @@ -256,7 +256,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl /** * Add rate votes * - * @return \Magento\Review\Model\Resource\Review\Collection + * @return $this */ public function addRateVotes() { @@ -276,7 +276,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl /** * Add reviews total count * - * @return \Magento\Review\Model\Resource\Review\Collection + * @return $this */ public function addReviewsTotalCount() { @@ -295,7 +295,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl * * @param boolean $printQuery * @param boolean $logQuery - * @return \Magento\Review\Model\Resource\Review\Collection + * @return $this */ public function load($printQuery = false, $logQuery = false) { @@ -313,6 +313,7 @@ class Collection extends \Magento\Core\Model\Resource\Db\Collection\AbstractColl /** * Add store data * + * @return void */ protected function _addStoreData() { diff --git a/app/code/Magento/Review/Model/Resource/Review/Product/Collection.php b/app/code/Magento/Review/Model/Resource/Review/Product/Collection.php index c4cfe55e4d3276ab128ff5e1c564d7f546adb94a..0ddcd16cb2a72ad6d8f71fbd5a0ea775a4c464c0 100644 --- a/app/code/Magento/Review/Model/Resource/Review/Product/Collection.php +++ b/app/code/Magento/Review/Model/Resource/Review/Product/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\Review\Model\Resource\Review\Product; +use \Magento\Eav\Model\Entity\Attribute\AbstractAttribute; /** * Review Product Collection @@ -32,8 +34,6 @@ * @package Magento_Review * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\Review\Model\Resource\Review\Product; - class Collection extends \Magento\Catalog\Model\Resource\Product\Collection { /** @@ -53,11 +53,10 @@ class Collection extends \Magento\Catalog\Model\Resource\Product\Collection /** * Add store data flag * - * @var boolean + * @var bool */ protected $_addStoreDataFlag = false; - /** * Filter by stores for the collection * @@ -162,7 +161,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Product\Collection /** * init select * - * @return \Magento\Review\Model\Resource\Review\Product\Collection + * @return $this */ protected function _initSelect() { @@ -174,8 +173,8 @@ class Collection extends \Magento\Catalog\Model\Resource\Product\Collection /** * Adds store filter into array * - * @param mixed $storeId - * @return \Magento\Review\Model\Resource\Review\Product\Collection + * @param int|int[] $storeId + * @return $this */ public function addStoreFilter($storeId = null) { @@ -202,7 +201,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Product\Collection * Adds specific store id into array * * @param array $storeId - * @return \Magento\Review\Model\Resource\Review\Product\Collection + * @return $this */ public function setStoreFilter($storeId) { @@ -227,7 +226,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Product\Collection * Applies all store filters in one place to prevent multiple joins in select * * @param null|Zend_Db_Select $select - * @return \Magento\Review\Model\Resource\Review\Product\Collection + * @return $this */ protected function _applyStoresFilterToSelect(\Zend_Db_Select $select = null) { @@ -259,7 +258,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Product\Collection /** * Add stores data * - * @return \Magento\Review\Model\Resource\Review\Product\Collection + * @return $this */ public function addStoreData() { @@ -271,7 +270,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Product\Collection * Add customer filter * * @param int $customerId - * @return \Magento\Review\Model\Resource\Review\Product\Collection + * @return $this */ public function addCustomerFilter($customerId) { @@ -284,7 +283,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Product\Collection * Add entity filter * * @param int $entityId - * @return \Magento\Review\Model\Resource\Review\Product\Collection + * @return $this */ public function addEntityFilter($entityId) { @@ -296,8 +295,8 @@ class Collection extends \Magento\Catalog\Model\Resource\Product\Collection /** * Add status filter * - * @param mixed $status - * @return \Magento\Review\Model\Resource\Review\Product\Collection + * @param int $status + * @return $this */ public function addStatusFilter($status) { @@ -310,7 +309,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Product\Collection * Set date order * * @param string $dir - * @return \Magento\Review\Model\Resource\Review\Product\Collection + * @return $this */ public function setDateOrder($dir = 'DESC') { @@ -321,7 +320,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Product\Collection /** * Add review summary * - * @return \Magento\Review\Model\Resource\Review\Product\Collection + * @return $this */ public function addReviewSummary() { @@ -336,7 +335,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Product\Collection /** * Add rote votes * - * @return \Magento\Review\Model\Resource\Review\Product\Collection + * @return $this */ public function addRateVotes() { @@ -352,9 +351,9 @@ class Collection extends \Magento\Catalog\Model\Resource\Product\Collection } /** - * join fields to entity + * Join fields to entity * - * @return \Magento\Review\Model\Resource\Review\Product\Collection + * @return $this */ protected function _joinFields() { @@ -428,7 +427,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Product\Collection * * @param string $attribute * @param string $dir - * @return \Magento\Review\Model\Resource\Review\Product\Collection + * @return $this */ public function setOrder($attribute, $dir = 'DESC') { @@ -457,10 +456,10 @@ class Collection extends \Magento\Catalog\Model\Resource\Product\Collection /** * Add attribute to filter * - * @param \Magento\Eav\Model\Entity\Attribute\AbstractAttribute|string $attribute - * @param array $condition + * @param AbstractAttribute|string $attribute + * @param array|null $condition * @param string $joinType - * @return \Magento\Review\Model\Resource\Review\Product\Collection + * @return $this */ public function addAttributeToFilter($attribute, $condition = null, $joinType = 'inner') { @@ -527,7 +526,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Product\Collection /** * Action after load * - * @return \Magento\Review\Model\Resource\Review\Product\Collection + * @return $this */ protected function _afterLoad() { @@ -541,6 +540,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Product\Collection /** * Add store data * + * @return void */ protected function _addStoreData() { @@ -577,7 +577,7 @@ class Collection extends \Magento\Catalog\Model\Resource\Product\Collection /** * Redeclare parent method for store filters applying * - * @return \Magento\Review\Model\Resource\Review\Product\Collection + * @return $this */ protected function _beforeLoad() { diff --git a/app/code/Magento/Review/Model/Resource/Review/Summary.php b/app/code/Magento/Review/Model/Resource/Review/Summary.php index 2f44a63753ae6470a23aa13edd5480244328e3bf..97ddf61f1eaa9b9591c55ae4daf64f8316efc20c 100644 --- a/app/code/Magento/Review/Model/Resource/Review/Summary.php +++ b/app/code/Magento/Review/Model/Resource/Review/Summary.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\Review\Model\Resource\Review; +use Magento\Core\Model\AbstractModel; /** * Review summary resource model @@ -32,8 +34,6 @@ * @package Magento_Review * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\Review\Model\Resource\Review; - class Summary extends \Magento\Core\Model\Resource\Db\AbstractDb { /** @@ -50,8 +50,8 @@ class Summary extends \Magento\Core\Model\Resource\Db\AbstractDb * * @param string $field * @param mixed $value - * @param \Magento\Core\Model\AbstractModel $object - * @return unknown + * @param AbstractModel $object + * @return \Zend_Db_Select */ protected function _getLoadSelect($field, $value, $object) { diff --git a/app/code/Magento/Review/Model/Review.php b/app/code/Magento/Review/Model/Review.php index 252465010c7f58fa930f3da68eb157c920b339fa..2ce301b60d6cd26424ef46251223f0629fa8158f 100644 --- a/app/code/Magento/Review/Model/Review.php +++ b/app/code/Magento/Review/Model/Review.php @@ -23,6 +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\Review\Model; + +use Magento\Review\Model\Resource\Review\Product\Collection as ProductCollection; +use Magento\Review\Model\Resource\Review\Status\Collection as StatusCollection; +use Magento\Catalog\Model\Product; /** * Review model @@ -41,8 +46,6 @@ * @package Magento_Review * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\Review\Model; - class Review extends \Magento\Core\Model\AbstractModel { /** @@ -142,27 +145,47 @@ class Review extends \Magento\Core\Model\AbstractModel $this->_init('Magento\Review\Model\Resource\Review'); } + /** + * @return ProductCollection + */ public function getProductCollection() { return $this->_productFactory->create(); } + /** + * @return StatusCollection + */ public function getStatusCollection() { return $this->_statusFactory->create(); } + /** + * @param int $entityPkValue + * @param bool approvedOnly + * @param int $storeId + * @return int + */ public function getTotalReviews($entityPkValue, $approvedOnly=false, $storeId=0) { return $this->getResource()->getTotalReviews($entityPkValue, $approvedOnly, $storeId); } + /** + * @return $this + */ public function aggregate() { $this->getResource()->aggregate($this); return $this; } + /** + * @param Product $product + * @param int $storeId + * @return void + */ public function getEntitySummary($product, $storeId=0) { $summaryData = $this->_summaryModFactory->create() @@ -173,16 +196,25 @@ class Review extends \Magento\Core\Model\AbstractModel $product->setRatingSummary($summary); } + /** + * @return int + */ public function getPendingStatus() { return self::STATUS_PENDING; } + /** + * @return string + */ public function getReviewUrl() { return $this->_urlModel->getUrl('review/product/view', array('id' => $this->getReviewId())); } + /** + * @return bool|string[] + */ public function validate() { $errors = array(); @@ -219,8 +251,8 @@ class Review extends \Magento\Core\Model\AbstractModel /** * Append review summary to product collection * - * @param \Magento\Catalog\Model\Resource\Product\Collection $collection - * @return \Magento\Review\Model\Review + * @param ProductCollection $collection + * @return $this */ public function appendSummary($collection) { @@ -249,6 +281,9 @@ class Review extends \Magento\Core\Model\AbstractModel return $this; } + /** + * @return $this + */ protected function _beforeDelete() { $this->_protectFromNonAdmin(); diff --git a/app/code/Magento/Review/Model/Review/Summary.php b/app/code/Magento/Review/Model/Review/Summary.php index 4118a2a5407c0c69b389986eb9e886d9fda74534..9ce693020bfa394ef9e7f5cf3f9a407486797016 100644 --- a/app/code/Magento/Review/Model/Review/Summary.php +++ b/app/code/Magento/Review/Model/Review/Summary.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\Review\Model\Review; /** * Review summary */ - -namespace Magento\Review\Model\Review; - class Summary extends \Magento\Core\Model\AbstractModel { /** @@ -49,16 +47,25 @@ class Summary extends \Magento\Core\Model\AbstractModel parent::__construct($context, $registry, $resource, $resourceCollection, $data); } + /** + * @return int + */ public function getEntityPkValue() { return $this->_getData('entity_pk_value'); } + /** + * @return string + */ public function getRatingSummary() { return $this->_getData('rating_summary'); } + /** + * @return int + */ public function getReviewsCount() { return $this->_getData('reviews_count'); diff --git a/app/code/Magento/Review/etc/frontend/di.xml b/app/code/Magento/Review/etc/frontend/di.xml index 97900597754f7c4824c59cf8a196d92a48222d7a..0959fd7c574db66dd389c98c61c5c82fd70da6ec 100644 --- a/app/code/Magento/Review/etc/frontend/di.xml +++ b/app/code/Magento/Review/etc/frontend/di.xml @@ -50,16 +50,16 @@ </type> <type name="Magento\Core\Model\Url\SecurityInfo"> <param name="secureUrlList"> - <value> - <review_customer>/review/customer/</review_customer> - </value> + <array> + <item key="review_customer"><value>/review/customer/</value></item> + </array> </param> </type> <virtualType name="reviewProductInitSession" type="Magento\Core\App\Action\Plugin\Session"> <param name="cookieCheckActions"> - <value> - <productReviewPost>post</productReviewPost> - </value> + <array> + <item key="productReviewPost"><value>post</value></item> + </array> </param> </virtualType> </config> diff --git a/app/code/Magento/Rss/App/Action/Plugin/Authentication.php b/app/code/Magento/Rss/App/Action/Plugin/Authentication.php index d5a579d2ed2c512e017b8d0fae81d5451ec49220..8cd80cb51b84623b48ab4f31e64a3238911326fd 100644 --- a/app/code/Magento/Rss/App/Action/Plugin/Authentication.php +++ b/app/code/Magento/Rss/App/Action/Plugin/Authentication.php @@ -56,7 +56,7 @@ class Authentication extends \Magento\Backend\App\Action\Plugin\Authentication /** * @param \Magento\Backend\Model\Auth $auth - * @param \Magento\Backend\Model\Url $url + * @param \Magento\Backend\Model\UrlInterface $url * @param \Magento\App\ResponseInterface $response * @param \Magento\App\ActionFlag $actionFlag * @param \Magento\Message\ManagerInterface $messageManager @@ -66,7 +66,7 @@ class Authentication extends \Magento\Backend\App\Action\Plugin\Authentication */ public function __construct( \Magento\Backend\Model\Auth $auth, - \Magento\Backend\Model\Url $url, + \Magento\Backend\Model\UrlInterface $url, \Magento\App\ResponseInterface $response, \Magento\App\ActionFlag $actionFlag, \Magento\Message\ManagerInterface $messageManager, diff --git a/app/code/Magento/Rss/Block/Catalog/AbstractCatalog.php b/app/code/Magento/Rss/Block/Catalog/AbstractCatalog.php index 5244c5699c48bdcbd5f40502230bdfd9fb297e3c..cf0e59c185a7f208d6f87acd87f185de279ae07e 100644 --- a/app/code/Magento/Rss/Block/Catalog/AbstractCatalog.php +++ b/app/code/Magento/Rss/Block/Catalog/AbstractCatalog.php @@ -29,23 +29,15 @@ namespace Magento\Rss\Block\Catalog; class AbstractCatalog extends \Magento\Rss\Block\AbstractBlock { /** - * Stored price block instances - * @var array + * Block alias fallback */ - protected $_priceBlock = array(); + const DEFAULT_TYPE = 'default'; /** - * Stored price blocks info + * Stored price block instances * @var array */ - protected $_priceBlockTypes = array(); - - /** - * Default values for price block and template - * @var string - */ - protected $_priceBlockDefaultTemplate = 'rss/product/price.phtml'; - protected $_priceBlockDefaultType = 'Magento\Catalog\Block\Product\Price'; + protected $_priceBlock = array(); /** * Whether to show "As low as" as a link @@ -87,37 +79,27 @@ class AbstractCatalog extends \Magento\Rss\Block\AbstractBlock /** * Return Price Block renderer for specified product type * - * @param string $productTypeId Catalog Product type - * @return \Magento\View\Element\AbstractBlock + * @param string $type Catalog Product type + * @return \Magento\View\Element\Template */ - protected function _getPriceBlock($productTypeId) + protected function _getPriceBlock($type) { - if (!isset($this->_priceBlock[$productTypeId])) { - $block = $this->_priceBlockDefaultType; - if (isset($this->_priceBlockTypes[$productTypeId])) { - if ($this->_priceBlockTypes[$productTypeId]['block'] != '') { - $block = $this->_priceBlockTypes[$productTypeId]['block']; - } + if (!isset($this->_priceBlock[$type])) { + /** @var \Magento\View\Element\RendererList $rendererList */ + $rendererList = $this->getRendererListName() + ? $this->getLayout()->getBlock($this->getRendererListName()) + : $this->getChildBlock('renderer.list'); + if (!$rendererList) { + throw new \RuntimeException( + 'Renderer list for block "' . $this->getNameInLayout() . '" is not defined' + ); } - $this->_priceBlock[$productTypeId] = $this->getLayout()->createBlock($block); + $overriddenTemplates = $this->getOverriddenTemplates() ?: array(); + $template = isset($overriddenTemplates[$type]) ? $overriddenTemplates[$type] : $this->getRendererTemplate(); + $renderer = $rendererList->getRenderer($type, self::DEFAULT_TYPE, $template); + $this->_priceBlock[$type] = $renderer; } - return $this->_priceBlock[$productTypeId]; - } - - /** - * Return template for Price Block renderer - * - * @param string $productTypeId Catalog Product type - * @return string - */ - protected function _getPriceBlockTemplate($productTypeId) - { - if (isset($this->_priceBlockTypes[$productTypeId])) { - if ($this->_priceBlockTypes[$productTypeId]['template'] != '') { - return $this->_priceBlockTypes[$productTypeId]['template']; - } - } - return $this->_priceBlockDefaultTemplate; + return $this->_priceBlock[$type]; } /** @@ -136,28 +118,10 @@ class AbstractCatalog extends \Magento\Rss\Block\AbstractBlock } return $this->_getPriceBlock($typeId) - ->setTemplate($this->_getPriceBlockTemplate($typeId)) ->setProduct($product) ->setDisplayMinimalPrice($displayMinimalPrice) ->setIdSuffix($idSuffix) ->setUseLinkForAsLowAs($this->_useLinkForAsLowAs) ->toHtml(); } - - /** - * Adding customized price template for product type, used as action in layouts - * - * @param string $type Catalog Product Type - * @param string $block Block Type - * @param string $template Template - */ - public function addPriceBlockType($type, $block = '', $template = '') - { - if ($type) { - $this->_priceBlockTypes[$type] = array( - 'block' => $block, - 'template' => $template - ); - } - } } diff --git a/app/code/Magento/Rss/Block/Catalog/Review.php b/app/code/Magento/Rss/Block/Catalog/Review.php index ded1c8572161c63e558e100cf7149a4fd704eddf..f569004435741d08b7400cc39822b97581adadbb 100644 --- a/app/code/Magento/Rss/Block/Catalog/Review.php +++ b/app/code/Magento/Rss/Block/Catalog/Review.php @@ -51,18 +51,12 @@ class Review extends \Magento\Backend\Block\AbstractBlock */ protected $_storeManager; - /** - * @var \Magento\Core\Model\Url - */ - protected $_urlModel; - /** * @param \Magento\Backend\Block\Context $context * @param \Magento\Rss\Model\RssFactory $rssFactory * @param \Magento\Core\Model\Resource\Iterator $resourceIterator * @param \Magento\Review\Model\ReviewFactory $reviewFactory * @param \Magento\Core\Model\StoreManagerInterface $storeManager - * @param \Magento\Core\Model\Url $urlModel * @param array $data */ public function __construct( @@ -71,14 +65,12 @@ class Review extends \Magento\Backend\Block\AbstractBlock \Magento\Core\Model\Resource\Iterator $resourceIterator, \Magento\Review\Model\ReviewFactory $reviewFactory, \Magento\Core\Model\StoreManagerInterface $storeManager, - \Magento\Core\Model\Url $urlModel, array $data = array() ) { $this->_rssFactory = $rssFactory; $this->_resourceIterator = $resourceIterator; $this->_reviewFactory = $reviewFactory; $this->_storeManager = $storeManager; - $this->_urlModel = $urlModel; parent::__construct($context, $data); } @@ -130,8 +122,8 @@ class Review extends \Magento\Backend\Block\AbstractBlock $rssObj = $args['rssObj']; $row = $args['row']; - $productUrl = $this->_urlModel - ->setStore($row['store_id']) + $productUrl = $this->_urlBuilder + ->setScope($row['store_id']) ->getUrl('catalog/product/view', array('id' => $row['entity_id'])); $reviewUrl = $this->getUrl( 'catalog/product_review/edit/', diff --git a/app/code/Magento/Rss/Controller/Adminhtml/Authenticate.php b/app/code/Magento/Rss/Controller/Adminhtml/Authenticate.php index 991f4381c059f28dcc8c7753caea5b7d46aa9ba5..c025c09eccb385f7b84041986e115ab8adf87b25 100644 --- a/app/code/Magento/Rss/Controller/Adminhtml/Authenticate.php +++ b/app/code/Magento/Rss/Controller/Adminhtml/Authenticate.php @@ -39,6 +39,6 @@ class Authenticate extends \Magento\Backend\App\Action public function __construct(Action\Context $context) { parent::__construct($context); - $this->_objectManager->get('Magento\Backend\Model\Url')->turnOffSecretKey(); + $this->_objectManager->get('Magento\Backend\Model\UrlInterface')->turnOffSecretKey(); } } diff --git a/app/code/Magento/Rss/Model/System/Config/Backend/Links.php b/app/code/Magento/Rss/Model/System/Config/Backend/Links.php index 18b02f0d15452e373860169fbe43766017b168a5..84953cec8ddc388b4002143cc532963fc13f3f3e 100644 --- a/app/code/Magento/Rss/Model/System/Config/Backend/Links.php +++ b/app/code/Magento/Rss/Model/System/Config/Backend/Links.php @@ -41,7 +41,7 @@ class Links extends \Magento\Core\Model\Config\Value * @param \Magento\Core\Model\Context $context * @param \Magento\Core\Model\Registry $registry * @param \Magento\Core\Model\StoreManagerInterface $storeManager - * @param \Magento\Core\Model\Config $config + * @param \Magento\App\ConfigInterface $config * @param \Magento\App\Cache\TypeListInterface $cacheTypeList * @param \Magento\Core\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection @@ -51,7 +51,7 @@ class Links extends \Magento\Core\Model\Config\Value \Magento\Core\Model\Context $context, \Magento\Core\Model\Registry $registry, \Magento\Core\Model\StoreManagerInterface $storeManager, - \Magento\Core\Model\Config $config, + \Magento\App\ConfigInterface $config, \Magento\App\Cache\TypeListInterface $cacheTypeList, \Magento\Core\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, diff --git a/app/code/Magento/Rss/view/frontend/layout/rss_catalog_category.xml b/app/code/Magento/Rss/view/frontend/layout/rss_catalog_category.xml index e5d031662dbe59007edc5ed0ed2e3afca89508df..ae600eef4793fae93d1312664364fefdb7c16da4 100644 --- a/app/code/Magento/Rss/view/frontend/layout/rss_catalog_category.xml +++ b/app/code/Magento/Rss/view/frontend/layout/rss_catalog_category.xml @@ -24,11 +24,8 @@ */ --> <layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <update handle="catalog_product_rss_feed_renderer_list" /> <block class="Magento\Rss\Block\Catalog\Category" output="1" name="rss.catalog.category" cacheable="false"> - <action method="addPriceBlockType"> - <argument name="type" xsi:type="string">msrp_rss</argument> - <argument name="block" xsi:type="string">Magento\Catalog\Block\Product\Price</argument> - <argument name="template" xsi:type="string">product/price_msrp_rss.phtml</argument> - </action> + <block class="Magento\View\Element\RendererList" name="catalog.product.rss.feed.renderer.list" as="renderer.list" /> </block> </layout> diff --git a/app/code/Magento/Rss/view/frontend/layout/rss_catalog_new.xml b/app/code/Magento/Rss/view/frontend/layout/rss_catalog_new.xml index 0961f315709e974a57849ce29302618d2ec1bd75..dfc688fd6bde083764dffac7a4d9380e7f8449d7 100644 --- a/app/code/Magento/Rss/view/frontend/layout/rss_catalog_new.xml +++ b/app/code/Magento/Rss/view/frontend/layout/rss_catalog_new.xml @@ -24,11 +24,8 @@ */ --> <layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <update handle="catalog_product_rss_feed_renderer_list" /> <block class="Magento\Rss\Block\Catalog\NewCatalog" output="1" name="rss.catalog.new" cacheable="false"> - <action method="addPriceBlockType"> - <argument name="type" xsi:type="string">msrp_rss</argument> - <argument name="block" xsi:type="string">Magento\Catalog\Block\Product\Price</argument> - <argument name="template" xsi:type="string">product/price_msrp_rss.phtml</argument> - </action> + <block class="Magento\View\Element\RendererList" name="catalog.product.rss.feed.renderer.list" as="renderer.list" /> </block> </layout> diff --git a/app/code/Magento/Sales/Block/Adminhtml/Billing/Agreement/Grid.php b/app/code/Magento/Sales/Block/Adminhtml/Billing/Agreement/Grid.php index ab034b11330cef165926e7c9a87c33105275613a..f21568db051d326acf8a7a92865fa9884e0ed834 100644 --- a/app/code/Magento/Sales/Block/Adminhtml/Billing/Agreement/Grid.php +++ b/app/code/Magento/Sales/Block/Adminhtml/Billing/Agreement/Grid.php @@ -52,7 +52,6 @@ class Grid extends \Magento\Backend\Block\Widget\Grid\Extended /** * @param \Magento\Backend\Block\Template\Context $context - * @param \Magento\Core\Model\Url $urlModel * @param \Magento\Backend\Helper\Data $backendHelper * @param \Magento\Payment\Helper\Data $paymentData * @param \Magento\Sales\Model\Resource\Billing\Agreement\CollectionFactory $agreementFactory @@ -61,7 +60,6 @@ class Grid extends \Magento\Backend\Block\Widget\Grid\Extended */ public function __construct( \Magento\Backend\Block\Template\Context $context, - \Magento\Core\Model\Url $urlModel, \Magento\Backend\Helper\Data $backendHelper, \Magento\Payment\Helper\Data $paymentData, \Magento\Sales\Model\Resource\Billing\Agreement\CollectionFactory $agreementFactory, @@ -71,7 +69,7 @@ class Grid extends \Magento\Backend\Block\Widget\Grid\Extended $this->_paymentData = $paymentData; $this->_agreementFactory = $agreementFactory; $this->_agreementModel = $agreementModel; - parent::__construct($context, $urlModel, $backendHelper, $data); + parent::__construct($context, $backendHelper, $data); } /** diff --git a/app/code/Magento/Sales/Block/Adminhtml/Billing/Agreement/View/Tab/Info.php b/app/code/Magento/Sales/Block/Adminhtml/Billing/Agreement/View/Tab/Info.php index 002d19e665e4ed535f2efadcb240b06adbfe853e..fae56154761647a5a57a88eb0bf5da5b4f290524 100644 --- a/app/code/Magento/Sales/Block/Adminhtml/Billing/Agreement/View/Tab/Info.php +++ b/app/code/Magento/Sales/Block/Adminhtml/Billing/Agreement/View/Tab/Info.php @@ -43,27 +43,23 @@ class Info extends \Magento\Backend\Block\Template */ protected $_coreRegistry = null; - /** - * Core registry - * - * @var \Magento\Customer\Model\CustomerFactory - */ - protected $_customerFactory; + /** @var \Magento\Customer\Service\V1\CustomerServiceInterface */ + protected $_customerService; /** * @param \Magento\Backend\Block\Template\Context $context * @param \Magento\Core\Model\Registry $registry - * @param \Magento\Customer\Model\CustomerFactory $customerFactory + * @param \Magento\Customer\Service\V1\CustomerServiceInterface $customerService * @param array $data */ public function __construct( \Magento\Backend\Block\Template\Context $context, \Magento\Core\Model\Registry $registry, - \Magento\Customer\Model\CustomerFactory $customerFactory, + \Magento\Customer\Service\V1\CustomerServiceInterface $customerService, array $data = array() ) { $this->_coreRegistry = $registry; - $this->_customerFactory = $customerFactory; + $this->_customerService = $customerService; parent::__construct($context, $data); } @@ -126,11 +122,13 @@ class Info extends \Magento\Backend\Block\Template { $agreement = $this->_getBillingAgreement(); $this->setReferenceId($agreement->getReferenceId()); - $customer = $this->_customerFactory->create()->load($agreement->getCustomerId()); + $customerId = $agreement->getCustomerId(); + $customer = $this->_customerService->getCustomer($customerId); + + $this->setCustomerEmail($customer->getEmail()); $this->setCustomerUrl( - $this->getUrl('customer/index/edit', array('id' => $customer->getId())) + $this->getUrl('customer/index/edit', array('id' => $customerId)) ); - $this->setCustomerEmail($customer->getEmail()); $this->setStatus($agreement->getStatusLabel()); $this->setCreatedAt( $this->formatDate($agreement->getCreatedAt(), 'short', true) diff --git a/app/code/Magento/Sales/Block/Adminhtml/Creditmemo/Grid.php b/app/code/Magento/Sales/Block/Adminhtml/Creditmemo/Grid.php index 59c01c8d39232a602e2a47546602df8edd67f270..e0480bfd91cfeca07f7f0100b2d5ec91166266fa 100644 --- a/app/code/Magento/Sales/Block/Adminhtml/Creditmemo/Grid.php +++ b/app/code/Magento/Sales/Block/Adminhtml/Creditmemo/Grid.php @@ -45,7 +45,6 @@ class Grid extends \Magento\Backend\Block\Widget\Grid\Extended /** * @param \Magento\Backend\Block\Template\Context $context - * @param \Magento\Core\Model\Url $urlModel * @param \Magento\Backend\Helper\Data $backendHelper * @param \Magento\Sales\Model\Order\CreditmemoFactory $creditmemoFactory * @param \Magento\Sales\Model\Resource\Order\Creditmemo\Grid\CollectionFactory $collectionFactory @@ -53,7 +52,6 @@ class Grid extends \Magento\Backend\Block\Widget\Grid\Extended */ public function __construct( \Magento\Backend\Block\Template\Context $context, - \Magento\Core\Model\Url $urlModel, \Magento\Backend\Helper\Data $backendHelper, \Magento\Sales\Model\Order\CreditmemoFactory $creditmemoFactory, \Magento\Sales\Model\Resource\Order\Creditmemo\Grid\CollectionFactory $collectionFactory, @@ -61,7 +59,7 @@ class Grid extends \Magento\Backend\Block\Widget\Grid\Extended ) { $this->_creditmemoFactory = $creditmemoFactory; $this->_collectionFactory = $collectionFactory; - parent::__construct($context, $urlModel, $backendHelper, $data); + parent::__construct($context, $backendHelper, $data); } protected function _construct() diff --git a/app/code/Magento/Sales/Block/Adminhtml/Customer/Edit/Tab/Agreement.php b/app/code/Magento/Sales/Block/Adminhtml/Customer/Edit/Tab/Agreement.php index 29007f631b39614436f6dcc6a56db7ed9ae46033..26967cda12b080af567f5b16ba3aef462df8c04b 100644 --- a/app/code/Magento/Sales/Block/Adminhtml/Customer/Edit/Tab/Agreement.php +++ b/app/code/Magento/Sales/Block/Adminhtml/Customer/Edit/Tab/Agreement.php @@ -51,7 +51,6 @@ class Agreement /** * @param \Magento\Backend\Block\Template\Context $context - * @param \Magento\Core\Model\Url $urlModel * @param \Magento\Backend\Helper\Data $backendHelper * @param \Magento\Payment\Helper\Data $paymentData * @param \Magento\Sales\Model\Resource\Billing\Agreement\CollectionFactory $agreementFactory @@ -61,7 +60,6 @@ class Agreement */ public function __construct( \Magento\Backend\Block\Template\Context $context, - \Magento\Core\Model\Url $urlModel, \Magento\Backend\Helper\Data $backendHelper, \Magento\Payment\Helper\Data $paymentData, \Magento\Sales\Model\Resource\Billing\Agreement\CollectionFactory $agreementFactory, @@ -72,7 +70,6 @@ class Agreement $this->_coreRegistry = $coreRegistry; parent::__construct( $context, - $urlModel, $backendHelper, $paymentData, $agreementFactory, @@ -119,7 +116,7 @@ class Agreement public function canShowTab() { $customer = $this->_coreRegistry->registry('current_customer'); - return (bool)$customer->getId(); + return !is_null($customer); } /** @@ -154,8 +151,12 @@ class Agreement */ protected function _prepareCollection() { + $customerId = $this->_coreRegistry->registry('current_customer_id'); + if (!$customerId) { + $customerId = $this->_coreRegistry->registry('current_customer')->getId(); + } $collection = $this->_agreementFactory->create() - ->addFieldToFilter('customer_id', $this->_coreRegistry->registry('current_customer')->getId()) + ->addFieldToFilter('customer_id', $customerId) ->setOrder('created_at'); $this->setCollection($collection); return \Magento\Backend\Block\Widget\Grid::_prepareCollection(); diff --git a/app/code/Magento/Sales/Block/Adminhtml/Customer/Edit/Tab/Recurring/Profile.php b/app/code/Magento/Sales/Block/Adminhtml/Customer/Edit/Tab/Recurring/Profile.php index f20749ec7480f2ceb33dd136cb427a46154d08d6..d589742d0d7a63d64fcf5d02a0c66589633e4803 100644 --- a/app/code/Magento/Sales/Block/Adminhtml/Customer/Edit/Tab/Recurring/Profile.php +++ b/app/code/Magento/Sales/Block/Adminhtml/Customer/Edit/Tab/Recurring/Profile.php @@ -18,19 +18,17 @@ * 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_Sales * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ /** * Adminhtml customer recurring profiles tab - * - * @author Magento Core Team <core@magentocommerce.com> */ namespace Magento\Sales\Block\Adminhtml\Customer\Edit\Tab\Recurring; +use Magento\Customer\Controller\Adminhtml\Index as CustomerController; + class Profile extends \Magento\Sales\Block\Adminhtml\Recurring\Profile\Grid implements \Magento\Backend\Block\Widget\Tab\TabInterface @@ -42,9 +40,13 @@ class Profile */ protected $_coreRegistry = null; + /** + * @var int + */ + protected $_currentCustomerId; + /** * @param \Magento\Backend\Block\Template\Context $context - * @param \Magento\Core\Model\Url $urlModel * @param \Magento\Backend\Helper\Data $backendHelper * @param \Magento\Payment\Helper\Data $paymentData * @param \Magento\Sales\Model\Resource\Recurring\Profile\CollectionFactory $profileCollection @@ -54,7 +56,6 @@ class Profile */ public function __construct( \Magento\Backend\Block\Template\Context $context, - \Magento\Core\Model\Url $urlModel, \Magento\Backend\Helper\Data $backendHelper, \Magento\Payment\Helper\Data $paymentData, \Magento\Sales\Model\Resource\Recurring\Profile\CollectionFactory $profileCollection, @@ -63,9 +64,19 @@ class Profile array $data = array() ) { $this->_coreRegistry = $coreRegistry; + + // @todo remove usage of REGISTRY_CURRENT_CUSTOMER in advantage of REGISTRY_CURRENT_CUSTOMER_ID + $currentCustomer = $this->_coreRegistry->registry(CustomerController::REGISTRY_CURRENT_CUSTOMER); + if ($currentCustomer) { + $this->_currentCustomerId = $currentCustomer->getId(); + } else { + $this->_currentCustomerId = $this->_coreRegistry->registry( + CustomerController::REGISTRY_CURRENT_CUSTOMER_ID + ); + } + parent::__construct( $context, - $urlModel, $backendHelper, $paymentData, $profileCollection, @@ -111,8 +122,7 @@ class Profile */ public function canShowTab() { - $customer = $this->_coreRegistry->registry('current_customer'); - return (bool)$customer->getId(); + return (bool)$this->_currentCustomerId; } /** @@ -132,12 +142,18 @@ class Profile */ protected function _prepareCollection() { - $collection = $this->_profileCollection->create() - ->addFieldToFilter('customer_id', $this->_coreRegistry->registry('current_customer')->getId()); + if (!$this->_currentCustomerId) { + return $this; + } + + $collection = $this->_profileCollection->create()->addFieldToFilter('customer_id', $this->_currentCustomerId); + if (!$this->getParam($this->getVarNameSort())) { $collection->setOrder('profile_id', 'desc'); } + $this->setCollection($collection); + return parent::_prepareCollection(); } diff --git a/app/code/Magento/Sales/Block/Adminhtml/Invoice/Grid.php b/app/code/Magento/Sales/Block/Adminhtml/Invoice/Grid.php index cbe163e88403061ad75e79185a64c51e15bf6622..5043c9b50e1fea22a10fa4e3eb77bf42d39d00a9 100644 --- a/app/code/Magento/Sales/Block/Adminhtml/Invoice/Grid.php +++ b/app/code/Magento/Sales/Block/Adminhtml/Invoice/Grid.php @@ -45,7 +45,6 @@ class Grid extends \Magento\Backend\Block\Widget\Grid\Extended /** * @param \Magento\Backend\Block\Template\Context $context - * @param \Magento\Core\Model\Url $urlModel * @param \Magento\Backend\Helper\Data $backendHelper * @param \Magento\Sales\Model\Order\InvoiceFactory $invoiceFactory * @param \Magento\Sales\Model\Resource\Order\Invoice\Grid\CollectionFactory $collectionFactory @@ -53,7 +52,6 @@ class Grid extends \Magento\Backend\Block\Widget\Grid\Extended */ public function __construct( \Magento\Backend\Block\Template\Context $context, - \Magento\Core\Model\Url $urlModel, \Magento\Backend\Helper\Data $backendHelper, \Magento\Sales\Model\Order\InvoiceFactory $invoiceFactory, \Magento\Sales\Model\Resource\Order\Invoice\Grid\CollectionFactory $collectionFactory, @@ -61,7 +59,7 @@ class Grid extends \Magento\Backend\Block\Widget\Grid\Extended ) { $this->_invoiceFactory = $invoiceFactory; $this->_collectionFactory = $collectionFactory; - parent::__construct($context, $urlModel, $backendHelper, $data); + parent::__construct($context, $backendHelper, $data); } protected function _construct() diff --git a/app/code/Magento/Sales/Block/Adminhtml/Order/Address/Form.php b/app/code/Magento/Sales/Block/Adminhtml/Order/Address/Form.php index 15c4b2e2ad84e8e59ececa8ca5136229a16fe8d8..348a185fc5a87815d45e4a15825859ecaafdae1e 100644 --- a/app/code/Magento/Sales/Block/Adminhtml/Order/Address/Form.php +++ b/app/code/Magento/Sales/Block/Adminhtml/Order/Address/Form.php @@ -18,21 +18,15 @@ * 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_Sales * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -/** - * Adminhtml sales order edit address block - * - * @category Magento - * @package Magento_Sales - * @author Magento Core Team <core@magentocommerce.com> - */ namespace Magento\Sales\Block\Adminhtml\Order\Address; +/** + * Adminhtml sales order address block + */ class Form extends \Magento\Sales\Block\Adminhtml\Order\Create\Form\Address { @@ -52,13 +46,12 @@ class Form * @param \Magento\Data\FormFactory $formFactory * @param \Magento\Core\Helper\Data $coreData * @param \Magento\Json\EncoderInterface $jsonEncoder - * @param \Magento\Customer\Model\AddressFactory $addressFactory - * @param \Magento\Customer\Model\FormFactory $customerFormFactory - * @param \Magento\Backend\Helper\Addresses $adminhtmlAddresses + * @param \Magento\Customer\Model\Metadata\FormFactory $customerFormFactory * @param \Magento\Customer\Helper\Data $customerHelper + * @param \Magento\Customer\Service\V1\CustomerAddressServiceInterface $addressService + * @param \Magento\Customer\Helper\Address $addressHelper * @param \Magento\Core\Model\Registry $registry * @param array $data - * * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ public function __construct( @@ -68,10 +61,10 @@ class Form \Magento\Data\FormFactory $formFactory, \Magento\Core\Helper\Data $coreData, \Magento\Json\EncoderInterface $jsonEncoder, - \Magento\Customer\Model\AddressFactory $addressFactory, - \Magento\Customer\Model\FormFactory $customerFormFactory, - \Magento\Backend\Helper\Addresses $adminhtmlAddresses, + \Magento\Customer\Model\Metadata\FormFactory $customerFormFactory, \Magento\Customer\Helper\Data $customerHelper, + \Magento\Customer\Service\V1\CustomerAddressServiceInterface $addressService, + \Magento\Customer\Helper\Address $addressHelper, \Magento\Core\Model\Registry $registry, array $data = array() ) { @@ -83,10 +76,10 @@ class Form $formFactory, $coreData, $jsonEncoder, - $addressFactory, $customerFormFactory, - $adminhtmlAddresses, $customerHelper, + $addressService, + $addressHelper, $data ); } @@ -111,7 +104,9 @@ class Form parent::_prepareForm(); $this->_form->setId('edit_form'); $this->_form->setMethod('post'); - $this->_form->setAction($this->getUrl('sales/*/addressSave', array('address_id'=>$this->_getAddress()->getId()))); + $this->_form->setAction( + $this->getUrl('sales/*/addressSave', array('address_id' => $this->_getAddress()->getId())) + ); $this->_form->setUseContainer(true); return $this; } diff --git a/app/code/Magento/Sales/Block/Adminhtml/Order/Create/AbstractCreate.php b/app/code/Magento/Sales/Block/Adminhtml/Order/Create/AbstractCreate.php index 942ff0f5072fb3b3f9a9d60a23e88205c6ef927f..f70617314472a828fb41171a6a2a8c42c364f52d 100644 --- a/app/code/Magento/Sales/Block/Adminhtml/Order/Create/AbstractCreate.php +++ b/app/code/Magento/Sales/Block/Adminhtml/Order/Create/AbstractCreate.php @@ -86,16 +86,6 @@ abstract class AbstractCreate extends \Magento\Backend\Block\Widget return $this->_getSession()->getQuote(); } - /** - * Retrieve customer model object - * - * @return \Magento\Customer\Model\Customer - */ - public function getCustomer() - { - return $this->_getSession()->getCustomer(); - } - /** * Retrieve customer identifier * diff --git a/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Billing/Address.php b/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Billing/Address.php index a6900f817f540a045c70fb939e57a105eafc6181..c2fba38e16e013280d96375494d043b7e8fdc428 100644 --- a/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Billing/Address.php +++ b/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Billing/Address.php @@ -97,7 +97,7 @@ class Address /** * Return billing address object * - * @return \Magento\Customer\Model\Address + * @return \Magento\Sales\Model\Quote\Address */ public function getAddress() { diff --git a/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Form.php b/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Form.php index 982d4c3bf2f533e0ddf72b4fb36cd360d6d36175..5b9b5708f4b2a80c47520217c725e0bfff0c1f6e 100644 --- a/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Form.php +++ b/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Form.php @@ -18,40 +18,33 @@ * 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_Sales * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -/** - * Adminhtml sales order create sidebar - * - * @category Magento - * @package Magento_Sales - * @author Magento Core Team <core@magentocommerce.com> - */ - namespace Magento\Sales\Block\Adminhtml\Order\Create; +/** + * Adminhtml sales order create form block + */ class Form extends \Magento\Sales\Block\Adminhtml\Order\Create\AbstractCreate { - /** - * @var \Magento\Customer\Model\FormFactory - */ + /** @var \Magento\Customer\Model\Metadata\FormFactory */ protected $_customerFormFactory; - /** - * @var \Magento\Json\EncoderInterface - */ + /** @var \Magento\Json\EncoderInterface */ protected $_jsonEncoder; + /** @var \Magento\Customer\Service\V1\CustomerAddressServiceInterface */ + protected $_addressService; + /** * @param \Magento\Backend\Block\Template\Context $context * @param \Magento\Json\EncoderInterface $jsonEncoder * @param \Magento\Backend\Model\Session\Quote $sessionQuote * @param \Magento\Sales\Model\AdminOrder\Create $orderCreate - * @param \Magento\Customer\Model\FormFactory $customerFormFactory + * @param \Magento\Customer\Model\Metadata\FormFactory $customerFormFactory + * @param \Magento\Customer\Service\V1\CustomerAddressServiceInterface $addressService * @param array $data */ public function __construct( @@ -59,11 +52,13 @@ class Form extends \Magento\Sales\Block\Adminhtml\Order\Create\AbstractCreate \Magento\Backend\Model\Session\Quote $sessionQuote, \Magento\Sales\Model\AdminOrder\Create $orderCreate, \Magento\Json\EncoderInterface $jsonEncoder, - \Magento\Customer\Model\FormFactory $customerFormFactory, + \Magento\Customer\Model\Metadata\FormFactory $customerFormFactory, + \Magento\Customer\Service\V1\CustomerAddressServiceInterface $addressService, array $data = array() ) { $this->_jsonEncoder = $jsonEncoder; $this->_customerFormFactory = $customerFormFactory; + $this->_addressService = $addressService; parent::__construct($context, $sessionQuote, $orderCreate, $data); } @@ -75,6 +70,7 @@ class Form extends \Magento\Sales\Block\Adminhtml\Order\Create\AbstractCreate /** * Retrieve url for loading blocks + * * @return string */ public function getLoadBlockUrl() @@ -84,6 +80,7 @@ class Form extends \Magento\Sales\Block\Adminhtml\Order\Create\AbstractCreate /** * Retrieve url for form submiting + * * @return string */ public function getSaveUrl() @@ -102,7 +99,7 @@ class Form extends \Magento\Sales\Block\Adminhtml\Order\Create\AbstractCreate public function getStoreSelectorDisplay() { - $storeId = $this->getStoreId(); + $storeId = $this->getStoreId(); $customerId = $this->getCustomerId(); if (!is_null($customerId) && !$storeId) { return 'block'; @@ -112,7 +109,7 @@ class Form extends \Magento\Sales\Block\Adminhtml\Order\Create\AbstractCreate public function getDataSelectorDisplay() { - $storeId = $this->getStoreId(); + $storeId = $this->getStoreId(); $customerId = $this->getCustomerId(); if (!is_null($customerId) && $storeId) { return 'block'; @@ -123,16 +120,17 @@ class Form extends \Magento\Sales\Block\Adminhtml\Order\Create\AbstractCreate public function getOrderDataJson() { $data = array(); - if (!is_null($this->getCustomerId())) { + if ($this->getCustomerId()) { $data['customer_id'] = $this->getCustomerId(); $data['addresses'] = array(); - - /* @var $addressForm \Magento\Customer\Model\Form */ - $addressForm = $this->_customerFormFactory->create() - ->setFormCode('adminhtml_customer_address') - ->setStore($this->getStore()); - foreach ($this->getCustomer()->getAddresses() as $address) { - $data['addresses'][$address->getId()] = $addressForm->setEntity($address) + $addresses = $this->_addressService->getAddresses($this->getCustomerId()); + foreach ($addresses as $addressDto) { + $addressForm = $this->_customerFormFactory->create( + 'customer_address', + 'adminhtml_customer_address', + $addressDto->__toArray() + ); + $data['addresses'][$addressDto->getId()] = $addressForm ->outputData(\Magento\Eav\Model\AttributeDataFactory::OUTPUT_FORMAT_JSON); } } diff --git a/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Form/AbstractForm.php b/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Form/AbstractForm.php index 36d1aa152fa39d3762c5c9053410001262af30ce..8b028e58fe9ffb2bf80eb6cb3018096c7dd9eb5b 100644 --- a/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Form/AbstractForm.php +++ b/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Form/AbstractForm.php @@ -160,7 +160,7 @@ abstract class AbstractForm /** * Add rendering EAV attributes to Form element * - * @param array|\Magento\Data\Collection $attributes + * @param \Magento\Customer\Service\V1\Dto\Eav\AttributeMetadata[] $attributes * @param \Magento\Data\Form\AbstractForm $form * @return \Magento\Sales\Block\Adminhtml\Order\Create\Form\AbstractForm */ @@ -174,16 +174,14 @@ abstract class AbstractForm $renderers = $this->_getAdditionalFormElementRenderers(); foreach ($attributes as $attribute) { - /** @var $attribute \Magento\Customer\Model\Attribute */ - $attribute->setStoreId($this->_sessionQuote->getStoreId()); - $inputType = $attribute->getFrontend()->getInputType(); + $inputType = $attribute->getFrontendInput(); if ($inputType) { $element = $form->addField($attribute->getAttributeCode(), $inputType, array( 'name' => $attribute->getAttributeCode(), 'label' => __($attribute->getStoreLabel()), - 'class' => $attribute->getFrontend()->getClass(), - 'required' => $attribute->getIsRequired(), + 'class' => $attribute->getFrontendClass(), + 'required' => $attribute->isRequired(), )); if ($inputType == 'multiline') { $element->setLineCount($attribute->getMultilineCount()); @@ -196,7 +194,11 @@ abstract class AbstractForm } if ($inputType == 'select' || $inputType == 'multiselect') { - $element->setValues($attribute->getFrontend()->getSelectOptions()); + $options = array(); + foreach ($attribute->getOptions() as $optionDto) { + $options[] = $optionDto->__toArray(); + } + $element->setValues($options); } else if ($inputType == 'date') { $format = $this->_locale->getDateFormat(\Magento\Core\Model\LocaleInterface::FORMAT_TYPE_SHORT); $element->setImage($this->getViewFileUrl('images/grid-cal.gif')); diff --git a/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Form/Account.php b/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Form/Account.php index c08c18eb0a6e39f5cd54b400c5c81d57602aa4e8..363f0cf19638c24000975baebc26b755b788e536 100644 --- a/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Form/Account.php +++ b/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Form/Account.php @@ -34,22 +34,20 @@ namespace Magento\Sales\Block\Adminhtml\Order\Create\Form; class Account extends \Magento\Sales\Block\Adminhtml\Order\Create\Form\AbstractForm { /** - * @var \Magento\Customer\Model\CustomerFactory + * @var \Magento\Customer\Model\Metadata\FormFactory */ - protected $_customerFactory; + protected $_metadataFormFactory; - /** - * @var \Magento\Customer\Model\FormFactory - */ - protected $_customerFormFactory; + /** @var \Magento\Customer\Service\V1\CustomerServiceInterface */ + protected $_customerService; /** * @param \Magento\Backend\Block\Template\Context $context * @param \Magento\Backend\Model\Session\Quote $sessionQuote * @param \Magento\Sales\Model\AdminOrder\Create $orderCreate * @param \Magento\Data\FormFactory $formFactory - * @param \Magento\Customer\Model\CustomerFactory $customerFactory - * @param \Magento\Customer\Model\FormFactory $customerFormFactory + * @param \Magento\Customer\Model\Metadata\FormFactory $metadataFormFactory + * @param \Magento\Customer\Service\V1\CustomerServiceInterface $customerService * @param array $data */ public function __construct( @@ -57,12 +55,12 @@ class Account extends \Magento\Sales\Block\Adminhtml\Order\Create\Form\AbstractF \Magento\Backend\Model\Session\Quote $sessionQuote, \Magento\Sales\Model\AdminOrder\Create $orderCreate, \Magento\Data\FormFactory $formFactory, - \Magento\Customer\Model\CustomerFactory $customerFactory, - \Magento\Customer\Model\FormFactory $customerFormFactory, + \Magento\Customer\Model\Metadata\FormFactory $metadataFormFactory, + \Magento\Customer\Service\V1\CustomerServiceInterface $customerService, array $data = array() ) { - $this->_customerFactory = $customerFactory; - $this->_customerFormFactory = $customerFormFactory; + $this->_metadataFormFactory = $metadataFormFactory; + $this->_customerService = $customerService; parent::__construct($context, $sessionQuote, $orderCreate, $formFactory, $data); } @@ -93,22 +91,18 @@ class Account extends \Magento\Sales\Block\Adminhtml\Order\Create\Form\AbstractF */ protected function _prepareForm() { - /* @var $customerModel \Magento\Customer\Model\Customer */ - $customerModel = $this->_customerFactory->create(); - - /* @var $customerForm \Magento\Customer\Model\Form */ - $customerForm = $this->_customerFormFactory->create(); - $customerForm->setFormCode('adminhtml_checkout') - ->setStore($this->getStore()) - ->setEntity($customerModel); + /** @var \Magento\Customer\Model\Metadata\Form $customerForm */ + $customerForm = $this->_metadataFormFactory->create( + 'customer', + 'adminhtml_checkout' + ); // prepare customer attributes to show - $attributes = array(); + $attributes = []; // add system required attributes foreach ($customerForm->getSystemAttributes() as $attribute) { - /* @var $attribute \Magento\Customer\Model\Attribute */ - if ($attribute->getIsRequired()) { + if ($attribute->isRequired()) { $attributes[$attribute->getAttributeCode()] = $attribute; } } @@ -119,7 +113,6 @@ class Account extends \Magento\Sales\Block\Adminhtml\Order\Create\Form\AbstractF // add user defined attributes foreach ($customerForm->getUserAttributes() as $attribute) { - /* @var $attribute \Magento\Customer\Model\Attribute */ $attributes[$attribute->getAttributeCode()] = $attribute; } @@ -157,7 +150,12 @@ class Account extends \Magento\Sales\Block\Adminhtml\Order\Create\Form\AbstractF */ public function getFormValues() { - $data = $this->getCustomer()->getData(); + try { + $customer = $this->_customerService->getCustomer($this->getCustomerId()); + } catch (\Exception $e) { + /** If customer does not exist do nothing. */ + } + $data = isset($customer) ? $customer->__toArray() : array(); foreach ($this->getQuote()->getData() as $key => $value) { if (strpos($key, 'customer_') === 0) { $data[substr($key, 9)] = $value; diff --git a/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Form/Address.php b/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Form/Address.php index 5c636f2791dffb353d8aa06b4c2335f0a62a78d9..84b9b7eb8a9b2964a2866d7b78f8cd91c04f636e 100644 --- a/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Form/Address.php +++ b/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Form/Address.php @@ -33,30 +33,10 @@ */ namespace Magento\Sales\Block\Adminhtml\Order\Create\Form; -class Address - extends \Magento\Sales\Block\Adminhtml\Order\Create\Form\AbstractForm +class Address extends \Magento\Sales\Block\Adminhtml\Order\Create\Form\AbstractForm { /** - * Customer Address Form instance - * - * @var \Magento\Customer\Model\Form - */ - protected $_addressForm; - - /** - * Adminhtml addresses - * - * @var \Magento\Backend\Helper\Addresses - */ - protected $_adminhtmlAddresses = null; - - /** - * @var \Magento\Customer\Model\AddressFactory - */ - protected $_addressFactory; - - /** - * @var \Magento\Customer\Model\FormFactory + * @var \Magento\Customer\Model\Metadata\FormFactory */ protected $_customerFormFactory; @@ -75,6 +55,16 @@ class Address */ protected $_customerHelper; + /** + * @var \Magento\Customer\Service\V1\CustomerAddressServiceInterface + */ + protected $_addressService; + + /** + * @var \Magento\Customer\Helper\Address + */ + protected $_addressHelper; + /** * @param \Magento\Backend\Block\Template\Context $context * @param \Magento\Backend\Model\Session\Quote $sessionQuote @@ -82,12 +72,12 @@ class Address * @param \Magento\Data\FormFactory $formFactory * @param \Magento\Core\Helper\Data $coreData * @param \Magento\Json\EncoderInterface $jsonEncoder - * @param \Magento\Customer\Model\AddressFactory $addressFactory - * @param \Magento\Customer\Model\FormFactory $customerFormFactory - * @param \Magento\Backend\Helper\Addresses $adminhtmlAddresses + * @param \Magento\Customer\Model\Metadata\FormFactory $customerFormFactory * @param \Magento\Customer\Helper\Data $customerHelper + * @param \Magento\Customer\Service\V1\CustomerAddressServiceInterface $addressService + * @param \Magento\Customer\Helper\Address $addressHelper * @param array $data - * + * * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ public function __construct( @@ -97,18 +87,18 @@ class Address \Magento\Data\FormFactory $formFactory, \Magento\Core\Helper\Data $coreData, \Magento\Json\EncoderInterface $jsonEncoder, - \Magento\Customer\Model\AddressFactory $addressFactory, - \Magento\Customer\Model\FormFactory $customerFormFactory, - \Magento\Backend\Helper\Addresses $adminhtmlAddresses, + \Magento\Customer\Model\Metadata\FormFactory $customerFormFactory, \Magento\Customer\Helper\Data $customerHelper, + \Magento\Customer\Service\V1\CustomerAddressServiceInterface $addressService, + \Magento\Customer\Helper\Address $addressHelper, array $data = array() ) { $this->_customerHelper = $customerHelper; $this->_coreData = $coreData; $this->_jsonEncoder = $jsonEncoder; - $this->_addressFactory = $addressFactory; $this->_customerFormFactory = $customerFormFactory; - $this->_adminhtmlAddresses = $adminhtmlAddresses; + $this->_addressService = $addressService; + $this->_addressHelper = $addressHelper; parent::__construct($context, $sessionQuote, $orderCreate, $formFactory, $data); } @@ -123,28 +113,16 @@ class Address return $this->_storeConfig->getConfig($path); } /** - * Return Customer Address Collection as array + * Retrieve current customer address DTOs collection. * - * @return array + * @return \Magento\Customer\Service\V1\Dto\Address[] */ public function getAddressCollection() { - return $this->getCustomer()->getAddresses(); - } - - /** - * Return customer address form instance - * - * @return \Magento\Customer\Model\Form - */ - protected function _getAddressForm() - { - if (is_null($this->_addressForm)) { - $this->_addressForm = $this->_customerFormFactory->create() - ->setFormCode('adminhtml_customer_address') - ->setStore($this->getStore()); + if ($this->getCustomerId()) { + return $this->_addressService->getAddresses($this->getCustomerId()); } - return $this->_addressForm; + return []; } /** @@ -154,18 +132,20 @@ class Address */ public function getAddressCollectionJson() { - $addressForm = $this->_getAddressForm(); - $data = array(); - - $emptyAddress = $this->getCustomer() - ->getAddressById(null) - ->setCountryId($this->_coreData->getDefaultCountry($this->getStore())); - $data[0] = $addressForm->setEntity($emptyAddress) - ->outputData(\Magento\Eav\Model\AttributeDataFactory::OUTPUT_FORMAT_JSON); - - foreach ($this->getAddressCollection() as $address) { - $addressForm->setEntity($address); - $data[$address->getId()] = $addressForm->outputData( + $defaultCountryId = $this->_coreData->getDefaultCountry($this->getStore()); + $emptyAddressForm = $this->_customerFormFactory->create( + 'customer_address', + 'adminhtml_customer_address', + [\Magento\Customer\Service\V1\Dto\Address::KEY_COUNTRY_ID => $defaultCountryId] + ); + $data = [0 => $emptyAddressForm->outputData(\Magento\Eav\Model\AttributeDataFactory::OUTPUT_FORMAT_JSON)]; + foreach ($this->getAddressCollection() as $addressDto) { + $addressForm = $this->_customerFormFactory->create( + 'customer_address', + 'adminhtml_customer_address', + $addressDto->__toArray() + ); + $data[$addressDto->getId()] = $addressForm->outputData( \Magento\Eav\Model\AttributeDataFactory::OUTPUT_FORMAT_JSON ); } @@ -175,6 +155,8 @@ class Address /** * Prepare Form and add elements to form * + * @SuppressWarnings(PHPMD.CyclomaticComplexity) + * @SuppressWarnings(PHPMD.NPathComplexity) * @return \Magento\Sales\Block\Adminhtml\Order\Create\Form\Address */ protected function _prepareForm() @@ -183,17 +165,11 @@ class Address 'no_container' => true )); - /* @var $addressModel \Magento\Customer\Model\Address */ - $addressModel = $this->_addressFactory->create(); - - $addressForm = $this->_getAddressForm() - ->setEntity($addressModel); - + $addressForm = $this->_customerFormFactory->create( + 'customer_address', + 'adminhtml_customer_address' + ); $attributes = $addressForm->getAttributes(); - if (isset($attributes['street'])) { - $this->_adminhtmlAddresses - ->processStreetAttribute($attributes['street']); - } $this->_addAttributesToForm($attributes, $fieldset); $prefixElement = $this->_form->getElement('prefix'); @@ -291,13 +267,18 @@ class Address } /** - * Return customer address formated as one-line string + * Represent customer address in 'online' format. * - * @param \Magento\Customer\Model\Address $address + * @param \Magento\Customer\Service\V1\Dto\Address $addressData * @return string */ - public function getAddressAsString($address) + public function getAddressAsString($addressData) { - return $this->escapeHtml($address->format('oneline')); + $formatTypeRenderer = $this->_addressHelper->getFormatTypeRenderer('oneline'); + $result = ''; + if ($formatTypeRenderer) { + $result = $formatTypeRenderer->renderArray($addressData->__toArray()); + } + return $this->escapeHtml($result); } } diff --git a/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Header.php b/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Header.php index 1a192c33cb712c108bc8773f10ed88d95c342989..64a59582d9f9d8edd3d41267f3dd092004c01903 100644 --- a/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Header.php +++ b/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Header.php @@ -18,46 +18,97 @@ * 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_Sales * @copyright Copyright (c) 2014 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\Block\Adminhtml\Order\Create; + /** * Create order form header - * - * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\Sales\Block\Adminhtml\Order\Create; - class Header extends \Magento\Sales\Block\Adminhtml\Order\Create\AbstractCreate { + /** @var \Magento\Customer\Service\V1\CustomerServiceInterface */ + protected $_customerService; + + /** @var \Magento\Customer\Helper\View */ + protected $_customerViewHelper; + + /** + * Initialize dependencies. + * + * @param \Magento\Backend\Block\Template\Context $context + * @param \Magento\Backend\Model\Session\Quote $sessionQuote + * @param \Magento\Sales\Model\AdminOrder\Create $orderCreate + * @param \Magento\Customer\Service\V1\CustomerServiceInterface $customerService + * @param \Magento\Customer\Helper\View $customerViewHelper + * @param array $data + */ + public function __construct( + \Magento\Backend\Block\Template\Context $context, + \Magento\Backend\Model\Session\Quote $sessionQuote, + \Magento\Sales\Model\AdminOrder\Create $orderCreate, + \Magento\Customer\Service\V1\CustomerServiceInterface $customerService, + \Magento\Customer\Helper\View $customerViewHelper, + array $data = array() + ) { + $this->_customerService = $customerService; + $this->_customerViewHelper = $customerViewHelper; + parent::__construct($context, $sessionQuote, $orderCreate, $data); + } + + /** + * {@inheritdoc} + */ protected function _toHtml() { if ($this->_getSession()->getOrder()->getId()) { return __('Edit Order #%1', $this->_getSession()->getOrder()->getIncrementId()); } + $out = $this->_getCreateOrderTitle(); + return $this->escapeHtml($out); + } + /** + * Generate title for new order creation page. + * + * @return string + */ + protected function _getCreateOrderTitle() + { $customerId = $this->getCustomerId(); - $storeId = $this->getStoreId(); + $storeId = $this->getStoreId(); $out = ''; if ($customerId && $storeId) { - $out.= __('Create New Order for %1 in %2', $this->getCustomer()->getName(), $this->getStore()->getName()); - } - elseif (!is_null($customerId) && $storeId){ - $out.= __('Create New Order for New Customer in %1', $this->getStore()->getName()); - } - elseif ($customerId) { - $out.= __('Create New Order for %1', $this->getCustomer()->getName()); - } - elseif (!is_null($customerId)){ - $out.= __('Create New Order for New Customer'); + $out .= __( + 'Create New Order for %1 in %2', + $this->_getCustomerName($customerId), + $this->getStore()->getName() + ); + return $out; + } elseif (!$customerId && $storeId) { + $out .= __('Create New Order for New Customer in %1', $this->getStore()->getName()); + return $out; + } elseif ($customerId && !$storeId) { + $out .= __('Create New Order for %1', $this->_getCustomerName($customerId)); + return $out; + } elseif (!$customerId && !$storeId) { + $out .= __('Create New Order for New Customer'); + return $out; } - else { - $out.= __('Create New Order'); - } - $out = $this->escapeHtml($out); return $out; } + + /** + * Get customer name by his ID. + * + * @param int $customerId + * @return string + */ + protected function _getCustomerName($customerId) + { + $customerData = $this->_customerService->getCustomer($customerId); + return $this->_customerViewHelper->getCustomerName($customerData); + } } diff --git a/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Search/Grid.php b/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Search/Grid.php index 2d27a4fdc21330cd6badc8b8a8dafa5924f69898..24c9cfe6bae84b22d50d06bd2bdbae4feb8205bd 100644 --- a/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Search/Grid.php +++ b/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Search/Grid.php @@ -57,7 +57,6 @@ class Grid extends \Magento\Backend\Block\Widget\Grid\Extended /** * @param \Magento\Backend\Block\Template\Context $context - * @param \Magento\Core\Model\Url $urlModel * @param \Magento\Backend\Helper\Data $backendHelper * @param \Magento\Catalog\Model\ProductFactory $productFactory * @param \Magento\Catalog\Model\Config $catalogConfig @@ -67,7 +66,6 @@ class Grid extends \Magento\Backend\Block\Widget\Grid\Extended */ public function __construct( \Magento\Backend\Block\Template\Context $context, - \Magento\Core\Model\Url $urlModel, \Magento\Backend\Helper\Data $backendHelper, \Magento\Catalog\Model\ProductFactory $productFactory, \Magento\Catalog\Model\Config $catalogConfig, @@ -79,7 +77,7 @@ class Grid extends \Magento\Backend\Block\Widget\Grid\Extended $this->_catalogConfig = $catalogConfig; $this->_sessionQuote = $sessionQuote; $this->_salesConfig = $salesConfig; - parent::__construct($context, $urlModel, $backendHelper, $data); + parent::__construct($context, $backendHelper, $data); } protected function _construct() diff --git a/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Search/Grid/Renderer/Qty.php b/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Search/Grid/Renderer/Qty.php index 734d7e96276702fee025ae194ff1f3f770dd5f5a..ec9d7ab7f05dd314aa75d4a2727ca8f25db3ef67 100644 --- a/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Search/Grid/Renderer/Qty.php +++ b/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Search/Grid/Renderer/Qty.php @@ -36,6 +36,25 @@ namespace Magento\Sales\Block\Adminhtml\Order\Create\Search\Grid\Renderer; class Qty extends \Magento\Backend\Block\Widget\Grid\Column\Renderer\Input { + /** + * @var \Magento\Catalog\Model\ProductTypes\ConfigInterface + */ + protected $typeConfig; + + /** + * @param \Magento\Backend\Block\Context $context + * @param \Magento\Catalog\Model\ProductTypes\ConfigInterface $typeConfig + * @param array $data + */ + public function __construct( + \Magento\Backend\Block\Context $context, + \Magento\Catalog\Model\ProductTypes\ConfigInterface $typeConfig, + array $data = array() + ) { + parent::__construct($context, $data); + $this->typeConfig = $typeConfig; + } + /** * Returns whether this qty field must be inactive * @@ -44,7 +63,7 @@ class Qty */ protected function _isInactive($row) { - return $row->getTypeId() == \Magento\GroupedProduct\Model\Product\Type\Grouped::TYPE_CODE; + return $this->typeConfig->isProductSet($row->getTypeId()); } /** @@ -56,10 +75,13 @@ class Qty public function render(\Magento\Object $row) { // Prepare values - $isInactive = $this->_isInactive($row); + $disabled = ''; + $addClass = ''; - if ($isInactive) { + if ($this->_isInactive($row)) { $qty = ''; + $disabled = 'disabled="disabled" '; + $addClass = ' input-inactive'; } else { $qty = $row->getData($this->getColumn()->getIndex()); $qty *= 1; @@ -71,11 +93,8 @@ class Qty // Compose html $html = '<input type="text" '; $html .= 'name="' . $this->getColumn()->getId() . '" '; - $html .= 'value="' . $qty . '" '; - if ($isInactive) { - $html .= 'disabled="disabled" '; - } - $html .= 'class="input-text ' . $this->getColumn()->getInlineCss() . ($isInactive ? ' input-inactive' : '') . '" />'; + $html .= 'value="' . $qty . '" ' . $disabled; + $html .= 'class="input-text ' . $this->getColumn()->getInlineCss() . $addClass . '" />'; return $html; } } diff --git a/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Shipping/Address.php b/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Shipping/Address.php index da382631565be948902ac623c461a707f3653853..313aab696aca1f017a947489f35261d7d98e9f9c 100644 --- a/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Shipping/Address.php +++ b/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Shipping/Address.php @@ -34,8 +34,7 @@ */ namespace Magento\Sales\Block\Adminhtml\Order\Create\Shipping; -class Address - extends \Magento\Sales\Block\Adminhtml\Order\Create\Form\Address +class Address extends \Magento\Sales\Block\Adminhtml\Order\Create\Form\Address { /** * Return header text @@ -127,7 +126,7 @@ class Address /** * Return address object * - * @return \Magento\Customer\Model\Address + * @return \Magento\Sales\Model\Quote\Address */ public function getAddress() { diff --git a/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Sidebar/AbstractSidebar.php b/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Sidebar/AbstractSidebar.php index 1529106211fc2c88153f3de0bedad4ad978fc9a2..42854d006252afd29375a3b608bbe2f76364b741 100644 --- a/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Sidebar/AbstractSidebar.php +++ b/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Sidebar/AbstractSidebar.php @@ -168,7 +168,7 @@ class AbstractSidebar extends \Magento\Sales\Block\Adminhtml\Order\Create\Abstra /* * Filtering items by allowed product type */ - foreach($items as $key => $item) { + foreach ($items as $key => $item) { if ($item instanceof \Magento\Catalog\Model\Product) { $type = $item->getTypeId(); } else if ($item instanceof \Magento\Sales\Model\Order\Item) { @@ -209,4 +209,25 @@ class AbstractSidebar extends \Magento\Sales\Block\Adminhtml\Order\Create\Abstra return true; } + /** + * Get item qty + * + * @param \Magento\Object $item + * @return int + */ + public function getItemQty(\Magento\Object $item) + { + return $item->getQty()*1 ? $item->getQty()*1 : 1; + } + + /** + * Check whether product configuration is required before adding to order + * + * @param $productType + * @return bool + */ + public function isConfigurationRequired($productType) + { + return false; + } } diff --git a/app/code/Magento/Sales/Block/Adminhtml/Order/View/Info.php b/app/code/Magento/Sales/Block/Adminhtml/Order/View/Info.php index 3212636b73d074701cd8d3215afcb68b511a2b11..e62c28153fdb12af00904120b83a2b899658f235 100644 --- a/app/code/Magento/Sales/Block/Adminhtml/Order/View/Info.php +++ b/app/code/Magento/Sales/Block/Adminhtml/Order/View/Info.php @@ -18,67 +18,57 @@ * 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_Sales * @copyright Copyright (c) 2014 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\Block\Adminhtml\Order\View; + +use Magento\Customer\Service\V1\CustomerMetadataServiceInterface; +use Magento\Eav\Model\AttributeDataFactory; /** * Order history block - * - * @category Magento - * @package Magento_Sales - * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\Sales\Block\Adminhtml\Order\View; - class Info extends \Magento\Sales\Block\Adminhtml\Order\AbstractOrder { /** - * @var \Magento\Customer\Model\GroupFactory - */ - protected $_groupFactory; - - /** - * @var \Magento\Eav\Model\AttributeDataFactory + * Customer service + * + * @var CustomerMetadataServiceInterface */ - protected $_attrDataFactory; + protected $_customerMetadataService; /** - * @var \Magento\Customer\Model\CustomerFactory + * @var \Magento\Customer\Service\V1\CustomerGroupServiceInterface */ - protected $_customerFactory; + protected $_groupService; /** - * @var \Magento\Eav\Model\Config + * @var \Magento\Customer\Model\Metadata\ElementFactory */ - protected $_eavConfig; + protected $_metadataElementFactory; /** * @param \Magento\Backend\Block\Template\Context $context * @param \Magento\Core\Model\Registry $registry * @param \Magento\Sales\Helper\Admin $adminHelper - * @param \Magento\Customer\Model\GroupFactory $groupFactory - * @param \Magento\Customer\Model\CustomerFactory $customerFactory - * @param \Magento\Eav\Model\Config $eavConfig - * @param \Magento\Eav\Model\AttributeDataFactory $attrDataFactory + * @param \Magento\Customer\Service\V1\CustomerGroupServiceInterface $groupService + * @param CustomerMetadataServiceInterface $customerMetadataService + * @param \Magento\Customer\Model\Metadata\ElementFactory $elementFactory * @param array $data */ public function __construct( \Magento\Backend\Block\Template\Context $context, \Magento\Core\Model\Registry $registry, \Magento\Sales\Helper\Admin $adminHelper, - \Magento\Customer\Model\GroupFactory $groupFactory, - \Magento\Customer\Model\CustomerFactory $customerFactory, - \Magento\Eav\Model\Config $eavConfig, - \Magento\Eav\Model\AttributeDataFactory $attrDataFactory, + \Magento\Customer\Service\V1\CustomerGroupServiceInterface $groupService, + CustomerMetadataServiceInterface $customerMetadataService, + \Magento\Customer\Model\Metadata\ElementFactory $elementFactory, array $data = array() ) { - $this->_customerFactory = $customerFactory; - $this->_groupFactory = $groupFactory; - $this->_eavConfig = $eavConfig; - $this->_attrDataFactory = $attrDataFactory; + $this->_groupService = $groupService; + $this->_customerMetadataService = $customerMetadataService; + $this->_metadataElementFactory = $elementFactory; parent::__construct($context, $registry, $adminHelper, $data); } @@ -118,22 +108,41 @@ class Info extends \Magento\Sales\Block\Adminhtml\Order\AbstractOrder return null; } + /** + * Return name of the customer group. + * + * @return string + */ public function getCustomerGroupName() { if ($this->getOrder()) { - return $this->_groupFactory->create()->load((int)$this->getOrder()->getCustomerGroupId())->getCode(); + $customerGroupId = $this->getOrder()->getCustomerGroupId(); + if (!is_null($customerGroupId)) { + return $this->_groupService->getGroup($customerGroupId)->getCode(); + } } - return null; + return ''; } + /** + * Get URL to edit the customer. + * + * @return string + */ public function getCustomerViewUrl() { if ($this->getOrder()->getCustomerIsGuest() || !$this->getOrder()->getCustomerId()) { - return false; + return ''; } return $this->getUrl('customer/index/edit', array('id' => $this->getOrder()->getCustomerId())); } + /** + * Get order view URL. + * + * @param int $orderId + * @return string + */ public function getViewUrl($orderId) { return $this->getUrl('sales/order/view', array('order_id'=>$orderId)); @@ -163,28 +172,25 @@ class Info extends \Magento\Sales\Block\Adminhtml\Order\AbstractOrder */ public function getCustomerAccountData() { - $accountData = array(); - + $accountData = []; $entityType = 'customer'; - $customer = $this->_customerFactory->create(); - foreach ($this->_eavConfig->getEntityAttributeCodes($entityType) as $attributeCode) { - /* @var $attribute \Magento\Customer\Model\Attribute */ - $attribute = $this->_eavConfig->getAttribute($entityType, $attributeCode); - if (!$attribute->getIsVisible() || $attribute->getIsSystem()) { + + foreach ($this->_customerMetadataService->getAllCustomerAttributeMetadata($entityType) as $attribute) { + /* @var $attribute \Magento\Customer\Service\V1\Dto\Eav\AttributeMetadata */ + if (!$attribute->isVisible() || $attribute->isSystem()) { continue; } $orderKey = sprintf('customer_%s', $attribute->getAttributeCode()); $orderValue = $this->getOrder()->getData($orderKey); if ($orderValue != '') { - $customer->setData($attribute->getAttributeCode(), $orderValue); - $dataModel = $this->_attrDataFactory->create($attribute, $customer); - $value = $dataModel->outputValue(\Magento\Eav\Model\AttributeDataFactory::OUTPUT_FORMAT_HTML); - $sortOrder = $attribute->getSortOrder() + $attribute->getIsUserDefined() ? 200 : 0; + $metadataElement = $this->_metadataElementFactory->create($attribute, $orderValue, $entityType); + $value = $metadataElement->outputValue(AttributeDataFactory::OUTPUT_FORMAT_HTML); + $sortOrder = $attribute->getSortOrder() + $attribute->isUserDefined() ? 200 : 0; $sortOrder = $this->_prepareAccountDataSortOrder($accountData, $sortOrder); - $accountData[$sortOrder] = array( + $accountData[$sortOrder] = [ 'label' => $attribute->getFrontendLabel(), - 'value' => $this->escapeHtml($value, array('br')) - ); + 'value' => $this->escapeHtml($value, ['br']) + ]; } } diff --git a/app/code/Magento/Sales/Block/Adminhtml/Order/View/Tab/Creditmemos.php b/app/code/Magento/Sales/Block/Adminhtml/Order/View/Tab/Creditmemos.php index d8b472d56b53d0ea24fd073931bdcc514df8c051..6cfa1ee36a42a9e68e2bdde02fbf41c7e872c2b8 100644 --- a/app/code/Magento/Sales/Block/Adminhtml/Order/View/Tab/Creditmemos.php +++ b/app/code/Magento/Sales/Block/Adminhtml/Order/View/Tab/Creditmemos.php @@ -56,7 +56,6 @@ class Creditmemos /** * @param \Magento\Backend\Block\Template\Context $context - * @param \Magento\Core\Model\Url $urlModel * @param \Magento\Backend\Helper\Data $backendHelper * @param \Magento\Sales\Model\Resource\Order\Collection\Factory $collectionFactory * @param \Magento\Sales\Model\Order\Creditmemo $orderCreditmemo @@ -65,7 +64,6 @@ class Creditmemos */ public function __construct( \Magento\Backend\Block\Template\Context $context, - \Magento\Core\Model\Url $urlModel, \Magento\Backend\Helper\Data $backendHelper, \Magento\Sales\Model\Resource\Order\Collection\Factory $collectionFactory, \Magento\Sales\Model\Order\Creditmemo $orderCreditmemo, @@ -75,7 +73,7 @@ class Creditmemos $this->_coreRegistry = $coreRegistry; $this->_orderCreditmemo = $orderCreditmemo; $this->_collectionFactory = $collectionFactory; - parent::__construct($context, $urlModel, $backendHelper, $data); + parent::__construct($context, $backendHelper, $data); } protected function _construct() diff --git a/app/code/Magento/Sales/Block/Adminhtml/Order/View/Tab/Invoices.php b/app/code/Magento/Sales/Block/Adminhtml/Order/View/Tab/Invoices.php index d1ef50e1ab266db1db8b8f3ded1485fda35b26f7..41743203a09111ebb903cd4920ce3b2faa1551e7 100644 --- a/app/code/Magento/Sales/Block/Adminhtml/Order/View/Tab/Invoices.php +++ b/app/code/Magento/Sales/Block/Adminhtml/Order/View/Tab/Invoices.php @@ -56,7 +56,6 @@ class Invoices /** * @param \Magento\Backend\Block\Template\Context $context - * @param \Magento\Core\Model\Url $urlModel * @param \Magento\Backend\Helper\Data $backendHelper * @param \Magento\Sales\Model\Resource\Order\Collection\Factory $collectionFactory * @param \Magento\Sales\Model\Order\Invoice $orderInvoice @@ -65,7 +64,6 @@ class Invoices */ public function __construct( \Magento\Backend\Block\Template\Context $context, - \Magento\Core\Model\Url $urlModel, \Magento\Backend\Helper\Data $backendHelper, \Magento\Sales\Model\Resource\Order\Collection\Factory $collectionFactory, \Magento\Sales\Model\Order\Invoice $orderInvoice, @@ -75,7 +73,7 @@ class Invoices $this->_coreRegistry = $coreRegistry; $this->_orderInvoice = $orderInvoice; $this->_collectionFactory = $collectionFactory; - parent::__construct($context, $urlModel, $backendHelper, $data); + parent::__construct($context, $backendHelper, $data); } protected function _construct() diff --git a/app/code/Magento/Sales/Block/Adminhtml/Order/View/Tab/Shipments.php b/app/code/Magento/Sales/Block/Adminhtml/Order/View/Tab/Shipments.php index 9d7598bc97c09d5d2f896f7bf2cbc8382495540c..ca7726e567b66d9deabb0f3baf1ed7954dbd05b5 100644 --- a/app/code/Magento/Sales/Block/Adminhtml/Order/View/Tab/Shipments.php +++ b/app/code/Magento/Sales/Block/Adminhtml/Order/View/Tab/Shipments.php @@ -47,7 +47,6 @@ class Shipments /** * @param \Magento\Backend\Block\Template\Context $context - * @param \Magento\Core\Model\Url $urlModel * @param \Magento\Backend\Helper\Data $backendHelper * @param \Magento\Sales\Model\Resource\Order\Collection\Factory $collectionFactory * @param \Magento\Core\Model\Registry $coreRegistry @@ -55,7 +54,6 @@ class Shipments */ public function __construct( \Magento\Backend\Block\Template\Context $context, - \Magento\Core\Model\Url $urlModel, \Magento\Backend\Helper\Data $backendHelper, \Magento\Sales\Model\Resource\Order\Collection\Factory $collectionFactory, \Magento\Core\Model\Registry $coreRegistry, @@ -63,7 +61,7 @@ class Shipments ) { $this->_coreRegistry = $coreRegistry; $this->_collectionFactory = $collectionFactory; - parent::__construct($context, $urlModel, $backendHelper, $data); + parent::__construct($context, $backendHelper, $data); } protected function _construct() diff --git a/app/code/Magento/Sales/Block/Adminhtml/Recurring/Profile/Grid.php b/app/code/Magento/Sales/Block/Adminhtml/Recurring/Profile/Grid.php index be1e8bb9e9117994255b3a8c4a990eb415cd065d..7847b9ceb92b046687159e963a4c7d07d2cd2837 100644 --- a/app/code/Magento/Sales/Block/Adminhtml/Recurring/Profile/Grid.php +++ b/app/code/Magento/Sales/Block/Adminhtml/Recurring/Profile/Grid.php @@ -53,7 +53,6 @@ class Grid extends \Magento\Backend\Block\Widget\Grid\Extended /** * @param \Magento\Backend\Block\Template\Context $context - * @param \Magento\Core\Model\Url $urlModel * @param \Magento\Backend\Helper\Data $backendHelper * @param \Magento\Payment\Helper\Data $paymentData * @param \Magento\Sales\Model\Resource\Recurring\Profile\CollectionFactory $profileCollection @@ -62,7 +61,6 @@ class Grid extends \Magento\Backend\Block\Widget\Grid\Extended */ public function __construct( \Magento\Backend\Block\Template\Context $context, - \Magento\Core\Model\Url $urlModel, \Magento\Backend\Helper\Data $backendHelper, \Magento\Payment\Helper\Data $paymentData, \Magento\Sales\Model\Resource\Recurring\Profile\CollectionFactory $profileCollection, @@ -72,7 +70,7 @@ class Grid extends \Magento\Backend\Block\Widget\Grid\Extended $this->_paymentData = $paymentData; $this->_profileCollection = $profileCollection; $this->_recurringProfile = $recurringProfile; - parent::__construct($context, $urlModel, $backendHelper, $data); + parent::__construct($context, $backendHelper, $data); } protected function _construct() diff --git a/app/code/Magento/Sales/Block/Adminhtml/Recurring/Profile/View/Tab/Orders.php b/app/code/Magento/Sales/Block/Adminhtml/Recurring/Profile/View/Tab/Orders.php index 422dcefdea86341267f79d1675c86a99f846aa8b..7b41c64d2b99ebbbef3ab417d4f8fa977a9d905f 100644 --- a/app/code/Magento/Sales/Block/Adminhtml/Recurring/Profile/View/Tab/Orders.php +++ b/app/code/Magento/Sales/Block/Adminhtml/Recurring/Profile/View/Tab/Orders.php @@ -52,7 +52,6 @@ class Orders /** * @param \Magento\Backend\Block\Template\Context $context - * @param \Magento\Core\Model\Url $urlModel * @param \Magento\Backend\Helper\Data $backendHelper * @param \Magento\Core\Model\Registry $coreRegistry * @param \Magento\Sales\Model\Resource\Order\Grid\CollectionFactory $orderCollection @@ -61,7 +60,6 @@ class Orders */ public function __construct( \Magento\Backend\Block\Template\Context $context, - \Magento\Core\Model\Url $urlModel, \Magento\Backend\Helper\Data $backendHelper, \Magento\Core\Model\Registry $coreRegistry, \Magento\Sales\Model\Resource\Order\Grid\CollectionFactory $orderCollection, @@ -71,7 +69,7 @@ class Orders $this->_coreRegistry = $coreRegistry; $this->_orderCollection = $orderCollection; $this->_orderConfig = $orderConfig; - parent::__construct($context, $urlModel, $backendHelper, $data); + parent::__construct($context, $backendHelper, $data); } /** diff --git a/app/code/Magento/Sales/Block/Adminhtml/Shipment/Grid.php b/app/code/Magento/Sales/Block/Adminhtml/Shipment/Grid.php index f69d9a75faea80000df3363f4195af164f9a9137..6ba615240c0e911f9884e00d790bd6090621019b 100644 --- a/app/code/Magento/Sales/Block/Adminhtml/Shipment/Grid.php +++ b/app/code/Magento/Sales/Block/Adminhtml/Shipment/Grid.php @@ -40,20 +40,18 @@ class Grid extends \Magento\Backend\Block\Widget\Grid\Extended /** * @param \Magento\Backend\Block\Template\Context $context - * @param \Magento\Core\Model\Url $urlModel * @param \Magento\Backend\Helper\Data $backendHelper * @param \Magento\Sales\Model\Resource\Order\Collection\Factory $collectionFactory * @param array $data */ public function __construct( \Magento\Backend\Block\Template\Context $context, - \Magento\Core\Model\Url $urlModel, \Magento\Backend\Helper\Data $backendHelper, \Magento\Sales\Model\Resource\Order\Collection\Factory $collectionFactory, array $data = array() ) { $this->_collectionFactory = $collectionFactory; - parent::__construct($context, $urlModel, $backendHelper, $data); + parent::__construct($context, $backendHelper, $data); } diff --git a/app/code/Magento/Sales/Block/Adminhtml/Transactions/Detail/Grid.php b/app/code/Magento/Sales/Block/Adminhtml/Transactions/Detail/Grid.php index 344a67cfef1e9a0c6889b294a2635ca53c5968c0..11c7f3a29b19311e86d2d2d535aa400249d6d275 100644 --- a/app/code/Magento/Sales/Block/Adminhtml/Transactions/Detail/Grid.php +++ b/app/code/Magento/Sales/Block/Adminhtml/Transactions/Detail/Grid.php @@ -49,7 +49,6 @@ class Grid extends \Magento\Backend\Block\Widget\Grid\Extended /** * @param \Magento\Backend\Block\Template\Context $context - * @param \Magento\Core\Model\Url $urlModel * @param \Magento\Backend\Helper\Data $backendHelper * @param \Magento\Data\CollectionFactory $collectionFactory * @param \Magento\Core\Model\Registry $coreRegistry @@ -57,7 +56,6 @@ class Grid extends \Magento\Backend\Block\Widget\Grid\Extended */ public function __construct( \Magento\Backend\Block\Template\Context $context, - \Magento\Core\Model\Url $urlModel, \Magento\Backend\Helper\Data $backendHelper, \Magento\Data\CollectionFactory $collectionFactory, \Magento\Core\Model\Registry $coreRegistry, @@ -65,7 +63,7 @@ class Grid extends \Magento\Backend\Block\Widget\Grid\Extended ) { $this->_collectionFactory = $collectionFactory; $this->_coreRegistry = $coreRegistry; - parent::__construct($context, $urlModel, $backendHelper, $data); + parent::__construct($context, $backendHelper, $data); } /** diff --git a/app/code/Magento/Sales/Block/Adminhtml/Transactions/Grid.php b/app/code/Magento/Sales/Block/Adminhtml/Transactions/Grid.php index a09fb1b1e8a6e25f7110d2d365b9ff212811019a..de7195575f2f7fffd86ccbe7203c99c1064093db 100644 --- a/app/code/Magento/Sales/Block/Adminhtml/Transactions/Grid.php +++ b/app/code/Magento/Sales/Block/Adminhtml/Transactions/Grid.php @@ -61,7 +61,6 @@ class Grid extends \Magento\Backend\Block\Widget\Grid\Extended /** * @param \Magento\Backend\Block\Template\Context $context - * @param \Magento\Core\Model\Url $urlModel * @param \Magento\Backend\Helper\Data $backendHelper * @param \Magento\Sales\Model\Order\Payment\Transaction $transaction * @param \Magento\Sales\Model\Resource\Order\Payment\Transaction\CollectionFactory $collectionFactory @@ -71,7 +70,6 @@ class Grid extends \Magento\Backend\Block\Widget\Grid\Extended */ public function __construct( \Magento\Backend\Block\Template\Context $context, - \Magento\Core\Model\Url $urlModel, \Magento\Backend\Helper\Data $backendHelper, \Magento\Sales\Model\Order\Payment\Transaction $transaction, \Magento\Sales\Model\Resource\Order\Payment\Transaction\CollectionFactory $collectionFactory, @@ -83,7 +81,7 @@ class Grid extends \Magento\Backend\Block\Widget\Grid\Extended $this->_paymentData = $paymentData; $this->_transaction = $transaction; $this->_collectionFactory = $collectionFactory; - parent::__construct($context, $urlModel, $backendHelper, $data); + parent::__construct($context, $backendHelper, $data); } /** diff --git a/app/code/Magento/Sales/Block/Billing/Agreement/View.php b/app/code/Magento/Sales/Block/Billing/Agreement/View.php index 59a5c435e2b12a9536fd80eab2f78f03c5b92b12..1493ade7ffc04c242ed8824bfb9eb1e7c94c0e36 100644 --- a/app/code/Magento/Sales/Block/Billing/Agreement/View.php +++ b/app/code/Magento/Sales/Block/Billing/Agreement/View.php @@ -116,14 +116,16 @@ class View extends \Magento\View\Element\Template public function getRelatedOrders() { if (is_null($this->_relatedOrders)) { + $billingAgreement = $this->_getBillingAgreementInstance(); + $billingAgreementId = $billingAgreement ? $billingAgreement->getAgreementId() : 0; $this->_relatedOrders = $this->_orderCollectionFactory->create() ->addFieldToSelect('*') - ->addFieldToFilter('customer_id', $this->_customerSession->getCustomer()->getId()) + ->addFieldToFilter('customer_id', (int)$this->_customerSession->getCustomerId()) ->addFieldToFilter( 'state', array('in' => $this->_orderConfig->getVisibleOnFrontStates()) ) - ->addBillingAgreementsFilter($this->_billingAgreementInstance->getAgreementId()) + ->addBillingAgreementsFilter($billingAgreementId) ->setOrder('created_at', 'desc'); } return $this->_relatedOrders; @@ -174,9 +176,6 @@ class View extends \Magento\View\Element\Template */ protected function _prepareLayout() { - if (is_null($this->_billingAgreementInstance)) { - $this->_billingAgreementInstance = $this->_coreRegistry->registry('current_billing_agreement'); - } parent::_prepareLayout(); $pager = $this->getLayout()->createBlock('Magento\Theme\Block\Html\Pager') @@ -187,6 +186,19 @@ class View extends \Magento\View\Element\Template return $this; } + /** + * Return current billing agreement. + * + * @return \Magento\Sales\Model\Billing\Agreement|null + */ + protected function _getBillingAgreementInstance() + { + if (is_null($this->_billingAgreementInstance)) { + $this->_billingAgreementInstance = $this->_coreRegistry->registry('current_billing_agreement'); + } + return $this->_billingAgreementInstance; + } + /** * Load available billing agreement methods * @@ -211,21 +223,22 @@ class View extends \Magento\View\Element\Template { $this->_loadPaymentMethods(); $this->setBackUrl($this->getUrl('*/billing_agreement/')); - if ($this->_billingAgreementInstance) { - $this->setReferenceId($this->_billingAgreementInstance->getReferenceId()); + $billingAgreement = $this->_getBillingAgreementInstance(); + if ($billingAgreement) { + $this->setReferenceId($billingAgreement->getReferenceId()); - $this->setCanCancel($this->_billingAgreementInstance->canCancel()); + $this->setCanCancel($billingAgreement->canCancel()); $this->setCancelUrl( $this->getUrl('*/billing_agreement/cancel', array( '_current' => true, - 'payment_method' => $this->_billingAgreementInstance->getMethodCode())) + 'payment_method' => $billingAgreement->getMethodCode())) ); - $paymentMethodTitle = $this->_billingAgreementInstance->getAgreementLabel(); + $paymentMethodTitle = $billingAgreement->getAgreementLabel(); $this->setPaymentMethodTitle($paymentMethodTitle); - $createdAt = $this->_billingAgreementInstance->getCreatedAt(); - $updatedAt = $this->_billingAgreementInstance->getUpdatedAt(); + $createdAt = $billingAgreement->getCreatedAt(); + $updatedAt = $billingAgreement->getUpdatedAt(); $this->setAgreementCreatedAt( ($createdAt) ? $this->formatDate($createdAt, 'short', true) @@ -236,7 +249,7 @@ class View extends \Magento\View\Element\Template $this->formatDate($updatedAt, 'short', true) ); } - $this->setAgreementStatus($this->_billingAgreementInstance->getStatusLabel()); + $this->setAgreementStatus($billingAgreement->getStatusLabel()); } return parent::_toHtml(); diff --git a/app/code/Magento/Sales/Block/Items/AbstractItems.php b/app/code/Magento/Sales/Block/Items/AbstractItems.php index aa0eeaf1b496882aed78ce2c64052457e1615d1d..53bb39eedfe8dc78942300d5b961dee041d3e0c8 100644 --- a/app/code/Magento/Sales/Block/Items/AbstractItems.php +++ b/app/code/Magento/Sales/Block/Items/AbstractItems.php @@ -40,21 +40,6 @@ class AbstractItems extends \Magento\View\Element\Template */ const DEFAULT_TYPE = 'default'; - /** - * Initialize default item renderer - */ - protected function _prepareLayout() - { - if (!$this->getChildBlock(self::DEFAULT_TYPE)) { - $this->addChild( - self::DEFAULT_TYPE, - 'Magento\Checkout\Block\Cart\Item\Renderer', - array('template' => 'cart/item/default.phtml') - ); - } - return parent::_prepareLayout(); - } - /** * Retrieve item renderer block * @@ -64,11 +49,16 @@ class AbstractItems extends \Magento\View\Element\Template */ public function getItemRenderer($type) { - $renderer = $this->getChildBlock($type) ?: $this->getChildBlock(self::DEFAULT_TYPE); - if (!$renderer instanceof \Magento\View\Element\BlockInterface) { - throw new \RuntimeException('Renderer for type "' . $type . '" does not exist.'); + /** @var \Magento\View\Element\RendererList $rendererList */ + $rendererList = $this->getRendererListName() + ? $this->getLayout()->getBlock($this->getRendererListName()) + : $this->getChildBlock('renderer.list'); + if (!$rendererList) { + throw new \RuntimeException('Renderer list for block "' . $this->getNameInLayout() . '" is not defined'); } - $renderer->setRenderedBlock($this); + $overriddenTemplates = $this->getOverriddenTemplates() ?: array(); + $template = isset($overriddenTemplates[$type]) ? $overriddenTemplates[$type] : $this->getRendererTemplate(); + $renderer = $rendererList->getRenderer($type, self::DEFAULT_TYPE, $template); return $renderer; } diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Billing/Agreement.php b/app/code/Magento/Sales/Controller/Adminhtml/Billing/Agreement.php index 7f246512a985776a4db48a79b3e39168057a98aa..9a8ae0c9627f24922a139c3c6a06c9711ad1174c 100644 --- a/app/code/Magento/Sales/Controller/Adminhtml/Billing/Agreement.php +++ b/app/code/Magento/Sales/Controller/Adminhtml/Billing/Agreement.php @@ -192,14 +192,10 @@ class Agreement extends \Magento\Backend\App\Action */ protected function _initCustomer() { - $customerId = (int) $this->getRequest()->getParam('id'); - $customer = $this->_objectManager->create('Magento\Customer\Model\Customer'); - + $customerId = (int)$this->getRequest()->getParam('id'); if ($customerId) { - $customer->load($customerId); + $this->_coreRegistry->register('current_customer_id', $customerId); } - - $this->_coreRegistry->register('current_customer', $customer); return $this; } diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Recurring/Profile.php b/app/code/Magento/Sales/Controller/Adminhtml/Recurring/Profile.php index 1b16eef117d8a62eeb3845c675259c8827d1644a..e3b936978d1c36c89f2adcd26a60fc42b0b18bab 100644 --- a/app/code/Magento/Sales/Controller/Adminhtml/Recurring/Profile.php +++ b/app/code/Magento/Sales/Controller/Adminhtml/Recurring/Profile.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_Sales * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ @@ -32,9 +30,27 @@ namespace Magento\Sales\Controller\Adminhtml\Recurring; use Magento\App\Action\NotFoundException; +use Magento\Core\Exception as CoreException; +use Magento\Customer\Controller\Adminhtml\Index as CustomerController; class Profile extends \Magento\Backend\App\Action { + /**#@+ + * Request parameter keys + */ + const PARAM_CUSTOMER_ID = 'id'; + const PARAM_PROFILE = 'profile'; + const PARAM_ACTION = 'action'; + /**#@-*/ + + /**#@+ + * Values for PARAM_ACTION request parameter + */ + const ACTION_CANCEL = 'cancel'; + const ACTION_SUSPEND = 'suspend'; + const ACTION_ACTIVATE = 'activate'; + /**#@-*/ + /** * Core registry * @@ -42,15 +58,31 @@ class Profile extends \Magento\Backend\App\Action */ protected $_coreRegistry = null; + /** + * @var \Magento\Customer\Service\V1\CustomerServiceInterface + */ + protected $_customerService; + + /** + * @var \Magento\Logger + */ + protected $_logger; + /** * @param \Magento\Backend\App\Action\Context $context * @param \Magento\Core\Model\Registry $coreRegistry + * @param \Magento\Customer\Service\V1\CustomerServiceInterface $customerService + * @param \Magento\Logger $logger */ public function __construct( \Magento\Backend\App\Action\Context $context, - \Magento\Core\Model\Registry $coreRegistry + \Magento\Core\Model\Registry $coreRegistry, + \Magento\Customer\Service\V1\CustomerServiceInterface $customerService, + \Magento\Logger $logger ) { $this->_coreRegistry = $coreRegistry; + $this->_customerService = $customerService; + $this->_logger = $logger; parent::__construct($context); } @@ -78,10 +110,10 @@ class Profile extends \Magento\Backend\App\Action $this->_title->add(__('Profile #%1', $profile->getReferenceId())); $this->_view->renderLayout(); return; - } catch (\Magento\Core\Exception $e) { + } catch (CoreException $e) { $this->messageManager->addError($e->getMessage()); } catch (\Exception $e) { - $this->_objectManager->get('Magento\Logger')->logException($e); + $this->_logger->logException($e); } $this->_redirect('sales/*/'); } @@ -94,10 +126,10 @@ class Profile extends \Magento\Backend\App\Action try { $this->_view->loadLayout()->renderLayout(); return; - } catch (\Magento\Core\Exception $e) { + } catch (CoreException $e) { $this->messageManager->addError($e->getMessage()); } catch (\Exception $e) { - $this->_objectManager->get('Magento\Logger')->logException($e); + $this->_logger->logException($e); } $this->_redirect('sales/*/'); } @@ -113,7 +145,7 @@ class Profile extends \Magento\Backend\App\Action $this->_initProfile(); $this->_view->loadLayout()->renderLayout(); } catch (\Exception $e) { - $this->_objectManager->get('Magento\Logger')->logException($e); + $this->_logger->logException($e); throw new NotFoundException(); } } @@ -126,27 +158,30 @@ class Profile extends \Magento\Backend\App\Action $profile = null; try { $profile = $this->_initProfile(); + $action = $this->getRequest()->getParam(self::PARAM_ACTION); - switch ($this->getRequest()->getParam('action')) { - case 'cancel': + switch ($action) { + case self::ACTION_CANCEL: $profile->cancel(); break; - case 'suspend': + case self::ACTION_SUSPEND: $profile->suspend(); break; - case 'activate': + case self::ACTION_ACTIVATE: $profile->activate(); break; + default: + throw new \Exception(sprintf('Wrong action parameter: %s', $action)); } $this->messageManager->addSuccess(__('The profile state has been updated.')); - } catch (\Magento\Core\Exception $e) { + } catch (CoreException $e) { $this->messageManager->addError($e->getMessage()); } catch (\Exception $e) { $this->messageManager->addError(__('We could not update the profile.')); - $this->_objectManager->get('Magento\Logger')->logException($e); + $this->_logger->logException($e); } if ($profile) { - $this->_redirect('sales/*/view', array('profile' => $profile->getId())); + $this->_redirect('sales/*/view', array(self::PARAM_PROFILE => $profile->getId())); } else { $this->_redirect('sales/*/'); } @@ -167,14 +202,14 @@ class Profile extends \Magento\Backend\App\Action } else { $this->messageManager->addNotice(__('The profile has no changes.')); } - } catch (\Magento\Core\Exception $e) { + } catch (CoreException $e) { $this->messageManager->addError($e->getMessage()); } catch (\Exception $e) { $this->messageManager->addError(__('We could not update the profile.')); - $this->_objectManager->get('Magento\Logger')->logException($e); + $this->_logger->logException($e); } if ($profile) { - $this->_redirect('sales/*/view', array('profile' => $profile->getId())); + $this->_redirect('sales/*/view', array(self::PARAM_PROFILE => $profile->getId())); } else { $this->_redirect('sales/*/'); } @@ -186,39 +221,29 @@ class Profile extends \Magento\Backend\App\Action */ public function customerGridAction() { - $this->_initCustomer(); - $this->_view->loadLayout(false); - $this->_view->renderLayout(); - } - - /** - * Initialize customer by ID specified in request - * - * @return \Magento\Sales\Controller\Adminhtml\Billing\Agreement - */ - protected function _initCustomer() - { - $customerId = (int) $this->getRequest()->getParam('id'); - $customer = $this->_objectManager->create('Magento\Customer\Model\Customer'); + $customerId = (int)$this->getRequest()->getParam(self::PARAM_CUSTOMER_ID); if ($customerId) { - $customer->load($customerId); + $this->_coreRegistry->register(CustomerController::REGISTRY_CURRENT_CUSTOMER_ID, $customerId); } - $this->_coreRegistry->register('current_customer', $customer); - return $this; + $this->_view->loadLayout(false); + $this->_view->renderLayout(); } /** * Load/set profile * * @return \Magento\Sales\Model\Recurring\Profile + * @throws \Magento\Core\Exception */ protected function _initProfile() { - $profile = $this->_objectManager->create('Magento\Sales\Model\Recurring\Profile')->load($this->getRequest()->getParam('profile')); + /** @var \Magento\Sales\Model\Recurring\Profile $profile */ + $profile = $this->_objectManager->create('Magento\Sales\Model\Recurring\Profile') + ->load($this->getRequest()->getParam(self::PARAM_PROFILE)); if (!$profile->getId()) { - throw new \Magento\Core\Exception(__('The profile you specified does not exist.')); + throw new CoreException(__('The profile you specified does not exist.')); } $this->_coreRegistry->register('current_recurring_profile', $profile); return $profile; diff --git a/app/code/Magento/Sales/Controller/Billing/Agreement.php b/app/code/Magento/Sales/Controller/Billing/Agreement.php index 6299b46c1c8ab9572b337a5cfb6bc32286264305..e5e63f5cad58a03a303124db27776199d2e55105 100644 --- a/app/code/Magento/Sales/Controller/Billing/Agreement.php +++ b/app/code/Magento/Sales/Controller/Billing/Agreement.php @@ -122,9 +122,9 @@ class Agreement extends \Magento\App\Action\Action $agreement ->setStoreId($this->_objectManager->get('Magento\Core\Model\StoreManager')->getStore()->getId()) ->setMethodCode($paymentCode) - ->setReturnUrl($this->_objectManager->create('Magento\Core\Model\Url') + ->setReturnUrl($this->_objectManager->create('Magento\UrlInterface') ->getUrl('*/*/returnWizard', array('payment_method' => $paymentCode))) - ->setCancelUrl($this->_objectManager->create('Magento\Core\Model\Url') + ->setCancelUrl($this->_objectManager->create('Magento\UrlInterface') ->getUrl('*/*/cancelWizard', array('payment_method' => $paymentCode))); return $this->getResponse()->setRedirect($agreement->initToken()); diff --git a/app/code/Magento/Sales/Model/AdminOrder/Create.php b/app/code/Magento/Sales/Model/AdminOrder/Create.php index 57913eee0c3c2c0e5f4b0eff03bda272e058fb16..97246cabba1035f5b236ce87a9c89eef0542b2f7 100644 --- a/app/code/Magento/Sales/Model/AdminOrder/Create.php +++ b/app/code/Magento/Sales/Model/AdminOrder/Create.php @@ -159,6 +159,11 @@ class Create extends \Magento\Object implements \Magento\Checkout\Model\Cart\Car */ protected $messageManager; + /** + * @var Product\Quote\Initializer + */ + protected $quoteInitializer; + /** * @param \Magento\ObjectManager $objectManager * @param \Magento\Event\ManagerInterface $eventManager @@ -168,6 +173,7 @@ class Create extends \Magento\Object implements \Magento\Checkout\Model\Cart\Car * @param \Magento\Logger $logger * @param \Magento\Object\Copy $objectCopyService * @param \Magento\Message\ManagerInterface $messageManager + * @param Product\Quote\Initializer $quoteInitializer * @param array $data */ public function __construct( @@ -179,6 +185,7 @@ class Create extends \Magento\Object implements \Magento\Checkout\Model\Cart\Car \Magento\Logger $logger, \Magento\Object\Copy $objectCopyService, \Magento\Message\ManagerInterface $messageManager, + Product\Quote\Initializer $quoteInitializer, array $data = array() ) { $this->_objectManager = $objectManager; @@ -187,6 +194,7 @@ class Create extends \Magento\Object implements \Magento\Checkout\Model\Cart\Car $this->_salesConfig = $salesConfig; $this->_logger = $logger; $this->_objectCopyService = $objectCopyService; + $this->quoteInitializer = $quoteInitializer; parent::__construct($data); $this->_session = $sessionQuote; $this->messageManager = $messageManager; @@ -817,30 +825,10 @@ class Create extends \Magento\Object implements \Magento\Checkout\Model\Cart\Car } } - $stockItem = $product->getStockItem(); - if ($stockItem && $stockItem->getIsQtyDecimal()) { - $product->setIsQtyDecimal(1); - } else { - $config->setQty((int) $config->getQty()); - } + $item = $this->quoteInitializer->init($this->getQuote(), $product, $config); - $product->setCartQty($config->getQty()); - $item = $this->getQuote()->addProductAdvanced( - $product, - $config, - \Magento\Catalog\Model\Product\Type\AbstractType::PROCESS_MODE_FULL - ); if (is_string($item)) { - if ($product->getTypeId() != \Magento\GroupedProduct\Model\Product\Type\Grouped::TYPE_CODE) { - $item = $this->getQuote()->addProductAdvanced( - $product, - $config, - \Magento\Catalog\Model\Product\Type\AbstractType::PROCESS_MODE_LITE - ); - } - if (is_string($item)) { - throw new \Magento\Core\Exception($item); - } + throw new \Magento\Core\Exception($item); } $item->checkData(); diff --git a/app/code/Magento/Sales/Model/AdminOrder/Product/Quote/Initializer.php b/app/code/Magento/Sales/Model/AdminOrder/Product/Quote/Initializer.php new file mode 100644 index 0000000000000000000000000000000000000000..0e77c12ac3978fcabf9397e8da3d96933d21ac80 --- /dev/null +++ b/app/code/Magento/Sales/Model/AdminOrder/Product/Quote/Initializer.php @@ -0,0 +1,64 @@ +<?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) + */ + +/** + * Product quote initializer + * + * @author Magento Core Team <core@magentocommerce.com> + * + */ +namespace Magento\Sales\Model\AdminOrder\Product\Quote; + +class Initializer +{ + /** + * @param \Magento\Sales\Model\Quote $quote + * @param \Magento\Catalog\Model\Product $product + * @param \Magento\Object $config + * @return \Magento\Sales\Model\Quote\Item|string + */ + public function init( + \Magento\Sales\Model\Quote $quote, + \Magento\Catalog\Model\Product $product, + \Magento\Object $config + ) { + $stockItem = $product->getStockItem(); + if ($stockItem && $stockItem->getIsQtyDecimal()) { + $product->setIsQtyDecimal(1); + } else { + $config->setQty((int) $config->getQty()); + } + + $product->setCartQty($config->getQty()); + + $item = $quote->addProductAdvanced( + $product, + $config, + \Magento\Catalog\Model\Product\Type\AbstractType::PROCESS_MODE_FULL + ); + + return $item; + } + +} diff --git a/app/code/Magento/Sales/Model/Order/Grid/Row/UrlGenerator.php b/app/code/Magento/Sales/Model/Order/Grid/Row/UrlGenerator.php index cc16eb5ea4f7dabe547871e88132c973997a73e6..d04a759081e56b803fb4a1d6ed6275134a0f53d3 100644 --- a/app/code/Magento/Sales/Model/Order/Grid/Row/UrlGenerator.php +++ b/app/code/Magento/Sales/Model/Order/Grid/Row/UrlGenerator.php @@ -37,12 +37,12 @@ class UrlGenerator extends \Magento\Backend\Model\Widget\Grid\Row\UrlGenerator protected $_authorization; /** - * @param \Magento\Backend\Model\Url $backendUrl + * @param \Magento\Backend\Model\UrlInterface $backendUrl * @param \Magento\AuthorizationInterface $authorization * @param array $args */ public function __construct( - \Magento\Backend\Model\Url $backendUrl, + \Magento\Backend\Model\UrlInterface $backendUrl, \Magento\AuthorizationInterface $authorization, array $args = array() ) { diff --git a/app/code/Magento/Sales/Model/Order/Pdf/Items/AbstractItems.php b/app/code/Magento/Sales/Model/Order/Pdf/Items/AbstractItems.php index 747da4c7137e31a2a795177a1ce414e116b04055..52700c71af862f55b6d3b52e1f2243850893eb4e 100644 --- a/app/code/Magento/Sales/Model/Order/Pdf/Items/AbstractItems.php +++ b/app/code/Magento/Sales/Model/Order/Pdf/Items/AbstractItems.php @@ -24,11 +24,11 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Sales\Model\Order\Pdf\Items; + /** * Sales Order Pdf Items renderer Abstract */ -namespace Magento\Sales\Model\Order\Pdf\Items; - abstract class AbstractItems extends \Magento\Core\Model\AbstractModel { /** @@ -71,18 +71,24 @@ abstract class AbstractItems extends \Magento\Core\Model\AbstractModel * * @var \Magento\Tax\Helper\Data */ - protected $_taxData = null; + protected $_taxData; /** * @var \Magento\Filesystem\Directory\ReadInterface */ protected $_rootDirectory; + /** + * @var \Magento\Filter\FilterManager + */ + protected $filterManager; + /** * @param \Magento\Core\Model\Context $context * @param \Magento\Core\Model\Registry $registry * @param \Magento\Tax\Helper\Data $taxData - * @param \Magento\App\Filesystem $filesystem, + * @param \Magento\App\Filesystem $filesystem , + * @param \Magento\Filter\FilterManager $filterManager * @param \Magento\Core\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data @@ -92,10 +98,12 @@ abstract class AbstractItems extends \Magento\Core\Model\AbstractModel \Magento\Core\Model\Registry $registry, \Magento\Tax\Helper\Data $taxData, \Magento\App\Filesystem $filesystem, + \Magento\Filter\FilterManager $filterManager, \Magento\Core\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { + $this->filterManager = $filterManager; $this->_taxData = $taxData; $this->_rootDirectory = $filesystem->getDirectoryRead(\Magento\App\Filesystem::ROOT_DIR); parent::__construct($context, $registry, $resource, $resourceCollection, $data); @@ -169,7 +177,7 @@ abstract class AbstractItems extends \Magento\Core\Model\AbstractModel */ public function getOrder() { - if (is_null($this->_order)) { + if (null === $this->_order) { throw new \Magento\Core\Exception(__('The order object is not specified.')); } return $this->_order; @@ -183,7 +191,7 @@ abstract class AbstractItems extends \Magento\Core\Model\AbstractModel */ public function getSource() { - if (is_null($this->_source)) { + if (null === $this->_source) { throw new \Magento\Core\Exception(__('The source object is not specified.')); } return $this->_source; @@ -197,7 +205,7 @@ abstract class AbstractItems extends \Magento\Core\Model\AbstractModel */ public function getItem() { - if (is_null($this->_item)) { + if (null === $this->_item) { throw new \Magento\Core\Exception(__('An item object is not specified.')); } return $this->_item; @@ -211,7 +219,7 @@ abstract class AbstractItems extends \Magento\Core\Model\AbstractModel */ public function getPdf() { - if (is_null($this->_pdf)) { + if (null === $this->_pdf) { throw new \Magento\Core\Exception(__('A PDF object is not specified.')); } return $this->_pdf; @@ -225,7 +233,7 @@ abstract class AbstractItems extends \Magento\Core\Model\AbstractModel */ public function getPage() { - if (is_null($this->_pdfPage)) { + if (null === $this->_pdfPage) { throw new \Magento\Core\Exception(__('A PDF page object is not specified.')); } return $this->_pdfPage; @@ -250,7 +258,7 @@ abstract class AbstractItems extends \Magento\Core\Model\AbstractModel $resultValue = ''; if (is_array($value)) { if (isset($value['qty'])) { - $resultValue .= sprintf('%d', $value['qty']) . ' x '; + $resultValue .= $this->filterManager->sprintf($value['qty'], array('format' => '%d')) . ' x '; } $resultValue .= $value['title']; @@ -313,7 +321,8 @@ abstract class AbstractItems extends \Magento\Core\Model\AbstractModel * * @return array */ - public function getItemOptions() { + public function getItemOptions() + { $result = array(); $options = $this->getItem()->getOrderItem()->getProductOptions(); if ($options) { diff --git a/app/code/Magento/Sales/Model/Order/Pdf/Items/Creditmemo/DefaultCreditmemo.php b/app/code/Magento/Sales/Model/Order/Pdf/Items/Creditmemo/DefaultCreditmemo.php index 644e446049ef087557afb42cc6370189824b6beb..e66e3689e6ef5802d9c4072fbffc922373bb2d24 100644 --- a/app/code/Magento/Sales/Model/Order/Pdf/Items/Creditmemo/DefaultCreditmemo.php +++ b/app/code/Magento/Sales/Model/Order/Pdf/Items/Creditmemo/DefaultCreditmemo.php @@ -24,15 +24,11 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Sales\Model\Order\Pdf\Items\Creditmemo; + /** * Sales Order Creditmemo Pdf default items renderer - * - * @category Magento - * @package Magento_Sales - * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\Sales\Model\Order\Pdf\Items\Creditmemo; - class DefaultCreditmemo extends \Magento\Sales\Model\Order\Pdf\Items\AbstractItems { /** @@ -47,6 +43,7 @@ class DefaultCreditmemo extends \Magento\Sales\Model\Order\Pdf\Items\AbstractIte * @param \Magento\Core\Model\Registry $registry * @param \Magento\Tax\Helper\Data $taxData * @param \Magento\App\Filesystem $filesystem + * @param \Magento\Filter\FilterManager $filterManager * @param \Magento\Stdlib\String $string * @param \Magento\Core\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection @@ -57,13 +54,23 @@ class DefaultCreditmemo extends \Magento\Sales\Model\Order\Pdf\Items\AbstractIte \Magento\Core\Model\Registry $registry, \Magento\Tax\Helper\Data $taxData, \Magento\App\Filesystem $filesystem, + \Magento\Filter\FilterManager $filterManager, \Magento\Stdlib\String $string, \Magento\Core\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { $this->string = $string; - parent::__construct($context, $registry, $taxData, $filesystem, $resource, $resourceCollection, $data); + parent::__construct( + $context, + $registry, + $taxData, + $filesystem, + $filterManager, + $resource, + $resourceCollection, + $data + ); } /** @@ -138,15 +145,17 @@ class DefaultCreditmemo extends \Magento\Sales\Model\Order\Pdf\Items\AbstractIte foreach ($options as $option) { // draw options label $lines[][] = array( - 'text' => $this->string->split(strip_tags($option['label']), 40, true, true), + 'text' => $this->string->split($this->filterManager->stripTags($option['label']), 40, true, true), 'font' => 'italic', 'feed' => 35 ); // draw options value - $_printValue = isset($option['print_value']) ? $option['print_value'] : strip_tags($option['value']); + $printValue = isset($option['print_value']) + ? $option['print_value'] + : $this->filterManager->stripTags($option['value']); $lines[][] = array( - 'text' => $this->string->split($_printValue, 30, true, true), + 'text' => $this->string->split($printValue, 30, true, true), 'feed' => 40 ); } diff --git a/app/code/Magento/Sales/Model/Order/Pdf/Items/Invoice/DefaultInvoice.php b/app/code/Magento/Sales/Model/Order/Pdf/Items/Invoice/DefaultInvoice.php index 2fd98305705292794651dcd61c26fe4dffa3aceb..ea9e408dc51bca8cdbf6e350ceec65ff7863a206 100644 --- a/app/code/Magento/Sales/Model/Order/Pdf/Items/Invoice/DefaultInvoice.php +++ b/app/code/Magento/Sales/Model/Order/Pdf/Items/Invoice/DefaultInvoice.php @@ -24,11 +24,11 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Sales\Model\Order\Pdf\Items\Invoice; + /** * Sales Order Invoice Pdf default items renderer */ -namespace Magento\Sales\Model\Order\Pdf\Items\Invoice; - class DefaultInvoice extends \Magento\Sales\Model\Order\Pdf\Items\AbstractItems { /** @@ -43,6 +43,7 @@ class DefaultInvoice extends \Magento\Sales\Model\Order\Pdf\Items\AbstractItems * @param \Magento\Core\Model\Registry $registry * @param \Magento\Tax\Helper\Data $taxData * @param \Magento\App\Filesystem $filesystem + * @param \Magento\Filter\FilterManager $filterManager * @param \Magento\Stdlib\String $string * @param \Magento\Core\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection @@ -53,13 +54,23 @@ class DefaultInvoice extends \Magento\Sales\Model\Order\Pdf\Items\AbstractItems \Magento\Core\Model\Registry $registry, \Magento\Tax\Helper\Data $taxData, \Magento\App\Filesystem $filesystem, + \Magento\Filter\FilterManager $filterManager, \Magento\Stdlib\String $string, \Magento\Core\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { $this->string = $string; - parent::__construct($context, $registry, $taxData, $filesystem, $resource, $resourceCollection, $data); + parent::__construct( + $context, + $registry, + $taxData, + $filesystem, + $filterManager, + $resource, + $resourceCollection, + $data + ); } /** @@ -98,7 +109,7 @@ class DefaultInvoice extends \Magento\Sales\Model\Order\Pdf\Items\AbstractItems $prices = $this->getItemPricesForDisplay(); $feedPrice = 395; $feedSubtotal = $feedPrice + 170; - foreach ($prices as $priceData){ + foreach ($prices as $priceData) { if (isset($priceData['label'])) { // draw Price label $lines[$i][] = array( @@ -145,18 +156,18 @@ class DefaultInvoice extends \Magento\Sales\Model\Order\Pdf\Items\AbstractItems foreach ($options as $option) { // draw options label $lines[][] = array( - 'text' => $this->string->split(strip_tags($option['label']), 40, true, true), + 'text' => $this->string->split($this->filterManager->stripTags($option['label']), 40, true, true), 'font' => 'italic', 'feed' => 35 ); if ($option['value']) { if (isset($option['print_value'])) { - $_printValue = $option['print_value']; + $printValue = $option['print_value']; } else { - $_printValue = strip_tags($option['value']); + $printValue = $this->filterManager->stripTags($option['value']); } - $values = explode(', ', $_printValue); + $values = explode(', ', $printValue); foreach ($values as $value) { $lines[][] = array( 'text' => $this->string->split($value, 30, true, true), diff --git a/app/code/Magento/Sales/Model/Order/Pdf/Items/Shipment/DefaultShipment.php b/app/code/Magento/Sales/Model/Order/Pdf/Items/Shipment/DefaultShipment.php index 3d5427b9e57b4d181e138cc4ca91d01ea1e9d05d..b51d13f24fcb5fe14fa6ca2b568af5f9a562d483 100644 --- a/app/code/Magento/Sales/Model/Order/Pdf/Items/Shipment/DefaultShipment.php +++ b/app/code/Magento/Sales/Model/Order/Pdf/Items/Shipment/DefaultShipment.php @@ -24,11 +24,11 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Sales\Model\Order\Pdf\Items\Shipment; + /** * Sales Order Shipment Pdf default items renderer */ -namespace Magento\Sales\Model\Order\Pdf\Items\Shipment; - class DefaultShipment extends \Magento\Sales\Model\Order\Pdf\Items\AbstractItems { /** @@ -43,6 +43,7 @@ class DefaultShipment extends \Magento\Sales\Model\Order\Pdf\Items\AbstractItems * @param \Magento\Core\Model\Registry $registry * @param \Magento\Tax\Helper\Data $taxData * @param \Magento\App\Filesystem $filesystem + * @param \Magento\Filter\FilterManager $filterManager * @param \Magento\Stdlib\String $string * @param \Magento\Core\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection @@ -53,13 +54,23 @@ class DefaultShipment extends \Magento\Sales\Model\Order\Pdf\Items\AbstractItems \Magento\Core\Model\Registry $registry, \Magento\Tax\Helper\Data $taxData, \Magento\App\Filesystem $filesystem, + \Magento\Filter\FilterManager $filterManager, \Magento\Stdlib\String $string, \Magento\Core\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { $this->string = $string; - parent::__construct($context, $registry, $taxData, $filesystem, $resource, $resourceCollection, $data); + parent::__construct( + $context, + $registry, + $taxData, + $filesystem, + $filterManager, + $resource, + $resourceCollection, + $data + ); } /** @@ -73,7 +84,6 @@ class DefaultShipment extends \Magento\Sales\Model\Order\Pdf\Items\AbstractItems $lines = array(); // draw Product name - $stringHelper = $this->string; $lines[0] = array(array( 'text' => $this->string->split($item->getName(), 60, true, true), 'feed' => 100, @@ -81,7 +91,7 @@ class DefaultShipment extends \Magento\Sales\Model\Order\Pdf\Items\AbstractItems // draw QTY $lines[0][] = array( - 'text' => $item->getQty()*1, + 'text' => $item->getQty() * 1, 'feed' => 35 ); @@ -98,17 +108,17 @@ class DefaultShipment extends \Magento\Sales\Model\Order\Pdf\Items\AbstractItems foreach ($options as $option) { // draw options label $lines[][] = array( - 'text' => $stringHelper->split(strip_tags($option['label']), 70, true, true), + 'text' => $this->string->split($this->filterManager->stripTags($option['label']), 70, true, true), 'font' => 'italic', 'feed' => 110 ); // draw options value if ($option['value']) { - $_printValue = isset($option['print_value']) + $printValue = isset($option['print_value']) ? $option['print_value'] - : strip_tags($option['value']); - $values = explode(', ', $_printValue); + : $this->filterManager->stripTags($option['value']); + $values = explode(', ', $printValue); foreach ($values as $value) { $lines[][] = array( 'text' => $this->string->split($value, 50, true, true), diff --git a/app/code/Magento/Sales/Model/Quote.php b/app/code/Magento/Sales/Model/Quote.php index 61594e2c68f5b5eb702c62436b706af70de90003..ac36e1945ac20950cf64ad25cb5962c6ca9b40c0 100644 --- a/app/code/Magento/Sales/Model/Quote.php +++ b/app/code/Magento/Sales/Model/Quote.php @@ -220,7 +220,7 @@ class Quote extends \Magento\Core\Model\AbstractModel protected $_storeManager; /** - * @var \Magento\Core\Model\Config + * @var \Magento\App\ConfigInterface */ protected $_config; @@ -291,7 +291,7 @@ class Quote extends \Magento\Core\Model\AbstractModel * @param \Magento\Catalog\Helper\Product $catalogProduct * @param \Magento\Core\Model\Store\ConfigInterface $coreStoreConfig * @param \Magento\Core\Model\StoreManagerInterface $storeManager - * @param \Magento\Core\Model\Config $config + * @param \Magento\App\ConfigInterface $config * @param \Magento\Sales\Model\Quote\AddressFactory $quoteAddressFactory * @param \Magento\Customer\Model\CustomerFactory $customerFactory * @param \Magento\Customer\Model\GroupFactory $customerGroupFactory @@ -315,7 +315,7 @@ class Quote extends \Magento\Core\Model\AbstractModel \Magento\Catalog\Helper\Product $catalogProduct, \Magento\Core\Model\Store\ConfigInterface $coreStoreConfig, \Magento\Core\Model\StoreManagerInterface $storeManager, - \Magento\Core\Model\Config $config, + \Magento\App\ConfigInterface $config, \Magento\Sales\Model\Quote\AddressFactory $quoteAddressFactory, \Magento\Customer\Model\CustomerFactory $customerFactory, \Magento\Customer\Model\GroupFactory $customerGroupFactory, diff --git a/app/code/Magento/Sales/Model/Quote/Item/RelatedProducts.php b/app/code/Magento/Sales/Model/Quote/Item/RelatedProducts.php new file mode 100644 index 0000000000000000000000000000000000000000..3776bf178d387e70f05e6ddf01d94bbb3ea24f10 --- /dev/null +++ b/app/code/Magento/Sales/Model/Quote/Item/RelatedProducts.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\Sales\Model\Quote\Item; + +class RelatedProducts +{ + /** + * List of related product types + * + * @var array + */ + protected $_relatedProductTypes; + + /** + * @param array $relatedProductTypes + */ + public function __construct($relatedProductTypes = array()) + { + $this->_relatedProductTypes = $relatedProductTypes; + } + + /** + * Retrieve Array of product ids which have special relation with products in Cart + * + * @param \Magento\Sales\Model\Quote\Item[] $quoteItems + * @return array + */ + public function getRelatedProductIds(array $quoteItems) + { + $productIds = array(); + /** @var $quoteItems \Magento\Sales\Model\Quote\Item[] */ + foreach ($quoteItems as $quoteItem) { + $productTypeOpt = $quoteItem->getOptionByCode('product_type'); + if ($productTypeOpt instanceof \Magento\Sales\Model\Quote\Item\Option) { + if (in_array($productTypeOpt->getValue(), $this->_relatedProductTypes) + && $productTypeOpt->getProductId() + ) { + $productIds[] = $productTypeOpt->getProductId(); + } + } + } + return $productIds; + } +} diff --git a/app/code/Magento/Sales/Model/Resource/Report/Bestsellers.php b/app/code/Magento/Sales/Model/Resource/Report/Bestsellers.php index 750cb6734018099dbb6e90a1dcc15bd644dc7a8c..5e6f50f10039c98b3567a36484b97f33f02b22c8 100644 --- a/app/code/Magento/Sales/Model/Resource/Report/Bestsellers.php +++ b/app/code/Magento/Sales/Model/Resource/Report/Bestsellers.php @@ -45,6 +45,17 @@ class Bestsellers extends \Magento\Sales\Model\Resource\Report\AbstractReport */ protected $_salesResourceHelper; + /** + * Ignored product types list + * + * @var array + */ + protected $ignoredProductTypes = array( + \Magento\Catalog\Model\Product\Type::TYPE_CONFIGURABLE + => \Magento\Catalog\Model\Product\Type::TYPE_CONFIGURABLE, + \Magento\Catalog\Model\Product\Type::TYPE_BUNDLE => \Magento\Catalog\Model\Product\Type::TYPE_BUNDLE, + ); + /** * @param \Magento\App\Resource $resource * @param \Magento\Logger $logger @@ -54,6 +65,7 @@ class Bestsellers extends \Magento\Sales\Model\Resource\Report\AbstractReport * @param \Magento\Stdlib\DateTime\Timezone\Validator $timezoneValidator * @param \Magento\Catalog\Model\Resource\Product $productResource * @param \Magento\Sales\Model\Resource\Helper $salesResourceHelper + * @param array $ignoredProductTypes */ public function __construct( \Magento\App\Resource $resource, @@ -63,11 +75,13 @@ class Bestsellers extends \Magento\Sales\Model\Resource\Report\AbstractReport \Magento\Stdlib\DateTime $dateTime, \Magento\Stdlib\DateTime\Timezone\Validator $timezoneValidator, \Magento\Catalog\Model\Resource\Product $productResource, - \Magento\Sales\Model\Resource\Helper $salesResourceHelper + \Magento\Sales\Model\Resource\Helper $salesResourceHelper, + array $ignoredProductTypes = array() ) { parent::__construct($resource, $logger, $locale, $reportsFlagFactory, $dateTime, $timezoneValidator); $this->_productResource = $productResource; $this->_salesResourceHelper = $salesResourceHelper; + $this->ignoredProductTypes = array_merge($this->ignoredProductTypes, $ignoredProductTypes); } @@ -154,16 +168,10 @@ class Bestsellers extends \Magento\Sales\Model\Resource\Report\AbstractReport ) ->where('source_table.state != ?', \Magento\Sales\Model\Order::STATE_CANCELED); - $productTypes = array( - \Magento\GroupedProduct\Model\Product\Type\Grouped::TYPE_CODE, - \Magento\Catalog\Model\Product\Type::TYPE_CONFIGURABLE, - \Magento\Catalog\Model\Product\Type::TYPE_BUNDLE, - ); - $joinExpr = array( 'product.entity_id = order_item.product_id', $adapter->quoteInto('product.entity_type_id = ?', $this->_productResource->getTypeId()), - $adapter->quoteInto('product.type_id NOT IN(?)', $productTypes) + $adapter->quoteInto('product.type_id NOT IN(?)', $this->ignoredProductTypes) ); $joinExpr = implode(' AND ', $joinExpr); diff --git a/app/code/Magento/Sales/Model/Resource/Setup.php b/app/code/Magento/Sales/Model/Resource/Setup.php index 4d0e07fc222336152d20e01cd5d35c90f1b46a6b..06de721bebb6da6f4c9b1ee1a5b689cbc4be2f5a 100644 --- a/app/code/Magento/Sales/Model/Resource/Setup.php +++ b/app/code/Magento/Sales/Model/Resource/Setup.php @@ -32,7 +32,7 @@ namespace Magento\Sales\Model\Resource; class Setup extends \Magento\Eav\Model\Entity\Setup { /** - * @var \Magento\Core\Model\Config + * @var \Magento\App\ConfigInterface */ protected $_config; @@ -46,7 +46,7 @@ class Setup extends \Magento\Eav\Model\Entity\Setup * @param string $resourceName * @param \Magento\App\CacheInterface $cache * @param \Magento\Eav\Model\Resource\Entity\Attribute\Group\CollectionFactory $attrGroupCollectionFactory - * @param \Magento\Core\Model\Config $config + * @param \Magento\App\ConfigInterface $config * @param string $moduleName * @param string $connectionName */ @@ -55,7 +55,7 @@ class Setup extends \Magento\Eav\Model\Entity\Setup $resourceName, \Magento\App\CacheInterface $cache, \Magento\Eav\Model\Resource\Entity\Attribute\Group\CollectionFactory $attrGroupCollectionFactory, - \Magento\Core\Model\Config $config, + \Magento\App\ConfigInterface $config, $moduleName = 'Magento_Sales', $connectionName = '' ) { @@ -260,7 +260,7 @@ class Setup extends \Magento\Eav\Model\Entity\Setup /** * Get config model * - * @return \Magento\Core\Model\Config + * @return \Magento\App\ConfigInterface */ public function getConfigModel() { diff --git a/app/code/Magento/Sales/etc/di.xml b/app/code/Magento/Sales/etc/di.xml index 59078dba80599692f7dc17f495e0589b29eea8f9..3c57eced9872388911a02517d4bd8b544bc33e3c 100644 --- a/app/code/Magento/Sales/etc/di.xml +++ b/app/code/Magento/Sales/etc/di.xml @@ -51,16 +51,16 @@ </type> <type name="Magento\Catalog\Model\Resource\Product\Flat\Indexer"> <param name="flatAttributeGroups"> - <value> - <sales_quote_item>sales_quote_item</sales_quote_item> - </value> + <array> + <item key="sales_quote_item"><value>sales_quote_item</value></item> + </array> </param> </type> <type name="Magento\Module\Updater\SetupFactory"> <param name="resourceTypes"> - <value> - <sales_setup>Magento\Sales\Model\Resource\Setup</sales_setup> - </value> + <array> + <item key="sales_setup"><value>Magento\Sales\Model\Resource\Setup</value></item> + </array> </param> </type> </config> diff --git a/app/code/Magento/Sales/etc/frontend/di.xml b/app/code/Magento/Sales/etc/frontend/di.xml index a80b694568a681a0b674c73404b33ce35d030840..dc8ac95a7b91c40efd3801502f637339bc4f3443 100644 --- a/app/code/Magento/Sales/etc/frontend/di.xml +++ b/app/code/Magento/Sales/etc/frontend/di.xml @@ -26,9 +26,9 @@ <config> <type name="Magento\Core\Model\Url\SecurityInfo"> <param name="secureUrlList"> - <value> - <sales>/sales/</sales> - </value> + <array> + <item key="sales"><value>/sales/</value></item> + </array> </param> </type> </config> diff --git a/app/code/Magento/Sales/etc/module.xml b/app/code/Magento/Sales/etc/module.xml index ca7f4f1ff6d8c4820dff45822dca37a821f0ccf9..6f7a570a72044c662e9a2e6ec9b702529c192bb5 100755 --- a/app/code/Magento/Sales/etc/module.xml +++ b/app/code/Magento/Sales/etc/module.xml @@ -28,13 +28,11 @@ <sequence> <module name="Magento_Rule"/> <module name="Magento_Catalog"/> - <module name="Magento_GroupedProduct" /> <module name="Magento_Customer"/> <module name="Magento_Payment"/> </sequence> <depends> <module name="Magento_Catalog"/> - <module name="Magento_GroupedProduct" /> <module name="Magento_Customer"/> <module name="Magento_Payment"/> <module name="Magento_Core"/> diff --git a/app/code/Magento/Sales/etc/pdf.xml b/app/code/Magento/Sales/etc/pdf.xml index d0c40dc3024d4b189cb5bd74fd2d92cf0baeabda..36342a1e9cda2b53ce33f2f453664f0debb18f13 100644 --- a/app/code/Magento/Sales/etc/pdf.xml +++ b/app/code/Magento/Sales/etc/pdf.xml @@ -27,14 +27,12 @@ <renderers> <page type="invoice"> <renderer product_type="default">Magento\Sales\Model\Order\Pdf\Items\Invoice\DefaultInvoice</renderer> - <renderer product_type="grouped">Magento\Sales\Model\Order\Pdf\Items\Invoice\Grouped</renderer> </page> <page type="shipment"> <renderer product_type="default">Magento\Sales\Model\Order\Pdf\Items\Shipment\DefaultShipment</renderer> </page> <page type="creditmemo"> <renderer product_type="default">Magento\Sales\Model\Order\Pdf\Items\Creditmemo\DefaultCreditmemo</renderer> - <renderer product_type="grouped">Magento\Sales\Model\Order\Pdf\Items\Creditmemo\Grouped</renderer> </page> </renderers> <totals> diff --git a/app/code/Magento/Sales/etc/sales.xml b/app/code/Magento/Sales/etc/sales.xml index 1d1a9e1d0108610cf0fac30749cba30e21bf12c3..9c9396f7723cd3abc4f4a5fed3a04a38a245dd2f 100644 --- a/app/code/Magento/Sales/etc/sales.xml +++ b/app/code/Magento/Sales/etc/sales.xml @@ -63,6 +63,5 @@ <available_product_type name="simple"/> <available_product_type name="virtual"/> <available_product_type name="configurable"/> - <available_product_type name="grouped"/> </order> </config> diff --git a/app/code/Magento/Sales/view/adminhtml/layout/sales_order_creditmemo_new.xml b/app/code/Magento/Sales/view/adminhtml/layout/sales_order_creditmemo_new.xml index 8ef5db3a77437053541a3ba16ef99ee3a8c912df..4d22558f1c87c736ae39f99b7813c030a1763d2b 100644 --- a/app/code/Magento/Sales/view/adminhtml/layout/sales_order_creditmemo_new.xml +++ b/app/code/Magento/Sales/view/adminhtml/layout/sales_order_creditmemo_new.xml @@ -33,40 +33,11 @@ <block class="Magento\Sales\Block\Adminhtml\Items\Renderer\DefaultRenderer" as="default" template="order/creditmemo/create/items/renderer/default.phtml"/> <block class="Magento\Sales\Block\Adminhtml\Items\Column\Qty" name="column_qty" template="items/column/qty.phtml" group="column"/> <block class="Magento\Sales\Block\Adminhtml\Items\Column\Name" name="column_name" template="items/column/name.phtml" group="column"/> - <block class="Magento\Sales\Block\Adminhtml\Items\Column\Name\Grouped" name="column_name_grouped" template="items/column/name.phtml" group="column"/> <block class="Magento\View\Element\Text\ListText" name="order_item_extra_info"/> <block class="Magento\Sales\Block\Adminhtml\Order\Totalbar" name="order_totalbar" template="order/totalbar.phtml"/> <block class="Magento\Sales\Block\Adminhtml\Order\Creditmemo\Totals" name="creditmemo_totals" template="order/totals.phtml"> <block class="Magento\Sales\Block\Adminhtml\Order\Creditmemo\Create\Adjustments" name="adjustments" template="order/creditmemo/create/totals/adjustments.phtml"/> <block class="Magento\Sales\Block\Adminhtml\Order\Totals\Tax" name="tax" template="order/totals/tax.phtml"/> - <!-- - <block class="Magento\Sales\Block\Adminhtml\Order\Totals\Item" name="footer" template="order/totals/footer.phtml"> - <block class="Magento\Sales\Block\Adminhtml\Order\Totals\Item" name="grand" template="order/totals/grand.phtml"> - <action method="setGrandTotalTitle"> - <argument name="title" xsi:type="string">Total Refund</argument> - </action> - </block> - </block> - <block class="Magento\Sales\Block\Adminhtml\Order\Totals\Item" name="sales.order.view.totals.main" as="main" template="order/totals/main.phtml"> - <block class="Magento\Sales\Block\Adminhtml\Order\Totals\Item" name="tax" template="order/totals/item.phtml"> - <action method="setSourceField"> - <argument name="value" xsi:type="string">tax_amount</argument> - </action> - <action method="setLabel"> - <argument name="value" xsi:type="string">Tax</argument> - </action> - </block> - <block class="Magento\Sales\Block\Adminhtml\Order\Totals\Item" name="discount" template="order/totals/item.phtml"> - <action method="setSourceField"> - <argument name="value" xsi:type="string">discount_amount</argument> - </action> - <action method="setLabel"> - <argument name="value" xsi:type="string">Discount</argument> - </action> - </block> - <block class="Magento\Sales\Block\Adminhtml\Order\Totals\Item" name="adjustments" template="order/creditmemo/create/totals/adjustments.phtml"/> - </block> - --> </block> <container name="submit_before" label="Submit Before"/> <container name="submit_after" label="Submit After"/> diff --git a/app/code/Magento/Sales/view/adminhtml/layout/sales_order_creditmemo_updateqty.xml b/app/code/Magento/Sales/view/adminhtml/layout/sales_order_creditmemo_updateqty.xml index f3eaade1dc2fcfcfa7811fb2a9f6330515e16f5d..4d23e16b955440fd2199bf7e435f65851c9da351 100644 --- a/app/code/Magento/Sales/view/adminhtml/layout/sales_order_creditmemo_updateqty.xml +++ b/app/code/Magento/Sales/view/adminhtml/layout/sales_order_creditmemo_updateqty.xml @@ -28,39 +28,11 @@ <block class="Magento\Sales\Block\Adminhtml\Items\Renderer\DefaultRenderer" as="default" template="order/creditmemo/create/items/renderer/default.phtml"/> <block class="Magento\Sales\Block\Adminhtml\Items\Column\Qty" name="column_qty" template="items/column/qty.phtml" group="column"/> <block class="Magento\Sales\Block\Adminhtml\Items\Column\Name" name="column_name" template="items/column/name.phtml" group="column"/> - <block class="Magento\Sales\Block\Adminhtml\Items\Column\Name\Grouped" name="column_name_grouped" template="items/column/name.phtml" group="column"/> <block class="Magento\View\Element\Text\ListText" name="order_item_extra_info"/> <block class="Magento\Sales\Block\Adminhtml\Order\Totalbar" name="order_totalbar" template="order/totalbar.phtml"/> <block class="Magento\Sales\Block\Adminhtml\Order\Creditmemo\Totals" name="creditmemo_totals" template="order/totals.phtml"> <block class="Magento\Sales\Block\Adminhtml\Order\Creditmemo\Create\Adjustments" name="adjustments" template="order/creditmemo/create/totals/adjustments.phtml"/> <block class="Magento\Sales\Block\Adminhtml\Order\Totals\Tax" name="tax" template="order/totals/tax.phtml"/> - <!--<block class="Magento\Sales\Block\Adminhtml\Order\Totals" name="order_totals" template="order/totals.phtml"/> - <block class="Magento\Sales\Block\Adminhtml\Order\Totals\Item" name="footer" template="order/totals/footer.phtml"> - <block class="Magento\Sales\Block\Adminhtml\Order\Totals\Item" name="grand" template="order/totals/grand.phtml"> - <action method="setGrandTotalTitle"> - <argument name="title" xsi:type="string">Total Refund</argument> - </action> - </block> - </block> - <block class="Magento\Sales\Block\Adminhtml\Order\Totals\Item" name="sales.order.view.totals.main" as="main" template="order/totals/main.phtml"> - <block class="Magento\Sales\Block\Adminhtml\Order\Totals\Item" name="tax" template="order/totals/item.phtml"> - <action method="setSourceField"> - <argument name="value" xsi:type="string">tax_amount</argument> - </action> - <action method="setLabel"> - <argument name="value" xsi:type="string">Tax</argument> - </action> - </block> - <block class="Magento\Sales\Block\Adminhtml\Order\Totals\Item" name="discount" template="order/totals/item.phtml"> - <action method="setSourceField"> - <argument name="value" xsi:type="string">discount_amount</argument> - </action> - <action method="setLabel"> - <argument name="value" xsi:type="string">Discount</argument> - </action> - </block> - <block class="Magento\Sales\Block\Adminhtml\Order\Totals\Item" name="adjustments" template="order/creditmemo/create/totals/adjustments.phtml"/> - </block>--> </block> <container name="submit_before" label="Submit Before"/> <container name="submit_after" label="Submit After"/> diff --git a/app/code/Magento/Sales/view/adminhtml/layout/sales_order_creditmemo_view.xml b/app/code/Magento/Sales/view/adminhtml/layout/sales_order_creditmemo_view.xml index 36169c4bf9dd1a36913cfa2b9c6653f2806c29f5..f98cf91803f03502ff11959861f2268ccb86025e 100644 --- a/app/code/Magento/Sales/view/adminhtml/layout/sales_order_creditmemo_view.xml +++ b/app/code/Magento/Sales/view/adminhtml/layout/sales_order_creditmemo_view.xml @@ -33,7 +33,6 @@ <block class="Magento\Sales\Block\Adminhtml\Items\Renderer\DefaultRenderer" as="default" template="order/creditmemo/view/items/renderer/default.phtml"/> <block class="Magento\Sales\Block\Adminhtml\Items\Column\Qty" name="column_qty" template="items/column/qty.phtml" group="column"/> <block class="Magento\Sales\Block\Adminhtml\Items\Column\Name" name="column_name" template="items/column/name.phtml" group="column"/> - <block class="Magento\Sales\Block\Adminhtml\Items\Column\Name\Grouped" name="column_name_grouped" template="items/column/name.phtml" group="column"/> <block class="Magento\View\Element\Text\ListText" name="order_item_extra_info"/> </block> <block class="Magento\Sales\Block\Adminhtml\Order\Comments\View" name="order_comments" template="order/comments/view.phtml"> @@ -43,41 +42,6 @@ </block> <block class="Magento\Sales\Block\Adminhtml\Order\Creditmemo\Totals" name="creditmemo_totals" template="order/totals.phtml"> <block class="Magento\Sales\Block\Adminhtml\Order\Totals\Tax" name="tax" template="order/totals/tax.phtml"/> - <!--<block class="Magento\Sales\Block\Adminhtml\Order\Totals\Item" name="footer" template="order/totals/footer.phtml"> - <block class="Magento\Sales\Block\Adminhtml\Order\Totals\Item" name="grand" template="order/totals/grand.phtml"/> - <block class="Magento\Sales\Block\Adminhtml\Order\Totals\Item" name="paid" template="order/totals/paid.phtml"/> - <block class="Magento\Sales\Block\Adminhtml\Order\Totals\Item" name="refunded" template="order/totals/refunded.phtml"/> - <block class="Magento\Sales\Block\Adminhtml\Order\Totals\Item" name="due" template="order/totals/due.phtml"/> - </block> - <block class="Magento\Sales\Block\Adminhtml\Order\Totals\Item" name="sales.order.view.totals.main" as="main" template="order/totals/main.phtml"> - <block class="Magento\Sales\Block\Adminhtml\Order\Totals\Tax" name="tax" template="order/totals/tax.phtml"/> - <block class="Magento\Sales\Block\Adminhtml\Order\Totals\Item" name="shipping" template="order/totals/shipping.phtml"/> - <block class="Magento\Sales\Block\Adminhtml\Order\Totals\Item" name="discount" template="order/totals/discount.phtml"/> - <block class="Magento\Sales\Block\Adminhtml\Order\Totals\Item" name="giftcert" template="order/totals/item.phtml"> - <action method="setSourceField"> - <argument name="value" xsi:type="string">giftcert_amount</argument> - </action> - <action method="setLabel"> - <argument name="value" xsi:type="string">Gift Certificate</argument> - </action> - </block> - <block class="Magento\Sales\Block\Adminhtml\Order\Totals\Item" name="adjustment_positive" template="order/totals/item.phtml"> - <action method="setSourceField"> - <argument name="value" xsi:type="string">adjustment_positive</argument> - </action> - <action method="setLabel"> - <argument name="value" xsi:type="string">Adjustment Refund</argument> - </action> - </block> - <block class="Magento\Sales\Block\Adminhtml\Order\Totals\Item" name="adjustment_negative" template="order/totals/item.phtml"> - <action method="setSourceField"> - <argument name="value" xsi:type="string">adjustment_negative</argument> - </action> - <action method="setLabel"> - <argument name="value" xsi:type="string">Adjustment Fee</argument> - </action> - </block> - </block>--> </block> </block> </block> diff --git a/app/code/Magento/Sales/view/adminhtml/layout/sales_order_invoice_new.xml b/app/code/Magento/Sales/view/adminhtml/layout/sales_order_invoice_new.xml index 6a00c82dd57a4e1a51e3f3ec8251af70f1beeedd..2b526cbbd12257acae317bf89a42295363820c8e 100644 --- a/app/code/Magento/Sales/view/adminhtml/layout/sales_order_invoice_new.xml +++ b/app/code/Magento/Sales/view/adminhtml/layout/sales_order_invoice_new.xml @@ -33,53 +33,10 @@ <block class="Magento\Sales\Block\Adminhtml\Items\Renderer\DefaultRenderer" as="default" template="order/invoice/create/items/renderer/default.phtml"/> <block class="Magento\Sales\Block\Adminhtml\Items\Column\Qty" name="column_qty" template="items/column/qty.phtml" group="column"/> <block class="Magento\Sales\Block\Adminhtml\Items\Column\Name" name="column_name" template="items/column/name.phtml" group="column"/> - <block class="Magento\Sales\Block\Adminhtml\Items\Column\Name\Grouped" name="column_name_grouped" template="items/column/name.phtml" group="column"/> <block class="Magento\View\Element\Text\ListText" name="order_item_extra_info"/> <block class="Magento\Sales\Block\Adminhtml\Order\Totalbar" name="order_totalbar" template="order/totalbar.phtml"/> <block class="Magento\Sales\Block\Adminhtml\Order\Invoice\Totals" name="invoice_totals" template="order/totals.phtml"> <block class="Magento\Sales\Block\Adminhtml\Order\Totals\Tax" name="tax" template="order/totals/tax.phtml"/> - <!--<block class="Magento\Sales\Block\Adminhtml\Order\Totals\Item" name="footer" template="order/totals/footer.phtml"> - <block class="Magento\Sales\Block\Adminhtml\Order\Totals\Item" name="grand" template="order/totals/grand.phtml"/> - <block class="Magento\Sales\Block\Adminhtml\Order\Totals\Item" name="paid" template="order/totals/paid.phtml"/> - <block class="Magento\Sales\Block\Adminhtml\Order\Totals\Item" name="refunded" template="order/totals/refunded.phtml"/> - <block class="Magento\Sales\Block\Adminhtml\Order\Totals\Item" name="due" template="order/totals/due.phtml"/> - </block> - <block class="Magento\Sales\Block\Adminhtml\Order\Totals\Item" name="sales.order.view.totals.main" as="main" template="order/totals/main.phtml"> - <block class="Magento\Sales\Block\Adminhtml\Order\Totals\Item" name="tax" template="order/totals/item.phtml"> - <action method="setSourceField"> - <argument name="value" xsi:type="string">tax_amount</argument> - </action> - <action method="setLabel"> - <argument name="value" xsi:type="string">Tax</argument> - </action> - </block> - <block class="Magento\Sales\Block\Adminhtml\Order\Totals\Item" name="shipping" template="order/totals/shipping.phtml"/> - <block class="Magento\Sales\Block\Adminhtml\Order\Totals\Item" name="discount" template="order/totals/discount.phtml"/> - <block class="Magento\Sales\Block\Adminhtml\Order\Totals\Item" name="giftcert" template="order/totals/item.phtml"> - <action method="setSourceField"> - <argument name="value" xsi:type="string">giftcert_amount</argument> - </action> - <action method="setLabel"> - <argument name="value" xsi:type="string">Gift Certificate</argument> - </action> - </block> - <block class="Magento\Sales\Block\Adminhtml\Order\Totals\Item" name="adjustment_positive" template="order/totals/item.phtml"> - <action method="setSourceField"> - <argument name="value" xsi:type="string">adjustment_positive</argument> - </action> - <action method="setLabel"> - <argument name="value" xsi:type="string">Adjustment Refund</argument> - </action> - </block> - <block class="Magento\Sales\Block\Adminhtml\Order\Totals\Item" name="adjustment_negative" template="order/totals/item.phtml"> - <action method="setSourceField"> - <argument name="value" xsi:type="string">adjustment_negative</argument> - </action> - <action method="setLabel"> - <argument name="value" xsi:type="string">Adjustment Fee</argument> - </action> - </block> - </block>--> </block> </block> </block> diff --git a/app/code/Magento/Sales/view/adminhtml/layout/sales_order_invoice_updateqty.xml b/app/code/Magento/Sales/view/adminhtml/layout/sales_order_invoice_updateqty.xml index 8a658bd1e9bd9a1aa10b2bdef363835683eca610..c0f08719b17fb87d4112521182efd90da72f8e5b 100644 --- a/app/code/Magento/Sales/view/adminhtml/layout/sales_order_invoice_updateqty.xml +++ b/app/code/Magento/Sales/view/adminhtml/layout/sales_order_invoice_updateqty.xml @@ -28,53 +28,10 @@ <block class="Magento\Sales\Block\Adminhtml\Items\Renderer\DefaultRenderer" as="default" template="order/invoice/create/items/renderer/default.phtml"/> <block class="Magento\Sales\Block\Adminhtml\Items\Column\Qty" name="column_qty" template="items/column/qty.phtml" group="column"/> <block class="Magento\Sales\Block\Adminhtml\Items\Column\Name" name="column_name" template="items/column/name.phtml" group="column"/> - <block class="Magento\Sales\Block\Adminhtml\Items\Column\Name\Grouped" name="column_name_grouped" template="items/column/name.phtml" group="column"/> <block class="Magento\View\Element\Text\ListText" name="order_item_extra_info"/> <block class="Magento\Sales\Block\Adminhtml\Order\Totalbar" name="order_totalbar" template="order/totalbar.phtml"/> <block class="Magento\Sales\Block\Adminhtml\Order\Invoice\Totals" name="invoice_totals" template="order/totals.phtml"> <block class="Magento\Sales\Block\Adminhtml\Order\Totals\Tax" name="tax" template="order/totals/tax.phtml"/> - <!--<block class="Magento\Sales\Block\Adminhtml\Order\Totals\Item" name="footer" template="order/totals/footer.phtml"> - <block class="Magento\Sales\Block\Adminhtml\Order\Totals\Item" name="grand" template="order/totals/grand.phtml"/> - <block class="Magento\Sales\Block\Adminhtml\Order\Totals\Item" name="paid" template="order/totals/paid.phtml"/> - <block class="Magento\Sales\Block\Adminhtml\Order\Totals\Item" name="refunded" template="order/totals/refunded.phtml"/> - <block class="Magento\Sales\Block\Adminhtml\Order\Totals\Item" name="due" template="order/totals/due.phtml"/> - </block> - <block class="Magento\Sales\Block\Adminhtml\Order\Totals\Item" name="sales.order.view.totals.main" as="main" template="order/totals/main.phtml"> - <block class="Magento\Sales\Block\Adminhtml\Order\Totals\Item" name="tax" template="order/totals/item.phtml"> - <action method="setSourceField"> - <argument name="value" xsi:type="string">tax_amount</argument> - </action> - <action method="setLabel"> - <argument name="value" xsi:type="string">Tax</argument> - </action> - </block> - <block class="Magento\Sales\Block\Adminhtml\Order\Totals\Item" name="shipping" template="order/totals/shipping.phtml"/> - <block class="Magento\Sales\Block\Adminhtml\Order\Totals\Item" name="discount" template="order/totals/discount.phtml"/> - <block class="Magento\Sales\Block\Adminhtml\Order\Totals\Item" name="giftcert" template="order/totals/item.phtml"> - <action method="setSourceField"> - <argument name="value" xsi:type="string">giftcert_amount</argument> - </action> - <action method="setLabel"> - <argument name="value" xsi:type="string">Gift Certificate</argument> - </action> - </block> - <block class="Magento\Sales\Block\Adminhtml\Order\Totals\Item" name="adjustment_positive" template="order/totals/item.phtml"> - <action method="setSourceField"> - <argument name="value" xsi:type="string">adjustment_positive</argument> - </action> - <action method="setLabel"> - <argument name="value" xsi:type="string">Adjustment Refund</argument> - </action> - </block> - <block class="Magento\Sales\Block\Adminhtml\Order\Totals\Item" name="adjustment_negative" template="order/totals/item.phtml"> - <action method="setSourceField"> - <argument name="value" xsi:type="string">adjustment_negative</argument> - </action> - <action method="setLabel"> - <argument name="value" xsi:type="string">Adjustment Fee</argument> - </action> - </block> - </block>--> </block> </block> </layout> diff --git a/app/code/Magento/Sales/view/adminhtml/layout/sales_order_invoice_view.xml b/app/code/Magento/Sales/view/adminhtml/layout/sales_order_invoice_view.xml index d8081b524f28d1b5d318b402762fe10072d0e682..9d5646513aeb15b651d29af035d707a6b1edc1c8 100644 --- a/app/code/Magento/Sales/view/adminhtml/layout/sales_order_invoice_view.xml +++ b/app/code/Magento/Sales/view/adminhtml/layout/sales_order_invoice_view.xml @@ -33,7 +33,6 @@ <block class="Magento\Sales\Block\Adminhtml\Items\Renderer\DefaultRenderer" as="default" template="order/invoice/view/items/renderer/default.phtml"/> <block class="Magento\Sales\Block\Adminhtml\Items\Column\Qty" name="column_qty" template="items/column/qty.phtml" group="column"/> <block class="Magento\Sales\Block\Adminhtml\Items\Column\Name" name="column_name" template="items/column/name.phtml" group="column"/> - <block class="Magento\Sales\Block\Adminhtml\Items\Column\Name\Grouped" name="column_name_grouped" template="items/column/name.phtml" group="column"/> <block class="Magento\View\Element\Text\ListText" name="order_item_extra_info"/> </block> <block class="Magento\Sales\Block\Adminhtml\Order\Comments\View" name="order_comments" template="order/comments/view.phtml"> @@ -43,48 +42,6 @@ </block> <block class="Magento\Sales\Block\Adminhtml\Order\Invoice\Totals" name="invoice_totals" template="order/totals.phtml"> <block class="Magento\Sales\Block\Adminhtml\Order\Totals\Tax" name="tax" template="order/totals/tax.phtml"/> - <!--<block class="Magento\Sales\Block\Adminhtml\Order\Totals\Item" name="footer" template="order/totals/footer.phtml"> - <block class="Magento\Sales\Block\Adminhtml\Order\Totals\Item" name="grand" template="order/totals/grand.phtml"/> - <block class="Magento\Sales\Block\Adminhtml\Order\Totals\Item" name="paid" template="order/totals/paid.phtml"/> - <block class="Magento\Sales\Block\Adminhtml\Order\Totals\Item" name="refunded" template="order/totals/refunded.phtml"/> - <block class="Magento\Sales\Block\Adminhtml\Order\Totals\Item" name="due" template="order/totals/due.phtml"/> - </block> - <block class="Magento\Sales\Block\Adminhtml\Order\Totals\Item" name="sales.order.view.totals.main" as="main" template="order/totals/main.phtml"> - <block class="Magento\Sales\Block\Adminhtml\Order\Totals\Item" name="tax" template="order/totals/item.phtml"> - <action method="setSourceField"> - <argument name="value" xsi:type="string">tax_amount</argument> - </action> - <action method="setLabel"> - <argument name="value" xsi:type="string">Tax</argument> - </action> - </block> - <block class="Magento\Sales\Block\Adminhtml\Order\Totals\Item" name="shipping" template="order/totals/shipping.phtml"/> - <block class="Magento\Sales\Block\Adminhtml\Order\Totals\Item" name="discount" template="order/totals/discount.phtml"/> - <block class="Magento\Sales\Block\Adminhtml\Order\Totals\Item" name="giftcert" template="order/totals/item.phtml"> - <action method="setSourceField"> - <argument name="value" xsi:type="string">giftcert_amount</argument> - </action> - <action method="setLabel"> - <argument name="value" xsi:type="string">Gift Certificate</argument> - </action> - </block> - <block class="Magento\Sales\Block\Adminhtml\Order\Totals\Item" name="adjustment_positive" template="order/totals/item.phtml"> - <action method="setSourceField"> - <argument name="value" xsi:type="string">adjustment_positive</argument> - </action> - <action method="setLabel"> - <argument name="value" xsi:type="string">Adjustment Refund</argument> - </action> - </block> - <block class="Magento\Sales\Block\Adminhtml\Order\Totals\Item" name="adjustment_negative" template="order/totals/item.phtml"> - <action method="setSourceField"> - <argument name="value" xsi:type="string">adjustment_negative</argument> - </action> - <action method="setLabel"> - <argument name="value" xsi:type="string">Adjustment Fee</argument> - </action> - </block> - </block>--> </block> </block> </block> diff --git a/app/code/Magento/Sales/view/adminhtml/layout/sales_order_view.xml b/app/code/Magento/Sales/view/adminhtml/layout/sales_order_view.xml index 48542594e246c4a260b7d068dd1a4f46acf7cbc9..b32df85183b4ba219b5a18d6a85cae1fec8f8fcc 100644 --- a/app/code/Magento/Sales/view/adminhtml/layout/sales_order_view.xml +++ b/app/code/Magento/Sales/view/adminhtml/layout/sales_order_view.xml @@ -48,7 +48,6 @@ <block class="Magento\Sales\Block\Adminhtml\Order\View\Items\Renderer\DefaultRenderer" as="default" template="order/view/items/renderer/default.phtml"/> <block class="Magento\Sales\Block\Adminhtml\Items\Column\Qty" name="column_qty" template="items/column/qty.phtml" group="column"/> <block class="Magento\Sales\Block\Adminhtml\Items\Column\Name" name="column_name" template="items/column/name.phtml" group="column"/> - <block class="Magento\Sales\Block\Adminhtml\Items\Column\Name\Grouped" name="column_name_grouped" template="items/column/name.phtml" group="column"/> <block class="Magento\View\Element\Text\ListText" name="order_item_extra_info"/> </block> <block class="Magento\Sales\Block\Adminhtml\Order\Payment" name="order_payment"/> diff --git a/app/code/Magento/Sales/view/adminhtml/order/create/form/address.phtml b/app/code/Magento/Sales/view/adminhtml/order/create/form/address.phtml index b83784b849ec58b9ff08f2826531c52bc3d73388..68a9f311f64a8d378dc529a29766aaccad9105ff 100644 --- a/app/code/Magento/Sales/view/adminhtml/order/create/form/address.phtml +++ b/app/code/Magento/Sales/view/adminhtml/order/create/form/address.phtml @@ -23,6 +23,10 @@ * @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) */ + +/** + * @var \Magento\Sales\Block\Adminhtml\Order\Create\Billing\Address|\Magento\Sales\Block\Adminhtml\Order\Create\Shipping\Address $this + */ if($this->getIsShipping()): $_fieldsContainerId = 'order-shipping_address_fields'; $_addressChoiceContainerId = 'order-shipping_address_choice'; diff --git a/app/code/Magento/Sales/view/adminhtml/order/create/sidebar/items.phtml b/app/code/Magento/Sales/view/adminhtml/order/create/sidebar/items.phtml index 702e9d3e2f75ef9bca6d9384c18facb0d94c2167..6e6d2171acf220cdd64372665116bb020e83a619 100644 --- a/app/code/Magento/Sales/view/adminhtml/order/create/sidebar/items.phtml +++ b/app/code/Magento/Sales/view/adminhtml/order/create/sidebar/items.phtml @@ -70,9 +70,7 @@ <td><?php echo $this->escapeHtml($_item->getName()) ?></td> <?php if ($this->canDisplayItemQty()): ?> <td class="a-center"> - <?php if ($_item->getProduct()->getTypeId() != \Magento\GroupedProduct\Model\Product\Type\Grouped::TYPE_CODE): ?> - <?php echo $_item->getQty()*1 ? $_item->getQty()*1 : 1 ?> - <?php endif; ?> + <?php echo $this->getItemQty($_item); ?> </td> <?php endif; ?> <?php if($this->canDisplayPrice()): ?> @@ -82,9 +80,9 @@ <td class="a-center"><input type="checkbox" name="sidebar[remove][<?php echo $this->getItemId($_item) ?>]" value="<?php echo $this->getDataId() ?>" title="<?php echo __('Remove') ?>"/></td> <?php endif; ?> <td class="a-center"> - <?php if ($_item->getTypeId() == \Magento\GroupedProduct\Model\Product\Type\Grouped::TYPE_CODE && $this->getDataId() == 'wishlist'): ?> + <?php if ($this->isConfigurationRequired($_item->getTypeId()) && $this->getDataId() == 'wishlist'): ?> <a href="#" onclick="order.sidebarConfigureProduct('<?php echo 'sidebar_wishlist' ?>', <?php echo $this->getProductId($_item) ?>, <?php echo $this->getItemId($_item) ?>); return false;"><img src="<?php echo $this->getViewFileUrl('images/grouped_to_order_icon.png') ?>" class="v-middle" alt="<?php echo __('Configure and Add to Order') ?>" title="<?php echo __('Configure and Add to Order') ?>" width="16" height="16"/></a> - <?php elseif ($_item->getTypeId() == \Magento\GroupedProduct\Model\Product\Type\Grouped::TYPE_CODE): ?> + <?php elseif ($this->isConfigurationRequired($_item->getTypeId())): ?> <a href="#" onclick="order.sidebarConfigureProduct('<?php echo 'sidebar' ?>', <?php echo $this->getProductId($_item) ?>); return false;"><img src="<?php echo $this->getViewFileUrl('images/grouped_to_order_icon.png') ?>" class="v-middle" alt="<?php echo __('Configure and Add to Order') ?>" title="<?php echo __('Configure and Add to Order') ?>" width="16" height="16"/></a> <?php else: ?> <input type="checkbox" name="sidebar[<?php echo $this->getSidebarStorageAction() ?>][<?php echo $this->getIdentifierId($_item) ?>]" value="<?php echo $this->canDisplayItemQty() ? $_item->getQty()*1 : 1 ?>" title="<?php echo __('Add To Order') ?>"/> diff --git a/app/code/Magento/Sales/view/frontend/layout/sales_email_order_creditmemo_items.xml b/app/code/Magento/Sales/view/frontend/layout/sales_email_order_creditmemo_items.xml index 8606fd7ae2387ec597f6da665735056471799d60..a92b603517b6b46cad6d8cd4c2c488870edb6aa7 100644 --- a/app/code/Magento/Sales/view/frontend/layout/sales_email_order_creditmemo_items.xml +++ b/app/code/Magento/Sales/view/frontend/layout/sales_email_order_creditmemo_items.xml @@ -24,9 +24,9 @@ */ --> <layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" label="Email Creditmemo Items List" design_abstraction="custom"> + <update handle="sales_email_order_creditmemo_renderers" /> <block class="Magento\Sales\Block\Order\Email\Creditmemo\Items" name="items" template="email/creditmemo/items.phtml"> - <block class="Magento\Sales\Block\Order\Email\Items\DefaultItems" as="default" template="email/items/creditmemo/default.phtml"/> - <block class="Magento\Sales\Block\Order\Email\Items\Order\Grouped" as="grouped" template="email/items/creditmemo/default.phtml"/> + <block class="Magento\View\Element\RendererList" name="sales.email.order.creditmemo.renderers" as="renderer.list" /> <block class="Magento\Sales\Block\Order\Creditmemo\Totals" name="creditmemo_totals" template="order/totals.phtml" cacheable="false"> <arguments> <argument name="label_properties" xsi:type="string">colspan="3" align="right" style="padding:3px 9px"</argument> diff --git a/app/code/Magento/Bundle/view/frontend/layout/sales_order_invoice.xml b/app/code/Magento/Sales/view/frontend/layout/sales_email_order_creditmemo_renderers.xml similarity index 75% rename from app/code/Magento/Bundle/view/frontend/layout/sales_order_invoice.xml rename to app/code/Magento/Sales/view/frontend/layout/sales_email_order_creditmemo_renderers.xml index 861baa1c1087f9f748001b0b099acbdbfa1349fc..6103c5b3f23974250ad8d5ee8dc6bf8d4cbca449 100644 --- a/app/code/Magento/Bundle/view/frontend/layout/sales_order_invoice.xml +++ b/app/code/Magento/Sales/view/frontend/layout/sales_email_order_creditmemo_renderers.xml @@ -23,8 +23,8 @@ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */ --> -<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> - <referenceBlock name="invoice_items"> - <block class="Magento\Bundle\Block\Sales\Order\Items\Renderer" as="bundle" template="sales/order/invoice/items/renderer.phtml"/> +<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" label="Email Creditmemo Items List" design_abstraction="custom"> + <referenceBlock name="sales.email.order.creditmemo.renderers"> + <block class="Magento\Sales\Block\Order\Email\Items\DefaultItems" as="default" template="email/items/creditmemo/default.phtml"/> </referenceBlock> </layout> diff --git a/app/code/Magento/Sales/view/frontend/layout/sales_email_order_invoice_items.xml b/app/code/Magento/Sales/view/frontend/layout/sales_email_order_invoice_items.xml index fc245231b47068db4458996b0f5baa7dccd598bb..20883ecb5ca3339ed2c374f3ec7551acd66dc8ac 100644 --- a/app/code/Magento/Sales/view/frontend/layout/sales_email_order_invoice_items.xml +++ b/app/code/Magento/Sales/view/frontend/layout/sales_email_order_invoice_items.xml @@ -24,9 +24,9 @@ */ --> <layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" label="Email Invoice Items List" design_abstraction="custom"> + <update handle="sales_email_order_invoice_renderers" /> <block class="Magento\Sales\Block\Order\Email\Invoice\Items" name="items" template="email/invoice/items.phtml"> - <block class="Magento\Sales\Block\Order\Email\Items\DefaultItems" as="default" template="email/items/invoice/default.phtml"/> - <block class="Magento\Sales\Block\Order\Email\Items\Order\Grouped" as="grouped" template="email/items/invoice/default.phtml"/> + <block class="Magento\View\Element\RendererList" name="sales.email.order.invoice.renderers" as="renderer.list" /> <block class="Magento\Sales\Block\Order\Invoice\Totals" name="invoice_totals" template="order/totals.phtml" cacheable="false"> <arguments> <argument name="label_properties" xsi:type="string">colspan="3" align="right" style="padding:3px 9px"</argument> diff --git a/app/code/Magento/Sales/view/frontend/layout/sales_email_order_invoice_renderers.xml b/app/code/Magento/Sales/view/frontend/layout/sales_email_order_invoice_renderers.xml new file mode 100644 index 0000000000000000000000000000000000000000..5a95ce784ced95af68240df7003f6e4a61cf5055 --- /dev/null +++ b/app/code/Magento/Sales/view/frontend/layout/sales_email_order_invoice_renderers.xml @@ -0,0 +1,30 @@ +<?xml version="1.0"?> +<!-- +/** + * 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) + */ +--> +<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" label="Email Creditmemo Items List" design_abstraction="custom"> + <referenceBlock name="sales.email.order.invoice.renderers"> + <block class="Magento\Sales\Block\Order\Email\Items\DefaultItems" as="default" template="email/items/invoice/default.phtml"/> + </referenceBlock> +</layout> diff --git a/app/code/Magento/Sales/view/frontend/layout/sales_email_order_items.xml b/app/code/Magento/Sales/view/frontend/layout/sales_email_order_items.xml index fcba97901fe214fd71feb29de31b09e6c68003e6..aea3fbcde4e3668049ca3c1d746c59625bc4e337 100644 --- a/app/code/Magento/Sales/view/frontend/layout/sales_email_order_items.xml +++ b/app/code/Magento/Sales/view/frontend/layout/sales_email_order_items.xml @@ -24,9 +24,9 @@ */ --> <layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" label="Email Order Items List" design_abstraction="custom"> + <update handle="sales_email_order_renderers" /> <block class="Magento\Sales\Block\Order\Email\Items" name="items" template="email/items.phtml"> - <block class="Magento\Sales\Block\Order\Email\Items\Order\DefaultOrder" as="default" template="email/items/order/default.phtml"/> - <block class="Magento\Sales\Block\Order\Email\Items\Order\Grouped" as="grouped" template="email/items/order/default.phtml"/> + <block class="Magento\View\Element\RendererList" name="sales.email.order.renderers" as="renderer.list" /> <block class="Magento\Sales\Block\Order\Totals" name="order_totals" template="order/totals.phtml"> <arguments> <argument name="label_properties" xsi:type="string">colspan="3" align="right" style="padding:3px 9px"</argument> diff --git a/app/code/Magento/Bundle/view/frontend/layout/sales_guest_shipment.xml b/app/code/Magento/Sales/view/frontend/layout/sales_email_order_renderers.xml similarity index 76% rename from app/code/Magento/Bundle/view/frontend/layout/sales_guest_shipment.xml rename to app/code/Magento/Sales/view/frontend/layout/sales_email_order_renderers.xml index d34a37f904840f4b2c8932aff3c1530eee0eb824..506495e63bf9cd2f1a11cc9eb07573daa8b9d2c6 100644 --- a/app/code/Magento/Bundle/view/frontend/layout/sales_guest_shipment.xml +++ b/app/code/Magento/Sales/view/frontend/layout/sales_email_order_renderers.xml @@ -23,8 +23,8 @@ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */ --> -<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> - <referenceBlock name="shipment_items"> - <block class="Magento\Bundle\Block\Sales\Order\Items\Renderer" as="bundle" template="sales/order/shipment/items/renderer.phtml"/> +<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" label="Email Creditmemo Items List" design_abstraction="custom"> + <referenceBlock name="sales.email.order.renderers"> + <block class="Magento\Sales\Block\Order\Email\Items\Order\DefaultOrder" as="default" template="email/items/order/default.phtml"/> </referenceBlock> </layout> diff --git a/app/code/Magento/Sales/view/frontend/layout/sales_email_order_shipment_items.xml b/app/code/Magento/Sales/view/frontend/layout/sales_email_order_shipment_items.xml index dbf12ea55f9c10d4690ad94dba6e58d423823b7e..f041570c04a1d4f9c8725bc75009c06b6251d287 100644 --- a/app/code/Magento/Sales/view/frontend/layout/sales_email_order_shipment_items.xml +++ b/app/code/Magento/Sales/view/frontend/layout/sales_email_order_shipment_items.xml @@ -24,8 +24,9 @@ */ --> <layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" label="Email Shipment Items List" design_abstraction="custom"> + <update handle="sales_email_order_shipment_renderers" /> <block class="Magento\Sales\Block\Order\Email\Shipment\Items" name="items" template="email/shipment/items.phtml"> - <block class="Magento\Sales\Block\Order\Email\Items\DefaultItems" as="default" template="email/items/shipment/default.phtml"/> + <block class="Magento\View\Element\RendererList" name="sales.email.order.shipment.renderers" as="renderer.list" /> </block> <block class="Magento\View\Element\Template" name="additional.product.info" template="Magento_Core::template.phtml"/> </layout> diff --git a/app/code/Magento/Sales/view/frontend/layout/sales_email_order_shipment_renderers.xml b/app/code/Magento/Sales/view/frontend/layout/sales_email_order_shipment_renderers.xml new file mode 100644 index 0000000000000000000000000000000000000000..1c435a00cc111df95caa690093ef1a3446d0716c --- /dev/null +++ b/app/code/Magento/Sales/view/frontend/layout/sales_email_order_shipment_renderers.xml @@ -0,0 +1,30 @@ +<?xml version="1.0"?> +<!-- +/** + * 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) + */ +--> +<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" label="Email Creditmemo Items List" design_abstraction="custom"> + <referenceBlock name="sales.email.order.shipment.renderers"> + <block class="Magento\Sales\Block\Order\Email\Items\DefaultItems" as="default" template="email/items/shipment/default.phtml"/> + </referenceBlock> +</layout> diff --git a/app/code/Magento/Sales/view/frontend/layout/sales_guest_creditmemo.xml b/app/code/Magento/Sales/view/frontend/layout/sales_guest_creditmemo.xml index 17b7d0cb21109226d67f943db0da6dee1aa0dd08..91ecf77c395327dd7c30d0e9ad6e1ca9d7a16101 100644 --- a/app/code/Magento/Sales/view/frontend/layout/sales_guest_creditmemo.xml +++ b/app/code/Magento/Sales/view/frontend/layout/sales_guest_creditmemo.xml @@ -24,6 +24,7 @@ */ --> <layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <update handle="sales_order_creditmemo_renderers" /> <referenceBlock name="root"> <action method="setTemplate"> <argument name="template" xsi:type="string">1column.phtml</argument> @@ -35,8 +36,7 @@ </block> <block class="Magento\Sales\Block\Order\Creditmemo" name="sales.order.creditmemo" after="sales.order.info" cacheable="false"> <block class="Magento\Sales\Block\Order\Creditmemo\Items" name="creditmemo_items" template="order/creditmemo/items.phtml"> - <block class="Magento\Sales\Block\Order\Item\Renderer\DefaultRenderer" as="default" template="order/creditmemo/items/renderer/default.phtml"/> - <block class="Magento\Sales\Block\Order\Item\Renderer\Grouped" as="grouped" template="order/creditmemo/items/renderer/default.phtml"/> + <block class="Magento\View\Element\RendererList" name="sales.order.creditmemo.renderers" as="renderer.list" /> <block class="Magento\Sales\Block\Order\Creditmemo\Totals" name="creditmemo_totals" template="order/totals.phtml"> <arguments> <argument name="label_properties" xsi:type="string">colspan="6" class="mark"</argument> diff --git a/app/code/Magento/Sales/view/frontend/layout/sales_guest_invoice.xml b/app/code/Magento/Sales/view/frontend/layout/sales_guest_invoice.xml index 54bd4a12913bc77ebc7e2c41f957b45c55d950f6..35aab993fe85a3ec28462731736d2fa0a5638609 100644 --- a/app/code/Magento/Sales/view/frontend/layout/sales_guest_invoice.xml +++ b/app/code/Magento/Sales/view/frontend/layout/sales_guest_invoice.xml @@ -24,6 +24,7 @@ */ --> <layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <update handle="sales_order_invoice_renderers" /> <referenceBlock name="root"> <action method="setTemplate"> <argument name="template" xsi:type="string">1column.phtml</argument> @@ -35,8 +36,7 @@ </block> <block class="Magento\Sales\Block\Order\Invoice" name="sales.order.invoice" after="sales.order.info" cacheable="false"> <block class="Magento\Sales\Block\Order\Invoice\Items" name="invoice_items" template="order/invoice/items.phtml"> - <block class="Magento\Sales\Block\Order\Item\Renderer\DefaultRenderer" as="default" template="order/invoice/items/renderer/default.phtml"/> - <block class="Magento\Sales\Block\Order\Item\Renderer\Grouped" as="grouped" template="order/invoice/items/renderer/default.phtml"/> + <block class="Magento\View\Element\RendererList" name="sales.order.invoice.renderers" as="renderer.list" /> <block class="Magento\Sales\Block\Order\Invoice\Totals" name="invoice_totals" template="order/totals.phtml"> <arguments> <argument name="label_properties" xsi:type="string">colspan="4" class="mark"</argument> diff --git a/app/code/Magento/Sales/view/frontend/layout/sales_guest_print.xml b/app/code/Magento/Sales/view/frontend/layout/sales_guest_print.xml index 7b55c73b3b5af4f3c82db2fcd8cc047e01fd0702..947436d8b71883172d8352adfa4f111e7ed583f2 100644 --- a/app/code/Magento/Sales/view/frontend/layout/sales_guest_print.xml +++ b/app/code/Magento/Sales/view/frontend/layout/sales_guest_print.xml @@ -24,10 +24,10 @@ */ --> <layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <update handle="sales_order_print_renderers" /> <referenceContainer name="content"> <block class="Magento\Sales\Block\Order\PrintShipment" name="sales.order.print" template="order/print.phtml"> - <block class="Magento\Sales\Block\Order\Item\Renderer\DefaultRenderer" as="default" template="order/items/renderer/default.phtml"/> - <block class="Magento\Sales\Block\Order\Item\Renderer\Grouped" as="grouped" template="order/items/renderer/default.phtml"/> + <block class="Magento\View\Element\RendererList" name="sales.order.print.renderers" as="renderer.list" /> <block class="Magento\Sales\Block\Order\Totals" name="order_totals" template="order/totals.phtml"> <arguments> <argument name="label_properties" xsi:type="string">colspan="4" class="mark"</argument> diff --git a/app/code/Magento/Sales/view/frontend/layout/sales_guest_printcreditmemo.xml b/app/code/Magento/Sales/view/frontend/layout/sales_guest_printcreditmemo.xml index f8d89184781e6f4225dd8cc4debb6c6a74003730..9fe41bf9baaac02da0ac27ec7552945e1dfb01cd 100644 --- a/app/code/Magento/Sales/view/frontend/layout/sales_guest_printcreditmemo.xml +++ b/app/code/Magento/Sales/view/frontend/layout/sales_guest_printcreditmemo.xml @@ -24,10 +24,10 @@ */ --> <layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <update handle="sales_order_print_creditmemo_renderers" /> <referenceContainer name="content"> <block class="Magento\Sales\Block\Order\PrintOrder\Creditmemo" name="sales.order.print.creditmemo" template="order/print/creditmemo.phtml"> - <block class="Magento\Sales\Block\Order\Item\Renderer\DefaultRenderer" as="default" template="order/creditmemo/items/renderer/default.phtml"/> - <block class="Magento\Sales\Block\Order\Item\Renderer\Grouped" as="grouped" template="order/creditmemo/items/renderer/default.phtml"/> + <block class="Magento\View\Element\RendererList" name="sales.order.print.creditmemo.renderers" as="renderer.list"/> <block class="Magento\Sales\Block\Order\Creditmemo\Totals" name="creditmemo_totals" template="order/totals.phtml" cacheable="false"> <arguments> <argument name="label_properties" xsi:type="string">colspan="6" class="mark"</argument> diff --git a/app/code/Magento/Sales/view/frontend/layout/sales_guest_printinvoice.xml b/app/code/Magento/Sales/view/frontend/layout/sales_guest_printinvoice.xml index 13c631f5b3f33bf4c63db1e667e7b6ba2fc52e8b..5eacd46c052b7fe2e80644c05c96c0dc883bf667 100644 --- a/app/code/Magento/Sales/view/frontend/layout/sales_guest_printinvoice.xml +++ b/app/code/Magento/Sales/view/frontend/layout/sales_guest_printinvoice.xml @@ -24,10 +24,10 @@ */ --> <layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <update handle="sales_order_print_invoice_renderers" /> <referenceContainer name="content"> <block class="Magento\Sales\Block\Order\PrintOrder\Invoice" name="sales.order.print.invoice" template="order/print/invoice.phtml"> - <block class="Magento\Sales\Block\Order\Item\Renderer\DefaultRenderer" as="default" template="order/invoice/items/renderer/default.phtml"/> - <block class="Magento\Sales\Block\Order\Item\Renderer\Grouped" as="grouped" template="order/invoice/items/renderer/default.phtml"/> + <block class="Magento\View\Element\RendererList" name="sales.order.print.invoice.renderers" as="renderer.list" /> <block class="Magento\Sales\Block\Order\Invoice\Totals" name="invoice_totals" template="order/totals.phtml" cacheable="false"> <arguments> <argument name="label_properties" xsi:type="string">colspan="4" class="mark"</argument> diff --git a/app/code/Magento/Sales/view/frontend/layout/sales_guest_printshipment.xml b/app/code/Magento/Sales/view/frontend/layout/sales_guest_printshipment.xml index 7725c008129299c5edb87a9c48e813afbf8dfb13..c496aad0a008a98e7b9b190779b5c442e0ac3d65 100644 --- a/app/code/Magento/Sales/view/frontend/layout/sales_guest_printshipment.xml +++ b/app/code/Magento/Sales/view/frontend/layout/sales_guest_printshipment.xml @@ -24,9 +24,10 @@ */ --> <layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <update handle="sales_order_print_shipment_renderers" /> <referenceContainer name="content"> <block class="Magento\Sales\Block\Order\PrintOrder\Shipment" name="sales.order.print.shipment" template="order/print/shipment.phtml"> - <block class="Magento\Sales\Block\Order\Item\Renderer\DefaultRenderer" as="default" template="order/shipment/items/renderer/default.phtml"/> + <block class="Magento\View\Element\RendererList" name="sales.order.print.shipment.renderers" as="renderer.list" /> </block> </referenceContainer> </layout> diff --git a/app/code/Magento/Sales/view/frontend/layout/sales_guest_view.xml b/app/code/Magento/Sales/view/frontend/layout/sales_guest_view.xml index eb67d146a8a4cf6829fe161b9ba3937fc934d77d..1474388986a216db2535f570f15e6120c838f39e 100644 --- a/app/code/Magento/Sales/view/frontend/layout/sales_guest_view.xml +++ b/app/code/Magento/Sales/view/frontend/layout/sales_guest_view.xml @@ -24,6 +24,8 @@ */ --> <layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <update handle="sales_order_item_renderers"/> + <referenceBlock name="root"> <action method="setTemplate"> <argument name="template" xsi:type="string">1column.phtml</argument> @@ -35,8 +37,7 @@ </block> <block class="Magento\Sales\Block\Order\View" name="sales.order.view" after="sales.order.info" cacheable="false"> <block class="Magento\Sales\Block\Order\Items" name="order_items" template="order/items.phtml"> - <block class="Magento\Sales\Block\Order\Item\Renderer\DefaultRenderer" as="default" template="order/items/renderer/default.phtml"/> - <block class="Magento\Sales\Block\Order\Item\Renderer\Grouped" as="grouped" template="order/items/renderer/default.phtml"/> + <block class="Magento\View\Element\RendererList" name="sales.order.items.renderers" as="renderer.list" /> <block class="Magento\Sales\Block\Order\Totals" name="order_totals" template="order/totals.phtml"> <arguments> <argument name="label_properties" xsi:type="string">colspan="4" class="mark"</argument> diff --git a/app/code/Magento/Sales/view/frontend/layout/sales_order_creditmemo.xml b/app/code/Magento/Sales/view/frontend/layout/sales_order_creditmemo.xml index 15fd5b781dec4330c478f26e8e87f240f0b3a4d4..edaffb426d1001cccb4261800acb61358f93e480 100644 --- a/app/code/Magento/Sales/view/frontend/layout/sales_order_creditmemo.xml +++ b/app/code/Magento/Sales/view/frontend/layout/sales_order_creditmemo.xml @@ -24,6 +24,7 @@ */ --> <layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <update handle="sales_order_creditmemo_renderers" /> <update handle="customer_account"/> <referenceContainer name="content"> <block class="Magento\Sales\Block\Order\Info" as="info" name="sales.order.info"> @@ -31,8 +32,7 @@ </block> <block class="Magento\Sales\Block\Order\Creditmemo" name="sales.order.creditmemo" after="sales.order.info" cacheable="false"> <block class="Magento\Sales\Block\Order\Creditmemo\Items" name="creditmemo_items" template="order/creditmemo/items.phtml"> - <block class="Magento\Sales\Block\Order\Item\Renderer\DefaultRenderer" as="default" template="order/creditmemo/items/renderer/default.phtml"/> - <block class="Magento\Sales\Block\Order\Item\Renderer\Grouped" as="grouped" template="order/creditmemo/items/renderer/default.phtml"/> + <block class="Magento\View\Element\RendererList" name="sales.order.creditmemo.renderers" as="renderer.list" /> <block class="Magento\Sales\Block\Order\Creditmemo\Totals" name="creditmemo_totals" template="order/totals.phtml"> <arguments> <argument name="label_properties" xsi:type="string">colspan="6" class="mark"</argument> diff --git a/app/code/Magento/Sales/view/frontend/layout/sales_order_creditmemo_renderers.xml b/app/code/Magento/Sales/view/frontend/layout/sales_order_creditmemo_renderers.xml new file mode 100644 index 0000000000000000000000000000000000000000..a963c5fa43eaf7c77d571cf26aff7c8504b61bff --- /dev/null +++ b/app/code/Magento/Sales/view/frontend/layout/sales_order_creditmemo_renderers.xml @@ -0,0 +1,30 @@ +<?xml version="1.0"?> +<!-- +/** + * 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) + */ +--> +<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <referenceBlock name="sales.order.creditmemo.renderers"> + <block class="Magento\Sales\Block\Order\Item\Renderer\DefaultRenderer" as="default" template="order/creditmemo/items/renderer/default.phtml"/> + </referenceBlock> +</layout> diff --git a/app/code/Magento/Sales/view/frontend/layout/sales_order_invoice.xml b/app/code/Magento/Sales/view/frontend/layout/sales_order_invoice.xml index 856c8e534e64fb2ae613e961fc4e87e7949c1196..127c7ea7d22a815eb132eeb70dc6ebdd400493e4 100644 --- a/app/code/Magento/Sales/view/frontend/layout/sales_order_invoice.xml +++ b/app/code/Magento/Sales/view/frontend/layout/sales_order_invoice.xml @@ -25,14 +25,14 @@ --> <layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <update handle="customer_account"/> + <update handle="sales_order_invoice_renderers" /> <referenceContainer name="content"> <block class="Magento\Sales\Block\Order\Info" as="info" name="sales.order.info"> <block class="Magento\Sales\Block\Order\Info\Buttons" as="buttons" name="sales.order.info.buttons" cacheable="false"/> </block> <block class="Magento\Sales\Block\Order\Invoice" name="sales.order.invoice" after="sales.order.info" cacheable="false"> <block class="Magento\Sales\Block\Order\Invoice\Items" name="invoice_items" template="order/invoice/items.phtml"> - <block class="Magento\Sales\Block\Order\Item\Renderer\DefaultRenderer" as="default" template="order/invoice/items/renderer/default.phtml"/> - <block class="Magento\Sales\Block\Order\Item\Renderer\Grouped" as="grouped" template="order/invoice/items/renderer/default.phtml"/> + <block class="Magento\View\Element\RendererList" name="sales.order.invoice.renderers" as="renderer.list"/> <block class="Magento\Sales\Block\Order\Invoice\Totals" name="invoice_totals" template="order/totals.phtml"> <arguments> <argument name="label_properties" xsi:type="string">colspan="4" class="mark"</argument> diff --git a/app/code/Magento/Sales/view/frontend/layout/sales_order_invoice_renderers.xml b/app/code/Magento/Sales/view/frontend/layout/sales_order_invoice_renderers.xml new file mode 100644 index 0000000000000000000000000000000000000000..81ebc1a621825fc7d9fcb56e39e57d713d2f27f6 --- /dev/null +++ b/app/code/Magento/Sales/view/frontend/layout/sales_order_invoice_renderers.xml @@ -0,0 +1,30 @@ +<?xml version="1.0"?> +<!-- +/** + * 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) + */ +--> +<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <referenceBlock name="sales.order.invoice.renderers"> + <block class="Magento\Sales\Block\Order\Item\Renderer\DefaultRenderer" as="default" template="order/invoice/items/renderer/default.phtml"/> + </referenceBlock> +</layout> diff --git a/app/code/Magento/Sales/view/frontend/layout/sales_order_item_renderers.xml b/app/code/Magento/Sales/view/frontend/layout/sales_order_item_renderers.xml new file mode 100644 index 0000000000000000000000000000000000000000..2789f977398fc99286166458f08dfe6394bc9ed1 --- /dev/null +++ b/app/code/Magento/Sales/view/frontend/layout/sales_order_item_renderers.xml @@ -0,0 +1,30 @@ +<?xml version="1.0"?> +<!-- +/** + * 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) + */ +--> +<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <referenceBlock name="sales.order.items.renderers"> + <block class="Magento\Sales\Block\Order\Item\Renderer\DefaultRenderer" as="default" template="order/items/renderer/default.phtml"/> + </referenceBlock> +</layout> diff --git a/app/code/Magento/Sales/view/frontend/layout/sales_order_print.xml b/app/code/Magento/Sales/view/frontend/layout/sales_order_print.xml index 26b8965c4893ab34bf52fc4a6715d3dba1bb8bd5..67df30b8b6c40ec7b0daed0cfcff1e5de2bb2789 100644 --- a/app/code/Magento/Sales/view/frontend/layout/sales_order_print.xml +++ b/app/code/Magento/Sales/view/frontend/layout/sales_order_print.xml @@ -24,10 +24,10 @@ */ --> <layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <update handle="sales_order_print_renderers" /> <referenceContainer name="content"> <block class="Magento\Sales\Block\Order\PrintShipment" name="sales.order.print" template="order/print.phtml"> - <block class="Magento\Sales\Block\Order\Item\Renderer\DefaultRenderer" as="default" template="order/items/renderer/default.phtml"/> - <block class="Magento\Sales\Block\Order\Item\Renderer\Grouped" as="grouped" template="order/items/renderer/default.phtml"/> + <block class="Magento\View\Element\RendererList" name="sales.order.print.renderers" as="renderer.list" /> <block class="Magento\Sales\Block\Order\Totals" name="order_totals" template="order/totals.phtml"> <arguments> <argument name="label_properties" xsi:type="string">colspan="4" class="mark"</argument> diff --git a/app/code/Magento/Bundle/view/frontend/layout/paypal_express_review.xml b/app/code/Magento/Sales/view/frontend/layout/sales_order_print_creditmemo_renderers.xml similarity index 82% rename from app/code/Magento/Bundle/view/frontend/layout/paypal_express_review.xml rename to app/code/Magento/Sales/view/frontend/layout/sales_order_print_creditmemo_renderers.xml index 657757e4e4a6d5a803e36f73c61c8b0f1b5d6ea2..66eb5714433312e66283d9e9a43b34b406492bf1 100644 --- a/app/code/Magento/Bundle/view/frontend/layout/paypal_express_review.xml +++ b/app/code/Magento/Sales/view/frontend/layout/sales_order_print_creditmemo_renderers.xml @@ -24,7 +24,7 @@ */ --> <layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> - <referenceBlock name="paypal.express.review.details"> - <block class="Magento\Bundle\Block\Checkout\Cart\Item\Renderer" as="bundle" template="Magento_Checkout::onepage/review/item.phtml" cacheable="false"/> + <referenceBlock name="sales.order.print.creditmemo.renderers"> + <block class="Magento\Sales\Block\Order\Item\Renderer\DefaultRenderer" as="default" template="order/creditmemo/items/renderer/default.phtml"/> </referenceBlock> </layout> diff --git a/app/code/Magento/Sales/view/frontend/layout/sales_order_print_invoice_renderers.xml b/app/code/Magento/Sales/view/frontend/layout/sales_order_print_invoice_renderers.xml new file mode 100644 index 0000000000000000000000000000000000000000..323263038a0a3fd381bc0c83fdcbb638a2431cfb --- /dev/null +++ b/app/code/Magento/Sales/view/frontend/layout/sales_order_print_invoice_renderers.xml @@ -0,0 +1,30 @@ +<?xml version="1.0"?> +<!-- +/** + * 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) + */ +--> +<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <referenceBlock name="sales.order.print.invoice.renderers"> + <block class="Magento\Sales\Block\Order\Item\Renderer\DefaultRenderer" as="default" template="order/invoice/items/renderer/default.phtml"/> + </referenceBlock> +</layout> diff --git a/app/code/Magento/Sales/view/frontend/layout/sales_order_print_renderers.xml b/app/code/Magento/Sales/view/frontend/layout/sales_order_print_renderers.xml new file mode 100644 index 0000000000000000000000000000000000000000..bc4ce6d24df16fbe3093a6deaca30c5fdcd57e82 --- /dev/null +++ b/app/code/Magento/Sales/view/frontend/layout/sales_order_print_renderers.xml @@ -0,0 +1,30 @@ +<?xml version="1.0"?> +<!-- +/** + * 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) + */ +--> +<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <referenceBlock name="sales.order.print.renderers"> + <block class="Magento\Sales\Block\Order\Item\Renderer\DefaultRenderer" as="default" template="order/items/renderer/default.phtml"/> + </referenceBlock> +</layout> diff --git a/app/code/Magento/Bundle/view/frontend/layout/sales_order_printorder.xml b/app/code/Magento/Sales/view/frontend/layout/sales_order_print_shipment_renderers.xml similarity index 83% rename from app/code/Magento/Bundle/view/frontend/layout/sales_order_printorder.xml rename to app/code/Magento/Sales/view/frontend/layout/sales_order_print_shipment_renderers.xml index bea81de24d9742052a68b02145956393f579c329..7b6bbe02442de362539f04b9f7c8f942543009d6 100644 --- a/app/code/Magento/Bundle/view/frontend/layout/sales_order_printorder.xml +++ b/app/code/Magento/Sales/view/frontend/layout/sales_order_print_shipment_renderers.xml @@ -24,7 +24,7 @@ */ --> <layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> - <referenceBlock name="sales.order.print"> - <block class="Magento\Bundle\Block\Sales\Order\Items\Renderer" as="bundle" template="sales/order/items/renderer.phtml"/> + <referenceBlock name="sales.order.print.shipment.renderers"> + <block class="Magento\Sales\Block\Order\Item\Renderer\DefaultRenderer" as="default" template="order/shipment/items/renderer/default.phtml"/> </referenceBlock> </layout> diff --git a/app/code/Magento/Sales/view/frontend/layout/sales_order_printcreditmemo.xml b/app/code/Magento/Sales/view/frontend/layout/sales_order_printcreditmemo.xml index 7f684f4d3060333870b57a065597e5ec8e85c61d..282a26605220191dce5998c77b0b9bbaff41fd29 100644 --- a/app/code/Magento/Sales/view/frontend/layout/sales_order_printcreditmemo.xml +++ b/app/code/Magento/Sales/view/frontend/layout/sales_order_printcreditmemo.xml @@ -24,10 +24,10 @@ */ --> <layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <update handle="sales_order_print_creditmemo_renderers" /> <referenceContainer name="content"> <block class="Magento\Sales\Block\Order\PrintOrder\Creditmemo" name="sales.order.print.creditmemo" template="order/print/creditmemo.phtml"> - <block class="Magento\Sales\Block\Order\Item\Renderer\DefaultRenderer" as="default" template="order/creditmemo/items/renderer/default.phtml"/> - <block class="Magento\Sales\Block\Order\Item\Renderer\Grouped" as="grouped" template="order/creditmemo/items/renderer/default.phtml"/> + <block class="Magento\View\Element\RendererList" name="sales.order.print.creditmemo.renderers" as="renderer.list"/> <block class="Magento\Sales\Block\Order\Creditmemo\Totals" name="creditmemo_totals" template="order/totals.phtml" cacheable="false"> <arguments> <argument name="label_properties" xsi:type="string">colspan="6" class="mark"</argument> diff --git a/app/code/Magento/Sales/view/frontend/layout/sales_order_printinvoice.xml b/app/code/Magento/Sales/view/frontend/layout/sales_order_printinvoice.xml index a080901d33eafcbd47d9417cba9c5d1d923b098d..8c6395175efb32993ec9f93a760ebfe1e2394841 100644 --- a/app/code/Magento/Sales/view/frontend/layout/sales_order_printinvoice.xml +++ b/app/code/Magento/Sales/view/frontend/layout/sales_order_printinvoice.xml @@ -24,10 +24,10 @@ */ --> <layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <update handle="sales_order_print_invoice_renderers" /> <referenceContainer name="content"> <block class="Magento\Sales\Block\Order\PrintOrder\Invoice" name="sales.order.print.invoice" template="order/print/invoice.phtml"> - <block class="Magento\Sales\Block\Order\Item\Renderer\DefaultRenderer" as="default" template="order/invoice/items/renderer/default.phtml"/> - <block class="Magento\Sales\Block\Order\Item\Renderer\Grouped" as="grouped" template="order/invoice/items/renderer/default.phtml"/> + <block class="Magento\View\Element\RendererList" name="sales.order.print.invoice.renderers" as="renderer.list" /> <block class="Magento\Sales\Block\Order\Invoice\Totals" name="invoice_totals" template="order/totals.phtml" cacheable="false"> <arguments> <argument name="label_properties" xsi:type="string">colspan="4" class="mark"</argument> diff --git a/app/code/Magento/Sales/view/frontend/layout/sales_order_printshipment.xml b/app/code/Magento/Sales/view/frontend/layout/sales_order_printshipment.xml index 70846a8bc6dfc6568adb9c63d0eb5301d04262de..0908006fc83532b1d35eb3a035cf209f37e12d18 100644 --- a/app/code/Magento/Sales/view/frontend/layout/sales_order_printshipment.xml +++ b/app/code/Magento/Sales/view/frontend/layout/sales_order_printshipment.xml @@ -24,9 +24,10 @@ */ --> <layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <update handle="sales_order_print_shipment_renderers" /> <referenceContainer name="content"> <block class="Magento\Sales\Block\Order\PrintOrder\Shipment" name="sales.order.print.shipment" template="order/print/shipment.phtml"> - <block class="Magento\Sales\Block\Order\Item\Renderer\DefaultRenderer" as="default" template="order/shipment/items/renderer/default.phtml"/> + <block class="Magento\View\Element\RendererList" name="sales.order.print.shipment.renderers" as="renderer.list"/> </block> </referenceContainer> <block class="Magento\View\Element\Template" name="additional.product.info" template="Magento_Core::template.phtml"/> diff --git a/app/code/Magento/Sales/view/frontend/layout/sales_order_shipment_renderers.xml b/app/code/Magento/Sales/view/frontend/layout/sales_order_shipment_renderers.xml new file mode 100644 index 0000000000000000000000000000000000000000..ce2ba02abff2d8edc472b4343293e13cdf7e28b6 --- /dev/null +++ b/app/code/Magento/Sales/view/frontend/layout/sales_order_shipment_renderers.xml @@ -0,0 +1,30 @@ +<?xml version="1.0"?> +<!-- +/** + * 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) + */ +--> +<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <referenceBlock name="sales.order.shipment.renderers"> + <block class="Magento\Sales\Block\Order\Item\Renderer\DefaultRenderer" as="default" template="order/shipment/items/renderer/default.phtml"/> + </referenceBlock> +</layout> diff --git a/app/code/Magento/Sales/view/frontend/layout/sales_order_view.xml b/app/code/Magento/Sales/view/frontend/layout/sales_order_view.xml index ac1f33f1ca9d8b363d8f90a26ee3f3c4a0ae8280..8cfeed067d18f3062fd93dbbfd10cc9e1ea2ed44 100644 --- a/app/code/Magento/Sales/view/frontend/layout/sales_order_view.xml +++ b/app/code/Magento/Sales/view/frontend/layout/sales_order_view.xml @@ -25,14 +25,14 @@ --> <layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <update handle="customer_account"/> + <update handle="sales_order_item_renderers"/> <referenceContainer name="content"> <block class="Magento\Sales\Block\Order\Info" as="info" name="sales.order.info"> <block class="Magento\Sales\Block\Order\Info\Buttons" as="buttons" name="sales.order.info.buttons" cacheable="false"/> </block> <block class="Magento\Sales\Block\Order\View" name="sales.order.view" after="sales.order.info" cacheable="false"> <block class="Magento\Sales\Block\Order\Items" name="order_items" template="order/items.phtml"> - <block class="Magento\Sales\Block\Order\Item\Renderer\DefaultRenderer" as="default" template="order/items/renderer/default.phtml"/> - <block class="Magento\Sales\Block\Order\Item\Renderer\Grouped" as="grouped" template="order/items/renderer/default.phtml"/> + <block class="Magento\View\Element\RendererList" name="sales.order.items.renderers" as="renderer.list" /> <block class="Magento\Sales\Block\Order\Totals" name="order_totals" template="order/totals.phtml"> <arguments> <argument name="label_properties" xsi:type="string">colspan="4" class="mark"</argument> diff --git a/app/code/Magento/SalesRule/Block/Adminhtml/Promo/Quote/Edit/Tab/Coupons/Grid.php b/app/code/Magento/SalesRule/Block/Adminhtml/Promo/Quote/Edit/Tab/Coupons/Grid.php index af304f06f027be3ceb51817db01e96e72c46f034..35da87ab0f25fc960f08fe1ba9635c6779ee89ad 100644 --- a/app/code/Magento/SalesRule/Block/Adminhtml/Promo/Quote/Edit/Tab/Coupons/Grid.php +++ b/app/code/Magento/SalesRule/Block/Adminhtml/Promo/Quote/Edit/Tab/Coupons/Grid.php @@ -50,7 +50,6 @@ class Grid extends \Magento\Backend\Block\Widget\Grid\Extended /** * @param \Magento\Backend\Block\Template\Context $context - * @param \Magento\Core\Model\Url $urlModel * @param \Magento\Backend\Helper\Data $backendHelper * @param \Magento\SalesRule\Model\Resource\Coupon\CollectionFactory $salesRuleCoupon * @param \Magento\Core\Model\Registry $coreRegistry @@ -58,7 +57,6 @@ class Grid extends \Magento\Backend\Block\Widget\Grid\Extended */ public function __construct( \Magento\Backend\Block\Template\Context $context, - \Magento\Core\Model\Url $urlModel, \Magento\Backend\Helper\Data $backendHelper, \Magento\SalesRule\Model\Resource\Coupon\CollectionFactory $salesRuleCoupon, \Magento\Core\Model\Registry $coreRegistry, @@ -66,7 +64,7 @@ class Grid extends \Magento\Backend\Block\Widget\Grid\Extended ) { $this->_coreRegistry = $coreRegistry; $this->_salesRuleCoupon = $salesRuleCoupon; - parent::__construct($context, $urlModel, $backendHelper, $data); + parent::__construct($context, $backendHelper, $data); } /** diff --git a/app/code/Magento/SalesRule/Block/Adminhtml/Promo/Widget/Chooser.php b/app/code/Magento/SalesRule/Block/Adminhtml/Promo/Widget/Chooser.php index d20c3b174cd6de7b10c5c73ef7156dabe49381d2..6bca308be0b0c7df69aab4ca5ab79a55e8cd7a3a 100644 --- a/app/code/Magento/SalesRule/Block/Adminhtml/Promo/Widget/Chooser.php +++ b/app/code/Magento/SalesRule/Block/Adminhtml/Promo/Widget/Chooser.php @@ -17,7 +17,7 @@ * 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) */ @@ -32,20 +32,18 @@ class Chooser extends \Magento\Backend\Block\Widget\Grid\Extended /** * @param \Magento\Backend\Block\Template\Context $context - * @param \Magento\Core\Model\Url $urlModel * @param \Magento\Backend\Helper\Data $backendHelper * @param \Magento\SalesRule\Model\RuleFactory $ruleFactory * @param array $data */ public function __construct( \Magento\Backend\Block\Template\Context $context, - \Magento\Core\Model\Url $urlModel, \Magento\Backend\Helper\Data $backendHelper, \Magento\SalesRule\Model\RuleFactory $ruleFactory, array $data = array() ) { $this->ruleFactory = $ruleFactory; - parent::__construct($context, $urlModel, $backendHelper, $data); + parent::__construct($context, $backendHelper, $data); } /** @@ -134,53 +132,53 @@ class Chooser extends \Magento\Backend\Block\Widget\Grid\Extended protected function _prepareColumns() { $this->addColumn('rule_id', array( - 'header' => __('ID'), - 'align' => 'right', - 'width' => '50px', - 'index' => 'rule_id', - )); + 'header' => __('ID'), + 'align' => 'right', + 'width' => '50px', + 'index' => 'rule_id', + )); $this->addColumn('name', array( - 'header' => __('Rule'), - 'align' => 'left', - 'index' => 'name', - )); + 'header' => __('Rule'), + 'align' => 'left', + 'index' => 'name', + )); $this->addColumn('coupon_code', array( - 'header' => __('Coupon Code'), - 'align' => 'left', - 'width' => '150px', - 'index' => 'code', - )); + 'header' => __('Coupon Code'), + 'align' => 'left', + 'width' => '150px', + 'index' => 'code', + )); $this->addColumn('from_date', array( - 'header' => __('Start on'), - 'align' => 'left', - 'width' => '120px', - 'type' => 'date', - 'index' => 'from_date', - )); + 'header' => __('Start on'), + 'align' => 'left', + 'width' => '120px', + 'type' => 'date', + 'index' => 'from_date', + )); $this->addColumn('to_date', array( - 'header' => __('End on'), - 'align' => 'left', - 'width' => '120px', - 'type' => 'date', - 'default' => '--', - 'index' => 'to_date', - )); + 'header' => __('End on'), + 'align' => 'left', + 'width' => '120px', + 'type' => 'date', + 'default' => '--', + 'index' => 'to_date', + )); $this->addColumn('is_active', array( - 'header' => __('Status'), - 'align' => 'left', - 'width' => '80px', - 'index' => 'is_active', - 'type' => 'options', - 'options' => array( - 1 => 'Active', - 0 => 'Inactive', - ), - )); + 'header' => __('Status'), + 'align' => 'left', + 'width' => '80px', + 'index' => 'is_active', + 'type' => 'options', + 'options' => array( + 1 => 'Active', + 0 => 'Inactive', + ), + )); return parent::_prepareColumns(); } diff --git a/app/code/Magento/SalesRule/etc/adminhtml/di.xml b/app/code/Magento/SalesRule/etc/adminhtml/di.xml index c411729e5b098ce8eeca2e1b9fa21dc82cb88df2..09cab679ac02e7dceeebb14ee6e077db6932c6ed 100644 --- a/app/code/Magento/SalesRule/etc/adminhtml/di.xml +++ b/app/code/Magento/SalesRule/etc/adminhtml/di.xml @@ -26,14 +26,16 @@ <config> <type name="Magento\SalesRule\Helper\Coupon"> <param name="couponParameters"> - <value> - <separator>-</separator> - <charset> - <alphanum>ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789</alphanum> - <alpha>ABCDEFGHIJKLMNOPQRSTUVWXYZ</alpha> - <num>0123456789</num> - </charset> - </value> + <array> + <item key="separator"><value>-</value></item> + <item key="charset"> + <array> + <item key="alphanum"><value>ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789</value></item> + <item key="alpha"><value>ABCDEFGHIJKLMNOPQRSTUVWXYZ</value></item> + <item key="num"><value>0123456789</value></item> + </array> + </item> + </array> </param> </type> </config> diff --git a/app/code/Magento/SalesRule/etc/di.xml b/app/code/Magento/SalesRule/etc/di.xml index 2ce784a1decdfe9b7b14973108c370f3a5a3c992..2f86d60345d63acfc09c620997d57c63d02eb0f4 100644 --- a/app/code/Magento/SalesRule/etc/di.xml +++ b/app/code/Magento/SalesRule/etc/di.xml @@ -30,9 +30,9 @@ </type> <type name="Magento\Module\Updater\SetupFactory"> <param name="resourceTypes"> - <value> - <salesrule_setup>Magento\SalesRule\Model\Resource\Setup</salesrule_setup> - </value> + <array> + <item key="salesrule_setup"><value>Magento\SalesRule\Model\Resource\Setup</value></item> + </array> </param> </type> </config> diff --git a/app/code/Magento/Sendfriend/Controller/Product.php b/app/code/Magento/Sendfriend/Controller/Product.php index e8cace7f2e0a00fd61150aa134e69558cdd389bc..61c2220522c2de438eb3056957b96889ffea5878 100644 --- a/app/code/Magento/Sendfriend/Controller/Product.php +++ b/app/code/Magento/Sendfriend/Controller/Product.php @@ -88,7 +88,7 @@ class Product extends \Magento\App\Action\Action $this->_actionFlag->set('', self::FLAG_NO_DISPATCH, true); if ($this->getRequest()->getActionName() == 'sendemail') { $session->setBeforeAuthUrl($this->_objectManager - ->create('Magento\Core\Model\Url') + ->create('Magento\UrlInterface') ->getUrl('*/*/send', array( '_current' => true ))); @@ -246,7 +246,7 @@ class Product extends \Magento\App\Action\Action $catalogSession->setSendfriendFormData($data); $url = $this->_objectManager - ->create('Magento\Core\Model\Url') + ->create('Magento\UrlInterface') ->getUrl('*/*/send', array('_current' => true)); $this->getResponse()->setRedirect($this->_redirect->error($url)); } diff --git a/app/code/Magento/Shipping/Block/Adminhtml/Carrier/Tablerate/Grid.php b/app/code/Magento/Shipping/Block/Adminhtml/Carrier/Tablerate/Grid.php index 8ab9b62ea10f957a22c30ab20d232ef20da6b852..46672da0c9205875d73558f9f307eafae6bc1499 100644 --- a/app/code/Magento/Shipping/Block/Adminhtml/Carrier/Tablerate/Grid.php +++ b/app/code/Magento/Shipping/Block/Adminhtml/Carrier/Tablerate/Grid.php @@ -62,7 +62,6 @@ class Grid extends \Magento\Backend\Block\Widget\Grid\Extended /** * @param \Magento\Backend\Block\Template\Context $context - * @param \Magento\Core\Model\Url $urlModel * @param \Magento\Backend\Helper\Data $backendHelper * @param \Magento\Shipping\Model\Resource\Carrier\Tablerate\CollectionFactory $collectionFactory * @param \Magento\Shipping\Model\Carrier\Tablerate $tablerate @@ -70,7 +69,6 @@ class Grid extends \Magento\Backend\Block\Widget\Grid\Extended */ public function __construct( \Magento\Backend\Block\Template\Context $context, - \Magento\Core\Model\Url $urlModel, \Magento\Backend\Helper\Data $backendHelper, \Magento\Shipping\Model\Resource\Carrier\Tablerate\CollectionFactory $collectionFactory, \Magento\Shipping\Model\Carrier\Tablerate $tablerate, @@ -78,7 +76,7 @@ class Grid extends \Magento\Backend\Block\Widget\Grid\Extended ) { $this->_collectionFactory = $collectionFactory; $this->_tablerate = $tablerate; - parent::__construct($context, $urlModel, $backendHelper, $data); + parent::__construct($context, $backendHelper, $data); } /** diff --git a/app/code/Magento/Shipping/Model/Config/Backend/Tablerate.php b/app/code/Magento/Shipping/Model/Config/Backend/Tablerate.php index 00d0e6a579439e9a3a06f343214ef928ba78bdba..f486f7d75b4a735c9cee54b72d299ae710e2cc92 100644 --- a/app/code/Magento/Shipping/Model/Config/Backend/Tablerate.php +++ b/app/code/Magento/Shipping/Model/Config/Backend/Tablerate.php @@ -45,7 +45,7 @@ class Tablerate extends \Magento\Core\Model\Config\Value * @param \Magento\Core\Model\Context $context * @param \Magento\Core\Model\Registry $registry * @param \Magento\Core\Model\StoreManagerInterface $storeManager - * @param \Magento\Core\Model\Config $config + * @param \Magento\App\ConfigInterface $config * @param \Magento\Shipping\Model\Resource\Carrier\TablerateFactory $tablerateFactory * @param \Magento\Core\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection @@ -55,7 +55,7 @@ class Tablerate extends \Magento\Core\Model\Config\Value \Magento\Core\Model\Context $context, \Magento\Core\Model\Registry $registry, \Magento\Core\Model\StoreManagerInterface $storeManager, - \Magento\Core\Model\Config $config, + \Magento\App\ConfigInterface $config, \Magento\Shipping\Model\Resource\Carrier\TablerateFactory $tablerateFactory, \Magento\Core\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, diff --git a/app/code/Magento/Shipping/Model/Resource/Carrier/Tablerate.php b/app/code/Magento/Shipping/Model/Resource/Carrier/Tablerate.php index 4d7365b57d38b44953adfd91a544eec1887814f5..92c32c7d01dd5aa535cef5d5913ed865e39cbc1b 100644 --- a/app/code/Magento/Shipping/Model/Resource/Carrier/Tablerate.php +++ b/app/code/Magento/Shipping/Model/Resource/Carrier/Tablerate.php @@ -100,7 +100,7 @@ class Tablerate extends \Magento\Core\Model\Resource\Db\AbstractDb protected $_conditionFullNames = array(); /** - * @var \Magento\Core\Model\Config + * @var \Magento\App\ConfigInterface */ protected $_coreConfig; @@ -139,7 +139,7 @@ class Tablerate extends \Magento\Core\Model\Resource\Db\AbstractDb /** * @param \Magento\App\Resource $resource * @param \Magento\Logger $logger - * @param \Magento\Core\Model\Config $coreConfig + * @param \Magento\App\ConfigInterface $coreConfig * @param \Magento\Core\Model\StoreManagerInterface $storeManager * @param \Magento\Shipping\Model\Carrier\Tablerate $carrierTablerate * @param \Magento\Directory\Model\Resource\Country\CollectionFactory $countryCollectionFactory @@ -149,7 +149,7 @@ class Tablerate extends \Magento\Core\Model\Resource\Db\AbstractDb public function __construct( \Magento\App\Resource $resource, \Magento\Logger $logger, - \Magento\Core\Model\Config $coreConfig, + \Magento\App\ConfigInterface $coreConfig, \Magento\Core\Model\StoreManagerInterface $storeManager, \Magento\Shipping\Model\Carrier\Tablerate $carrierTablerate, \Magento\Directory\Model\Resource\Country\CollectionFactory $countryCollectionFactory, diff --git a/app/code/Magento/Shipping/view/frontend/layout/sales_guest_shipment.xml b/app/code/Magento/Shipping/view/frontend/layout/sales_guest_shipment.xml index 514bfcc9d82e28f3044faa9858613f273be01ab2..0d905bf0aacc2e595d6d20ee6af6a35fd05f384e 100644 --- a/app/code/Magento/Shipping/view/frontend/layout/sales_guest_shipment.xml +++ b/app/code/Magento/Shipping/view/frontend/layout/sales_guest_shipment.xml @@ -24,17 +24,18 @@ */ --> <layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <update handle="sales_order_shipment_renderers" /> <referenceContainer name="content"> <block class="Magento\Shipping\Block\Order\Shipment" name="sales.order.shipment" after="sales.order.info" cacheable="false"> <block class="Magento\Shipping\Block\Items" name="shipment_items" template="items.phtml"> + <block class="Magento\View\Element\RendererList" name="sales.order.shipment.renderers" as="renderer.list" /> <block class="Magento\Shipping\Block\Tracking\Link" name="track-all-link" template="tracking/link.phtml"> <arguments> <argument name="label" xsi:type="string">Track All Shipments</argument> </arguments> </block> - <block class="Magento\Sales\Block\Order\Item\Renderer\DefaultRenderer" as="default" template="Magento_Sales::order/shipment/items/renderer/default.phtml"/> <block class="Magento\Sales\Block\Order\Comments" name="shipment_comments" template="order/comments.phtml"/> </block> </block> </referenceContainer> -</layout> \ No newline at end of file +</layout> diff --git a/app/code/Magento/Shipping/view/frontend/layout/sales_order_shipment.xml b/app/code/Magento/Shipping/view/frontend/layout/sales_order_shipment.xml index 514bfcc9d82e28f3044faa9858613f273be01ab2..0d905bf0aacc2e595d6d20ee6af6a35fd05f384e 100644 --- a/app/code/Magento/Shipping/view/frontend/layout/sales_order_shipment.xml +++ b/app/code/Magento/Shipping/view/frontend/layout/sales_order_shipment.xml @@ -24,17 +24,18 @@ */ --> <layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <update handle="sales_order_shipment_renderers" /> <referenceContainer name="content"> <block class="Magento\Shipping\Block\Order\Shipment" name="sales.order.shipment" after="sales.order.info" cacheable="false"> <block class="Magento\Shipping\Block\Items" name="shipment_items" template="items.phtml"> + <block class="Magento\View\Element\RendererList" name="sales.order.shipment.renderers" as="renderer.list" /> <block class="Magento\Shipping\Block\Tracking\Link" name="track-all-link" template="tracking/link.phtml"> <arguments> <argument name="label" xsi:type="string">Track All Shipments</argument> </arguments> </block> - <block class="Magento\Sales\Block\Order\Item\Renderer\DefaultRenderer" as="default" template="Magento_Sales::order/shipment/items/renderer/default.phtml"/> <block class="Magento\Sales\Block\Order\Comments" name="shipment_comments" template="order/comments.phtml"/> </block> </block> </referenceContainer> -</layout> \ No newline at end of file +</layout> diff --git a/app/code/Magento/Sitemap/Model/Sitemap.php b/app/code/Magento/Sitemap/Model/Sitemap.php index 83ac6d0b323c354fc567468d08f3c408546ecaf9..b09e67f21bf029bed8abbd0d48e58b99a2dba2b9 100644 --- a/app/code/Magento/Sitemap/Model/Sitemap.php +++ b/app/code/Magento/Sitemap/Model/Sitemap.php @@ -561,7 +561,7 @@ class Sitemap extends \Magento\Core\Model\AbstractModel * @param string $type * @return string */ - protected function _getStoreBaseUrl($type = \Magento\Core\Model\Store::URL_TYPE_LINK) + protected function _getStoreBaseUrl($type = \Magento\UrlInterface::URL_TYPE_LINK) { return rtrim($this->_storeManager->getStore($this->getStoreId())->getBaseUrl($type), '/') . '/'; } @@ -573,7 +573,7 @@ class Sitemap extends \Magento\Core\Model\AbstractModel * @param string $type * @return string */ - protected function _getUrl($url, $type = \Magento\Core\Model\Store::URL_TYPE_LINK) + protected function _getUrl($url, $type = \Magento\UrlInterface::URL_TYPE_LINK) { return $this->_getStoreBaseUrl($type) . ltrim($url, '/'); } @@ -586,7 +586,7 @@ class Sitemap extends \Magento\Core\Model\AbstractModel */ protected function _getMediaUrl($url) { - return $this->_getUrl($url, \Magento\Core\Model\Store::URL_TYPE_MEDIA); + return $this->_getUrl($url, \Magento\UrlInterface::URL_TYPE_MEDIA); } /** @@ -629,7 +629,7 @@ class Sitemap extends \Magento\Core\Model\AbstractModel $storeDomain = rtrim($url . '/' . $installationFolder, '/'); } else { //case when documentRoot contains symlink to basedir - $url = $this->_getStoreBaseUrl(\Magento\Core\Model\Store::URL_TYPE_WEB); + $url = $this->_getStoreBaseUrl(\Magento\UrlInterface::URL_TYPE_WEB); $storeDomain = rtrim($url, '/'); } diff --git a/app/code/Magento/Tax/Model/Config/Price/IncludePrice.php b/app/code/Magento/Tax/Model/Config/Price/IncludePrice.php index 5131c2d073d4c486297a85a6de5bb9e541e2fa93..41ce467fa9ae69778ce29fce5b67c50fe60b71eb 100644 --- a/app/code/Magento/Tax/Model/Config/Price/IncludePrice.php +++ b/app/code/Magento/Tax/Model/Config/Price/IncludePrice.php @@ -37,7 +37,7 @@ class IncludePrice extends \Magento\Core\Model\Config\Value * @param \Magento\Core\Model\Context $context * @param \Magento\Core\Model\Registry $registry * @param \Magento\Core\Model\StoreManagerInterface $storeManager - * @param \Magento\Core\Model\Config $config + * @param \Magento\App\ConfigInterface $config * @param \Magento\Core\Model\App $app * @param \Magento\Core\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection @@ -47,7 +47,7 @@ class IncludePrice extends \Magento\Core\Model\Config\Value \Magento\Core\Model\Context $context, \Magento\Core\Model\Registry $registry, \Magento\Core\Model\StoreManagerInterface $storeManager, - \Magento\Core\Model\Config $config, + \Magento\App\ConfigInterface $config, \Magento\Core\Model\App $app, \Magento\Core\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, diff --git a/app/code/Magento/Tax/Model/Resource/Setup.php b/app/code/Magento/Tax/Model/Resource/Setup.php index 03a4c4177976f44ac147296b553387d9f7fc29d0..d3876846b83b62a297e6f9eae90042ca2bf7e7da 100644 --- a/app/code/Magento/Tax/Model/Resource/Setup.php +++ b/app/code/Magento/Tax/Model/Resource/Setup.php @@ -41,7 +41,7 @@ class Setup extends \Magento\Sales\Model\Resource\Setup * @param string $resourceName * @param \Magento\App\CacheInterface $cache * @param \Magento\Eav\Model\Resource\Entity\Attribute\Group\CollectionFactory $attrGroupCollectionFactory - * @param \Magento\Core\Model\Config $config + * @param \Magento\App\ConfigInterface $config * @param \Magento\Catalog\Model\Resource\SetupFactory $setupFactory * @param string $moduleName * @param string $connectionName @@ -51,7 +51,7 @@ class Setup extends \Magento\Sales\Model\Resource\Setup $resourceName, \Magento\App\CacheInterface $cache, \Magento\Eav\Model\Resource\Entity\Attribute\Group\CollectionFactory $attrGroupCollectionFactory, - \Magento\Core\Model\Config $config, + \Magento\App\ConfigInterface $config, \Magento\Catalog\Model\Resource\SetupFactory $setupFactory, $moduleName = 'Magento_Tax', $connectionName = '' diff --git a/app/code/Magento/Tax/etc/di.xml b/app/code/Magento/Tax/etc/di.xml index a3a3cccb3cc732e783111364b243e5036ab87d9c..8a88e481c39821e3114fcdd545965ba4a7856f9a 100644 --- a/app/code/Magento/Tax/etc/di.xml +++ b/app/code/Magento/Tax/etc/di.xml @@ -31,9 +31,9 @@ </type> <type name="Magento\Module\Updater\SetupFactory"> <param name="resourceTypes"> - <value> - <tax_setup>Magento\Tax\Model\Resource\Setup</tax_setup> - </value> + <array> + <item key="tax_setup"><value>Magento\Tax\Model\Resource\Setup</value></item> + </array> </param> </type> <type name="Magento\Tax\Model\Resource\Calculation"> diff --git a/app/code/Magento/Theme/Block/Html.php b/app/code/Magento/Theme/Block/Html.php index f8bb35b1b90b59eed59ff0bb209c9ad7babcaa1d..7c2ebee96a9ac1629aa5b184f05e04de9d37a690 100644 --- a/app/code/Magento/Theme/Block/Html.php +++ b/app/code/Magento/Theme/Block/Html.php @@ -57,7 +57,7 @@ class Html extends \Magento\View\Element\Template $this->addBodyClass($this->_request->getFullActionName('-')); if ($this->_cacheState->isEnabled(self::CACHE_GROUP)) { - $this->_app->setUseSessionVar(true); + $this->_sidResolver->setUseSessionVar(true); } } @@ -119,7 +119,7 @@ class Html extends \Magento\View\Element\Template // buld url if (!empty($logo)) { - $logo = $this->_urlBuilder->getBaseUrl(array('_type' => \Magento\Core\Model\Store::URL_TYPE_MEDIA)) . $logo; + $logo = $this->_urlBuilder->getBaseUrl(array('_type' => \Magento\UrlInterface::URL_TYPE_MEDIA)) . $logo; } else { $logo = ''; } @@ -214,7 +214,7 @@ class Html extends \Magento\View\Element\Template protected function _afterToHtml($html) { if ($this->_cacheState->isEnabled(self::CACHE_GROUP)) { - $this->_app->setUseSessionVar(false); + $this->_sidResolver->setUseSessionVar(false); \Magento\Profiler::start('CACHE_URL'); $html = $this->_urlBuilder->sessionUrlVar($html); \Magento\Profiler::stop('CACHE_URL'); diff --git a/app/code/Magento/Theme/Block/Html/Head.php b/app/code/Magento/Theme/Block/Html/Head.php index 09600c188ace86278972b4386685d20afee27e49..4902352edb13bf83e08af1786d1b11e6b03462a3 100644 --- a/app/code/Magento/Theme/Block/Html/Head.php +++ b/app/code/Magento/Theme/Block/Html/Head.php @@ -386,7 +386,8 @@ class Head extends \Magento\View\Element\Template $folderName = \Magento\Backend\Model\Config\Backend\Image\Favicon::UPLOAD_DIR; $storeConfig = $this->_storeConfig->getConfig('design/head/shortcut_icon'); $path = $folderName . '/' . $storeConfig; - $faviconFile = $this->_storeManager->getStore()->getBaseUrl('media') . $path; + $faviconFile = $this->_storeManager->getStore() + ->getBaseUrl(\Magento\UrlInterface::URL_TYPE_MEDIA) . $path; if (!is_null($storeConfig) && $this->_isFile($path)) { $url = $faviconFile; diff --git a/app/code/Magento/Theme/Block/Html/Header.php b/app/code/Magento/Theme/Block/Html/Header.php index ff028e4139d3e3a03fbe96994c6b65857b967fae..32f9a799ab86ea74b5257d1366ebf0c9b02933bd 100644 --- a/app/code/Magento/Theme/Block/Html/Header.php +++ b/app/code/Magento/Theme/Block/Html/Header.php @@ -130,7 +130,7 @@ class Header extends \Magento\View\Element\Template $folderName = \Magento\Backend\Model\Config\Backend\Image\Logo::UPLOAD_DIR; $storeLogoPath = $this->_storeConfig->getConfig('design/header/logo_src'); $path = $folderName . '/' . $storeLogoPath; - $logoUrl = $this->_urlBuilder->getBaseUrl(array('_type' => \Magento\Core\Model\Store::URL_TYPE_MEDIA)) . $path; + $logoUrl = $this->_urlBuilder->getBaseUrl(array('_type' => \Magento\UrlInterface::URL_TYPE_MEDIA)) . $path; if (!is_null($storeLogoPath) && $this->_isFile($path)) { $url = $logoUrl; diff --git a/app/code/Magento/Theme/Block/Html/Notices.php b/app/code/Magento/Theme/Block/Html/Notices.php index f8cf1a1c2797a3972194026c79a2d78094455cb7..64740be03ec2efa2ab6e19c1e75a74cb58ed1055 100644 --- a/app/code/Magento/Theme/Block/Html/Notices.php +++ b/app/code/Magento/Theme/Block/Html/Notices.php @@ -29,22 +29,14 @@ namespace Magento\Theme\Block\Html; */ class Notices extends \Magento\View\Element\Template { - /** - * @var \Magento\Core\Model\Url - */ - protected $_urlModel; - /** * @param \Magento\View\Element\Template\Context $context - * @param \Magento\Core\Model\Url $urlModel * @param array $data */ public function __construct( \Magento\View\Element\Template\Context $context, - \Magento\Core\Model\Url $urlModel, array $data = array() ) { - $this->_urlModel = $urlModel; parent::__construct($context, $data); } @@ -75,6 +67,6 @@ class Notices extends \Magento\View\Element\Template */ public function getPrivacyPolicyLink() { - return $this->_urlModel->getUrl('privacy-policy-cookie-restriction-mode'); + return $this->_urlBuilder->getUrl('privacy-policy-cookie-restriction-mode'); } } diff --git a/app/code/Magento/Theme/Model/Config.php b/app/code/Magento/Theme/Model/Config.php index 3a6f43c3cf4db479e7a51382b932183c966825d4..f40d94b7b6a1bbc3a59f1d22bd8a298c85b92f09 100644 --- a/app/code/Magento/Theme/Model/Config.php +++ b/app/code/Magento/Theme/Model/Config.php @@ -37,7 +37,7 @@ class Config protected $_configWriter; /** - * @var \Magento\Core\Model\Config\Value + * @var \Magento\App\Config\ValueInterface */ protected $_configData; @@ -64,7 +64,7 @@ class Config protected $_layoutCache; /** - * @param \Magento\Core\Model\Config\Value $configData + * @param \Magento\App\Config\ValueInterface $configData * @param \Magento\Core\Model\Config\Storage\WriterInterface $configWriter * @param \Magento\Core\Model\StoreManagerInterface $storeManager * @param \Magento\Event\ManagerInterface $eventManager @@ -72,7 +72,7 @@ class Config * @param \Magento\Cache\FrontendInterface $layoutCache */ public function __construct( - \Magento\Core\Model\Config\Value $configData, + \Magento\App\Config\ValueInterface $configData, \Magento\Core\Model\Config\Storage\WriterInterface $configWriter, \Magento\Core\Model\StoreManagerInterface $storeManager, \Magento\Event\ManagerInterface $eventManager, @@ -95,8 +95,11 @@ class Config * @param string $scope * @return $this */ - public function assignToStore($theme, array $stores = array(), $scope = \Magento\Core\Model\Config::SCOPE_STORES) - { + public function assignToStore( + $theme, + array $stores = array(), + $scope = \Magento\Core\Model\ScopeInterface::SCOPE_STORES + ) { $isReassigned = false; $this->_unassignThemeFromStores( @@ -191,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\Config::SCOPE_DEFAULT); + $this->_configWriter->save($configPath, $themeId, \Magento\Core\Model\ScopeInterface::SCOPE_DEFAULT); $isReassigned = true; return $this; } diff --git a/app/code/Magento/Theme/etc/di.xml b/app/code/Magento/Theme/etc/di.xml index ad6d2b5d914cc866dffe25d5a24354a3161969b9..b1e7b0e503c6dd56caf3bd3579d314ae489c8809 100644 --- a/app/code/Magento/Theme/etc/di.xml +++ b/app/code/Magento/Theme/etc/di.xml @@ -34,10 +34,10 @@ </type> <type name="Magento\Theme\Model\Uploader\Service"> <param name="uploadLimits"> - <value> - <css>2M</css> - <js>2M</js> - </value> + <array> + <item key="css"><value>2M</value></item> + <item key="js"><value>2M</value></item> + </array> </param> </type> <type name="Magento\Theme\Model\Layout\Config\Reader"> diff --git a/app/code/Magento/Theme/view/frontend/html/breadcrumbs.phtml b/app/code/Magento/Theme/view/frontend/html/breadcrumbs.phtml index 7e7f174b21f92f58549602cc8796e79ef5366f5f..e358f2e12f49fe4471ee30cf57d12174828e7dd4 100644 --- a/app/code/Magento/Theme/view/frontend/html/breadcrumbs.phtml +++ b/app/code/Magento/Theme/view/frontend/html/breadcrumbs.phtml @@ -23,17 +23,19 @@ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */ ?> -<?php if($crumbs && is_array($crumbs)): ?> +<?php if ($crumbs && is_array($crumbs)) : ?> <div class="breadcrumbs"> <ul class="items"> - <?php foreach($crumbs as $_crumbName=>$_crumbInfo): ?> - <li class="item <?php echo $_crumbName ?>"> - <?php if($_crumbInfo['link']): ?> - <a href="<?php echo $_crumbInfo['link'] ?>" title="<?php echo $this->escapeHtml($_crumbInfo['title']) ?>"><?php echo $this->escapeHtml($_crumbInfo['label']) ?></a> - <?php elseif($_crumbInfo['last']): ?> - <strong><?php echo $this->escapeHtml($_crumbInfo['label']) ?></strong> + <?php foreach ($crumbs as $crumbName => $crumbInfo) : ?> + <li class="item <?php echo $crumbName ?>"> + <?php if ($crumbInfo['link']) : ?> + <a href="<?php echo $crumbInfo['link'] ?>" title="<?php echo $this->escapeHtml($crumbInfo['title']) ?>"> + <?php echo $this->escapeHtml($crumbInfo['label']) ?> + </a> + <?php elseif ($crumbInfo['last']) : ?> + <strong><?php echo $this->escapeHtml($crumbInfo['label']) ?></strong> <?php else: ?> - <?php echo $this->escapeHtml($_crumbInfo['label']) ?> + <?php echo $this->escapeHtml($crumbInfo['label']) ?> <?php endif; ?> </li> <?php endforeach; ?> diff --git a/app/code/Magento/Usa/etc/di.xml b/app/code/Magento/Usa/etc/di.xml index fd18f534c118a4092e81b02d7daf071e4446ba86..d3567f0116046051b9a0669884a69a78f2474bfd 100644 --- a/app/code/Magento/Usa/etc/di.xml +++ b/app/code/Magento/Usa/etc/di.xml @@ -26,9 +26,9 @@ <config> <type name="Magento\Module\Updater\SetupFactory"> <param name="resourceTypes"> - <value> - <usa_setup>Magento\Usa\Model\Resource\Setup</usa_setup> - </value> + <array> + <item key="usa_setup"><value>Magento\Usa\Model\Resource\Setup</value></item> + </array> </param> </type> </config> diff --git a/app/code/Magento/User/Block/Role/Grid/User.php b/app/code/Magento/User/Block/Role/Grid/User.php index 57727524e09bc93bbbfeff46beeb745605b8760f..da95b46590381d6a5f3f52d5587575fdb38e667b 100644 --- a/app/code/Magento/User/Block/Role/Grid/User.php +++ b/app/code/Magento/User/Block/Role/Grid/User.php @@ -50,7 +50,6 @@ class User extends \Magento\Backend\Block\Widget\Grid\Extended /** * @param \Magento\Backend\Block\Template\Context $context - * @param \Magento\Core\Model\Url $urlModel * @param \Magento\Backend\Helper\Data $backendHelper * @param \Magento\Json\EncoderInterface $jsonEncoder * @param \Magento\Core\Model\Registry $coreRegistry @@ -59,14 +58,13 @@ class User extends \Magento\Backend\Block\Widget\Grid\Extended */ public function __construct( \Magento\Backend\Block\Template\Context $context, - \Magento\Core\Model\Url $urlModel, \Magento\Backend\Helper\Data $backendHelper, \Magento\Json\EncoderInterface $jsonEncoder, \Magento\Core\Model\Registry $coreRegistry, \Magento\User\Model\RoleFactory $roleFactory, array $data = array() ) { - parent::__construct($context, $urlModel, $backendHelper, $data); + parent::__construct($context, $backendHelper, $data); $this->_jsonEncoder = $jsonEncoder; $this->_coreRegistry = $coreRegistry; $this->_roleFactory = $roleFactory; diff --git a/app/code/Magento/User/Block/User/Edit/Tab/Roles.php b/app/code/Magento/User/Block/User/Edit/Tab/Roles.php index 4eba9a1d87d5185fecae5125d0f7a6a3ac881757..cc496d68128ecdc3aceea2c60620f765b246459f 100644 --- a/app/code/Magento/User/Block/User/Edit/Tab/Roles.php +++ b/app/code/Magento/User/Block/User/Edit/Tab/Roles.php @@ -48,7 +48,6 @@ class Roles extends \Magento\Backend\Block\Widget\Grid\Extended /** * @param \Magento\Backend\Block\Template\Context $context - * @param \Magento\Core\Model\Url $urlModel * @param \Magento\Backend\Helper\Data $backendHelper * @param \Magento\Json\EncoderInterface $jsonEncoder * @param \Magento\User\Model\Resource\Role\CollectionFactory $userRolesFactory @@ -57,7 +56,6 @@ class Roles extends \Magento\Backend\Block\Widget\Grid\Extended */ public function __construct( \Magento\Backend\Block\Template\Context $context, - \Magento\Core\Model\Url $urlModel, \Magento\Backend\Helper\Data $backendHelper, \Magento\Json\EncoderInterface $jsonEncoder, \Magento\User\Model\Resource\Role\CollectionFactory $userRolesFactory, @@ -67,7 +65,7 @@ class Roles extends \Magento\Backend\Block\Widget\Grid\Extended $this->_jsonEncoder = $jsonEncoder; $this->_userRolesFactory = $userRolesFactory; $this->_coreRegistry = $coreRegistry; - parent::__construct($context, $urlModel, $backendHelper, $data); + parent::__construct($context, $backendHelper, $data); } protected function _construct() diff --git a/app/code/Magento/User/Model/User.php b/app/code/Magento/User/Model/User.php index bd4191de29e2468c4e26f810b9dfb6db6ec2abec..4cd95ead3db1e4df3fa7dbc9135f7460c1665a9b 100644 --- a/app/code/Magento/User/Model/User.php +++ b/app/code/Magento/User/Model/User.php @@ -532,7 +532,7 @@ class User */ public function authenticate($username, $password) { - $config = $this->_config->getFlag('admin/security/use_case_sensitive_login'); + $config = $this->_config->isSetFlag('admin/security/use_case_sensitive_login'); $result = false; try { diff --git a/app/code/Magento/User/etc/di.xml b/app/code/Magento/User/etc/di.xml index 2b49a54b1e4f2e76a5b76f96c61d2283652afe63..9330d554a19b101fd899561fcbf39771c7fe9b99 100644 --- a/app/code/Magento/User/etc/di.xml +++ b/app/code/Magento/User/etc/di.xml @@ -41,9 +41,9 @@ </type> <type name="Magento\Module\Updater\SetupFactory"> <param name="resourceTypes"> - <value> - <user_setup>Magento\User\Model\Resource\Setup</user_setup> - </value> + <array> + <item key="user_setup"><value>Magento\User\Model\Resource\Setup</value></item> + </array> </param> </type> <type name="Magento\Acl\Builder"> diff --git a/app/code/Magento/Webapi/Controller/Rest.php b/app/code/Magento/Webapi/Controller/Rest.php index b90d17b0344a0161a91464381b287dda5331f306..98b2a14b2ae82933c0ff392e4b13d1a2784fa695 100644 --- a/app/code/Magento/Webapi/Controller/Rest.php +++ b/app/code/Magento/Webapi/Controller/Rest.php @@ -25,11 +25,14 @@ namespace Magento\Webapi\Controller; use Magento\Authz\Service\AuthorizationV1Interface as AuthorizationService; +use Magento\Webapi\Controller\Rest\Router\Route; +use Magento\Service\Entity\MagentoDtoInterface; /** * Front controller for WebAPI REST area. * - * TODO: Fix coupling between objects + * TODO: Consider warnings suppression removal + * * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class Rest implements \Magento\App\FrontControllerInterface @@ -58,7 +61,18 @@ class Rest implements \Magento\App\FrontControllerInterface /** @var AuthorizationService */ protected $_authorizationService; + /** @var ServiceArgsSerializer */ + protected $_serializer; + + /** @var \Magento\Webapi\Controller\ErrorProcessor */ + protected $_errorProcessor; + /** + * Initialize dependencies. + * + * TODO: Consider removal of warning suppression + * + * @SuppressWarnings(PHPMD.ExcessiveParameterList) * @param Rest\Request $request * @param Rest\Response $response * @param Rest\Router $router @@ -67,6 +81,8 @@ class Rest implements \Magento\App\FrontControllerInterface * @param \Magento\Oauth\OauthInterface $oauthService * @param \Magento\Oauth\Helper\Request $oauthHelper * @param AuthorizationService $authorizationService + * @param ServiceArgsSerializer $serializer + * @param \Magento\Webapi\Controller\ErrorProcessor $errorProcessor */ public function __construct( \Magento\Webapi\Controller\Rest\Request $request, @@ -76,7 +92,9 @@ class Rest implements \Magento\App\FrontControllerInterface \Magento\App\State $appState, \Magento\Oauth\OauthInterface $oauthService, \Magento\Oauth\Helper\Request $oauthHelper, - AuthorizationService $authorizationService + AuthorizationService $authorizationService, + ServiceArgsSerializer $serializer, + \Magento\Webapi\Controller\ErrorProcessor $errorProcessor ) { $this->_router = $router; $this->_request = $request; @@ -86,16 +104,8 @@ class Rest implements \Magento\App\FrontControllerInterface $this->_oauthService = $oauthService; $this->_oauthHelper = $oauthHelper; $this->_authorizationService = $authorizationService; - } - - /** - * Initialize front controller - * - * @return \Magento\Webapi\Controller\Rest - */ - public function init() - { - return $this; + $this->_serializer = $serializer; + $this->_errorProcessor = $errorProcessor; } /** @@ -113,16 +123,13 @@ class Rest implements \Magento\App\FrontControllerInterface if (!$this->_appState->isInstalled()) { throw new \Magento\Webapi\Exception(__('Magento is not yet installed')); } - // TODO: Consider changing service interface to operate with objects to avoid overhead - $requestUrl = $this->_oauthHelper->getRequestUrl($this->_request); - $oauthRequest = $this->_oauthHelper->prepareRequest( - $this->_request, $requestUrl, $this->_request->getRequestData() - ); + $oauthRequest = $this->_oauthHelper->prepareRequest($this->_request); $consumerId = $this->_oauthService->validateAccessTokenRequest( - $oauthRequest, $requestUrl, $this->_request->getMethod() + $oauthRequest, + $this->_oauthHelper->getRequestUrl($this->_request), + $this->_request->getMethod() ); $this->_request->setConsumerId($consumerId); - $route = $this->_router->match($this->_request); if (!$this->_authorizationService->isAllowed($route->getAclResources())) { @@ -142,19 +149,66 @@ class Rest implements \Magento\App\FrontControllerInterface } /** @var array $inputData */ $inputData = $this->_request->getRequestData(); - $serviceMethod = $route->getServiceMethod(); - $service = $this->_objectManager->get($route->getServiceClass()); - $outputData = $service->$serviceMethod($inputData); - if (!is_array($outputData)) { - throw new \LogicException( - sprintf('The method "%s" of service "%s" must return an array.', $serviceMethod, - $route->getServiceClass()) - ); - } - $this->_response->prepareResponse($outputData); + $serviceMethodName = $route->getServiceMethod(); + $serviceClassName = $route->getServiceClass(); + $inputParams = $this->_serializer->getInputData($serviceClassName, $serviceMethodName, $inputData); + $service = $this->_objectManager->get($serviceClassName); + /** @var \Magento\Service\Entity\AbstractDto $outputData */ + $outputData = call_user_func_array([$service, $serviceMethodName], $inputParams); + $outputArray = $this->_processServiceOutput($outputData); + $this->_response->prepareResponse($outputArray); } catch (\Exception $e) { - $this->_response->setException($e); + $maskedException = $this->_errorProcessor->maskException($e); + $this->_response->setException($maskedException); } return $this->_response; } + + /** + * Converts the incoming data into scalar or an array of scalars format. + * + * If the data provided is null, then an empty array is returned. Otherwise, if the data is an object, it is + * assumed to be a DTO and converted to an associative array with keys representing the properties of the DTO. + * Nested DTOs are also converted. If the data provided is itself an array, then we iterate through the contents + * and convert each piece individually. + * + * @param mixed $data + * @return array|int|string|bool|float Scalar or array of scalars + */ + protected function _processServiceOutput($data) + { + if (is_array($data)) { + $result = []; + foreach ($data as $datum) { + if (is_object($datum)) { + $result[] = $this->_convertDtoToArray($datum); + } else { + $result[] = $datum; + } + } + } else if (is_object($data)) { + $result = $this->_convertDtoToArray($data); + } else if (is_null($data)) { + $result = []; + } else { + /** No processing is required for scalar types */ + $result = $data; + } + return $result; + } + + /** + * Convert DTO to array. + * + * @param object $dto + * @return array + * @throws \InvalidArgumentException + */ + protected function _convertDtoToArray($dto) + { + if (!is_object($dto) || !method_exists($dto, '__toArray')) { + throw new \InvalidArgumentException("All objects returned by service must implement __toArray()."); + } + return $dto->__toArray(); + } } diff --git a/app/code/Magento/Webapi/Controller/ServiceArgsSerializer.php b/app/code/Magento/Webapi/Controller/ServiceArgsSerializer.php new file mode 100644 index 0000000000000000000000000000000000000000..4a8ce5ea919ddf62aaf723506a1bbbac51b8b80f --- /dev/null +++ b/app/code/Magento/Webapi/Controller/ServiceArgsSerializer.php @@ -0,0 +1,171 @@ +<?php +/** + * Service Args Serializer + * + * 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\Webapi\Controller; + +use Zend\Code\Reflection\ClassReflection; +use Zend\Code\Reflection\MethodReflection; +use Zend\Code\Reflection\ParameterReflection; +use Magento\Webapi\Model\Config\ClassReflector\TypeProcessor; +use Magento\Webapi\Model\Soap\Wsdl\ComplexTypeStrategy; + +class ServiceArgsSerializer +{ + /** @var \Magento\Webapi\Model\Config\ClassReflector\TypeProcessor */ + protected $_typeProcessor; + + /** + * Initialize dependencies. + * + * @param TypeProcessor $typeProcessor + */ + public function __construct(TypeProcessor $typeProcessor) + { + $this->_typeProcessor = $typeProcessor; + } + + /** + * Converts the provided input array from key-value format to a list of parameters suitable for the specified + * class / method. + * + * The input array should have the field name as the key, and the value will either be a primitive or another + * key-value array. The top level of this array needs keys that match the names of the parameters on the + * service method. + * + * Mismatched types are caught by the PHP runtime, not explicitly checked for by this code. + * + * @param string $serviceClassName name of the service class that we are trying to call + * @param string $serviceMethodName name of the method that we are trying to call + * @param array $inputArray data to send to method in key-value format + * + * @return array list of parameters that can be used to call the service method + */ + public function getInputData($serviceClassName, $serviceMethodName, array $inputArray) + { + /** TODO: Reflection causes performance degradation when used in runtime. Should be optimized via caching */ + $serviceClass = new ClassReflection($serviceClassName); + /** @var MethodReflection $serviceMethod */ + $serviceMethod = $serviceClass->getMethod($serviceMethodName); + /** @var ParameterReflection[] $params */ + $params = $serviceMethod->getParameters(); + + $inputData = []; + foreach ($params as $param) { + $paramName = $param->getName(); + if (isset($inputArray[$paramName])) { + if ($this->_isArrayParam($param)) { + $paramType = "{$param->getType()}[]"; + /** Eliminate 'item' node if present. It is wrapping all data, declared in WSDL as array */ + $paramValue = isset($inputArray[$paramName][ComplexTypeStrategy::ARRAY_ITEM_KEY_NAME]) + ? $inputArray[$paramName][ComplexTypeStrategy::ARRAY_ITEM_KEY_NAME] + : $inputArray[$paramName]; + } else { + $paramType = $param->getType(); + $paramValue = $inputArray[$paramName]; + } + $inputData[] = $this->_convertValue($paramValue, $paramType); + } else { + $inputData[] = $param->getDefaultValue(); // not set, so use default + } + } + + return $inputData; + } + + /** + * Check if parameter is an array. + * + * @param ParameterReflection $param + * @return bool + */ + protected function _isArrayParam($param) + { + $isArray = $param->isArray(); + $docBlock = $param->getDeclaringFunction()->getDocBlock(); + /** If array type is not set explicitly in the method interface, examine annotations */ + if (!$isArray && $docBlock) { + /** This pattern will help to skip parameters declarations which precede to the current one */ + $precedingParamsPattern = str_repeat('.*\@param.*', $param->getPosition()); + $paramType = str_replace('\\', '\\\\', $param->getType()); + if (preg_match("/.*{$precedingParamsPattern}\@param\s+({$paramType}\[\]).*/i", $docBlock->getContents())) { + $isArray = true; + } + } + return $isArray; + } + + /** + * Creates a new instance of the given class and populates it with the array of data. + * + * @param string|\ReflectionClass $class + * @param array $data + * @return object the newly created and populated object + */ + protected function _createFromArray($class, $data) + { + $className = is_string($class) ? $class : $class->getName(); + try { + $class = new ClassReflection($className); + foreach ($data as $propertyName => $value) { + $getterName = 'get' . str_replace(' ', '', ucwords(str_replace('_', ' ', $propertyName))); + $methodReflection = $class->getMethod($getterName); + if ($methodReflection->isPublic()) { + $returnType = $this->_typeProcessor->getGetterReturnType($methodReflection)['type']; + $data[$propertyName] = $this->_convertValue($value, $returnType); + } + } + } catch (\ReflectionException $e) { + // Case where data array contains keys with no matching setter methods + // TODO: do we need to do anything here or can we just ignore this and keep going? + } + $obj = new $className($data); + return $obj; + } + + /** + * Convert data from array to DTO representation if type is DTO or array of DTOs. + * + * @param mixed $value + * @param string $type + * @return mixed + */ + protected function _convertValue($value, $type) + { + if (!$this->_typeProcessor->isTypeSimple($type)) { + if ($this->_typeProcessor->isArrayType($type)) { + $itemType = $this->_typeProcessor->getArrayItemType($type); + foreach ($value as $key => $item) { + $result[$key] = $this->_createFromArray($itemType, $item); + } + } else { + $result = $this->_createFromArray($type, $value); + } + } else { + $result = $value; + } + return $result; + } +} diff --git a/app/code/Magento/Webapi/Controller/Soap.php b/app/code/Magento/Webapi/Controller/Soap.php index 66b78a5a6b9bef9d2d03f9f662e84b0a386a158d..b617a0324a3cc3588e34442b466aecd96521cbc9 100644 --- a/app/code/Magento/Webapi/Controller/Soap.php +++ b/app/code/Magento/Webapi/Controller/Soap.php @@ -25,10 +25,12 @@ */ namespace Magento\Webapi\Controller; -use Magento\Webapi\Exception as WebapiException; use Magento\Service\AuthorizationException; +use Magento\Webapi\Exception as WebapiException; /** + * TODO: Consider warnings suppression removal + * * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class Soap implements \Magento\App\FrontControllerInterface @@ -73,7 +75,7 @@ class Soap implements \Magento\App\FrontControllerInterface * @param \Magento\Webapi\Model\Soap\Server $soapServer * @param \Magento\Webapi\Controller\ErrorProcessor $errorProcessor * @param \Magento\App\State $appState - * @param \Magento\Core\Model\AppInterface $application + * @param \Magento\AppInterface $application * @param \Magento\Oauth\OauthInterface $oauthService */ public function __construct( @@ -83,7 +85,7 @@ class Soap implements \Magento\App\FrontControllerInterface \Magento\Webapi\Model\Soap\Server $soapServer, \Magento\Webapi\Controller\ErrorProcessor $errorProcessor, \Magento\App\State $appState, - \Magento\Core\Model\AppInterface $application, + \Magento\AppInterface $application, \Magento\Oauth\OauthInterface $oauthService ) { $this->_request = $request; @@ -96,16 +98,6 @@ class Soap implements \Magento\App\FrontControllerInterface $this->_oauthService = $oauthService; } - /** - * Initialize front controller - * - * @return \Magento\Webapi\Controller\Soap - */ - public function init() - { - return $this; - } - /** * @param \Magento\App\RequestInterface $request * @return \Magento\App\ResponseInterface @@ -125,13 +117,12 @@ class Soap implements \Magento\App\FrontControllerInterface $this->_soapServer->generateUri() ); $this->_setResponseContentType(self::CONTENT_TYPE_WSDL_REQUEST); + $this->_setResponseBody($responseBody); } else { $consumerId = $this->_oauthService->validateAccessToken($this->_getAccessToken()); $this->_request->setConsumerId($consumerId); - $responseBody = $this->_soapServer->handle(); - $this->_setResponseContentType(self::CONTENT_TYPE_SOAP_CALL); + $this->_soapServer->handle(); } - $this->_setResponseBody($responseBody); } catch (\Exception $e) { $this->_prepareErrorResponse($e); } diff --git a/app/code/Magento/Webapi/Controller/Soap/Request.php b/app/code/Magento/Webapi/Controller/Soap/Request.php index 8f92e117285179f0b880ee1dec2edca23888df2a..b6e579e0463714a41bf090a71727c2c8c07c7f86 100644 --- a/app/code/Magento/Webapi/Controller/Soap/Request.php +++ b/app/code/Magento/Webapi/Controller/Soap/Request.php @@ -29,7 +29,6 @@ class Request extends \Magento\Webapi\Controller\Request { /** * Identify versions of resources that should be used for API configuration generation. - * TODO : This is getting called twice within a single request. Need to cache. * * @return array * @throws \Magento\Webapi\Exception When GET parameters are invalid @@ -55,7 +54,7 @@ class Request extends \Magento\Webapi\Controller\Request /** * Extract the resources query param value and return associative array of the form 'resource' => 'version' * - * @param string $param eg <pre> testModule1AllSoapAndRest:V1,testModule2AllSoapNoRest:V1 </pre> + * @param string $param eg <pre> testModule1AllSoapAndRestV1,testModule2AllSoapNoRestV1 </pre> * @return array <pre> eg array ( * 'testModule1AllSoapAndRest' => 'V1', * 'testModule2AllSoapNoRest' => 'V1', @@ -65,7 +64,6 @@ class Request extends \Magento\Webapi\Controller\Request protected function _convertRequestParamToServiceArray($param) { $serviceSeparator = ','; - //TODO: This should be a globally used pattern in Webapi module $serviceVerPattern = "[a-zA-Z\d]*V[\d]+"; $regexp = "/^($serviceVerPattern)([$serviceSeparator]$serviceVerPattern)*$/"; //Check if the $param is of valid format diff --git a/app/code/Magento/Webapi/Controller/Soap/Handler.php b/app/code/Magento/Webapi/Controller/Soap/Request/Handler.php similarity index 52% rename from app/code/Magento/Webapi/Controller/Soap/Handler.php rename to app/code/Magento/Webapi/Controller/Soap/Request/Handler.php index 7a731c938b964f5226f389611f5bfda02c46851e..383428ad47b62fe13d3bbc406f5e696eab5d7293 100644 --- a/app/code/Magento/Webapi/Controller/Soap/Handler.php +++ b/app/code/Magento/Webapi/Controller/Soap/Request/Handler.php @@ -22,18 +22,22 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Webapi\Controller\Soap; +namespace Magento\Webapi\Controller\Soap\Request; use Magento\Authz\Service\AuthorizationV1Interface as AuthorizationService; use Magento\Webapi\Model\Soap\Config as SoapConfig; use Magento\Webapi\Controller\Soap\Request as SoapRequest; use Magento\Webapi\Exception as WebapiException; use Magento\Service\AuthorizationException; +use Magento\Webapi\Controller\ServiceArgsSerializer; /** * Handler of requests to SOAP server. * * The main responsibility is to instantiate proper action controller (service) and execute requested method on it. + * + * TODO: Fix warnings suppression + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class Handler { @@ -51,6 +55,12 @@ class Handler /** @var AuthorizationService */ protected $_authorizationService; + /** @var \Magento\Webapi\Helper\Data */ + protected $_helper; + + /** @var ServiceArgsSerializer */ + protected $_serializer; + /** * Initialize dependencies. * @@ -58,17 +68,23 @@ class Handler * @param \Magento\ObjectManager $objectManager * @param SoapConfig $apiConfig * @param AuthorizationService $authorizationService + * @param \Magento\Webapi\Helper\Data $helper + * @param ServiceArgsSerializer $serializer */ public function __construct( SoapRequest $request, \Magento\ObjectManager $objectManager, SoapConfig $apiConfig, - AuthorizationService $authorizationService + AuthorizationService $authorizationService, + \Magento\Webapi\Helper\Data $helper, + ServiceArgsSerializer $serializer ) { $this->_request = $request; $this->_objectManager = $objectManager; $this->_apiConfig = $apiConfig; $this->_authorizationService = $authorizationService; + $this->_helper = $helper; + $this->_serializer = $serializer; } /** @@ -105,64 +121,105 @@ class Handler implode($serviceMethodInfo[SoapConfig::KEY_ACL_RESOURCES], ', ')); } $service = $this->_objectManager->get($serviceClass); - $outputData = $service->$serviceMethod($this->_prepareParameters($arguments)); - if (!is_array($outputData)) { - throw new \LogicException( - sprintf('The method "%s" of service "%s" must return an array.', $serviceMethod, $serviceClass) - ); - } - return $outputData; + $inputData = $this->_prepareRequestData($serviceClass, $serviceMethod, $arguments); + $outputData = call_user_func_array(array($service, $serviceMethod), $inputData); + return $this->_prepareResponseData($outputData); } /** - * Extract service method parameters from SOAP operation arguments. + * Convert SOAP operation arguments into format acceptable by service method. * - * @param \stdClass|array $arguments + * @param string $serviceClass + * @param string $serviceMethod + * @param array $arguments * @return array */ - protected function _prepareParameters($arguments) + protected function _prepareRequestData($serviceClass, $serviceMethod, $arguments) { /** SoapServer wraps parameters into array. Thus this wrapping should be removed to get access to parameters. */ $arguments = reset($arguments); - $this->_associativeObjectToArray($arguments); - $arguments = get_object_vars($arguments); - return $arguments; + $arguments = $this->_toArray($arguments); + return $this->_serializer->getInputData($serviceClass, $serviceMethod, $arguments); + } + + /** + * Convert service response into format acceptable by SoapServer. + * + * @param object|array|string|int|double|null $data + * @return array + * @throws \InvalidArgumentException + */ + protected function _prepareResponseData($data) + { + if ($this->_isDto($data)) { + $result = $this->_unpackDto($data); + } elseif (is_array($data)) { + foreach ($data as $key => $value) { + $result[$key] = $this->_isDto($value) ? $this->_unpackDto($value) : $value; + } + } elseif (is_string($data) || is_numeric($data) || is_null($data)) { + $result = $data; + } else { + throw new \InvalidArgumentException("Service returned result in invalid format."); + } + return array(self::RESULT_NODE_NAME => $result); } /** - * Go through an object parameters and unpack associative object to array. + * Create new object and initialize its public fields with data retrieved from DTO. * - * This function uses recursion and operates by reference. + * This method processes all nested DTOs recursively. + * + * @param object $dto + * @return \stdClass + * @throws \InvalidArgumentException + */ + protected function _unpackDto($dto) + { + if (!$this->_isDto($dto)) { + throw new \InvalidArgumentException("Object is expected to implement __toArray() method."); + } + $response = new \stdClass(); + foreach ($dto->__toArray() as $fieldName => $fieldValue) { + if ($this->_isDto($fieldValue)) { + $fieldValue = $this->_unpackDto($fieldValue); + } + $response->$fieldName = $fieldValue; + } + return $response; + } + + /** + * Check if provided variable is service DTO. * - * @param \stdClass|array $obj + * @param mixed $var * @return bool */ - protected function _associativeObjectToArray(&$obj) + protected function _isDto($var) + { + return (is_object($var) && method_exists($var, '__toArray')); + } + + /** + * Convert multidimensional object/array into multidimensional array of primitives. + * + * @param object|array $input + * @return array + * @throws \InvalidArgumentException + */ + protected function _toArray($input) { - if (is_object($obj)) { - if (property_exists($obj, 'key') && property_exists($obj, 'value')) { - if (count(array_keys(get_object_vars($obj))) === 2) { - $obj = array($obj->key => $obj->value); - return true; - } + if (!is_object($input) && !is_array($input)) { + throw new \InvalidArgumentException("Input argument must be an array or object"); + } + $result = array(); + foreach ((array)$input as $key => $value) { + if (is_object($value) || is_array($value)) { + $result[$key] = $this->_toArray($value); } else { - foreach (array_keys(get_object_vars($obj)) as $key) { - $this->_associativeObjectToArray($obj->$key); - } - } - } else if (is_array($obj)) { - $arr = array(); - $object = $obj; - foreach ($obj as &$value) { - if ($this->_associativeObjectToArray($value)) { - array_walk($value, function ($val, $key) use (&$arr) { - $arr[$key] = $val; - }); - $object = $arr; - } + $result[$key] = $value; } - $obj = $object; } - return false; + return $result; } } diff --git a/app/code/Magento/Webapi/Helper/Data.php b/app/code/Magento/Webapi/Helper/Data.php index a10e42a2066abf3dbd22234935edbab21c492013..aa996df32aa3c255f0cf40f496cfe5884e7e924e 100644 --- a/app/code/Magento/Webapi/Helper/Data.php +++ b/app/code/Magento/Webapi/Helper/Data.php @@ -50,4 +50,88 @@ class Data extends \Magento\App\Helper\AbstractHelper } return $selectedResourceIds; } + + /** + * Translate service interface name into service name. + * Example: + * <pre> + * - \Magento\Customer\Service\CustomerV1Interface => customer // $preserveVersion == false + * - \Magento\Customer\Service\Customer\AddressV1Interface => customerAddressV1 // $preserveVersion == true + * - \Magento\Catalog\Service\ProductV2Interface => catalogProductV2 // $preserveVersion == true + * </pre> + * + * @param string $interfaceName + * @param bool $preserveVersion Should version be preserved during interface name conversion into service name + * @return string + * @throws \InvalidArgumentException + */ + public function getServiceName($interfaceName, $preserveVersion = true) + { + $serviceNameParts = $this->getServiceNameParts($interfaceName, $preserveVersion); + return lcfirst(implode('', $serviceNameParts)); + } + + /** + * Identify the list of service name parts including sub-services using class name. + * + * Examples of input/output pairs: <br/> + * - 'Magento\Customer\Service\Customer\AddressV1Interface' => array('Customer', 'Address', 'V1') <br/> + * - 'Vendor\Customer\Service\Customer\AddressV1Interface' => array('VendorCustomer', 'Address', 'V1) <br/> + * - 'Magento\Catalog\Service\ProductV2Interface' => array('CatalogProduct', 'V2') + * + * @param string $className + * @param bool $preserveVersion Should version be preserved during class name conversion into service name + * @return array + * @throws \InvalidArgumentException When class is not valid API service. + */ + public function getServiceNameParts($className, $preserveVersion = false) + { + if (preg_match(\Magento\Webapi\Model\Config::SERVICE_CLASS_PATTERN, $className, $matches)) { + $moduleNamespace = $matches[1]; + $moduleName = $matches[2]; + $moduleNamespace = ($moduleNamespace == 'Magento') ? '' : $moduleNamespace; + $serviceNameParts = explode('\\', trim($matches[4], '\\')); + if ($moduleName == $serviceNameParts[0]) { + /** Avoid duplication of words in service name */ + $moduleName = ''; + } + $parentServiceName = $moduleNamespace . $moduleName . array_shift($serviceNameParts); + array_unshift($serviceNameParts, $parentServiceName); + if ($preserveVersion) { + $serviceVersion = $matches[3]; + $serviceNameParts[] = $serviceVersion; + } + return $serviceNameParts; + } + throw new \InvalidArgumentException(sprintf('The service interface name "%s" is invalid.', $className)); + } + + /** + * Convert DTO getter name into field name. + * + * @param string $getterName + * @return string + */ + public function dtoGetterNameToFieldName($getterName) + { + if ((strpos($getterName, 'get') === 0)) { + /** Remove 'get' prefix and make the first letter lower case */ + $fieldName = substr($getterName, strlen('get')); + } else { + /** If methods are with 'is' or 'has' prefix */ + $fieldName = $getterName; + } + return lcfirst($fieldName); + } + + /** + * Convert DTO field name into setter name. + * + * @param string $fieldName + * @return string + */ + public function dtoFieldNameToSetterName($fieldName) + { + return 'set' . ucfirst($fieldName); + } } diff --git a/app/code/Magento/Webapi/Model/Config.php b/app/code/Magento/Webapi/Model/Config.php index 3a729bee4f2d936f2caa7c0f7caea07ca2e4c2b8..404132d2eb2b561e318d61ecf9ee5756c8750420 100644 --- a/app/code/Magento/Webapi/Model/Config.php +++ b/app/code/Magento/Webapi/Model/Config.php @@ -36,7 +36,7 @@ class Config /** * Pattern for Web API interface name. */ - const SERVICE_CLASS_PATTERN = '/^(.+?)\\\\(.+?)\\\\Service(\\\\.+)+(V\d+)Interface$/'; + const SERVICE_CLASS_PATTERN = '/^(.+?)\\\\(.+?)\\\\Service\\\\(V\d+)+(\\\\.+)Interface$/'; /** * @var \Magento\App\Cache\Type\Config diff --git a/app/code/Magento/Webapi/Model/Config/ClassReflector.php b/app/code/Magento/Webapi/Model/Config/ClassReflector.php new file mode 100644 index 0000000000000000000000000000000000000000..72cc4f855587013c2d169c4d5ca15d26487b6d21 --- /dev/null +++ b/app/code/Magento/Webapi/Model/Config/ClassReflector.php @@ -0,0 +1,132 @@ +<?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\Webapi\Model\Config; + +use Zend\Server\Reflection; +use Zend\Server\Reflection\ReflectionMethod; + +/** + * Class reflector. + */ +class ClassReflector +{ + /** @var \Magento\Webapi\Model\Config\ClassReflector\TypeProcessor */ + protected $_typeProcessor; + + /** + * Construct reflector. + * + * @param \Magento\Webapi\Model\Config\ClassReflector\TypeProcessor $typeProcessor + */ + public function __construct(\Magento\Webapi\Model\Config\ClassReflector\TypeProcessor $typeProcessor) + { + $this->_typeProcessor = $typeProcessor; + } + + /** + * Reflect methods in given class and set retrieved data into reader. + * + * @param array $methods + * @param string $className + * @return array <pre>array( + * $firstMethod => array( + * 'documentation' => $methodDocumentation, + * 'interface' => array( + * 'in' => array( + * 'parameters' => array( + * $firstParameter => array( + * 'type' => $type, + * 'required' => $isRequired, + * 'documentation' => $parameterDocumentation + * ), + * ... + * ) + * ), + * 'out' => array( + * 'parameters' => array( + * $firstParameter => array( + * 'type' => $type, + * 'required' => $isRequired, + * 'documentation' => $parameterDocumentation + * ), + * ... + * ) + * ) + * ) + * ), + * ... + * )</pre> + */ + public function reflectClassMethods($className, $methods) + { + $data = array(); + $classReflection = new \Zend\Server\Reflection\ReflectionClass(new \ReflectionClass($className)); + /** @var $methodReflection ReflectionMethod */ + foreach ($classReflection->getMethods() as $methodReflection) { + $methodName = $methodReflection->getName(); + if (array_key_exists($methodName, $methods)) { + $data[$methodName] = $this->extractMethodData($methodReflection); + } + } + return $data; + } + + /** + * Retrieve method interface and documentation description. + * + * @param ReflectionMethod $method + * @return array + * @throws \InvalidArgumentException + */ + public function extractMethodData(ReflectionMethod $method) + { + $methodData = array('documentation' => $method->getDescription(), 'interface' => array()); + $prototypes = $method->getPrototypes(); + /** Take the fullest interface that also includes optional parameters. */ + /** @var \Zend\Server\Reflection\Prototype $prototype */ + $prototype = end($prototypes); + /** @var \Zend\Server\Reflection\ReflectionParameter $parameter */ + foreach ($prototype->getParameters() as $parameter) { + $parameterData = array( + 'type' => $this->_typeProcessor->process($parameter->getType()), + 'required' => !$parameter->isOptional(), + 'documentation' => $parameter->getDescription(), + ); + if ($parameter->isOptional()) { + $parameterData['default'] = $parameter->getDefaultValue(); + } + $methodData['interface']['in']['parameters'][$parameter->getName()] = $parameterData; + } + if ($prototype->getReturnType() != 'void') { + $methodData['interface']['out']['parameters']['result'] = array( + 'type' => $this->_typeProcessor->process($prototype->getReturnType()), + 'documentation' => $prototype->getReturnValue()->getDescription(), + 'required' => true, + ); + } + + return $methodData; + } +} diff --git a/app/code/Magento/Webapi/Model/Config/ClassReflector/TypeProcessor.php b/app/code/Magento/Webapi/Model/Config/ClassReflector/TypeProcessor.php new file mode 100644 index 0000000000000000000000000000000000000000..72264cf7c75c80cd332c34107f0274f47cf9ed88 --- /dev/null +++ b/app/code/Magento/Webapi/Model/Config/ClassReflector/TypeProcessor.php @@ -0,0 +1,374 @@ +<?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\Webapi\Model\Config\ClassReflector; + +use Zend\Code\Reflection\ClassReflection; + +/** + * Type processor of config reader properties + */ +class TypeProcessor +{ + /** @var \Magento\Webapi\Helper\Data */ + protected $_helper; + + /** + * Array of types data. + * + * @var array <pre>array( + * $complexTypeName => array( + * 'documentation' => $typeDocumentation + * 'parameters' => array( + * $firstParameter => array( + * 'type' => $type, + * 'required' => $isRequired, + * 'default' => $defaultValue, + * 'documentation' => $parameterDocumentation + * ), + * ... + * ) + * ), + * ... + * )</pre> + */ + protected $_types = array(); + + /** + * Types class map. + * + * @var array <pre>array( + * $complexTypeName => $interfaceName, + * ... + * )</pre> + */ + protected $_typeToClassMap = array(); + + /** + * Construct type processor. + * + * @param \Magento\Webapi\Helper\Data $helper + */ + public function __construct(\Magento\Webapi\Helper\Data $helper) + { + $this->_helper = $helper; + } + + /** + * Retrieve processed types data. + * + * @return array + */ + public function getTypesData() + { + return $this->_types; + } + + /** + * Retrieve data type details for the given type name. + * + * @param string $typeName + * @return array + * @throws \InvalidArgumentException + */ + public function getTypeData($typeName) + { + if (!isset($this->_types[$typeName])) { + throw new \InvalidArgumentException(sprintf('Data type "%s" is not declared.', $typeName)); + } + return $this->_types[$typeName]; + } + + /** + * Add or update type data in config. + * + * @param string $typeName + * @param array $data + */ + public function setTypeData($typeName, $data) + { + if (!isset($this->_types[$typeName])) { + $this->_types[$typeName] = $data; + } else { + $this->_types[$typeName] = array_merge_recursive($this->_types[$typeName], $data); + } + } + + /** + * Process type name. In case parameter type is a complex type (class) - process its properties. + * + * @param string $type + * @return string + * @throws \LogicException + */ + public function process($type) + { + $typeName = $this->normalizeType($type); + if (!$this->isTypeSimple($typeName)) { + if ((!$this->isArrayType($type) && !class_exists($type)) + || !class_exists(str_replace('[]', '', $type)) + ) { + throw new \LogicException( + sprintf('Class "%s" does not exist. Please note that namespace must be specified.', $type) + ); + } + $complexTypeName = $this->translateTypeName($type); + if (!isset($this->_types[$complexTypeName])) { + $this->_processComplexType($type); + if (!$this->isArrayType($complexTypeName)) { + $this->_typeToClassMap[$complexTypeName] = $type; + } + } + $typeName = $complexTypeName; + } + + return $typeName; + } + + /** + * Retrieve complex type information from class public properties. + * + * @param string $class + * @return array + * @throws \InvalidArgumentException + */ + protected function _processComplexType($class) + { + $typeName = $this->translateTypeName($class); + $this->_types[$typeName] = array(); + if ($this->isArrayType($class)) { + $this->process($this->getArrayItemType($class)); + } else { + if (!class_exists($class)) { + throw new \InvalidArgumentException( + sprintf('Could not load the "%s" class as parameter type.', $class) + ); + } + $reflection = new ClassReflection($class); + $docBlock = $reflection->getDocBlock(); + $this->_types[$typeName]['documentation'] = $docBlock ? $this->_getDescription($docBlock) : ''; + /** @var \Zend\Code\Reflection\MethodReflection $methodReflection */ + foreach ($reflection->getMethods(\ReflectionMethod::IS_PUBLIC) as $methodReflection) { + $this->_processMethod($methodReflection, $typeName); + } + } + + return $this->_types[$typeName]; + } + + /** + * Collect metadata for virtual field corresponding to current method if it is a getter (used in WSDL generation). + * + * @param \Zend\Code\Reflection\MethodReflection $methodReflection + * @param string $typeName + */ + protected function _processMethod(\Zend\Code\Reflection\MethodReflection $methodReflection, $typeName) + { + $isGetter = (strpos($methodReflection->getName(), 'get') === 0) + || (strpos($methodReflection->getName(), 'is') === 0) + || (strpos($methodReflection->getName(), 'has') === 0); + if ($isGetter) { + $returnMetadata = $this->getGetterReturnType($methodReflection); + $fieldName = $this->_helper->dtoGetterNameToFieldName($methodReflection->getName()); + $this->_types[$typeName]['parameters'][$fieldName] = array( + 'type' => $this->process($returnMetadata['type']), + 'required' => $returnMetadata['isRequired'], + 'documentation' => $returnMetadata['description'] + ); + } + } + + /** + * Get short and long description from docblock and concatenate. + * + * @param \Zend\Code\Reflection\DocBlockReflection $doc + * @return string + */ + protected function _getDescription(\Zend\Code\Reflection\DocBlockReflection $doc) + { + $shortDescription = $doc->getShortDescription(); + $longDescription = $doc->getLongDescription(); + + $description = rtrim($shortDescription); + $longDescription = str_replace(array("\n", "\r"), '', $longDescription); + if (!empty($longDescription) && !empty($description)) { + $description .= " "; + } + $description .= ltrim($longDescription); + + return $description; + } + + /** + * Identify getter return type by its reflection. + * + * @param \Zend\Code\Reflection\MethodReflection $methodReflection + * @return array <pre>array( + * 'type' => <string>$type, + * 'isRequired' => $isRequired, + * 'description' => $description + * )</pre> + * @throws \InvalidArgumentException + */ + public function getGetterReturnType($methodReflection) + { + $methodDocBlock = $methodReflection->getDocBlock(); + if (!$methodDocBlock) { + throw new \InvalidArgumentException('Each getter must have description with @return annotation.'); + } + $returnAnnotations = $methodDocBlock->getTags('return'); + if (empty($returnAnnotations)) { + throw new \InvalidArgumentException('Getter return type must be specified using @return annotation.'); + } + /** @var \Zend\Code\Reflection\DocBlock\Tag\ReturnTag $returnAnnotation */ + $returnAnnotation = current($returnAnnotations); + $returnType = $returnAnnotation->getType(); + /* + * Adding this code as a workaround since \Zend\Code\Reflection\DocBlock\Tag\ReturnTag::initialize does not + * detect and return correct type for array of objects in annotation. + * eg @return \Magento\Webapi\Service\Entity\SimpleDto[] is returned with type + * \Magento\Webapi\Service\Entity\SimpleDto instead of \Magento\Webapi\Service\Entity\SimpleDto[] + */ + $escapedReturnType = str_replace('\\', '\\\\', $returnType); + if (preg_match("/.*\@return\s+({$escapedReturnType}\[\]).*/i", $methodDocBlock->getContents(), $matches)) { + $returnType = $matches[1]; + } + $isRequired = preg_match("/.*\@return\s+\S+\|null.*/i", $methodDocBlock->getContents(), $matches) + ? false + : true; + return [ + 'type' => $returnType, + 'isRequired' => $isRequired, + 'description' => $returnAnnotation->getDescription() + ]; + } + + /** + * Normalize short type names to full type names. + * + * @param string $type + * @return string + */ + public function normalizeType($type) + { + $normalizationMap = array( + 'str' => 'string', + 'integer' => 'int', + 'bool' => 'boolean', + ); + + return is_string($type) && isset($normalizationMap[$type]) ? $normalizationMap[$type] : $type; + } + + /** + * Check if given type is a simple type. + * + * @param string $type + * @return bool + */ + public function isTypeSimple($type) + { + $type = $this->normalizeType($type); + if ($this->isArrayType($type)) { + $type = $this->getArrayItemType($type); + } + + return in_array($type, array('string', 'int', 'float', 'double', 'boolean')); + } + + /** + * Check if given type is an array of type items. + * Example: + * <pre> + * ComplexType[] -> array of ComplexType items + * string[] -> array of strings + * </pre> + * + * @param string $type + * @return bool + */ + public function isArrayType($type) + { + return (bool)preg_match('/(\[\]$|^ArrayOf)/', $type); + } + + /** + * Get item type of the array. + * Example: + * <pre> + * ComplexType[] => ComplexType + * string[] => string + * int[] => integer + * </pre> + * + * @param string $arrayType + * @return string + */ + public function getArrayItemType($arrayType) + { + return $this->normalizeType(str_replace('[]', '', $arrayType)); + } + + /** + * Translate complex type class name into type name. + * + * Example: + * <pre> + * Magento_Customer_Service_CustomerData => CustomerData + * Magento_Catalog_Service_ProductData => CatalogProductData + * </pre> + * + * @param string $class + * @return string + * @throws \InvalidArgumentException + */ + public function translateTypeName($class) + { + if (preg_match('/\\\\?(.*)\\\\(.*)\\\\Service\\\\\2?(.*)/', $class, $matches)) { + $moduleNamespace = $matches[1] == 'Magento' ? '' : $matches[1]; + $moduleName = $matches[2]; + $typeNameParts = explode('\\', $matches[3]); + + return ucfirst($moduleNamespace . $moduleName . implode('', $typeNameParts)); + } + throw new \InvalidArgumentException(sprintf('Invalid parameter type "%s".', $class)); + } + + /** + * Translate array complex type name. + * + * Example: + * <pre> + * ComplexTypeName[] => ArrayOfComplexTypeName + * string[] => ArrayOfString + * </pre> + * + * @param string $type + * @return string + */ + public function translateArrayTypeName($type) + { + return 'ArrayOf' . ucfirst($this->getArrayItemType($type)); + } +} diff --git a/app/code/Magento/Webapi/Model/Rest/Config.php b/app/code/Magento/Webapi/Model/Rest/Config.php index 48284a6c402c2ee4c603d0fbd37845834c0be1ca..7f75332c38e1687480f8fdcfddfffced37689e40 100644 --- a/app/code/Magento/Webapi/Model/Rest/Config.php +++ b/app/code/Magento/Webapi/Model/Rest/Config.php @@ -109,6 +109,8 @@ class Config } /** + * TODO: Refactor $this->_config->getServices() to return array with baseUrl as the key since its unique and + * needs to be used directly instead of looping each key * Generate the list of available REST routes. Current HTTP method is taken into account. * * @param \Magento\Webapi\Controller\Rest\Request $request diff --git a/app/code/Magento/Webapi/Model/Soap/Config.php b/app/code/Magento/Webapi/Model/Soap/Config.php index 2cc8a36e6dacae110ea67c063a487fa12609a00d..76d8a4c5b3e3c597e70925180c74600cf2726fb4 100644 --- a/app/code/Magento/Webapi/Model/Soap/Config.php +++ b/app/code/Magento/Webapi/Model/Soap/Config.php @@ -65,20 +65,35 @@ class Config */ protected $_soapOperations; + /** @var \Magento\Webapi\Helper\Data */ + protected $_helper; + + /** @var \Magento\Webapi\Model\Config\ClassReflector */ + protected $_classReflector; + /** + * Initialize dependencies. + * * @param \Magento\ObjectManager $objectManager * @param \Magento\App\Filesystem $filesystem * @param \Magento\Webapi\Model\Config $config + * @param \Magento\Webapi\Model\Config\ClassReflector $classReflector + * @param \Magento\Webapi\Helper\Data $helper */ public function __construct( \Magento\ObjectManager $objectManager, \Magento\App\Filesystem $filesystem, - \Magento\Webapi\Model\Config $config + \Magento\Webapi\Model\Config $config, + \Magento\Webapi\Model\Config\ClassReflector $classReflector, + \Magento\Webapi\Helper\Data $helper ) { // TODO: Check if Service specific XSD is already cached $this->modulesDirectory = $filesystem->getDirectoryRead(\Magento\App\Filesystem::MODULES_DIR); $this->_config = $config; $this->_objectManager = $objectManager; + $this->_helper = $helper; + $this->_classReflector = $classReflector; + $this->_initServicesMetadata(); } /** @@ -118,29 +133,37 @@ class Config /** * Collect the list of services with their operations available in SOAP. - * The list of services is taken from webapi.xml configuration files. - * The list of methods in contrast to REST is taken from PHP Interface using reflection. * * @return array */ - protected function _getSoapServices() + protected function _initServicesMetadata() { // TODO: Implement caching if this approach is approved if (is_null($this->_soapServices)) { $this->_soapServices = array(); foreach ($this->_config->getServices() as $serviceData) { $serviceClass = $serviceData[Converter::KEY_SERVICE_CLASS]; + $serviceName = $this->_helper->getServiceName($serviceClass); foreach ($serviceData[Converter::KEY_SERVICE_METHODS] as $methodMetadata) { // TODO: Simplify the structure in SOAP. Currently it is unified in SOAP and REST $methodName = $methodMetadata[Converter::KEY_SERVICE_METHOD]; - $this->_soapServices[$serviceClass]['methods'][$methodName] = array( + $this->_soapServices[$serviceName]['methods'][$methodName] = array( self::KEY_METHOD => $methodName, self::KEY_IS_REQUIRED => (bool)$methodMetadata[Converter::KEY_IS_SECURE], self::KEY_IS_SECURE => $methodMetadata[Converter::KEY_IS_SECURE], self::KEY_ACL_RESOURCES => $methodMetadata[Converter::KEY_ACL_RESOURCES] ); - $this->_soapServices[$serviceClass][self::KEY_CLASS] = $serviceClass; + $this->_soapServices[$serviceName][self::KEY_CLASS] = $serviceClass; }; + $reflectedMethodsMetadata = $this->_classReflector->reflectClassMethods( + $serviceClass, + $this->_soapServices[$serviceName]['methods'] + ); + // TODO: Consider service documentation extraction via reflection + $this->_soapServices[$serviceName]['methods'] = array_merge_recursive( + $this->_soapServices[$serviceName]['methods'], + $reflectedMethodsMetadata + ); }; } return $this->_soapServices; @@ -182,49 +205,13 @@ class Config { $services = array(); foreach ($requestedServices as $serviceName) { - foreach ($this->_getSoapServices() as $serviceData) { - $serviceWithVersion = $this->getServiceName($serviceData[self::KEY_CLASS]); - if ($serviceWithVersion === $serviceName) { - $services[] = $serviceData; - } + if (isset($this->_soapServices[$serviceName])) { + $services[] = $this->_soapServices[$serviceName]; } } return $services; } - /** - * Load and return Service XSD for the provided Service Class - * - * @param $serviceClass - * @return \DOMDocument - */ - public function getServiceSchemaDOM($serviceClass) - { - // TODO: Change pattern to match interface instead of class. Think about sub-services. - if (!preg_match(\Magento\Webapi\Model\Config::SERVICE_CLASS_PATTERN, $serviceClass, $matches)) { - // TODO: Generate exception when error handling strategy is defined - } - - $vendorName = $matches[1]; - $moduleName = $matches[2]; - /** Convert "_Catalog_Attribute" into "Catalog/Attribute" */ - $servicePath = str_replace('_', '/', ltrim($matches[3], '_')); - $version = $matches[4]; - $schemaPath = "{$vendorName}/{$moduleName}/etc/schema/{$servicePath}{$version}.xsd"; - - if ($this->modulesDirectory->isFile($schemaPath)) { - $schema = $this->modulesDirectory->readFile($schemaPath); - } else { - $schema = ''; - } - - // TODO: Should happen only once the cache is in place - $serviceSchema = $this->_objectManager->create('DOMDocument'); - $serviceSchema->loadXML($schema); - - return $serviceSchema; - } - /** * Generate SOAP operation name. * @@ -234,63 +221,23 @@ class Config */ public function getSoapOperation($interfaceName, $methodName) { - $serviceName = $this->getServiceName($interfaceName); + $serviceName = $this->_helper->getServiceName($interfaceName); $operationName = $serviceName . ucfirst($methodName); return $operationName; } /** - * Translate service interface name into service name. - * Example: - * <pre> - * - \Magento\Customer\Service\CustomerV1Interface => customer // $preserveVersion == false - * - \Magento\Customer\Service\Customer\AddressV1Interface => customerAddressV1 // $preserveVersion == true - * - \Magento\Catalog\Service\ProductV2Interface => catalogProductV2 // $preserveVersion == true - * </pre> - * - * @param string $interfaceName - * @param bool $preserveVersion Should version be preserved during interface name conversion into service name - * @return string - * @throws \InvalidArgumentException - */ - public function getServiceName($interfaceName, $preserveVersion = true) - { - $serviceNameParts = $this->getServiceNameParts($interfaceName, $preserveVersion); - return lcfirst(implode('', $serviceNameParts)); - } - - /** - * Identify the list of service name parts including sub-services using class name. + * Retrieve specific service interface data. * - * Examples of input/output pairs: <br/> - * - 'Magento\Customer\Service\Customer\AddressV1Interface' => array('Customer', 'Address', 'V1') <br/> - * - 'Vendor\Customer\Service\Customer\AddressV1Interface' => array('VendorCustomer', 'Address', 'V1) <br/> - * - 'Magento\Catalog\Service\ProductV2Interface' => array('CatalogProduct', 'V2') - * - * @param string $className - * @param bool $preserveVersion Should version be preserved during class name conversion into service name + * @param string $serviceName * @return array - * @throws \InvalidArgumentException When class is not valid API service. + * @throws \RuntimeException */ - public function getServiceNameParts($className, $preserveVersion = false) + public function getServiceMetadata($serviceName) { - if (preg_match(\Magento\Webapi\Model\Config::SERVICE_CLASS_PATTERN, $className, $matches)) { - $moduleNamespace = $matches[1]; - $moduleName = $matches[2]; - $moduleNamespace = ($moduleNamespace == 'Magento') ? '' : $moduleNamespace; - $serviceNameParts = explode('\\', trim($matches[3], '\\')); - if ($moduleName == $serviceNameParts[0]) { - /** Avoid duplication of words in service name */ - $moduleName = ''; - } - $parentServiceName = $moduleNamespace . $moduleName . array_shift($serviceNameParts); - array_unshift($serviceNameParts, $parentServiceName); - if ($preserveVersion) { - $serviceVersion = $matches[4]; - $serviceNameParts[] = $serviceVersion; - } - return $serviceNameParts; + if (!isset($this->_soapServices[$serviceName]) || !is_array($this->_soapServices[$serviceName])) { + throw new \RuntimeException(__('Requested service is not available: "%1"', $serviceName)); } - throw new \InvalidArgumentException(sprintf('The service interface name "%s" is invalid.', $className)); + return $this->_soapServices[$serviceName]; } } diff --git a/app/code/Magento/Webapi/Model/Soap/Fault.php b/app/code/Magento/Webapi/Model/Soap/Fault.php index b74295bbb75ed4845aad2d12f1d27cbc5681c196..b748e5bf2244974e5be9642386a4edddaef63f7a 100644 --- a/app/code/Magento/Webapi/Model/Soap/Fault.php +++ b/app/code/Magento/Webapi/Model/Soap/Fault.php @@ -40,8 +40,12 @@ class Fault extends \RuntimeException */ const NODE_DETAIL_CODE = 'Code'; const NODE_DETAIL_PARAMETERS = 'Parameters'; + /** Note that parameter node must be unique in scope of all complex types declared in WSDL */ + const NODE_DETAIL_PARAMETER = 'GenericFaultParameter'; + const NODE_DETAIL_PARAMETER_KEY = 'key'; + const NODE_DETAIL_PARAMETER_VALUE = 'value'; const NODE_DETAIL_TRACE = 'Trace'; - const NODE_DETAIL_WRAPPER = 'DefaultFault'; + const NODE_DETAIL_WRAPPER = 'GenericFault'; /**#@-*/ /** @var string */ @@ -280,12 +284,47 @@ FAULT_MESSAGE; if (is_numeric($detailNode)) { continue; } - if (is_string($detailValue) || is_numeric($detailValue)) { - $detailsXml .= "<m:$detailNode>" . htmlspecialchars($detailValue) . "</m:$detailNode>"; - } elseif (is_array($detailValue)) { - $detailsXml .= "<m:$detailNode>" . $this->_convertDetailsToXml($detailValue) . "</m:$detailNode>"; + switch ($detailNode) { + case self::NODE_DETAIL_CODE: + // break is intentionally omitted + case self::NODE_DETAIL_TRACE: + if (is_string($detailValue) || is_numeric($detailValue)) { + $detailsXml .= "<m:$detailNode>" . htmlspecialchars($detailValue) . "</m:$detailNode>"; + } + break; + case self::NODE_DETAIL_PARAMETERS: + $detailsXml .= $this->_getParametersXml($detailValue, $detailNode, $detailsXml); + break; } } return $detailsXml; } + + /** + * Generate XML for parameters. + * + * @param array $parameters + * @return string + */ + protected function _getParametersXml($parameters) + { + $result = ''; + if (is_array($parameters)) { + $paramsXml = ''; + foreach ($parameters as $parameterName => $parameterValue) { + if (is_string($parameterName) && (is_string($parameterValue) || is_numeric($parameterValue))) { + $keyNode = self::NODE_DETAIL_PARAMETER_KEY; + $valueNode = self::NODE_DETAIL_PARAMETER_VALUE; + $parameterNode = self::NODE_DETAIL_PARAMETER; + $paramsXml .= "<m:$parameterNode><m:$keyNode>$parameterName</m:$keyNode><m:$valueNode>" + . htmlspecialchars($parameterValue) . "</m:$valueNode></m:$parameterNode>"; + } + } + if (!empty($paramsXml)) { + $parametersNode = self::NODE_DETAIL_PARAMETERS; + $result = "<m:$parametersNode>" . $paramsXml . "</m:$parametersNode>"; + } + } + return $result; + } } diff --git a/app/code/Magento/Webapi/Model/Soap/Server.php b/app/code/Magento/Webapi/Model/Soap/Server.php index ad8650753c1551fc858772c5bf11290fd535f193..cf9e60c9ded323d0b24a29bdcd9b4ebae0d15667 100644 --- a/app/code/Magento/Webapi/Model/Soap/Server.php +++ b/app/code/Magento/Webapi/Model/Soap/Server.php @@ -61,6 +61,9 @@ class Server /** @var \Magento\Webapi\Model\Soap\Server\Factory */ protected $_soapServerFactory; + /** @var \Magento\Webapi\Model\Config\ClassReflector\TypeProcessor */ + protected $_typeProcessor; + /** * Initialize dependencies, initialize WSDL cache. * @@ -70,6 +73,7 @@ class Server * @param \Magento\DomDocument\Factory $domDocumentFactory * @param \Magento\Core\Model\StoreManagerInterface $storeManager * @param \Magento\Webapi\Model\Soap\Server\Factory $soapServerFactory + * @param \Magento\Webapi\Model\Config\ClassReflector\TypeProcessor $typeProcessor * @throws \Magento\Webapi\Exception */ public function __construct( @@ -78,7 +82,8 @@ class Server \Magento\Webapi\Controller\Soap\Request $request, \Magento\DomDocument\Factory $domDocumentFactory, \Magento\Core\Model\StoreManagerInterface $storeManager, - \Magento\Webapi\Model\Soap\Server\Factory $soapServerFactory + \Magento\Webapi\Model\Soap\Server\Factory $soapServerFactory, + \Magento\Webapi\Model\Config\ClassReflector\TypeProcessor $typeProcessor ) { if (!extension_loaded('soap')) { throw new \Magento\Webapi\Exception('SOAP extension is not loaded.', 0, @@ -90,6 +95,7 @@ class Server $this->_domDocumentFactory = $domDocumentFactory; $this->_storeManager = $storeManager; $this->_soapServerFactory = $soapServerFactory; + $this->_typeProcessor = $typeProcessor; /** Enable or disable SOAP extension WSDL cache depending on Magento configuration. */ $wsdlCacheEnabled = (bool)$storeManager->getStore()->getConfig(self::CONFIG_PATH_WSDL_CACHE_ENABLED); if ($wsdlCacheEnabled) { @@ -100,9 +106,7 @@ class Server } /** - * Handle SOAP request. - * - * @return string + * Handle SOAP request. Response is sent by SOAP server. */ public function handle() { @@ -112,8 +116,8 @@ class Server 'encoding' => $this->getApiCharset(), 'soap_version' => SOAP_1_2 ); - $soap = $this->_soapServerFactory->create($this->generateUri(true), $options); - return $soap->handle($rawRequestBody); + $soapServer = $this->_soapServerFactory->create($this->generateUri(true), $options); + $soapServer->handle($rawRequestBody); } /** diff --git a/app/code/Magento/Webapi/Model/Soap/Server/Factory.php b/app/code/Magento/Webapi/Model/Soap/Server/Factory.php index 53deae10a27d7079c17291875afc931585a62994..e11f120d7700a5d37b6d4e70ac8c4161a948657f 100644 --- a/app/code/Magento/Webapi/Model/Soap/Server/Factory.php +++ b/app/code/Magento/Webapi/Model/Soap/Server/Factory.php @@ -33,7 +33,7 @@ class Factory protected $_objectManager; /** - * @var \Magento\Webapi\Controller\Soap\Handler + * @var \Magento\Webapi\Controller\Soap\Request\Handler */ protected $_soapHandler; @@ -41,11 +41,11 @@ class Factory * Initialize the class * * @param \Magento\ObjectManager $objectManager - * @param \Magento\Webapi\Controller\Soap\Handler $soapHandler + * @param \Magento\Webapi\Controller\Soap\Request\Handler $soapHandler */ public function __construct( \Magento\ObjectManager $objectManager, - \Magento\Webapi\Controller\Soap\Handler $soapHandler + \Magento\Webapi\Controller\Soap\Request\Handler $soapHandler ) { $this->_objectManager = $objectManager; $this->_soapHandler = $soapHandler; diff --git a/app/code/Magento/Webapi/Model/Soap/Wsdl.php b/app/code/Magento/Webapi/Model/Soap/Wsdl.php index 776339b260a2ffd715795baef9df8ac4935773fc..026ca0330cceb23720b9ba5c618cf6f420088c59 100644 --- a/app/code/Magento/Webapi/Model/Soap/Wsdl.php +++ b/app/code/Magento/Webapi/Model/Soap/Wsdl.php @@ -24,6 +24,7 @@ namespace Magento\Webapi\Model\Soap; use DOMElement; +use Magento\Webapi\Model\Soap\Wsdl\ComplexTypeStrategy; /** * Magento-specific WSDL builder. @@ -36,106 +37,36 @@ class Wsdl extends \Zend\Soap\Wsdl * * @param string $name * @param string|\Zend\Uri\Uri $uri - * @param \Magento\Webapi\Model\Soap\Wsdl\ComplexTypeStrategy\AnyComplexType $strategy + * @param ComplexTypeStrategy $strategy */ - public function __construct( - $name, - $uri, - \Magento\Webapi\Model\Soap\Wsdl\ComplexTypeStrategy\AnyComplexType $strategy - ) { - parent::__construct($name, $uri, $strategy); - } - - /** - * Add complex type definition - * - * @param \DOMNode $complexTypeNode XSD of service method for input/output - * @return string|null - */ - public function addComplexType($complexTypeNode) + public function __construct($name, $uri, ComplexTypeStrategy $strategy) { - $this->addSchemaTypeSection(); - - $strategy = $this->getComplexTypeStrategy(); - $strategy->setContext($this); - // delegates the detection of a complex type to the current strategy - return $strategy->addComplexType($complexTypeNode); + parent::__construct($name, $uri, $strategy); } /** * Add an operation to port type. * - * Multiple faults generation is allowed, while it is not allowed in parent. - * * @param DOMElement $portType * @param string $name Operation name * @param string|bool $input Input Message * @param string|bool $output Output Message - * @param array|bool $fault array of Fault messages in the format: array(array('message' => ..., 'name' => ...)) + * @param string|bool|array $fault Message name OR array('message' => ..., 'name' => ...) * @return object The new operation's XML_Tree_Node */ public function addPortOperation($portType, $name, $input = false, $output = false, $fault = false) { $operation = parent::addPortOperation($portType, $name, $input, $output, false); if (is_array($fault)) { - foreach ($fault as $faultInfo) { - $isMessageValid = isset($faultInfo['message']) && is_string($faultInfo['message']) - && strlen(trim($faultInfo['message'])); - $isNameValid = isset($faultInfo['name']) && is_string($faultInfo['name']) - && strlen(trim($faultInfo['name'])); - - if ($isNameValid && $isMessageValid) { - $node = $this->toDomDocument()->createElement('fault'); - $node->setAttribute('name', $faultInfo['name']); - $node->setAttribute('message', $faultInfo['message']); - $operation->appendChild($node); - } - } - } - return $operation; - } - - /** - * Add an operation to a binding element. - * - * Multiple faults binding is allowed, while it is not allowed in parent. - * - * @param DOMElement $binding - * @param string $name Operation name - * @param bool|array $input An array of attributes for the input element, - * allowed keys are: 'use', 'namespace', 'encodingStyle'. - * @param bool|array $output An array of attributes for the output element, - * allowed keys are: 'use', 'namespace', 'encodingStyle'. - * @param bool|array $fault An array of arrays which contain fault names: array(array('name' => ...))). - * @param int $soapVersion SOAP version to be used in binding operation. 1.1 used by default. - * @return DOMElement The new Operation's XML_Tree_Node - */ - public function addBindingOperation( - $binding, - $name, - $input = false, - $output = false, - $fault = false, - $soapVersion = SOAP_1_1 - ) { - $operation = parent::addBindingOperation($binding, $name, $input, $output, false, $soapVersion); - if (is_array($fault)) { - foreach ($fault as $faultInfo) { - $isNameValid = isset($faultInfo['name']) && is_string($faultInfo['name']) - && strlen(trim($faultInfo['name'])); - - if ($isNameValid) { - $faultInfo['use'] = 'literal'; - $wsdlFault = $this->toDomDocument()->createElement('fault'); - $wsdlFault->setAttribute('name', $faultInfo['name']); - - $soapFault = $this->toDomDocument()->createElement('soap:fault'); - $soapFault->setAttribute('name', $faultInfo['name']); - $soapFault->setAttribute('use', 'literal'); + $isMessageValid = isset($fault['message']) && is_string($fault['message']) + && strlen(trim($fault['message'])); + $isNameValid = isset($fault['name']) && is_string($fault['name']) && strlen(trim($fault['name'])); - $wsdlFault->appendChild($soapFault); - $operation->appendChild($wsdlFault); - } + if ($isNameValid && $isMessageValid) { + $node = $this->toDomDocument()->createElement('fault'); + $node->setAttribute('name', $fault['name']); + $node->setAttribute('message', $fault['message']); + $operation->appendChild($node); } } return $operation; diff --git a/app/code/Magento/Webapi/Model/Soap/Wsdl/ComplexTypeStrategy.php b/app/code/Magento/Webapi/Model/Soap/Wsdl/ComplexTypeStrategy.php new file mode 100644 index 0000000000000000000000000000000000000000..cc48f70fced4d87d2a85cb4a27a82cb68d17a9e1 --- /dev/null +++ b/app/code/Magento/Webapi/Model/Soap/Wsdl/ComplexTypeStrategy.php @@ -0,0 +1,460 @@ +<?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\Webapi\Model\Soap\Wsdl; + +use Zend\Soap\Wsdl\ComplexTypeStrategy\AbstractComplexTypeStrategy; +use Zend\Soap\Wsdl; + +/** + * Magento-specific Complex type strategy for WSDL auto discovery. + */ +class ComplexTypeStrategy extends AbstractComplexTypeStrategy +{ + /** + * Array item key value for element. + */ + const ARRAY_ITEM_KEY_NAME = 'item'; + + /** + * Appinfo nodes namespace. + */ + const APP_INF_NS = 'inf'; + + /** @var \Magento\Webapi\Model\Config\ClassReflector\TypeProcessor */ + protected $_typeProcessor; + + /** + * Resources configuration data. + * + * @var array + */ + protected $_data; + + /** + * Construct strategy with config helper. + * + * @param \Magento\Webapi\Model\Config\ClassReflector\TypeProcessor $typeProcessor + */ + public function __construct(\Magento\Webapi\Model\Config\ClassReflector\TypeProcessor $typeProcessor) + { + $this->_typeProcessor = $typeProcessor; + } + + /** + * Return DOM Document + * + * @return \DomDocument + */ + protected function _getDom() + { + return $this->getContext()->toDomDocument(); + } + + /** + * Add complex type. + * + * @param string $type + * @param array $parentCallInfo array of callInfo from parent complex type + * @return string + * @throws \InvalidArgumentException + */ + public function addComplexType($type, $parentCallInfo = array()) + { + if (($soapType = $this->scanRegisteredTypes($type)) !== null) { + return $soapType; + } + $soapType = Wsdl::TYPES_NS . ':' . $type; + // Register type here to avoid recursion + $this->getContext()->addType($type, $soapType); + $complexType = $this->_getDom()->createElement(Wsdl::XSD_NS . ':complexType'); + $complexType->setAttribute('name', $type); + $typeData = $this->_typeProcessor->getTypeData($type); + if (isset($typeData['documentation'])) { + $this->addAnnotation($complexType, $typeData['documentation']); + } + + if (isset($typeData['parameters']) && is_array($typeData['parameters'])) { + $callInfo = isset($typeData['callInfo']) ? $typeData['callInfo'] : $parentCallInfo; + $sequence = $this->_processParameters($typeData['parameters'], $callInfo); + $complexType->appendChild($sequence); + } + + $this->getContext()->getSchema()->appendChild($complexType); + return $soapType; + } + + /** + * Process type parameters and create complex type sequence. + * + * @param array $parameters + * @param array $callInfo + * @return \DOMElement + */ + protected function _processParameters($parameters, $callInfo) + { + $sequence = $this->_getDom()->createElement(Wsdl::XSD_NS . ':sequence'); + foreach ($parameters as $parameterName => $parameterData) { + $parameterType = $parameterData['type']; + $element = $this->_getDom()->createElement(Wsdl::XSD_NS . ':element'); + $element->setAttribute('name', $parameterName); + $isRequired = isset($parameterData['required']) && $parameterData['required']; + $default = isset($parameterData['default']) ? $parameterData['default'] : null; + $this->_revertRequiredCallInfo($isRequired, $callInfo); + + if ($this->_typeProcessor->isArrayType($parameterType)) { + $this->_processArrayParameter($parameterType, $callInfo); + $element->setAttribute( + 'type', + Wsdl::TYPES_NS . ':' . $this->_typeProcessor->translateArrayTypeName($parameterType) + ); + } else { + $this->_processParameter($element, $isRequired, $parameterData, $parameterType, $callInfo); + } + + $this->addAnnotation($element, $parameterData['documentation'], $default, $callInfo); + $sequence->appendChild($element); + } + + return $sequence; + } + + /** + * Process parameter and declare complex type if necessary. + * + * @param \DOMElement $element + * @param boolean $isRequired + * @param array $parameterData + * @param string $parameterType + * @param array $callInfo + */ + protected function _processParameter(\DOMElement $element, $isRequired, $parameterData, $parameterType, $callInfo) + { + $element->setAttribute('minOccurs', $isRequired ? 1 : 0); + $maxOccurs = (isset($parameterData['isArray']) && $parameterData['isArray']) ? 'unbounded' : 1; + $element->setAttribute('maxOccurs', $maxOccurs); + if ($this->_typeProcessor->isTypeSimple($parameterType)) { + $typeNs = Wsdl::XSD_NS; + } else { + $typeNs = Wsdl::TYPES_NS; + $this->addComplexType($parameterType, $callInfo); + } + $element->setAttribute('type', $typeNs . ':' . $parameterType); + } + + /** + * Process array of types. + * + * @param string $type + * @param array $callInfo + */ + protected function _processArrayParameter($type, $callInfo = array()) + { + $arrayItemType = $this->_typeProcessor->getArrayItemType($type); + $arrayTypeName = $this->_typeProcessor->translateArrayTypeName($type); + if (!$this->_typeProcessor->isTypeSimple($arrayItemType)) { + $this->addComplexType($arrayItemType, $callInfo); + } + $arrayTypeParameters = array( + self::ARRAY_ITEM_KEY_NAME => array( + 'type' => $arrayItemType, + 'required' => false, + 'isArray' => true, + 'documentation' => sprintf('An item of %s.', $arrayTypeName) + ) + ); + $arrayTypeData = array( + 'documentation' => sprintf('An array of %s items.', $arrayItemType), + 'parameters' => $arrayTypeParameters, + ); + $this->_typeProcessor->setTypeData($arrayTypeName, $arrayTypeData); + $this->addComplexType($arrayTypeName, $callInfo); + } + + /** + * Revert required call info data if needed. + * + * @param boolean $isRequired + * @param array $callInfo + */ + protected function _revertRequiredCallInfo($isRequired, &$callInfo) + { + if (!$isRequired) { + if (isset($callInfo['requiredInput']['yes'])) { + $callInfo['requiredInput']['no']['calls'] = $callInfo['requiredInput']['yes']['calls']; + unset($callInfo['requiredInput']['yes']); + } + if (isset($callInfo['returned']['always'])) { + $callInfo['returned']['conditionally']['calls'] = $callInfo['returned']['always']['calls']; + unset($callInfo['returned']['always']); + } + } + } + + /** + * Generate annotation data for WSDL. + * + * Convert all {key:value} from documentation into appinfo nodes. + * Override default callInfo values if defined in parameter documentation. + * + * @param \DOMElement $element + * @param string $documentation parameter documentation string + * @param string|null $default + * @param array $callInfo + */ + public function addAnnotation(\DOMElement $element, $documentation, $default = null, $callInfo = array()) + { + $annotationNode = $this->_getDom()->createElement(Wsdl::XSD_NS . ':annotation'); + + $elementType = $this->_getElementType($element); + $appInfoNode = $this->_getDom()->createElement(Wsdl::XSD_NS . ':appinfo'); + $appInfoNode->setAttributeNS( + Wsdl::XML_NS_URI, + Wsdl::XML_NS . ':' . self::APP_INF_NS, + $this->getContext()->getTargetNamespace() + ); + + $this->_processDefaultValueAnnotation($elementType, $default, $appInfoNode); + $this->_processElementType($elementType, $documentation, $appInfoNode); + + if (preg_match_all('/{([a-z]+):(.+)}/Ui', $documentation, $matches)) { + for ($i = 0; $i < count($matches[0]); $i++) { + $appinfoTag = $matches[0][$i]; + $tagName = $matches[1][$i]; + $tagValue = $matches[2][$i]; + switch ($tagName) { + case 'callInfo': + $callInfoRegExp = '/([a-z].+):(returned|requiredInput):(yes|no|always|conditionally)/i'; + if (preg_match($callInfoRegExp, $tagValue)) { + list($callName, $direction, $condition) = explode(':', $tagValue); + $condition = strtolower($condition); + if (preg_match('/allCallsExcept\(([a-zA-Z].+)\)/', $callName, $calls)) { + $callInfo[$direction][$condition] = array( + 'allCallsExcept' => $calls[1], + ); + } else if (!isset($callInfo[$direction][$condition]['allCallsExcept'])) { + $this->_overrideCallInfoName($callInfo, $callName); + $callInfo[$direction][$condition]['calls'][] = $callName; + } + } + break; + case 'seeLink': + $this->_processSeeLink($appInfoNode, $tagValue); + break; + case 'docInstructions': + $this->_processDocInstructions($appInfoNode, $tagValue); + break; + default: + $nodeValue = trim($tagValue); + $simpleTextNode = $this->_getDom()->createElement(self::APP_INF_NS . ':' . $tagName); + $simpleTextNode->appendChild($this->_getDom()->createTextNode($nodeValue)); + $appInfoNode->appendChild($simpleTextNode); + break; + } + $documentation = str_replace($appinfoTag, '', $documentation); + } + } + $this->_processCallInfo($appInfoNode, $callInfo); + $documentationNode = $this->_getDom()->createElement(Wsdl::XSD_NS . ':documentation'); + $documentationText = trim($documentation); + $documentationNode->appendChild($this->_getDom()->createTextNode($documentationText)); + $annotationNode->appendChild($documentationNode); + $annotationNode->appendChild($appInfoNode); + $element->appendChild($annotationNode); + } + + /** + * Process different element types. + * + * @param string $elementType + * @param string $documentation + * @param \DOMElement $appInfoNode + */ + protected function _processElementType($elementType, $documentation, \DOMElement $appInfoNode) + { + if ($elementType == 'int') { + $this->_processRequiredAnnotation('min', $documentation, $appInfoNode); + $this->_processRequiredAnnotation('max', $documentation, $appInfoNode); + } + if ($elementType == 'string') { + $this->_processRequiredAnnotation('maxLength', $documentation, $appInfoNode); + } + + if ($this->_typeProcessor->isArrayType($elementType)) { + $natureOfTypeNode = $this->_getDom()->createElement(self::APP_INF_NS . ':natureOfType'); + $natureOfTypeNode->appendChild($this->_getDom()->createTextNode('array')); + $appInfoNode->appendChild($natureOfTypeNode); + } + } + + /** + * Process default value annotation. + * + * @param string $elementType + * @param string $default + * @param \DOMElement $appInfoNode + */ + protected function _processDefaultValueAnnotation($elementType, $default, \DOMElement $appInfoNode) + { + if ($elementType == 'boolean') { + $default = (bool)$default ? 'true' : 'false'; + } + if ($default) { + $defaultNode = $this->_getDom()->createElement(self::APP_INF_NS . ':default'); + $defaultNode->appendChild($this->_getDom()->createTextNode($default)); + $appInfoNode->appendChild($defaultNode); + } + } + + /** + * Retrieve element type. + * + * @param \DOMElement $element + * @return string|null + * @SuppressWarnings(PHPMD.UnusedLocalVariable) + */ + protected function _getElementType(\DOMElement $element) + { + $elementType = null; + if ($element->hasAttribute('type')) { + list($typeNs, $elementType) = explode(':', $element->getAttribute('type')); + } + return $elementType; + } + + /** + * Check if there is given annotation in documentation, and if not - create an empty one. + * + * @param $annotation + * @param $documentation + * @param \DOMElement $appInfoNode + */ + protected function _processRequiredAnnotation($annotation, $documentation, \DOMElement $appInfoNode) + { + if (!preg_match("/{{$annotation}:.+}/Ui", $documentation)) { + $annotationNode = $this->_getDom()->createElement(self::APP_INF_NS . ':' . $annotation); + $appInfoNode->appendChild($annotationNode); + } + } + + /** + * Process 'callInfo' appinfo tag. + * + * @param \DOMElement $appInfoNode + * @param $callInfo + */ + protected function _processCallInfo(\DOMElement $appInfoNode, $callInfo) + { + if (!empty($callInfo)) { + foreach ($callInfo as $direction => $conditions) { + foreach ($conditions as $condition => $info) { + $callInfoNode = $this->_getDom()->createElement(self::APP_INF_NS . ':callInfo'); + if (isset($info['allCallsExcept'])) { + $allExceptNode = $this->_getDom()->createElement(self::APP_INF_NS . ':allCallsExcept'); + $allExceptNode->appendChild($this->_getDom()->createTextNode($info['allCallsExcept'])); + $callInfoNode->appendChild($allExceptNode); + } else if (isset($info['calls'])) { + foreach ($info['calls'] as $callName) { + $callNode = $this->_getDom()->createElement(self::APP_INF_NS . ':callName'); + $callNode->appendChild($this->_getDom()->createTextNode($callName)); + $callInfoNode->appendChild($callNode); + } + } + $directionNode = $this->_getDom()->createElement(self::APP_INF_NS . ':' . $direction); + $directionNode->appendChild($this->_getDom()->createTextNode(ucfirst($condition))); + $callInfoNode->appendChild($directionNode); + $appInfoNode->appendChild($callInfoNode); + } + } + } + } + + /** + * Process 'docInstructions' appinfo tag. + * + * @param \DOMElement $appInfoNode + * @param $tagValue + */ + protected function _processDocInstructions(\DOMElement $appInfoNode, $tagValue) + { + if (preg_match('/(input|output):(.+)/', $tagValue, $docMatches)) { + $docInstructionsNode = $this->_getDom()->createElement(self::APP_INF_NS . ':docInstructions'); + $directionNode = $this->_getDom()->createElement(self::APP_INF_NS . ':' . $docMatches[1]); + $directionValueNode = $this->_getDom()->createElement(self::APP_INF_NS . ':' . $docMatches[2]); + $directionNode->appendChild($directionValueNode); + $docInstructionsNode->appendChild($directionNode); + $appInfoNode->appendChild($docInstructionsNode); + } + } + + /** + * Process 'seeLink' appinfo tag. + * + * @param \DOMElement $appInfoNode + * @param $tagValue + */ + protected function _processSeeLink(\DOMElement $appInfoNode, $tagValue) + { + if (preg_match('|([http://]?.+):(.+):(.+)|i', $tagValue, $matches)) { + $seeLink = array( + 'url' => $matches[1], + 'title' => $matches[2], + 'for' => $matches[3], + ); + $seeLinkNode = $this->_getDom()->createElement(self::APP_INF_NS . ':seeLink'); + foreach (array('url', 'title', 'for') as $subNodeName) { + if (isset($seeLink[$subNodeName])) { + $seeLinkSubNode = $this->_getDom()->createElement(self::APP_INF_NS . ':' . $subNodeName); + $seeLinkSubNode->appendChild($this->_getDom()->createTextNode($seeLink[$subNodeName])); + $seeLinkNode->appendChild($seeLinkSubNode); + } + } + $appInfoNode->appendChild($seeLinkNode); + } + } + + /** + * Delete callName if it's already defined in some direction group. + * + * @param $callInfo + * @param $callName + */ + protected function _overrideCallInfoName(&$callInfo, $callName) + { + foreach ($callInfo as $direction => &$callInfoData) { + foreach ($callInfoData as $condition => &$data) { + if (isset($data['calls'])) { + $foundCallNameIndex = array_search($callName, $data['calls']); + if ($foundCallNameIndex !== false) { + unset($data['calls'][$foundCallNameIndex]); + if (empty($data['calls'])) { + unset($callInfo[$direction][$condition]); + } + break; + } + } + } + } + } +} diff --git a/app/code/Magento/Webapi/Model/Soap/Wsdl/Factory.php b/app/code/Magento/Webapi/Model/Soap/Wsdl/Factory.php index 54891183f7a03c4f78c4f3a1becc27e67323cb01..11e06a519ea2c9def7d8d4302dc0a3f2a365f0dc 100644 --- a/app/code/Magento/Webapi/Model/Soap/Wsdl/Factory.php +++ b/app/code/Magento/Webapi/Model/Soap/Wsdl/Factory.php @@ -1,7 +1,5 @@ <?php /** - * Factory of WSDL builders. - * * Magento * * NOTICE OF LICENSE @@ -23,8 +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\Webapi\Model\Soap\Wsdl; +/** + * Factory of WSDL builders. + */ class Factory { /** diff --git a/app/code/Magento/Webapi/Model/Soap/Wsdl/Generator.php b/app/code/Magento/Webapi/Model/Soap/Wsdl/Generator.php index 4528ca5861fe341dcf8218fcf11ffae9d35a286b..018327b311e8143582d94dbb42b4edd9f9bf3b04 100644 --- a/app/code/Magento/Webapi/Model/Soap/Wsdl/Generator.php +++ b/app/code/Magento/Webapi/Model/Soap/Wsdl/Generator.php @@ -1,7 +1,5 @@ <?php - /** - * WSDL generator. * * Magento * @@ -24,16 +22,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\Webapi\Model\Soap\Wsdl; use Magento\Webapi\Model\Soap\Wsdl; use Magento\Webapi\Model\Soap\Fault; +/** + * WSDL generator. + */ class Generator { const WSDL_NAME = 'MagentoWSDL'; const WSDL_CACHE_ID = 'WSDL'; - /** * WSDL factory instance. * @@ -51,6 +52,9 @@ class Generator */ protected $_apiConfig; + /** @var \Magento\Webapi\Model\Config\ClassReflector\TypeProcessor */ + protected $_typeProcessor; + /** * The list of registered complex types. * @@ -64,15 +68,18 @@ class Generator * @param \Magento\Webapi\Model\Soap\Config $apiConfig * @param \Magento\Webapi\Model\Soap\Wsdl\Factory $wsdlFactory * @param \Magento\Webapi\Model\Cache\Type $cache + * @param \Magento\Webapi\Model\Config\ClassReflector\TypeProcessor $typeProcessor */ public function __construct( \Magento\Webapi\Model\Soap\Config $apiConfig, \Magento\Webapi\Model\Soap\Wsdl\Factory $wsdlFactory, - \Magento\Webapi\Model\Cache\Type $cache + \Magento\Webapi\Model\Cache\Type $cache, + \Magento\Webapi\Model\Config\ClassReflector\TypeProcessor $typeProcessor ) { $this->_apiConfig = $apiConfig; $this->_wsdlFactory = $wsdlFactory; $this->_cache = $cache; + $this->_typeProcessor = $typeProcessor; } /** @@ -81,7 +88,7 @@ class Generator * @param array $requestedServices * @param string $endPointUrl * @return string - * @throws \Magento\Webapi\Exception + * @throws \Exception */ public function generate($requestedServices, $endPointUrl) { @@ -92,8 +99,12 @@ class Generator if ($cachedWsdlContent !== false) { return $cachedWsdlContent; } + $services = array(); + foreach ($requestedServices as $serviceName) { + $services[$serviceName] = $this->_apiConfig->getServiceMetadata($serviceName); + } - $wsdlContent = $this->_generate($requestedServices, $endPointUrl); + $wsdlContent = $this->_generate($services, $endPointUrl); $this->_cache->save($wsdlContent, $cacheId, array(\Magento\Webapi\Model\Cache\Type::CACHE_TAG)); return $wsdlContent; @@ -109,22 +120,11 @@ class Generator */ protected function _generate($requestedServices, $endPointUrl) { - $services = array(); - - try { - foreach ($requestedServices as $serviceName) { - $services[$serviceName] = $this->_prepareServiceData($serviceName); - } - } catch (\Magento\Webapi\Exception $e) { - throw $e; - } catch (\Exception $e) { - throw new \Magento\Webapi\Exception($e->getMessage()); - } - + $this->_collectCallInfo($requestedServices); $wsdl = $this->_wsdlFactory->create(self::WSDL_NAME, $endPointUrl); $wsdl->addSchemaTypeSection(); - $this->_addDefaultFaultComplexTypeNodes($wsdl); - foreach ($services as $serviceClass => $serviceData) { + $faultMessageName = $this->_addGenericFaultComplexTypeNodes($wsdl); + foreach ($requestedServices as $serviceClass => $serviceData) { $portTypeName = $this->getPortTypeName($serviceClass); $bindingName = $this->getBindingName($serviceClass); $portType = $wsdl->addPortType($portTypeName); @@ -137,43 +137,31 @@ class Generator foreach ($serviceData['methods'] as $methodName => $methodData) { $operationName = $this->getOperationName($serviceClass, $methodName); - $inputBinding = array('use' => 'literal'); + $bindingDataPrototype = array('use' => 'literal'); + $inputBinding = $bindingDataPrototype; $inputMessageName = $this->_createOperationInput($wsdl, $operationName, $methodData); $outputMessageName = false; $outputBinding = false; - if (isset($methodData['interface']['outputComplexTypes'])) { - $outputBinding = array('use' => 'literal'); + if (isset($methodData['interface']['out']['parameters'])) { + $outputBinding = $bindingDataPrototype; $outputMessageName = $this->_createOperationOutput($wsdl, $operationName, $methodData); } - - /** Default SOAP fault should be added to each operation declaration */ - $faultsInfo = array( - array( - 'name' => Fault::NODE_DETAIL_WRAPPER, - 'message' => Wsdl::TYPES_NS . ':' . $this->_getDefaultFaultMessageName() - ) - ); - if (isset($methodData['interface']['faultComplexTypes'])) { - $faultsInfo = array_merge( - $faultsInfo, - $this->_createOperationFaults($wsdl, $operationName, $methodData) - ); - } + $faultBinding = array_merge($bindingDataPrototype, array('name' => Fault::NODE_DETAIL_WRAPPER)); $wsdl->addPortOperation( $portType, $operationName, $inputMessageName, $outputMessageName, - $faultsInfo + array('message' => $faultMessageName, 'name' => Fault::NODE_DETAIL_WRAPPER) ); $bindingOperation = $wsdl->addBindingOperation( $binding, $operationName, $inputBinding, $outputBinding, - $faultsInfo, + $faultBinding, SOAP_1_2 ); $wsdl->addSoapOperation($bindingOperation, $operationName, SOAP_1_2); @@ -182,63 +170,6 @@ class Generator return $wsdl->toXML(); } - /** - * Extract complex type element from dom document by type name (include referenced types as well). - * - * @param string $serviceName - * @param string $typeName Type names as defined in Service XSDs - * @param \DOMDocument $domDocument - * @return \DOMNode[] - */ - public function getComplexTypeNodes($serviceName, $typeName, $domDocument) - { - $response = array(); - /** TODO: Use object manager to instantiate objects */ - $xpath = new \DOMXPath($domDocument); - $typeXPath = "//xsd:complexType[@name='{$typeName}']"; - $complexTypeNodes = $xpath->query($typeXPath); - if ($complexTypeNodes) { - $complexTypeNode = $complexTypeNodes->item(0); - } - if (isset($complexTypeNode)) { - $this->_registeredTypes[] = $serviceName . $typeName; - - $referencedTypes = $xpath->query("{$typeXPath}//@type"); - foreach ($referencedTypes as $referencedType) { - $referencedTypeName = $referencedType->value; - $prefixedRefTypeName = $serviceName . $referencedTypeName; - if ($this->isComplexType($referencedTypeName, $domDocument) - && !in_array($prefixedRefTypeName, $this->_registeredTypes) - ) { - $response += $this->getComplexTypeNodes($serviceName, $referencedTypeName, $domDocument); - /** Add target namespace to the referenced type name */ - $referencedType->value = Wsdl::TYPES_NS . ':' . $prefixedRefTypeName; - } - } - $complexTypeNode->setAttribute( - 'name', - $serviceName . $typeName - ); - $response[$serviceName . $typeName] - = $complexTypeNode->cloneNode(true); - } - return $response; - } - - /** - * Check if provided type is complex or simple type. - * - * Current implementation is based on the assumption that complex types are not prefixed with any namespace, - * and simple types are prefixed. - * - * @param string $typeName - * @return bool - */ - public function isComplexType($typeName) - { - return !strpos($typeName, ':'); - } - /** * Create input message and corresponding element and complex types in WSDL. * @@ -250,18 +181,27 @@ class Generator protected function _createOperationInput(Wsdl $wsdl, $operationName, $methodData) { $inputMessageName = $this->getInputMessageName($operationName); + $complexTypeName = $this->getElementComplexTypeName($inputMessageName); + $inputParameters = array(); $elementData = array( 'name' => $inputMessageName, - 'type' => Wsdl::TYPES_NS . ':' . $inputMessageName + 'type' => Wsdl::TYPES_NS . ':' . $complexTypeName ); - if (isset($methodData['interface']['inputComplexTypes'])) { - foreach ($methodData['interface']['inputComplexTypes'] as $complexTypeNode) { - $wsdl->addComplexType($complexTypeNode); - } + if (isset($methodData['interface']['in']['parameters'])) { + $inputParameters = $methodData['interface']['in']['parameters']; } else { $elementData['nillable'] = 'true'; } $wsdl->addElement($elementData); + $callInfo = array(); + $callInfo['requiredInput']['yes']['calls'] = array($operationName); + $typeData = array( + 'documentation' => $methodData['documentation'], + 'parameters' => $inputParameters, + 'callInfo' => $callInfo, + ); + $this->_typeProcessor->setTypeData($complexTypeName, $typeData); + $wsdl->addComplexType($complexTypeName); $wsdl->addMessage( $inputMessageName, array( @@ -274,7 +214,7 @@ class Generator } /** - * Create output message, corresponding element and complex types in WSDL. + * Create output message and corresponding element and complex types in WSDL. * * @param Wsdl $wsdl * @param string $operationName @@ -284,17 +224,22 @@ class Generator protected function _createOperationOutput(Wsdl $wsdl, $operationName, $methodData) { $outputMessageName = $this->getOutputMessageName($operationName); + $complexTypeName = $this->getElementComplexTypeName($outputMessageName); $wsdl->addElement( array( 'name' => $outputMessageName, - 'type' => Wsdl::TYPES_NS . ':' . $outputMessageName + 'type' => Wsdl::TYPES_NS . ':' . $complexTypeName ) ); - if (isset($methodData['interface']['outputComplexTypes'])) { - foreach ($methodData['interface']['outputComplexTypes'] as $complexTypeNode) { - $wsdl->addComplexType($complexTypeNode); - } - } + $callInfo = array(); + $callInfo['returned']['always']['calls'] = array($operationName); + $typeData = array( + 'documentation' => sprintf('Response container for the %s call.', $operationName), + 'parameters' => $methodData['interface']['out']['parameters'], + 'callInfo' => $callInfo, + ); + $this->_typeProcessor->setTypeData($complexTypeName, $typeData); + $wsdl->addComplexType($complexTypeName); $wsdl->addMessage( $outputMessageName, array( @@ -306,46 +251,6 @@ class Generator return Wsdl::TYPES_NS . ':' . $outputMessageName; } - /** - * Create an array of items that contain information about method faults. - * - * @param Wsdl $wsdl - * @param string $operationName - * @param array $methodData - * @return array array(array('name' => ..., 'message' => ...)) - */ - protected function _createOperationFaults(Wsdl $wsdl, $operationName, $methodData) - { - $faults = array(); - if (isset($methodData['interface']['faultComplexTypes'])) { - foreach ($methodData['interface']['faultComplexTypes'] as $faultName => $faultComplexTypes) { - $faultMessageName = $this->getFaultMessageName($operationName, $faultName); - $wsdl->addElement( - array( - 'name' => $faultMessageName, - 'type' => Wsdl::TYPES_NS . ':' . $faultMessageName - ) - ); - foreach ($faultComplexTypes as $complexTypeNode) { - $wsdl->addComplexType($complexTypeNode); - } - $wsdl->addMessage( - $faultMessageName, - array( - 'messageParameters' => array( - 'element' => Wsdl::TYPES_NS . ':' . $faultMessageName - ) - ) - ); - $faults[] = array( - 'name' => $operationName . $faultName, - 'message' => Wsdl::TYPES_NS . ':' . $faultMessageName - ); - } - } - return $faults; - } - /** * Get name of complexType for message element. * @@ -436,245 +341,111 @@ class Generator } /** - * Get fault message node name for operation. + * Collect data about complex types call info. * - * @param string $operationName - * @param string $faultName - * @return string - */ - public function getFaultMessageName($operationName, $faultName) - { - return $operationName . $faultName . 'Fault'; - } - - /** - * Get complexType name defined in the XSD for requests + * Walks through all requested services and checks all methods 'in' and 'out' parameters. * - * @param $serviceMethod - * @return string - */ - public function getXsdRequestTypeName($serviceMethod) - { - return ucfirst($serviceMethod) . "Request"; - } - - /** - * Get complexType name defined in the XSD for responses - * - * @param $serviceMethod - * @return string - */ - public function getXsdResponseTypeName($serviceMethod) - { - return ucfirst($serviceMethod) . "Response"; - } - - /** - * Get info about complex types defined in the XSD for the service method faults. - * - * @param string $serviceMethod - * @param \DOMDocument $domDocument - * @return array array(array('complexTypeName' => ..., 'faultName' => ...)) + * @param array $requestedServices */ - public function getXsdFaultTypeNames($serviceMethod, $domDocument) + protected function _collectCallInfo($requestedServices) { - $faultTypeNames = array(); - $xpath = new \DOMXPath($domDocument); - $serviceMethod = ucfirst($serviceMethod); - $typeXPath = "//xsd:complexType[starts-with(@name,'{$serviceMethod}') and contains(@name,'Fault')]"; - $complexTypeNodes = $xpath->query($typeXPath); - /** @var \DOMElement $complexTypeNode */ - foreach ($complexTypeNodes as $complexTypeNode) { - $complexTypeName = $complexTypeNode->getAttribute('name'); - if (preg_match("/^{$serviceMethod}(\w+)Fault$/", $complexTypeName, $matches)) { - $faultTypeNames[] = array('complexTypeName' => $complexTypeName, 'faultName' => $matches[1]); + foreach ($requestedServices as $serviceName => $serviceData) { + foreach ($serviceData['methods'] as $methodName => $methodData) { + $this->_processInterfaceCallInfo($methodData['interface'], $serviceName, $methodName); } } - return $faultTypeNames; } /** - * Prepare data about requested service for WSDL generator. + * Process call info data from interface. * + * @param array $interface * @param string $serviceName - * @return array - * @throws \Magento\Webapi\Exception - * @throws \LogicException + * @param string $methodName */ - protected function _prepareServiceData($serviceName) + protected function _processInterfaceCallInfo($interface, $serviceName, $methodName) { - $requestedServices = $this->_apiConfig->getRequestedSoapServices(array($serviceName)); - if (empty($requestedServices)) { - throw new \Magento\Webapi\Exception( - __('Service %1 is not available.', $serviceName), - 0, - \Magento\Webapi\Exception::HTTP_NOT_FOUND - ); - } - /** $requestedServices is expected to contain exactly one item */ - $serviceData = reset($requestedServices); - $serviceDataTypes = array('methods' => array()); - $serviceClass = $serviceData[\Magento\Webapi\Model\Soap\Config::KEY_CLASS]; - foreach ($serviceData['methods'] as $operationData) { - $methodInterface = array(); - $serviceMethod = $operationData[\Magento\Webapi\Model\Soap\Config::KEY_METHOD]; - /** @var $payloadSchemaDom \DOMDocument */ - $payloadSchemaDom = $this->_apiConfig->getServiceSchemaDOM($serviceClass); - $operationName = $this->getOperationName($serviceName, $serviceMethod); - - /** Process input complex type */ - $inputParameterName = $this->getInputMessageName($operationName); - $inputComplexTypes = $this->getComplexTypeNodes( - $serviceName, - $this->getXsdRequestTypeName($serviceMethod), - $payloadSchemaDom - ); - if (empty($inputComplexTypes)) { - if ($operationData[\Magento\Webapi\Model\Soap\Config::KEY_IS_REQUIRED]) { - throw new \LogicException( - sprintf('The method "%s" of service "%s" must have "%s" complex type defined in its schema.', - $serviceMethod, $serviceName, $inputParameterName) - ); - } else { - /** Generate empty input request to make WSDL compliant with WS-I basic profile */ - $inputComplexTypes[] = $this->_generateEmptyComplexType($inputParameterName, $payloadSchemaDom); + foreach ($interface as $direction => $interfaceData) { + $direction = ($direction == 'in') ? 'requiredInput' : 'returned'; + foreach ($interfaceData['parameters'] as $parameterData) { + $parameterType = $parameterData['type']; + if (!$this->_typeProcessor->isTypeSimple($parameterType)) { + $operation = $this->getOperationName($serviceName, $methodName); + if ($parameterData['required']) { + $condition = ($direction == 'requiredInput') ? 'yes' : 'always'; + } else { + $condition = ($direction == 'requiredInput') ? 'no' : 'conditionally'; + } + $callInfo = array(); + $callInfo[$direction][$condition]['calls'][] = $operation; + $this->_typeProcessor->setTypeData($parameterType, array('callInfo' => $callInfo)); } } - $methodInterface['inputComplexTypes'] = $inputComplexTypes; - - /** Process output complex type */ - $outputParameterName = $this->getOutputMessageName($operationName); - $outputComplexTypes = $this->getComplexTypeNodes( - $serviceName, - $this->getXsdResponseTypeName($serviceMethod), - $payloadSchemaDom - ); - if (!empty($outputComplexTypes)) { - $methodInterface['outputComplexTypes'] = $outputComplexTypes; - } else { - throw new \LogicException( - sprintf('The method "%s" of service "%s" must have "%s" complex type defined in its schema.', - $serviceMethod, $serviceName, $outputParameterName) - ); - } - - /** Process fault complex types */ - foreach ($this->getXsdFaultTypeNames($serviceMethod, $payloadSchemaDom) as $faultComplexType) { - $faultComplexTypes = $this->_getFaultComplexTypeNodes( - $serviceName, - $faultComplexType['complexTypeName'], - $payloadSchemaDom - ); - if (!empty($faultComplexTypes)) { - $methodInterface['faultComplexTypes'][$faultComplexType['faultName']] = $faultComplexTypes; - } - } - $serviceDataTypes['methods'][$serviceMethod]['interface'] = $methodInterface; } - return $serviceDataTypes; } /** - * Add WSDL elements related to default SOAP fault, which are common for all operations: element, type and message. + * Add WSDL elements related to generic SOAP fault, which are common for all operations: element, type and message. * * @param Wsdl $wsdl - * @return \DOMNode[] + * @return string Default fault message name */ - protected function _addDefaultFaultComplexTypeNodes($wsdl) + protected function _addGenericFaultComplexTypeNodes($wsdl) { - $domDocument = new \DOMDocument(); - $typeName = Fault::NODE_DETAIL_WRAPPER; - $defaultFault = $this->_generateEmptyComplexType($typeName, $domDocument); - $elementName = Fault::NODE_DETAIL_WRAPPER; - $wsdl->addElement(array('name' => $elementName, 'type' => Wsdl::TYPES_NS . ':' . $typeName)); + $faultMessageName = Fault::NODE_DETAIL_WRAPPER; + $complexTypeName = $this->getElementComplexTypeName($faultMessageName); + $wsdl->addElement( + array( + 'name' => $faultMessageName, + 'type' => Wsdl::TYPES_NS . ':' . $complexTypeName + ) + ); + $faultParamsComplexType = Fault::NODE_DETAIL_PARAMETER; + $faultParamsData = array( + 'parameters' => array( + Fault::NODE_DETAIL_PARAMETER_KEY => array( + 'type' => 'string', + 'required' => true, + 'documentation' => '', + ), + Fault::NODE_DETAIL_PARAMETER_VALUE => array( + 'type' => 'string', + 'required' => true, + 'documentation' => '', + ) + ) + ); + $genericFaultTypeData = array( + 'parameters' => array( + Fault::NODE_DETAIL_CODE => array( + 'type' => 'int', + 'required' => true, + 'documentation' => 'SOAP fault code, unique for each type of exceptions.', + ), + Fault::NODE_DETAIL_TRACE => array( + 'type' => 'string', + 'required' => false, + 'documentation' => 'Exception calls stack trace.', + ), + Fault::NODE_DETAIL_PARAMETERS => array( + 'type' => "{$faultParamsComplexType}[]", + 'required' => false, + 'documentation' => 'Additional exception parameters.', + ) + ) + ); + $this->_typeProcessor->setTypeData($faultParamsComplexType, $faultParamsData); + $this->_typeProcessor->setTypeData($complexTypeName, $genericFaultTypeData); + $wsdl->addComplexType($complexTypeName); $wsdl->addMessage( - $this->_getDefaultFaultMessageName(), - array('messageParameters' => array('element' => Wsdl::TYPES_NS . ':' . $elementName)) + $faultMessageName, + array( + 'messageParameters' => array( + 'element' => Wsdl::TYPES_NS . ':' . $faultMessageName + ) + ) ); - $this->_addDefaultFaultElements($defaultFault); - $wsdl->addComplexType($defaultFault); - } - /** - * Generate all necessary complex types for the fault of specified type. - * - * @param string $serviceName - * @param string $typeName - * @param \DOMDocument $domDocument - * @return \DOMNode[] - */ - protected function _getFaultComplexTypeNodes($serviceName, $typeName, $domDocument) - { - $complexTypesNodes = $this->getComplexTypeNodes($serviceName, $typeName, $domDocument); - $faultTypeName = $serviceName . $typeName; - $paramsTypeName = $faultTypeName . 'Params'; - if (isset($complexTypesNodes[$faultTypeName])) { - /** Rename fault complex type to fault param complex type */ - $faultComplexType = $complexTypesNodes[$faultTypeName]; - $faultComplexType->setAttribute('name', $paramsTypeName); - $complexTypesNodes[$paramsTypeName] = $complexTypesNodes[$faultTypeName]; - - /** Create new fault complex type, which will contain reference to fault param complex type */ - $newFaultComplexType = $this->_generateEmptyComplexType($faultTypeName, $domDocument); - $this->_addDefaultFaultElements($newFaultComplexType); - /** Create 'Parameters' element and use fault param complex type as its type */ - $parametersElement = $domDocument->createElement('xsd:element'); - $parametersElement->setAttribute('name', Fault::NODE_DETAIL_PARAMETERS); - $parametersElement->setAttribute('type', Wsdl::TYPES_NS . ':' . $paramsTypeName); - $newFaultComplexType->firstChild->appendChild($parametersElement); - - $complexTypesNodes[$faultTypeName] = $newFaultComplexType; - } - return $complexTypesNodes; - } - - /** - * Generate empty complex type with the specified name. - * - * @param string $complexTypeName - * @param \DOMDocument $domDocument - * @return \DOMElement - */ - protected function _generateEmptyComplexType($complexTypeName, $domDocument) - { - $complexTypeNode = $domDocument->createElement('xsd:complexType'); - $complexTypeNode->setAttribute('name', $complexTypeName); - $xsdNamespace = 'http://www.w3.org/2001/XMLSchema'; - $complexTypeNode->setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns:xsd', $xsdNamespace); - $domDocument->appendChild($complexTypeNode); - $sequenceNode = $domDocument->createElement('xsd:sequence'); - $complexTypeNode->appendChild($sequenceNode); - return $complexTypeNode; - } - - /** - * Add 'Detail' and 'Trace' elements to the fault element. - * - * @param \DOMElement $faultElement - */ - protected function _addDefaultFaultElements($faultElement) - { - /** Create 'Code' element */ - $codeElement = $faultElement->ownerDocument->createElement('xsd:element'); - $codeElement->setAttribute('name', Fault::NODE_DETAIL_CODE); - $codeElement->setAttribute('type', 'xsd:int'); - $faultElement->firstChild->appendChild($codeElement); - - /** Create 'Trace' element */ - $traceElement = $faultElement->ownerDocument->createElement('xsd:element'); - $traceElement->setAttribute('name', Fault::NODE_DETAIL_TRACE); - $traceElement->setAttribute('type', 'xsd:string'); - $traceElement->setAttribute('minOccurs', '0'); - $faultElement->firstChild->appendChild($traceElement); - } - - /** - * Retrieve name of default SOAP fault message name in WSDL. - * - * @return string - */ - protected function _getDefaultFaultMessageName() - { - return Fault::NODE_DETAIL_WRAPPER; + return Wsdl::TYPES_NS . ':' . $faultMessageName; } } diff --git a/app/code/Magento/Webapi/etc/di.xml b/app/code/Magento/Webapi/etc/di.xml index 48f019da28b05e29750f66880261410bd4b1e690..c981e05a523d74b180a5e1e185401378020e0fd3 100644 --- a/app/code/Magento/Webapi/etc/di.xml +++ b/app/code/Magento/Webapi/etc/di.xml @@ -26,14 +26,18 @@ <config> <type name="Magento\App\AreaList"> <param name="areas"> - <value> - <webapi_rest> - <frontName>rest</frontName> - </webapi_rest> - <webapi_soap> - <frontName>soap</frontName> - </webapi_soap> - </value> + <array> + <item key="webapi_rest"> + <array> + <item key="frontName"><value>rest</value></item> + </array> + </item> + <item key="webapi_soap"> + <array> + <item key="frontName"><value>soap</value></item> + </array> + </item> + </array> </param> </type> <type name="Magento\Xml\Generator" shared="false" /> diff --git a/app/code/Magento/Webapi/etc/webapi_rest/di.xml b/app/code/Magento/Webapi/etc/webapi_rest/di.xml index 0ff022f4deaf2b8e8a84c54e515ce2d47823074b..a4b50fa47bff278c29a6c46a7d1e1f5780210f80 100644 --- a/app/code/Magento/Webapi/etc/webapi_rest/di.xml +++ b/app/code/Magento/Webapi/etc/webapi_rest/di.xml @@ -34,50 +34,68 @@ <type name="Magento\Webapi\Controller\Rest\Router\Route" shared="false" /> <type name="Magento\Webapi\Controller\Rest\Request\Deserializer\Factory"> <param name="deserializers"> - <value> - <application_json> - <type>application/json</type> - <model>Magento\Webapi\Controller\Rest\Request\Deserializer\Json</model> - </application_json> - <application_xml> - <type>application/xml</type> - <model>Magento\Webapi\Controller\Rest\Request\Deserializer\Xml</model> - </application_xml> - <application_xhtml_xml> - <type>application/xhtml+xml</type> - <model>Magento\Webapi\Controller\Rest\Request\Deserializer\Xml</model> - </application_xhtml_xml> - <text_xml> - <type>text/xml</type> - <model>Magento\Webapi\Controller\Rest\Request\Deserializer\Xml</model> - </text_xml> - </value> + <array> + <item key="application_json"> + <array> + <item key="type"><value>application/json</value></item> + <item key="model"><value>Magento\Webapi\Controller\Rest\Request\Deserializer\Json</value></item> + </array> + </item> + <item key="application_xml"> + <array> + <item key="type"><value>application/xml</value></item> + <item key="model"><value>Magento\Webapi\Controller\Rest\Request\Deserializer\Xml</value></item> + </array> + </item> + <item key="application_xhtml_xml"> + <array> + <item key="type"><value>application/xhtml+xml</value></item> + <item key="model"><value>Magento\Webapi\Controller\Rest\Request\Deserializer\Xml</value></item> + </array> + </item> + <item key="text_xml"> + <array> + <item key="type"><value>text/xml</value></item> + <item key="model"><value>Magento\Webapi\Controller\Rest\Request\Deserializer\Xml</value></item> + </array> + </item> + </array> </param> </type> <type name="Magento\Webapi\Controller\Rest\Response\Renderer\Factory"> <param name="renders"> - <value> - <default> - <type>*/*</type> - <model>Magento\Webapi\Controller\Rest\Response\Renderer\Json</model> - </default> - <application_json> - <type>application/json</type> - <model>Magento\Webapi\Controller\Rest\Response\Renderer\Json</model> - </application_json> - <text_xml> - <type>text/xml</type> - <model>Magento\Webapi\Controller\Rest\Response\Renderer\Xml</model> - </text_xml> - <application_xml> - <type>application/xml</type> - <model>Magento\Webapi\Controller\Rest\Response\Renderer\Xml</model> - </application_xml> - <application_xhtml_xml> - <type>application/xhtml+xml</type> - <model>Magento\Webapi\Controller\Rest\Response\Renderer\Xml</model> - </application_xhtml_xml> - </value> + <array> + <item key="default"> + <array> + <item key="type"><value>*/*</value></item> + <item key="model"><value>Magento\Webapi\Controller\Rest\Response\Renderer\Json</value></item> + </array> + </item> + <item key="application_json"> + <array> + <item key="type"><value>application/json</value></item> + <item key="model"><value>Magento\Webapi\Controller\Rest\Response\Renderer\Json</value></item> + </array> + </item> + <item key="text_xml"> + <array> + <item key="type"><value>text/xml</value></item> + <item key="model"><value>Magento\Webapi\Controller\Rest\Response\Renderer\Xml</value></item> + </array> + </item> + <item key="application_xml"> + <array> + <item key="type"><value>application/xml</value></item> + <item key="model"><value>Magento\Webapi\Controller\Rest\Response\Renderer\Xml</value></item> + </array> + </item> + <item key="application_xhtml_xml"> + <array> + <item key="type"><value>application/xhtml+xml</value></item> + <item key="model"><value>Magento\Webapi\Controller\Rest\Response\Renderer\Xml</value></item> + </array> + </item> + </array> </param> </type> <type name="Magento\Webapi\Controller\Rest"> diff --git a/app/code/Magento/Webapi/etc/webapi_soap/di.xml b/app/code/Magento/Webapi/etc/webapi_soap/di.xml index 836d05317eed01777f3f98ebd732a8ddb1191626..f98dd0fc07df413fc114b93f0a4bec59df1922dc 100644 --- a/app/code/Magento/Webapi/etc/webapi_soap/di.xml +++ b/app/code/Magento/Webapi/etc/webapi_soap/di.xml @@ -40,7 +40,7 @@ <instance type="Magento\Webapi\Controller\ErrorProcessor\Proxy"/> </param> </type> - <type name="Magento\Webapi\Controller\Soap\Handler"> + <type name="Magento\Webapi\Controller\Soap\Request\Handler"> <param name="authorizationService"> <instance type="Magento\Authz\Service\AuthorizationV1Interface\Proxy" /> </param> diff --git a/app/code/Magento/Weee/Model/Attribute/Backend/Weee/Tax.php b/app/code/Magento/Weee/Model/Attribute/Backend/Weee/Tax.php index 005495c828160099aa472a21b8f68564fc1ee754..4d5efa77bd4ebb40bda6eb6268766e13240d7ecc 100644 --- a/app/code/Magento/Weee/Model/Attribute/Backend/Weee/Tax.php +++ b/app/code/Magento/Weee/Model/Attribute/Backend/Weee/Tax.php @@ -48,7 +48,7 @@ class Tax extends \Magento\Catalog\Model\Product\Attribute\Backend\Price * @param \Magento\Directory\Model\CurrencyFactory $currencyFactory * @param \Magento\Core\Model\StoreManagerInterface $storeManager * @param \Magento\Catalog\Helper\Data $catalogData - * @param \Magento\Core\Model\Config $config + * @param \Magento\App\ConfigInterface $config * @param \Magento\Directory\Helper\Data $directoryHelper * @param \Magento\Weee\Model\Resource\Attribute\Backend\Weee\Tax $attributeTax */ @@ -57,7 +57,7 @@ class Tax extends \Magento\Catalog\Model\Product\Attribute\Backend\Price \Magento\Directory\Model\CurrencyFactory $currencyFactory, \Magento\Core\Model\StoreManagerInterface $storeManager, \Magento\Catalog\Helper\Data $catalogData, - \Magento\Core\Model\Config $config, + \Magento\App\ConfigInterface $config, \Magento\Directory\Helper\Data $directoryHelper, \Magento\Weee\Model\Resource\Attribute\Backend\Weee\Tax $attributeTax ) { diff --git a/app/code/Magento/Weee/Model/Observer.php b/app/code/Magento/Weee/Model/Observer.php index 7ddee5c048ecf0a89d3355d9bbdbeb4173e07549..babc527a64bfa75c4bf8cd287714ba63ab15aed3 100644 --- a/app/code/Magento/Weee/Model/Observer.php +++ b/app/code/Magento/Weee/Model/Observer.php @@ -50,13 +50,19 @@ class Observer extends \Magento\Core\Model\AbstractModel */ protected $_layout; + /** + * @var \Magento\Catalog\Model\ProductTypes\ConfigInterface + */ + protected $productTypeConfig; + /** * @param \Magento\Core\Model\Context $context * @param \Magento\Core\Model\Registry $registry * @param \Magento\View\LayoutInterface $layout - * @param \Magento\Weee\Model\Tax $weeeTax + * @param Tax $weeeTax * @param \Magento\Weee\Helper\Data $weeeData * @param \Magento\Catalog\Model\Product\Type $productType + * @param \Magento\Catalog\Model\ProductTypes\ConfigInterface $productTypeConfig * @param \Magento\Core\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data @@ -68,6 +74,7 @@ class Observer extends \Magento\Core\Model\AbstractModel \Magento\Weee\Model\Tax $weeeTax, \Magento\Weee\Helper\Data $weeeData, \Magento\Catalog\Model\Product\Type $productType, + \Magento\Catalog\Model\ProductTypes\ConfigInterface $productTypeConfig, \Magento\Core\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() @@ -76,6 +83,7 @@ class Observer extends \Magento\Core\Model\AbstractModel $this->_weeeTax = $weeeTax; $this->_productType = $productType; $this->_weeeData = $weeeData; + $this->productTypeConfig = $productTypeConfig; parent::__construct($context, $registry, $resource, $resourceCollection, $data); } @@ -158,9 +166,6 @@ class Observer extends \Magento\Core\Model\AbstractModel '_default_value', '_front_fieldset', ), - 'disabled_types' => array( - \Magento\GroupedProduct\Model\Product\Type\Grouped::TYPE_CODE, - ) ); $response->setTypes($types); @@ -184,7 +189,7 @@ class Observer extends \Magento\Core\Model\AbstractModel if (!$object->getApplyTo()) { $applyTo = array(); foreach ($this->_productType->getOptions() as $option) { - if ($option['value'] == \Magento\GroupedProduct\Model\Product\Type\Grouped::TYPE_CODE) { + if ($this->productTypeConfig->isProductSet($option['value'])) { continue; } $applyTo[] = $option['value']; @@ -199,7 +204,8 @@ class Observer extends \Magento\Core\Model\AbstractModel /** * Add custom element type for attributes form * - * @param \Magento\Event\Observer $observer + * @param \Magento\Event\Observer $observer + * @return \Magento\Weee\Model\Observer */ public function updateElementTypes(\Magento\Event\Observer $observer) { diff --git a/app/code/Magento/Weee/etc/di.xml b/app/code/Magento/Weee/etc/di.xml index d57ab7dc70f3eb49bad15648ae93ddf550f3fd6c..0dda633d0ca47932f650d02f340c631f037119e1 100644 --- a/app/code/Magento/Weee/etc/di.xml +++ b/app/code/Magento/Weee/etc/di.xml @@ -42,9 +42,9 @@ </type> <type name="Magento\Module\Updater\SetupFactory"> <param name="resourceTypes"> - <value> - <weee_setup>Magento\Sales\Model\Resource\Setup</weee_setup> - </value> + <array> + <item key="weee_setup"><value>Magento\Sales\Model\Resource\Setup</value></item> + </array> </param> </type> </config> diff --git a/app/code/Magento/Weee/etc/module.xml b/app/code/Magento/Weee/etc/module.xml index 6d8f60b135c531b389e15de6c4728e29a36d9805..0f4adb9404d23310be193766bdfbc9ce400e6a86 100644 --- a/app/code/Magento/Weee/etc/module.xml +++ b/app/code/Magento/Weee/etc/module.xml @@ -41,7 +41,6 @@ <module name="Magento_Customer"/> <module name="Magento_Bundle"/> <module name="Magento_Theme"/> - <module name="Magento_GroupedProduct"/> </depends> </module> </config> diff --git a/app/code/Magento/Widget/Model/Widget/Config.php b/app/code/Magento/Widget/Model/Widget/Config.php index 198f32cdf4fb4e0c8984f0242008d6c50fbf60f1..1dc177919a515bcefea82e2f2ffcfd0c0fbb7b10 100644 --- a/app/code/Magento/Widget/Model/Widget/Config.php +++ b/app/code/Magento/Widget/Model/Widget/Config.php @@ -40,7 +40,7 @@ class Config protected $_widget; /** - * @var \Magento\Backend\Model\Url + * @var \Magento\Backend\Model\UrlInterface */ protected $_backendUrl; @@ -55,13 +55,13 @@ class Config protected $_widgetFactory; /** - * @param \Magento\Backend\Model\Url $backendUrl + * @param \Magento\Backend\Model\UrlInterface $backendUrl * @param \Magento\Core\Helper\Data $coreHelper * @param \Magento\View\Url $viewUrl * @param \Magento\Widget\Model\WidgetFactory $widgetFactory */ public function __construct( - \Magento\Backend\Model\Url $backendUrl, + \Magento\Backend\Model\UrlInterface $backendUrl, \Magento\Core\Helper\Data $coreHelper, \Magento\View\Url $viewUrl, \Magento\Widget\Model\WidgetFactory $widgetFactory diff --git a/app/code/Magento/Widget/etc/adminhtml/di.xml b/app/code/Magento/Widget/etc/adminhtml/di.xml index 74be126898b9bbdb2e3a1149a7772d3b48dd5a4b..df83b22764ac4d43f8fcc2b2e235b261dbc73698 100644 --- a/app/code/Magento/Widget/etc/adminhtml/di.xml +++ b/app/code/Magento/Widget/etc/adminhtml/di.xml @@ -26,10 +26,10 @@ <config> <type name="Magento\Widget\Model\Widget\Instance"> <param name="relatedCacheTypes"> - <value> - <blockCache>block_html</blockCache> - <layoutCache>layout</layoutCache> - </value> + <array> + <item key="blockCache"><value>block_html</value></item> + <item key="layoutCache"><value>layout</value></item> + </array> </param> </type> </config> diff --git a/app/code/Magento/Widget/etc/di.xml b/app/code/Magento/Widget/etc/di.xml index deb509512138750e2c0860704f287e5b5c2e2067..9c37d60bbab666d7276460dc4a4e623d7b437c87 100644 --- a/app/code/Magento/Widget/etc/di.xml +++ b/app/code/Magento/Widget/etc/di.xml @@ -53,9 +53,9 @@ </type> <type name="Magento\Module\Updater\SetupFactory"> <param name="resourceTypes"> - <value> - <widget_setup>Magento\Core\Model\Resource\Setup\Generic</widget_setup> - </value> + <array> + <item key="widget_setup"><value>Magento\Core\Model\Resource\Setup\Generic</value></item> + </array> </param> </type> </config> diff --git a/app/code/Magento/Wishlist/Block/Share/Email/Items.php b/app/code/Magento/Wishlist/Block/Share/Email/Items.php index 8253de85176f7e13933a1a11c23aacab34eaa2ff..0d331f2d7908c84fe4854f63feda0049c7e67e29 100644 --- a/app/code/Magento/Wishlist/Block/Share/Email/Items.php +++ b/app/code/Magento/Wishlist/Block/Share/Email/Items.php @@ -47,7 +47,7 @@ class Items extends \Magento\Wishlist\Block\AbstractBlock */ public function getProductUrl($product, $additional = array()) { - $additional['_store_to_url'] = true; + $additional['_scope_to_url'] = true; return parent::getProductUrl($product, $additional); } @@ -61,7 +61,7 @@ class Items extends \Magento\Wishlist\Block\AbstractBlock public function getAddToCartUrl($product, $additional = array()) { $additional['nocookie'] = 1; - $additional['_store_to_url'] = true; + $additional['_scope_to_url'] = true; return parent::getAddToCartUrl($product, $additional); } diff --git a/app/code/Magento/Wishlist/Controller/AbstractController.php b/app/code/Magento/Wishlist/Controller/AbstractController.php index 2057f16ac78d6b5e2dcfcabebb019725b0c67931..85a1e808b0e86f90dfea2e1c0bad23f5aca3ddfd 100644 --- a/app/code/Magento/Wishlist/Controller/AbstractController.php +++ b/app/code/Magento/Wishlist/Controller/AbstractController.php @@ -151,7 +151,7 @@ abstract class AbstractController extends \Magento\App\Action\Action if ($isOwner) { $indexUrl = $this->_objectManager->get('Magento\Wishlist\Helper\Data')->getListUrl($wishlist->getId()); } else { - $indexUrl = $this->_objectManager->create('Magento\Core\Model\Url') + $indexUrl = $this->_objectManager->create('Magento\UrlInterface') ->getUrl('wishlist/shared', array('code' => $wishlist->getSharingCode())); } if ($this->_objectManager->get('Magento\Checkout\Helper\Cart')->getShouldRedirectToCart()) { diff --git a/app/code/Magento/Wishlist/Helper/Data.php b/app/code/Magento/Wishlist/Helper/Data.php index e3db7e1738ce479bdb1d755997b7e9edc4f7cffd..1038fa3166746f9e0ddd6ee430cee21e661df7ea 100644 --- a/app/code/Magento/Wishlist/Helper/Data.php +++ b/app/code/Magento/Wishlist/Helper/Data.php @@ -389,7 +389,7 @@ class Data extends \Magento\App\Helper\AbstractHelper $this->_getUrl('*/*/*', array( '_current' => true, '_use_rewrite' => true, - '_store_to_url' => true, + '_scope_to_url' => true, )) ); @@ -412,7 +412,7 @@ class Data extends \Magento\App\Helper\AbstractHelper $continueUrl = $this->_coreData->urlEncode($this->_getUrl('*/*/*', array( '_current' => true, '_use_rewrite' => true, - '_store_to_url' => true, + '_scope_to_url' => true, ))); $urlParamName = \Magento\App\Action\Action::PARAM_NAME_URL_ENCODED; diff --git a/app/code/Magento/Wishlist/Model/Item.php b/app/code/Magento/Wishlist/Model/Item.php index 9725b930f0e95008231a38015e610542cd74d936..dd5e0bcb807c3d0b380ee523e2def232210ff5f0 100644 --- a/app/code/Magento/Wishlist/Model/Item.php +++ b/app/code/Magento/Wishlist/Model/Item.php @@ -131,6 +131,11 @@ class Item extends \Magento\Core\Model\AbstractModel */ protected $_wishlOptionCollectionFactory; + /** + * @var \Magento\Catalog\Model\ProductTypes\ConfigInterface + */ + protected $productTypeConfig; + /** * @param \Magento\Core\Model\Context $context * @param \Magento\Core\Model\Registry $registry @@ -138,8 +143,9 @@ class Item extends \Magento\Core\Model\AbstractModel * @param \Magento\Core\Model\Date $date * @param \Magento\Catalog\Model\ProductFactory $productFactory * @param \Magento\Catalog\Model\Resource\Url $catalogUrl - * @param \Magento\Wishlist\Model\Item\OptionFactory $wishlistOptFactory - * @param \Magento\Wishlist\Model\Resource\Item\Option\CollectionFactory $wishlOptionCollectionFactory + * @param Item\OptionFactory $wishlistOptFactory + * @param Resource\Item\Option\CollectionFactory $wishlOptionCollectionFactory + * @param \Magento\Catalog\Model\ProductTypes\ConfigInterface $productTypeConfig * @param \Magento\Core\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data @@ -153,10 +159,12 @@ class Item extends \Magento\Core\Model\AbstractModel \Magento\Catalog\Model\Resource\Url $catalogUrl, \Magento\Wishlist\Model\Item\OptionFactory $wishlistOptFactory, \Magento\Wishlist\Model\Resource\Item\Option\CollectionFactory $wishlOptionCollectionFactory, + \Magento\Catalog\Model\ProductTypes\ConfigInterface $productTypeConfig, \Magento\Core\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { + $this->productTypeConfig = $productTypeConfig; $this->_storeManager = $storeManager; $this->_date = $date; $this->_productFactory = $productFactory; @@ -474,7 +482,6 @@ class Item extends \Magento\Core\Model\AbstractModel $option = $this->getOptionByCode('info_buyRequest'); $initialData = $option ? unserialize($option->getValue()) : null; - // There can be wrong data due to bug in Grouped products - it formed 'info_buyRequest' as \Magento\Object if ($initialData instanceof \Magento\Object) { $initialData = $initialData->getData(); } @@ -724,7 +731,7 @@ class Item extends \Magento\Core\Model\AbstractModel public function canHaveQty() { $product = $this->getProduct(); - return $product->getTypeId() != \Magento\GroupedProduct\Model\Product\Type\Grouped::TYPE_CODE; + return !$this->productTypeConfig->isProductSet($product->getTypeId()); } /** diff --git a/app/code/Magento/Wishlist/etc/frontend/di.xml b/app/code/Magento/Wishlist/etc/frontend/di.xml index 6ebfe13ebf1a1bac8c5d974a9e74cb9e4a987dfb..c20d0f98265cffc9a3cbd68ca1827636ddb66210 100644 --- a/app/code/Magento/Wishlist/etc/frontend/di.xml +++ b/app/code/Magento/Wishlist/etc/frontend/di.xml @@ -44,16 +44,16 @@ </type> <type name="Magento\Core\Model\Url\SecurityInfo"> <param name="secureUrlList"> - <value> - <wishlist>/wishlist/</wishlist> - </value> + <array> + <item key="wishlist"><value>/wishlist/</value></item> + </array> </param> </type> <virtualType name="wishlistInitSession" type="Magento\Core\App\Action\Plugin\Session"> <param name="cookieCheckActions"> - <value> - <wishlistAdd>add</wishlistAdd> - </value> + <array> + <item key="wishlistAdd"><value>add</value></item> + </array> </param> </virtualType> <type name="Magento\Wishlist\Controller\Index"> diff --git a/app/etc/di.xml b/app/etc/di.xml index 741d3dfa0e95a0d1d560c690bca2bc91a2908567..f0700b2a744a7da1beca2a54b85118bb7ef67267 100644 --- a/app/etc/di.xml +++ b/app/etc/di.xml @@ -30,7 +30,7 @@ <preference for="Magento\App\RouterListInterface" type="Magento\App\RouterList" /> <preference for="Magento\App\FrontControllerInterface" type="Magento\App\FrontController" /> <preference for="Magento\Module\UpdaterInterface" type="Magento\Module\Updater" /> - <preference for="Magento\Core\Model\AppInterface" type="Magento\Core\Model\App\Proxy" /> + <preference for="Magento\AppInterface" type="Magento\Core\Model\App\Proxy" /> <preference for="Magento\App\CacheInterface" type="Magento\App\Cache\Proxy" /> <preference for="Magento\App\Cache\StateInterface" type="Magento\App\Cache\State" /> <preference for="Magento\App\Cache\TypeListInterface" type="Magento\App\Cache\TypeList" /> @@ -40,12 +40,12 @@ <preference for="Magento\View\Design\ThemeInterface" type="Magento\Core\Model\Theme" /> <preference for="Magento\View\ConfigInterface" type="Magento\View\Config" /> <preference for="Magento\Core\Model\LocaleInterface" type="Magento\Core\Model\Locale" /> - <preference for="Magento\UrlInterface" type="Magento\Core\Model\Url" /> + <preference for="Magento\UrlInterface" type="Magento\Url" /> <preference for="Magento\Data\Collection\Db\FetchStrategyInterface" type="Magento\Data\Collection\Db\FetchStrategy\Query" /> <preference for="Magento\Config\ScopeInterface" type="Magento\Config\Scope" /> <preference for="Magento\Config\FileResolverInterface" type="Magento\Core\Model\Config\FileResolver" /> <preference for="Magento\Config\CacheInterface" type="Magento\App\Cache\Type\Config" /> - <preference for="Magento\Config\ValidationStateInterface" type="Magento\App\Config\ValidationState" /> + <preference for="Magento\Config\ValidationStateInterface" type="Magento\App\Arguments\ValidationState" /> <preference for="Magento\Module\ModuleListInterface" type="Magento\Module\ModuleList" /> <preference for="Magento\Event\ConfigInterface" type="Magento\Event\Config" /> <preference for="Magento\Event\InvokerInterface" type="Magento\Event\Invoker\InvokerDefault" /> @@ -64,6 +64,7 @@ <preference for="Magento\Json\EncoderInterface" type="Magento\Json\Encoder" /> <preference for="Magento\Json\DecoderInterface" type="Magento\Json\Decoder" /> <preference for="Magento\Message\ManagerInterface" type="Magento\Message\Manager" /> + <preference for="Magento\App\Config\ValueInterface" type="Magento\Core\Model\Config\Value" /> <type name="Magento\Message\Manager"> <param name="session"> <instance type="Magento\Message\Session\Proxy" /> @@ -84,9 +85,9 @@ </type> <type name="Magento\Session\SaveHandlerFactory"> <param name="handlers"> - <value> - <db>Magento\Session\SaveHandler\DbTable</db> - </value> + <array> + <item key="db"><value>Magento\Session\SaveHandler\DbTable</value></item> + </array> </param> </type> <preference for="Magento\Module\Output\ConfigInterface" type="Magento\Core\Model\Module\Output\Config" /> @@ -116,14 +117,14 @@ <instance type="Magento\App\Cache\Type\Config" /> </param> </type> - <type name="Magento\App\Config\ValidationState"> + <type name="Magento\App\Arguments\ValidationState"> <param name="appMode"> <value type="argument">Magento\App\State::PARAM_MODE</value> </param> </type> - <type name="Magento\App\Config\Loader"> + <type name="Magento\App\Arguments\Loader"> <param name="customFile"> - <value type="argument">Magento\App\Config\Loader::PARAM_CUSTOM_FILE</value> + <value type="argument">Magento\App\Arguments\Loader::PARAM_CUSTOM_FILE</value> </param> </type> <type name="Magento\Module\Declaration\Reader\Filesystem"> @@ -133,17 +134,21 @@ </type> <type name="Magento\App\Cache\Frontend\Factory"> <param name="enforcedOptions"> - <value type="argument">Magento\Core\Model\App::PARAM_CACHE_OPTIONS</value> + <value type="argument">Magento\Core\Model\App::PARAM_CACHE_FORCED_OPTIONS</value> </param> <param name="decorators"> - <value> - <tag> - <class>Magento\Cache\Frontend\Decorator\TagScope</class> - <parameters> - <tag>MAGE</tag> - </parameters> - </tag> - </value> + <array> + <item key="tag"> + <array> + <item key="class"><value>Magento\Cache\Frontend\Decorator\TagScope</value></item> + <item key="parameters"> + <array> + <item key="tag"><value>MAGE</value></item> + </array> + </item> + </array> + </item> + </array> </param> <param name="resource"> <instance type="Magento\App\Resource\Proxy" /> @@ -167,11 +172,6 @@ <instance type="Magento\App\Cache\Type\Translate" /> </param> </type> - <type name="Magento\Install\Model\Installer"> - <param name="config"> - <instance type="Magento\Core\Model\Config\Proxy" /> - </param> - </type> <type name="Magento\Data\Structure" shared="false" /> <type name="Magento\Core\Model\View\Design"> <param name="storeManager"> @@ -221,9 +221,9 @@ <value>plugin-list</value> </param> <param name="scopePriorityScheme"> - <value> - <first>global</first> - </value> + <array> + <item key="first"><value>global</value></item> + </array> </param> </type> <type name="Magento\App\Resource"> @@ -252,31 +252,39 @@ <instance type="Magento\App\AreaList\Proxy" /> </param> </type> - <type name="Magento\Core\Model\Url"> + <type name="Magento\Url"> <param name="session"> <instance type="Magento\Core\Model\Session\Proxy" /> </param> </type> <type name="Magento\View\Url"> <param name="fileUrlMap"> - <value> - <urlLib> - <key type="const">Magento\Core\Model\Store::URL_TYPE_LIB</key> - <value type="const">Magento\App\Filesystem::PUB_LIB_DIR</value> - </urlLib> - <urlMedia> - <key type="const">Magento\Core\Model\Store::URL_TYPE_MEDIA</key> - <value type="const">Magento\App\Filesystem::MEDIA_DIR</value> - </urlMedia> - <urlStatic> - <key type="const">Magento\Core\Model\Store::URL_TYPE_STATIC</key> - <value type="const">Magento\App\Filesystem::STATIC_VIEW_DIR</value> - </urlStatic> - <urlCache> - <key type="const">Magento\Core\Model\Store::URL_TYPE_CACHE</key> - <value type="const">Magento\App\Filesystem::PUB_VIEW_CACHE_DIR</value> - </urlCache> - </value> + <array> + <item key="urlLib"> + <array> + <item key="key"><value type="const">Magento\UrlInterface::URL_TYPE_LIB</value></item> + <item key="value"><value type="const">Magento\App\Filesystem::PUB_LIB_DIR</value></item> + </array> + </item> + <item key="urlMedia"> + <array> + <item key="key"><value type="const">Magento\UrlInterface::URL_TYPE_MEDIA</value></item> + <item key="value"><value type="const">Magento\App\Filesystem::MEDIA_DIR</value></item> + </array> + </item> + <item key="urlStatic"> + <array> + <item key="key"><value type="const">Magento\UrlInterface::URL_TYPE_STATIC</value></item> + <item key="value"><value type="const">Magento\App\Filesystem::STATIC_VIEW_DIR</value></item> + </array> + </item> + <item key="urlCache"> + <array> + <item key="key"><value type="const">Magento\UrlInterface::URL_TYPE_CACHE</value></item> + <item key="value"><value type="const">Magento\App\Filesystem::PUB_VIEW_CACHE_DIR</value></item> + </array> + </item> + </array> </param> </type> <type name="Magento\HTTP\PhpEnvironment\RemoteAddress"> @@ -297,16 +305,24 @@ </type> <type name="Magento\View\Layout\Argument\HandlerFactory"> <param name="handlerFactories"> - <value> - <object>Magento\Core\Model\Layout\Argument\Handler\Object</object> - <options>Magento\Core\Model\Layout\Argument\Handler\Options</options> - <url>Magento\Core\Model\Layout\Argument\Handler\Url</url> - <array>Magento\Core\Model\Layout\Argument\Handler\ArrayHandler</array> - <boolean>Magento\Core\Model\Layout\Argument\Handler\Boolean</boolean> - <helper>Magento\Core\Model\Layout\Argument\Handler\Helper</helper> - <number>Magento\Core\Model\Layout\Argument\Handler\Number</number> - <string>Magento\Core\Model\Layout\Argument\Handler\String</string> - </value> + <array> + <item key="object"><value>Magento\Core\Model\Layout\Argument\Handler\Object</value></item> + <item key="options"><value>Magento\Core\Model\Layout\Argument\Handler\Options</value></item> + <item key="url"><value>Magento\Core\Model\Layout\Argument\Handler\Url</value></item> + <item key="array"><value>Magento\Core\Model\Layout\Argument\Handler\ArrayHandler</value></item> + <item key="boolean"><value>Magento\Core\Model\Layout\Argument\Handler\Boolean</value></item> + <item key="helper"><value>Magento\Core\Model\Layout\Argument\Handler\Helper</value></item> + <item key="number"><value>Magento\Core\Model\Layout\Argument\Handler\Number</value></item> + <item key="string"><value>Magento\Core\Model\Layout\Argument\Handler\String</value></item> + </array> + </param> + </type> + <type name="Magento\Mview\View"> + <param name="state"> + <instance type="Magento\Core\Model\Mview\View\State" shared="false"/> + </param> + <param name="changelog"> + <instance type="Magento\Mview\View\Changelog" shared="false"/> </param> </type> </config> diff --git a/dev/shell/newindexer.php b/dev/shell/newindexer.php new file mode 100644 index 0000000000000000000000000000000000000000..224444eed58e3ef1d50cf8f3dff2183269acd01c --- /dev/null +++ b/dev/shell/newindexer.php @@ -0,0 +1,36 @@ +<?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_Shell + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +require_once __DIR__ . '/../../app/bootstrap.php'; +$params = array( + \Magento\Core\Model\App::PARAM_RUN_CODE => 'admin', + \Magento\Core\Model\App::PARAM_RUN_TYPE => 'store', +); + +$entryPoint = new \Magento\App\EntryPoint\EntryPoint(BP, $params); +$entryPoint->run('Magento\Indexer\App\Shell', array( + 'entryFileName' => basename(__FILE__), +)); diff --git a/dev/tests/integration/framework/Magento/TestFramework/Annotation/ConfigFixture.php b/dev/tests/integration/framework/Magento/TestFramework/Annotation/ConfigFixture.php index 3a63194fbfd8488411880c70a24ac16c13410b4e..994f8aa334f9698e83e90f50868be0d29dbddfbb 100644 --- a/dev/tests/integration/framework/Magento/TestFramework/Annotation/ConfigFixture.php +++ b/dev/tests/integration/framework/Magento/TestFramework/Annotation/ConfigFixture.php @@ -85,7 +85,7 @@ class ConfigFixture $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); if (strpos($configPath, 'default/') === 0) { $configPath = substr($configPath, 8); - $objectManager->get('Magento\Core\Model\Config')->setValue($configPath, $value); + $objectManager->get('Magento\App\ConfigInterface')->setValue($configPath, $value); } } else { \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Core\Model\StoreManagerInterface') diff --git a/dev/tests/integration/framework/Magento/TestFramework/Application.php b/dev/tests/integration/framework/Magento/TestFramework/Application.php index a8ac17b9701cf788932e728794b8228fc3f2dd2d..24fc545255d182b3d5cf6ed7dba98aadc157f287 100644 --- a/dev/tests/integration/framework/Magento/TestFramework/Application.php +++ b/dev/tests/integration/framework/Magento/TestFramework/Application.php @@ -285,7 +285,7 @@ class Application $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); /** @var \Magento\App\Http $app */ $app = $objectManager->get('Magento\App\Http'); - $response = $app->execute(); + $response = $app->launch(); $response->sendResponse(); } diff --git a/dev/tests/integration/framework/Magento/TestFramework/ObjectManagerFactory.php b/dev/tests/integration/framework/Magento/TestFramework/ObjectManagerFactory.php index 0b3b92cd05f0be22de0b5a8fae6498a43a7a36b0..103b28f3693a6111d4713db38e3d857d394ecc88 100644 --- a/dev/tests/integration/framework/Magento/TestFramework/ObjectManagerFactory.php +++ b/dev/tests/integration/framework/Magento/TestFramework/ObjectManagerFactory.php @@ -94,12 +94,12 @@ class ObjectManagerFactory extends \Magento\App\ObjectManagerFactory ), )); - $options = new \Magento\App\Config( + $options = new \Magento\App\Arguments( $arguments, - new \Magento\App\Config\Loader($directoryList) + new \Magento\App\Arguments\Loader($directoryList) ); - $objectManager->addSharedInstance($options, 'Magento\App\Config'); + $objectManager->addSharedInstance($options, 'Magento\App\Arguments'); $objectManager->getFactory()->setArguments($options->get()); $objectManager->configure( $objectManager->get('Magento\App\ObjectManager\ConfigLoader')->load('global') diff --git a/dev/tests/integration/framework/Magento/TestFramework/TestCase/AbstractConfigFiles.php b/dev/tests/integration/framework/Magento/TestFramework/TestCase/AbstractConfigFiles.php index 6bc49bb751558f7b8f68d2b0290be1d1537acf0e..066eb5d8ca449ef1309122cbb88caf18b917def3 100644 --- a/dev/tests/integration/framework/Magento/TestFramework/TestCase/AbstractConfigFiles.php +++ b/dev/tests/integration/framework/Magento/TestFramework/TestCase/AbstractConfigFiles.php @@ -54,7 +54,7 @@ abstract class AbstractConfigFiles extends \PHPUnit_Framework_TestCase $xmlFiles = $this->getXmlConfigFiles(); if (!empty($xmlFiles)) { - $this->_fileResolverMock = $this->getMockBuilder('Magento\App\Config\FileResolver\Primary') + $this->_fileResolverMock = $this->getMockBuilder('Magento\App\Arguments\FileResolver\Primary') ->disableOriginalConstructor()->getMock(); /* Enable Validation regardles of MAGE_MODE */ diff --git a/dev/tests/integration/testsuite/Magento/App/Cache/Frontend/PoolTest.php b/dev/tests/integration/testsuite/Magento/App/Cache/Frontend/PoolTest.php deleted file mode 100644 index 2f505766f28123721a28c8b592aa4f4de1ebcd08..0000000000000000000000000000000000000000 --- a/dev/tests/integration/testsuite/Magento/App/Cache/Frontend/PoolTest.php +++ /dev/null @@ -1,64 +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\App\Cache\Frontend; - -class PoolTest extends \PHPUnit_Framework_TestCase -{ - /** - * @var \Magento\App\Cache\Frontend\Pool - */ - protected $_model; - - /** - * @dataProvider cacheBackendDataProvider - */ - public function testGetCache($cacheBackendName) - { - $settings = array('backend' => $cacheBackendName); - $this->_model = new \Magento\App\Cache\Frontend\Pool( - \Magento\TestFramework\Helper\Bootstrap::getObjectManager() - ->create('Magento\App\Cache\Frontend\Factory'), - $settings - ); - - - $cache = $this->_model->get(\Magento\App\Cache\Frontend\Pool::DEFAULT_FRONTEND_ID); - $this->assertInstanceOf('Magento\Cache\FrontendInterface', $cache); - $this->assertInstanceOf('Zend_Cache_Backend_Interface', $cache->getBackend()); - } - - public function cacheBackendDataProvider() - { - return array( - array('sqlite'), - array('memcached'), - array('apc'), - array('xcache'), - array('eaccelerator'), - array('database'), - array('File'), - array('') - ); - } -} diff --git a/dev/tests/integration/testsuite/Magento/Backend/App/AbstractActionTest.php b/dev/tests/integration/testsuite/Magento/Backend/App/AbstractActionTest.php index d4a0abd7aa441f493f6da05300f90bf9c32137db..71541542828ce867c6b71f6992ad50a9b0c25f12 100644 --- a/dev/tests/integration/testsuite/Magento/Backend/App/AbstractActionTest.php +++ b/dev/tests/integration/testsuite/Magento/Backend/App/AbstractActionTest.php @@ -39,9 +39,9 @@ class AbstractActionTest extends \Magento\Backend\Utility\Controller \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Config\ScopeInterface') ->setCurrentScope(\Magento\Backend\App\Area\FrontNameResolver::AREA_CODE); $this->dispatch('backend'); - /** @var $backendUrlModel \Magento\Backend\Model\Url */ + /** @var $backendUrlModel \Magento\Backend\Model\UrlInterface */ $backendUrlModel = - \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Backend\Model\Url'); + \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Backend\Model\UrlInterface'); $url = $backendUrlModel->getStartupPageUrl(); $expected = $backendUrlModel->getUrl($url); $this->assertRedirect($this->stringStartsWith($expected)); diff --git a/dev/tests/integration/testsuite/Magento/Backend/Block/_files/form_key_disabled.php b/dev/tests/integration/testsuite/Magento/Backend/Block/_files/form_key_disabled.php index a77587caaddbec75b71777584e264420e75e4897..c1e11729087b87067d33cbcb71d5c0f895a4b20c 100644 --- a/dev/tests/integration/testsuite/Magento/Backend/Block/_files/form_key_disabled.php +++ b/dev/tests/integration/testsuite/Magento/Backend/Block/_files/form_key_disabled.php @@ -25,4 +25,6 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -\Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Backend\Model\Url')->turnOffSecretKey(); +\Magento\TestFramework\Helper\Bootstrap::getObjectManager() + ->get('Magento\Backend\Model\UrlInterface') + ->turnOffSecretKey(); diff --git a/dev/tests/integration/testsuite/Magento/Backend/Block/_files/form_key_disabled_rollback.php b/dev/tests/integration/testsuite/Magento/Backend/Block/_files/form_key_disabled_rollback.php index c21363e308a76d906baa048a96556fc3c31e4ede..6c4cba7cea101541bedb08ecc78eef43f626a336 100644 --- a/dev/tests/integration/testsuite/Magento/Backend/Block/_files/form_key_disabled_rollback.php +++ b/dev/tests/integration/testsuite/Magento/Backend/Block/_files/form_key_disabled_rollback.php @@ -25,4 +25,6 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -\Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Backend\Model\Url')->turnOnSecretKey(); +\Magento\TestFramework\Helper\Bootstrap::getObjectManager() + ->get('Magento\Backend\Model\UrlInterface') + ->turnOnSecretKey(); diff --git a/dev/tests/integration/testsuite/Magento/Backend/Controller/Adminhtml/AuthTest.php b/dev/tests/integration/testsuite/Magento/Backend/Controller/Adminhtml/AuthTest.php index 3eeccffb45b338bd81052d6ab1b10fdde55fcfde..be170ad67df5141d21ce46a45377a6500fc358cf 100644 --- a/dev/tests/integration/testsuite/Magento/Backend/Controller/Adminhtml/AuthTest.php +++ b/dev/tests/integration/testsuite/Magento/Backend/Controller/Adminhtml/AuthTest.php @@ -55,7 +55,7 @@ class AuthTest extends \Magento\TestFramework\TestCase\AbstractController */ protected function _login() { - \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Backend\Model\Url') + \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Backend\Model\UrlInterface') ->turnOffSecretKey(); $this->_auth = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Backend\Model\Auth'); @@ -71,7 +71,7 @@ class AuthTest extends \Magento\TestFramework\TestCase\AbstractController { $this->_auth->logout(); \Magento\TestFramework\Helper\Bootstrap::getObjectManager() - ->get('Magento\Backend\Model\Url')->turnOnSecretKey(); + ->get('Magento\Backend\Model\UrlInterface')->turnOnSecretKey(); } /** @@ -98,9 +98,9 @@ class AuthTest extends \Magento\TestFramework\TestCase\AbstractController $this->_login(); $this->dispatch('backend/admin/auth/login'); - /** @var $backendUrlModel \Magento\Backend\Model\Url */ + /** @var $backendUrlModel \Magento\Backend\Model\UrlInterface */ $backendUrlModel = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() - ->get('Magento\Backend\Model\Url'); + ->get('Magento\Backend\Model\UrlInterface'); $url = $backendUrlModel->getStartupPageUrl(); $expected = $backendUrlModel->getUrl($url); $this->assertRedirect($this->stringStartsWith($expected)); diff --git a/dev/tests/integration/testsuite/Magento/Backend/Helper/DataTest.php b/dev/tests/integration/testsuite/Magento/Backend/Helper/DataTest.php index 20363600811ce1a07a1196311620580908b6b14c..f966f72d105d3ce64d04ceef20f49cb0c3730322 100644 --- a/dev/tests/integration/testsuite/Magento/Backend/Helper/DataTest.php +++ b/dev/tests/integration/testsuite/Magento/Backend/Helper/DataTest.php @@ -64,7 +64,7 @@ class DataTest extends \PHPUnit_Framework_TestCase */ protected function _login() { - \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Backend\Model\Url') + \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Backend\Model\UrlInterface') ->turnOffSecretKey(); $this->_auth = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Backend\Model\Auth'); $this->_auth->login( @@ -78,7 +78,7 @@ class DataTest extends \PHPUnit_Framework_TestCase { $this->_auth->logout(); \Magento\TestFramework\Helper\Bootstrap::getObjectManager() - ->get('Magento\Backend\Model\Url')->turnOnSecretKey(); + ->get('Magento\Backend\Model\UrlInterface')->turnOnSecretKey(); } /** @@ -112,7 +112,7 @@ class DataTest extends \PHPUnit_Framework_TestCase /** * perform login */ - \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Backend\Model\Url') + \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Backend\Model\UrlInterface') ->turnOffSecretKey(); $auth = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() @@ -125,7 +125,7 @@ class DataTest extends \PHPUnit_Framework_TestCase */ $auth->logout(); \Magento\TestFramework\Helper\Bootstrap::getObjectManager() - ->get('Magento\Backend\Model\Url')->turnOnSecretKey(); + ->get('Magento\Backend\Model\UrlInterface')->turnOnSecretKey(); $this->assertFalse($this->_helper->getCurrentUserId()); } 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 59fec14dc23f904a4764c0fd90fecb86cd151787..4e449a74d09774de4583311e90800d156a206ff9 100644 --- a/dev/tests/integration/testsuite/Magento/Backend/Model/Translate/InlineTest.php +++ b/dev/tests/integration/testsuite/Magento/Backend/Model/Translate/InlineTest.php @@ -52,7 +52,7 @@ class InlineTest extends \PHPUnit_Framework_TestCase public function testAjaxUrl() { $body = '<html><body>some body</body></html>'; - /** @var \Magento\Backend\Model\Url $url */ + /** @var \Magento\Backend\Model\UrlInterface $url */ $url = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() ->get('Magento\UrlInterface'); $url->getUrl(\Magento\Backend\App\Area\FrontNameResolver::AREA_CODE . '/ajax/translate'); diff --git a/dev/tests/integration/testsuite/Magento/Backend/Model/UrlTest.php b/dev/tests/integration/testsuite/Magento/Backend/Model/UrlTest.php index 16b369343b12864c1b957e23d74f66ed993eae8f..16259d9d9fba6a159eeb957a2d3a009613db621e 100644 --- a/dev/tests/integration/testsuite/Magento/Backend/Model/UrlTest.php +++ b/dev/tests/integration/testsuite/Magento/Backend/Model/UrlTest.php @@ -28,14 +28,14 @@ namespace Magento\Backend\Model; /** - * Test class for \Magento\Backend\Model\Url. + * Test class for \Magento\Backend\Model\UrlInterface. * * @magentoAppArea adminhtml */ class UrlTest extends \PHPUnit_Framework_TestCase { /** - * @var \Magento\Backend\Model\Url + * @var \Magento\Backend\Model\UrlInterface */ protected $_model; @@ -43,40 +43,7 @@ class UrlTest extends \PHPUnit_Framework_TestCase { parent::setUp(); $this->_model = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() - ->create('Magento\Backend\Model\Url'); - } - - /** - * @covers \Magento\Backend\Model\Url::isSecure - */ - public function testIsSecure() - { - \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Backend\App\ConfigInterface') - ->setValue('web/secure/use_in_adminhtml', true); - $this->assertTrue($this->_model->isSecure()); - - \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Backend\App\ConfigInterface') - ->setValue('web/secure/use_in_adminhtml', false); - $this->assertFalse($this->_model->isSecure()); - - $this->_model->setData('secure_is_forced', true); - $this->_model->setData('secure', true); - $this->assertTrue($this->_model->isSecure()); - - $this->_model->setData('secure', false); - $this->assertFalse($this->_model->isSecure()); - } - - /** - * @covers \Magento\Backend\Model\Url::setRouteParams - */ - public function testSetRouteParams() - { - $this->_model->setRouteParams(array('_nosecret' => 'any_value')); - $this->assertTrue($this->_model->getNoSecret()); - - $this->_model->setRouteParams(array()); - $this->assertFalse($this->_model->getNoSecret()); + ->create('Magento\Backend\Model\UrlInterface'); } /** diff --git a/dev/tests/integration/testsuite/Magento/Backend/Utility/Controller.php b/dev/tests/integration/testsuite/Magento/Backend/Utility/Controller.php index 250e1309b59f420d7915ee91dc7fce784679d046..f224998cae5047f51c90798b0d4ffb4e21ebb217 100644 --- a/dev/tests/integration/testsuite/Magento/Backend/Utility/Controller.php +++ b/dev/tests/integration/testsuite/Magento/Backend/Utility/Controller.php @@ -48,7 +48,7 @@ class Controller extends \Magento\TestFramework\TestCase\AbstractController { parent::setUp(); - $this->_objectManager->get('Magento\Backend\Model\Url')->turnOffSecretKey(); + $this->_objectManager->get('Magento\Backend\Model\UrlInterface')->turnOffSecretKey(); $this->_auth = $this->_objectManager->get('Magento\Backend\Model\Auth'); $this->_session = $this->_auth->getAuthStorage(); @@ -74,7 +74,7 @@ class Controller extends \Magento\TestFramework\TestCase\AbstractController $this->_auth->logout(); $this->_auth = null; $this->_session = null; - $this->_objectManager->get('Magento\Backend\Model\Url')->turnOnSecretKey(); + $this->_objectManager->get('Magento\Backend\Model\UrlInterface')->turnOnSecretKey(); parent::tearDown(); } diff --git a/dev/tests/integration/testsuite/Magento/Captcha/Model/ObserverTest.php b/dev/tests/integration/testsuite/Magento/Captcha/Model/ObserverTest.php index 9f39840800c63ee36941f4c980389dc37e841005..4db394c4f71b1d14f7383bf72c54cd9a83412cdb 100644 --- a/dev/tests/integration/testsuite/Magento/Captcha/Model/ObserverTest.php +++ b/dev/tests/integration/testsuite/Magento/Captcha/Model/ObserverTest.php @@ -41,7 +41,7 @@ class ObserverTest extends \Magento\TestFramework\TestCase\AbstractController */ public function testBackendLoginActionWithInvalidCaptchaReturnsError() { - \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Backend\Model\Url') + \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Backend\Model\UrlInterface') ->turnOffSecretKey(); $post = array( @@ -114,7 +114,7 @@ class ObserverTest extends \Magento\TestFramework\TestCase\AbstractController */ public function testCheckUnsuccessfulMessageWhenCaptchaFailed() { - \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Backend\Model\Url') + \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Backend\Model\UrlInterface') ->turnOffSecretKey(); $this->getRequest()->setPost(array('email' => 'dummy@dummy.com', 'captcha' => '1234')); $this->dispatch('backend/admin/auth/forgotpassword'); diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/Action/AttributeTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/Action/AttributeTest.php index 178ed26d782a7388bafcb56279f3c261ce770bb7..de04f8cc86c159e19cead68ea82377a6e136b017 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/Action/AttributeTest.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/Action/AttributeTest.php @@ -49,7 +49,7 @@ class AttributeTest extends \Magento\Backend\Utility\Controller $this->dispatch('backend/catalog/product_action_attribute/save/store/0'); $this->assertEquals(302, $this->getResponse()->getHttpResponseCode()); - /** @var \Magento\Backend\Model\Url $urlBuilder */ + /** @var \Magento\Backend\Model\UrlInterface $urlBuilder */ $urlBuilder = $objectManager->get('Magento\UrlInterface'); /** @var \Magento\Catalog\Helper\Product\Edit\Action\Attribute $attributeHelper */ diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Helper/DataTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Helper/DataTest.php index cfa52de7bfb8a3b339844a6743388d4f079da43f..11afaaf1b4e0afd5de70db0f0f5309bf9036092b 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/Helper/DataTest.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/Helper/DataTest.php @@ -118,21 +118,6 @@ class DataTest extends \PHPUnit_Framework_TestCase } } - public function testGetAttributeDisabledTypes() - { - $this->assertEquals(array(), $this->_helper->getAttributeDisabledTypes()); - /** @var $objectManager \Magento\TestFramework\ObjectManager */ - $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); - $objectManager->get('Magento\Core\Model\Registry')->register('attribute_type_disabled_types', 'test'); - try { - $this->assertEquals('test', $this->_helper->getAttributeDisabledTypes()); - $objectManager->get('Magento\Core\Model\Registry')->unregister('attribute_type_disabled_types'); - } catch (\Exception $e) { - $objectManager->get('Magento\Core\Model\Registry')->unregister('attribute_type_disabled_types'); - throw $e; - } - } - public function testGetPriceScopeDefault() { // $this->assertEquals(\Magento\Core\Model\Store::PRICE_SCOPE_GLOBAL, $this->_helper->getPriceScope()); diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Helper/Product/UrlTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Helper/Product/UrlTest.php index ec11ea38f56d0f5a5d07c82c87ac8b9d88d335b3..2048e65afe50732281e0fdd0784278403bc8555a 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/Helper/Product/UrlTest.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/Helper/Product/UrlTest.php @@ -36,8 +36,8 @@ class UrlTest extends \PHPUnit_Framework_TestCase public static function setUpBeforeClass() { - /** @var $configModel \Magento\Core\Model\Config */ - $configModel = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Core\Model\Config'); + /** @var $configModel \Magento\App\ConfigInterface */ + $configModel = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\App\ConfigInterface'); // @todo re-implement this test $data = array( 'from' => 'â„¢', diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/Category/CategoryImageTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/Category/CategoryImageTest.php index 565f59cc2aa0d6862043a30301c2d12fc6e753f1..27216bf362b677387358e7b9a1b68afc641b2f6f 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/Model/Category/CategoryImageTest.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/Category/CategoryImageTest.php @@ -47,7 +47,6 @@ class CategoryImageTest extends \PHPUnit_Framework_TestCase protected function setUp() { - /** @var $configModel \Magento\Core\Model\Config */ $this->_oldLogActive = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() ->get('Magento\Core\Model\StoreManagerInterface')->getStore()->getConfig('dev/log/active'); $this->_oldExceptionFile = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/CategoryTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/CategoryTest.php index 26bc170f7770c16e245478ee19867a88ee789c52..d1882e7714162b4ba4f04b90692be497b1c4262a 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/Model/CategoryTest.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/CategoryTest.php @@ -74,8 +74,8 @@ class CategoryTest extends \PHPUnit_Framework_TestCase } // get list of not existing tables - /** @var $application \Magento\Core\Model\App */ - $application = self::$_objectManager->get('Magento\Core\Model\App'); + /** @var $storeManager \Magento\Core\Model\StoreManagerInterface */ + $storeManager = self::$_objectManager->get('Magento\Core\Model\StoreManagerInterface'); /** @var $categoryResource \Magento\Catalog\Model\Resource\Category\Flat */ $categoryResource = self::$_objectManager->create('Magento\Catalog\Model\Resource\Category\Flat'); /** @var $setupModel \Magento\Core\Model\Resource\Setup */ @@ -85,7 +85,7 @@ class CategoryTest extends \PHPUnit_Framework_TestCase 'moduleName' => 'Magento_Core', ) ); - $stores = $application->getStores(); + $stores = $storeManager->getStores(); /** @var $store \Magento\Core\Model\Store */ foreach ($stores as $store) { $tableName = $categoryResource->getMainStoreTable($store->getId()); @@ -146,16 +146,16 @@ class CategoryTest extends \PHPUnit_Framework_TestCase protected function setUp() { - /** @var $application \Magento\Core\Model\App */ - $application = self::$_objectManager->get('Magento\Core\Model\App'); - $this->_store = $application->getStore(); + /** @var $storeManager \Magento\Core\Model\StoreManagerInterface */ + $storeManager = self::$_objectManager->get('Magento\Core\Model\StoreManagerInterface'); + $this->_store = $storeManager->getStore(); $this->_model = self::$_objectManager->create('Magento\Catalog\Model\Category'); } public function testGetUrlInstance() { $instance = $this->_model->getUrlInstance(); - $this->assertInstanceOf('Magento\Core\Model\Url', $instance); + $this->assertInstanceOf('Magento\Url', $instance); $this->assertSame($instance, $this->_model->getUrlInstance()); } diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/UrlTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/UrlTest.php index 85c032855c14b529657a1f415e07b5fe15716dfd..9af13541978564580d55543858ca9f7e15f02568 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/UrlTest.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/UrlTest.php @@ -48,7 +48,7 @@ class UrlTest extends \PHPUnit_Framework_TestCase public function testGetUrlInstance() { $instance = $this->_model->getUrlInstance(); - $this->assertInstanceOf('Magento\Core\Model\Url', $instance); + $this->assertInstanceOf('Magento\Url', $instance); $this->assertSame($instance, $this->_model->getUrlInstance()); } diff --git a/dev/tests/integration/testsuite/Magento/CatalogSearch/Controller/ResultTest.php b/dev/tests/integration/testsuite/Magento/CatalogSearch/Controller/ResultTest.php index ea346db313adb5acfd2f4166734319fc619cc1a6..091b0952a8c8651b57796a48200819370b3b475c 100644 --- a/dev/tests/integration/testsuite/Magento/CatalogSearch/Controller/ResultTest.php +++ b/dev/tests/integration/testsuite/Magento/CatalogSearch/Controller/ResultTest.php @@ -31,11 +31,9 @@ class ResultTest extends \Magento\TestFramework\TestCase\AbstractController { /** * @magentoDataFixture Magento/CatalogSearch/_files/query.php - * @magentoConfigFixture current_store general/locale/code de_DE */ public function testIndexActionTranslation() { - $this->markTestIncomplete('endTest() called too early, config fixture reseted'); $this->getRequest()->setParam('q', 'query_text'); $this->dispatch('catalogsearch/result'); @@ -46,4 +44,15 @@ class ResultTest extends \Magento\TestFramework\TestCase\AbstractController $this->assertNotContains('Search entire store here...', $responseBody); $this->assertContains('Den gesamten Shop durchsuchen...', $responseBody); } + + public function testIndexActionXSSQueryVerification() + { + $this->getRequest()->setParam('q', '<script>alert(1)</script>'); + $this->dispatch('catalogsearch/result'); + + $responseBody = $this->getResponse()->getBody(); + $data = '<script>alert(1)</script>'; + $this->assertNotContains($data, $responseBody); + $this->assertContains(htmlspecialchars($data, ENT_COMPAT, 'UTF-8', false), $responseBody); + } } diff --git a/dev/tests/integration/testsuite/Magento/CatalogSearch/_files/query.php b/dev/tests/integration/testsuite/Magento/CatalogSearch/_files/query.php index d38233ea17ad354969951661ef9f3fdcff166518..483a9d426f8790061092add24fac3585cda7fb30 100644 --- a/dev/tests/integration/testsuite/Magento/CatalogSearch/_files/query.php +++ b/dev/tests/integration/testsuite/Magento/CatalogSearch/_files/query.php @@ -27,6 +27,8 @@ $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); +$objectManager->get('Magento\Core\Model\Locale')->setLocale('de_DE'); + /** @var $query \Magento\CatalogSearch\Model\Query */ $query = $objectManager->create('Magento\CatalogSearch\Model\Query'); $query->setStoreId(1); diff --git a/dev/tests/integration/testsuite/Magento/Checkout/Block/Cart/SidebarTest.php b/dev/tests/integration/testsuite/Magento/Checkout/Block/Cart/SidebarTest.php index 587d686a5d7d4a338c03ae3d2a1efb3119fb9413..0d77e8059b1ee7c682de439c30683a844a365e0f 100644 --- a/dev/tests/integration/testsuite/Magento/Checkout/Block/Cart/SidebarTest.php +++ b/dev/tests/integration/testsuite/Magento/Checkout/Block/Cart/SidebarTest.php @@ -36,6 +36,13 @@ class SidebarTest extends \PHPUnit_Framework_TestCase ->setAreaCode('frontend'); $this->_block = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\View\LayoutInterface') ->createBlock('Magento\Checkout\Block\Cart\Sidebar'); + $this->_block->addChild('renderer.list', '\Magento\View\Element\RendererList'); + $this->_block->getChildBlock('renderer.list') + ->addChild( + 'default', + '\Magento\Checkout\Block\Cart\Item\Renderer', + array('template' => 'cart/item/default.phtml') + ); } public function testGetCacheKeyInfo() diff --git a/dev/tests/integration/testsuite/Magento/Cms/Model/Wysiwyg/Images/StorageTest.php b/dev/tests/integration/testsuite/Magento/Cms/Model/Wysiwyg/Images/StorageTest.php index 3f79c091d33a316d6162644d66336ed56ada222a..93521b3a2e92f04d6d768231840bb40cbf2eeb83 100644 --- a/dev/tests/integration/testsuite/Magento/Cms/Model/Wysiwyg/Images/StorageTest.php +++ b/dev/tests/integration/testsuite/Magento/Cms/Model/Wysiwyg/Images/StorageTest.php @@ -85,7 +85,7 @@ class StorageTest extends \PHPUnit_Framework_TestCase $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); $filesystem = $objectManager->get('Magento\App\Filesystem'); $session = $objectManager->get('Magento\Backend\Model\Session'); - $backendUrl = $objectManager->get('Magento\Backend\Model\Url'); + $backendUrl = $objectManager->get('Magento\Backend\Model\UrlInterface'); $imageFactory = $objectManager->get('Magento\Image\AdapterFactory'); $viewUrl = $objectManager->get('Magento\View\Url'); $imageHelper = $objectManager->get('Magento\Cms\Helper\Wysiwyg\Images'); diff --git a/dev/tests/integration/testsuite/Magento/Core/Model/AppTest.php b/dev/tests/integration/testsuite/Magento/Core/Model/AppTest.php index 11be911df5dbd2c581e29ff7d7a95e51844ff4ad..5a89cae7fff2a2c146a3f31c588be74e0ba283d4 100644 --- a/dev/tests/integration/testsuite/Magento/Core/Model/AppTest.php +++ b/dev/tests/integration/testsuite/Magento/Core/Model/AppTest.php @@ -60,41 +60,6 @@ class AppTest extends \PHPUnit_Framework_TestCase $this->assertInstanceOf('Magento\Stdlib\Cookie', $this->_model->getCookie()); } - /** - * @magentoAppIsolation enabled - * @magentoConfigFixture current_store general/single_store_mode/enabled 1 - */ - public function testIsSingleStoreModeWhenEnabled() - { - $this->assertTrue($this->_mageModel->isSingleStoreMode()); - } - - /** - * @magentoAppIsolation enabled - * @magentoConfigFixture current_store general/single_store_mode/enabled 0 - */ - public function testIsSingleStoreModeWhenDisabled() - { - $this->assertFalse($this->_mageModel->isSingleStoreMode());; - } - - public function testHasSingleStore() - { - $this->assertTrue($this->_model->hasSingleStore()); - $this->assertTrue($this->_mageModel->hasSingleStore()); - } - - /** - * @magentoAppIsolation enabled - */ - public function testSetCurrentStore() - { - $store = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() - ->create('Magento\Core\Model\Store'); - $this->_model->setCurrentStore($store); - $this->assertSame($store, $this->_model->getStore()); - } - public function testSetErrorHandler() { $this->_model->setErrorHandler(array($this, 'errorHandler')); @@ -122,70 +87,11 @@ class AppTest extends \PHPUnit_Framework_TestCase $this->assertSame($area, $this->_model->getArea('frontend')); } - /** - * @expectedException \Magento\Core\Model\Store\Exception - */ - public function testGetNotExistingStore() - { - $this->_mageModel->getStore(100); - } - - public function testGetSafeNotExistingStore() - { - $this->_mageModel->getSafeStore(100); - $request = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\App\Request\Http'); - $this->assertEquals('noroute', $request->getActionName()); - } - - public function testGetStores() - { - $this->assertNotEmpty($this->_mageModel->getStores()); - $this->assertNotContains( - \Magento\Core\Model\Store::DEFAULT_STORE_ID, - array_keys($this->_mageModel->getStores()) - ); - $this->assertContains( - \Magento\Core\Model\Store::DEFAULT_STORE_ID, - array_keys($this->_mageModel->getStores(true)) - ); - } - - public function testGetDefaultStoreView() - { - $store = $this->_mageModel->getDefaultStoreView(); - $this->assertEquals('default', $store->getCode()); - } - public function testGetDistroLocaleCode() { $this->assertEquals(\Magento\Core\Model\App::DISTRO_LOCALE_CODE, $this->_model->getDistroLocaleCode()); } - /** - * @expectedException \Magento\Core\Exception - */ - public function testGetWebsiteNonExisting() - { - $this->assertNotEmpty($this->_mageModel->getWebsite(true)->getId()); - $this->_mageModel->getWebsite(100); - } - - public function testGetWebsites() - { - $this->assertNotEmpty($this->_mageModel->getWebsites()); - $this->assertNotContains(0, array_keys($this->_mageModel->getWebsites())); - $this->assertContains(0, array_keys($this->_mageModel->getWebsites(true))); - } - - /** - * @expectedException \Magento\Core\Exception - */ - public function testGetGroupNonExisting() - { - $this->assertNotEmpty($this->_mageModel->getGroup(true)->getId()); - $this->_mageModel->getGroup(100); - } - public function testGetLocale() { $locale = $this->_model->getLocale(); @@ -263,38 +169,4 @@ class AppTest extends \PHPUnit_Framework_TestCase $this->assertSame($response, $this->_model->getResponse()); $this->assertEmpty($this->_model->getResponse()->getHeaders()); } - - /** - * @expectedException \Magento\Core\Model\Store\Exception - */ - public function testThrowStoreException() - { - $this->_model->throwStoreException('test'); - } - - public function testSetGetUseSessionVar() - { - $this->assertFalse($this->_model->getUseSessionVar()); - $this->_model->setUseSessionVar(true); - $this->assertTrue($this->_model->getUseSessionVar()); - } - - public function testGetAnyStoreView() - { - $this->assertInstanceOf('Magento\Core\Model\Store', $this->_mageModel->getAnyStoreView()); - } - - public function testSetGetUseSessionInUrl() - { - $this->assertTrue($this->_model->getUseSessionInUrl()); - $this->_model->setUseSessionInUrl(false); - $this->assertFalse($this->_model->getUseSessionInUrl()); - } - - public function testGetGroups() - { - $groups = $this->_mageModel->getGroups(); - $this->assertInternalType('array', $groups); - $this->assertGreaterThanOrEqual(1, count($groups)); - } } diff --git a/dev/tests/integration/testsuite/Magento/Core/Model/Resource/Db/ProfilerTest.php b/dev/tests/integration/testsuite/Magento/Core/Model/Resource/Db/ProfilerTest.php index 2886e5fc2957d07e538f2de4e791cc92dbab4529..8ac262b63b1ee50732bf9b5d325d1c5a745bfde8 100644 --- a/dev/tests/integration/testsuite/Magento/Core/Model/Resource/Db/ProfilerTest.php +++ b/dev/tests/integration/testsuite/Magento/Core/Model/Resource/Db/ProfilerTest.php @@ -61,7 +61,7 @@ class ProfilerTest extends \PHPUnit_Framework_TestCase protected function _getConnectionRead() { $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); - $localConfig = $objectManager->get('Magento\App\Config'); + $localConfig = $objectManager->get('Magento\App\Arguments'); $connectionConfig = $localConfig->getConnection('default'); $connectionConfig['profiler'] = array( 'class' => 'Magento\Core\Model\Resource\Db\Profiler', diff --git a/dev/tests/integration/testsuite/Magento/Core/Model/Resource/Store/CollectionTest.php b/dev/tests/integration/testsuite/Magento/Core/Model/Resource/Store/CollectionTest.php index 336cb762097ac4eebc0a03c81ae8b745a9725461..ee1da0f464290310a27bdefd09f3c20f8ae88d13 100644 --- a/dev/tests/integration/testsuite/Magento/Core/Model/Resource/Store/CollectionTest.php +++ b/dev/tests/integration/testsuite/Magento/Core/Model/Resource/Store/CollectionTest.php @@ -147,7 +147,7 @@ class CollectionTest extends \PHPUnit_Framework_TestCase */ public function testGetAllIds() { - $this->assertContains(\Magento\Core\Model\AppInterface::DISTRO_STORE_ID, $this->_collection->getAllIds()); + $this->assertContains(\Magento\Core\Model\Store::DISTRO_STORE_ID, $this->_collection->getAllIds()); } /** diff --git a/dev/tests/integration/testsuite/Magento/Core/Model/Session/AbstractSession/VarienTest.php b/dev/tests/integration/testsuite/Magento/Core/Model/Session/AbstractSession/VarienTest.php index ffa56717443d99eb8f8cd94dff8de02e1387e2a7..d562960a71cff442b0b8449e474b760475b4c533 100644 --- a/dev/tests/integration/testsuite/Magento/Core/Model/Session/AbstractSession/VarienTest.php +++ b/dev/tests/integration/testsuite/Magento/Core/Model/Session/AbstractSession/VarienTest.php @@ -49,8 +49,8 @@ class VarienTest extends \PHPUnit_Framework_TestCase $this->markTestSkipped("Can't set '$iniValue' as session save handler"); } ini_set('session.save_handler', $origSessionHandler); - /** @var $configModel \Magento\Core\Model\Config */ - $configModel = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Core\Model\Config'); + /** @var $configModel \Magento\App\ConfigInterface */ + $configModel = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\App\ConfigInterface'); $configModel->setNode(\Magento\Core\Model\Session\Config::PARAM_SESSION_SAVE_METHOD, $saveMethod); /** * @var \Magento\Session\SessionManagerInterface $model diff --git a/dev/tests/integration/testsuite/Magento/Core/Model/Session/SidResolverTest.php b/dev/tests/integration/testsuite/Magento/Core/Model/Session/SidResolverTest.php index 4af3964a06de56347f8138401dbc1d3c112d85de..d655fe20c98f2b4154ef07e17f86f66349355a5e 100644 --- a/dev/tests/integration/testsuite/Magento/Core/Model/Session/SidResolverTest.php +++ b/dev/tests/integration/testsuite/Magento/Core/Model/Session/SidResolverTest.php @@ -76,7 +76,7 @@ class SidResolverTest extends \PHPUnit_Framework_TestCase ->disableOriginalConstructor() ->getMockForAbstractClass(); - $this->urlBuilder = $this->getMockBuilder('Magento\UrlInterface') + $this->urlBuilder = $this->getMockBuilder('Magento\Url') ->setMethods(array('isOwnOriginUrl')) ->disableOriginalConstructor() ->getMockForAbstractClass(); @@ -156,4 +156,18 @@ class SidResolverTest extends \PHPUnit_Framework_TestCase ); $this->session->setName($oldSessionName); } + + public function testSetGetUseSessionVar() + { + $this->assertFalse($this->model->getUseSessionVar()); + $this->model->setUseSessionVar(true); + $this->assertTrue($this->model->getUseSessionVar()); + } + + public function testSetGetUseSessionInUrl() + { + $this->assertTrue($this->model->getUseSessionInUrl()); + $this->model->setUseSessionInUrl(false); + $this->assertFalse($this->model->getUseSessionInUrl()); + } } diff --git a/dev/tests/integration/testsuite/Magento/Core/Model/StoreTest.php b/dev/tests/integration/testsuite/Magento/Core/Model/StoreTest.php index f2cd9f2752e4b448fc106d0c4a0495a956aa8e4f..7db7aef1bbe054c922db4084ea96ba6c65796de9 100644 --- a/dev/tests/integration/testsuite/Magento/Core/Model/StoreTest.php +++ b/dev/tests/integration/testsuite/Magento/Core/Model/StoreTest.php @@ -55,12 +55,12 @@ class StoreTest extends \PHPUnit_Framework_TestCase 'registry' => $objectManager->get('Magento\Core\Model\Registry'), 'coreFileStorageDatabase' => $objectManager->get('Magento\Core\Helper\File\Storage\Database'), 'configCacheType' => $objectManager->get('Magento\App\Cache\Type\Config'), - 'url' => $objectManager->get('Magento\Core\Model\Url'), + 'url' => $objectManager->get('Magento\Url'), 'request' => $objectManager->get('Magento\App\RequestInterface'), 'configDataResource' => $objectManager->get('Magento\Core\Model\Resource\Config\Data'), 'filesystem' => $objectManager->get('Magento\App\Filesystem'), 'coreStoreConfig' => $objectManager->get('Magento\Core\Model\Store\Config'), - 'coreConfig' => $objectManager->get('Magento\Core\Model\Config'), + 'coreConfig' => $objectManager->get('Magento\App\ReinitableConfigInterface'), 'resource' => $objectManager->get('Magento\Core\Model\Resource\Store'), 'storeManager' => $objectManager->get('Magento\Core\Model\StoreManager'), 'sidResolver' => $objectManager->get('Magento\Session\SidResolverInterface'), @@ -128,8 +128,8 @@ class StoreTest extends \PHPUnit_Framework_TestCase public function testSetGetGroup() { $this->assertFalse($this->_model->getGroup()); - $storeGroup = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Core\Model\App') - ->getGroup(); + $storeGroup = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + ->get('Magento\Core\Model\StoreManager')->getGroup(); $this->_model->setGroup($storeGroup); $actualResult = $this->_model->getGroup(); $this->assertSame($storeGroup, $actualResult); @@ -162,34 +162,34 @@ class StoreTest extends \PHPUnit_Framework_TestCase public function getBaseUrlDataProvider() { return array( - array(\Magento\Core\Model\Store::URL_TYPE_WEB, false, false, 'http://localhost/'), - array(\Magento\Core\Model\Store::URL_TYPE_WEB, false, true, 'http://localhost/'), - array(\Magento\Core\Model\Store::URL_TYPE_WEB, true, false, 'http://localhost/'), - array(\Magento\Core\Model\Store::URL_TYPE_WEB, true, true, 'http://localhost/'), - array(\Magento\Core\Model\Store::URL_TYPE_LINK, false, false, 'http://localhost/index.php/'), - array(\Magento\Core\Model\Store::URL_TYPE_LINK, false, true, 'http://localhost/index.php/default/'), - array(\Magento\Core\Model\Store::URL_TYPE_LINK, true, false, 'http://localhost/'), - array(\Magento\Core\Model\Store::URL_TYPE_LINK, true, true, 'http://localhost/default/'), - array(\Magento\Core\Model\Store::URL_TYPE_DIRECT_LINK, false, false, 'http://localhost/index.php/'), - array(\Magento\Core\Model\Store::URL_TYPE_DIRECT_LINK, false, true, 'http://localhost/index.php/'), - array(\Magento\Core\Model\Store::URL_TYPE_DIRECT_LINK, true, false, 'http://localhost/'), - array(\Magento\Core\Model\Store::URL_TYPE_DIRECT_LINK, true, true, 'http://localhost/'), - array(\Magento\Core\Model\Store::URL_TYPE_STATIC, false, false, 'http://localhost/pub/static/'), - array(\Magento\Core\Model\Store::URL_TYPE_STATIC, false, true, 'http://localhost/pub/static/'), - array(\Magento\Core\Model\Store::URL_TYPE_STATIC, true, false, 'http://localhost/pub/static/'), - array(\Magento\Core\Model\Store::URL_TYPE_STATIC, true, true, 'http://localhost/pub/static/'), - array(\Magento\Core\Model\Store::URL_TYPE_CACHE, false, false, 'http://localhost/pub/cache/'), - array(\Magento\Core\Model\Store::URL_TYPE_CACHE, false, true, 'http://localhost/pub/cache/'), - array(\Magento\Core\Model\Store::URL_TYPE_CACHE, true, false, 'http://localhost/pub/cache/'), - array(\Magento\Core\Model\Store::URL_TYPE_CACHE, true, true, 'http://localhost/pub/cache/'), - array(\Magento\Core\Model\Store::URL_TYPE_LIB, false, false, 'http://localhost/pub/lib/'), - array(\Magento\Core\Model\Store::URL_TYPE_LIB, false, true, 'http://localhost/pub/lib/'), - array(\Magento\Core\Model\Store::URL_TYPE_LIB, true, false, 'http://localhost/pub/lib/'), - array(\Magento\Core\Model\Store::URL_TYPE_LIB, true, true, 'http://localhost/pub/lib/'), - array(\Magento\Core\Model\Store::URL_TYPE_MEDIA, false, false, 'http://localhost/pub/media/'), - array(\Magento\Core\Model\Store::URL_TYPE_MEDIA, false, true, 'http://localhost/pub/media/'), - array(\Magento\Core\Model\Store::URL_TYPE_MEDIA, true, false, 'http://localhost/pub/media/'), - array(\Magento\Core\Model\Store::URL_TYPE_MEDIA, true, true, 'http://localhost/pub/media/'), + array(\Magento\UrlInterface::URL_TYPE_WEB, false, false, 'http://localhost/'), + array(\Magento\UrlInterface::URL_TYPE_WEB, false, true, 'http://localhost/'), + array(\Magento\UrlInterface::URL_TYPE_WEB, true, false, 'http://localhost/'), + array(\Magento\UrlInterface::URL_TYPE_WEB, true, true, 'http://localhost/'), + array(\Magento\UrlInterface::URL_TYPE_LINK, false, false, 'http://localhost/index.php/'), + array(\Magento\UrlInterface::URL_TYPE_LINK, false, true, 'http://localhost/index.php/default/'), + array(\Magento\UrlInterface::URL_TYPE_LINK, true, false, 'http://localhost/'), + array(\Magento\UrlInterface::URL_TYPE_LINK, true, true, 'http://localhost/default/'), + array(\Magento\UrlInterface::URL_TYPE_DIRECT_LINK, false, false, 'http://localhost/index.php/'), + array(\Magento\UrlInterface::URL_TYPE_DIRECT_LINK, false, true, 'http://localhost/index.php/'), + array(\Magento\UrlInterface::URL_TYPE_DIRECT_LINK, true, false, 'http://localhost/'), + array(\Magento\UrlInterface::URL_TYPE_DIRECT_LINK, true, true, 'http://localhost/'), + array(\Magento\UrlInterface::URL_TYPE_STATIC, false, false, 'http://localhost/pub/static/'), + array(\Magento\UrlInterface::URL_TYPE_STATIC, false, true, 'http://localhost/pub/static/'), + array(\Magento\UrlInterface::URL_TYPE_STATIC, true, false, 'http://localhost/pub/static/'), + array(\Magento\UrlInterface::URL_TYPE_STATIC, true, true, 'http://localhost/pub/static/'), + array(\Magento\UrlInterface::URL_TYPE_CACHE, false, false, 'http://localhost/pub/cache/'), + array(\Magento\UrlInterface::URL_TYPE_CACHE, false, true, 'http://localhost/pub/cache/'), + array(\Magento\UrlInterface::URL_TYPE_CACHE, true, false, 'http://localhost/pub/cache/'), + array(\Magento\UrlInterface::URL_TYPE_CACHE, true, true, 'http://localhost/pub/cache/'), + array(\Magento\UrlInterface::URL_TYPE_LIB, false, false, 'http://localhost/pub/lib/'), + array(\Magento\UrlInterface::URL_TYPE_LIB, false, true, 'http://localhost/pub/lib/'), + array(\Magento\UrlInterface::URL_TYPE_LIB, true, false, 'http://localhost/pub/lib/'), + array(\Magento\UrlInterface::URL_TYPE_LIB, true, true, 'http://localhost/pub/lib/'), + array(\Magento\UrlInterface::URL_TYPE_MEDIA, false, false, 'http://localhost/pub/media/'), + array(\Magento\UrlInterface::URL_TYPE_MEDIA, false, true, 'http://localhost/pub/media/'), + array(\Magento\UrlInterface::URL_TYPE_MEDIA, true, false, 'http://localhost/pub/media/'), + array(\Magento\UrlInterface::URL_TYPE_MEDIA, true, true, 'http://localhost/pub/media/'), ); } @@ -206,15 +206,15 @@ class StoreTest extends \PHPUnit_Framework_TestCase $this->assertEquals( 'http://localhost/pub/static/', - $this->_model->getBaseUrl(\Magento\Core\Model\Store::URL_TYPE_STATIC) + $this->_model->getBaseUrl(\Magento\UrlInterface::URL_TYPE_STATIC) ); $this->assertEquals( 'http://localhost/pub/lib/', - $this->_model->getBaseUrl(\Magento\Core\Model\Store::URL_TYPE_LIB) + $this->_model->getBaseUrl(\Magento\UrlInterface::URL_TYPE_LIB) ); $this->assertEquals( 'http://localhost/pub/media/', - $this->_model->getBaseUrl(\Magento\Core\Model\Store::URL_TYPE_MEDIA) + $this->_model->getBaseUrl(\Magento\UrlInterface::URL_TYPE_MEDIA) ); } @@ -252,14 +252,14 @@ class StoreTest extends \PHPUnit_Framework_TestCase public function getBaseUrlForCustomEntryPointDataProvider() { return array( - array(\Magento\Core\Model\Store::URL_TYPE_LINK, false, false, 'http://localhost/custom_entry.php/'), - array(\Magento\Core\Model\Store::URL_TYPE_LINK, false, true, 'http://localhost/custom_entry.php/default/'), - array(\Magento\Core\Model\Store::URL_TYPE_LINK, true, false, 'http://localhost/index.php/'), - array(\Magento\Core\Model\Store::URL_TYPE_LINK, true, true, 'http://localhost/index.php/default/'), - array(\Magento\Core\Model\Store::URL_TYPE_DIRECT_LINK, false, false, 'http://localhost/custom_entry.php/'), - array(\Magento\Core\Model\Store::URL_TYPE_DIRECT_LINK, false, true, 'http://localhost/custom_entry.php/'), - array(\Magento\Core\Model\Store::URL_TYPE_DIRECT_LINK, true, false, 'http://localhost/index.php/'), - array(\Magento\Core\Model\Store::URL_TYPE_DIRECT_LINK, true, true, 'http://localhost/index.php/'), + array(\Magento\UrlInterface::URL_TYPE_LINK, false, false, 'http://localhost/custom_entry.php/'), + array(\Magento\UrlInterface::URL_TYPE_LINK, false, true, 'http://localhost/custom_entry.php/default/'), + array(\Magento\UrlInterface::URL_TYPE_LINK, true, false, 'http://localhost/index.php/'), + array(\Magento\UrlInterface::URL_TYPE_LINK, true, true, 'http://localhost/index.php/default/'), + array(\Magento\UrlInterface::URL_TYPE_DIRECT_LINK, false, false, 'http://localhost/custom_entry.php/'), + array(\Magento\UrlInterface::URL_TYPE_DIRECT_LINK, false, true, 'http://localhost/custom_entry.php/'), + array(\Magento\UrlInterface::URL_TYPE_DIRECT_LINK, true, false, 'http://localhost/index.php/'), + array(\Magento\UrlInterface::URL_TYPE_DIRECT_LINK, true, true, 'http://localhost/index.php/'), ); } diff --git a/dev/tests/integration/testsuite/Magento/Core/Model/ThemeTest.php b/dev/tests/integration/testsuite/Magento/Core/Model/ThemeTest.php index 56ec20cde913ada118a966f0c18012a97be07615..a87314e98cc18d5764661ef7033b838ec97b518b 100644 --- a/dev/tests/integration/testsuite/Magento/Core/Model/ThemeTest.php +++ b/dev/tests/integration/testsuite/Magento/Core/Model/ThemeTest.php @@ -70,9 +70,9 @@ class ThemeTest extends \PHPUnit_Framework_TestCase public function testChildRelation() { /** @var $theme \Magento\View\Design\ThemeInterface */ - /** @var $currentTheme \Magento\View\Design\ThemeInterface */ $theme = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\View\Design\ThemeInterface'); $collection = $theme->getCollection()->addTypeFilter(\Magento\View\Design\ThemeInterface::TYPE_VIRTUAL); + /** @var $currentTheme \Magento\View\Design\ThemeInterface */ foreach ($collection as $currentTheme) { $parentTheme = $currentTheme->getParentTheme(); if (!empty($parentTheme)) { @@ -80,4 +80,23 @@ class ThemeTest extends \PHPUnit_Framework_TestCase } } } + + /** + * @magentoDataFixture Magento/Core/Model/_files/design/themes.php + * @magentoAppIsolation enabled + * @magentoAppArea frontend + */ + public function testGetInheritedThemes() + { + /** @var \Magento\View\Design\Theme\FlyweightFactory $themeFactory */ + $themeFactory = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + ->get('Magento\View\Design\Theme\FlyweightFactory'); + $theme = $themeFactory->create('vendor_custom_theme'); + $this->assertCount(2, $theme->getInheritedThemes()); + $expected = array(); + foreach ($theme->getInheritedThemes() as $someTheme) { + $expected[] = $someTheme->getFullPath(); + } + $this->assertEquals(array('frontend/vendor_default', 'frontend/vendor_custom_theme'), $expected); + } } diff --git a/dev/tests/integration/testsuite/Magento/Core/Model/TranslateTest.php b/dev/tests/integration/testsuite/Magento/Core/Model/TranslateTest.php index 1cb656463fa38cb1bd84843ba0473004e0b71dea..877dd2c8be70b89574f94e01b9619755d889b0c6 100644 --- a/dev/tests/integration/testsuite/Magento/Core/Model/TranslateTest.php +++ b/dev/tests/integration/testsuite/Magento/Core/Model/TranslateTest.php @@ -91,7 +91,7 @@ class TranslateTest extends \PHPUnit_Framework_TestCase array( $objectManager->get('Magento\Core\Model\StoreManagerInterface'), $objectManager->get('Magento\View\Design\Theme\FlyweightFactory'), - $objectManager->get('Magento\Core\Model\Config'), + $objectManager->get('Magento\App\ConfigInterface'), $objectManager->get('Magento\Core\Model\Store\Config'), $objectManager->get('Magento\Core\Model\ThemeFactory'), $objectManager->get('Magento\Core\Model\App'), diff --git a/dev/tests/integration/testsuite/Magento/Core/Model/_files/design/themes.php b/dev/tests/integration/testsuite/Magento/Core/Model/_files/design/themes.php index 94efdd66113593edfd2bb8f8bd9964a81655610d..ed6935bd236c1092bb74ac2493912de654c806bc 100644 --- a/dev/tests/integration/testsuite/Magento/Core/Model/_files/design/themes.php +++ b/dev/tests/integration/testsuite/Magento/Core/Model/_files/design/themes.php @@ -42,6 +42,4 @@ /** @var $registration \Magento\Core\Model\Theme\Registration */ $registration = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() ->create('Magento\Core\Model\Theme\Registration'); -$registration->register( - implode('/', array('*', '*', 'theme.xml')) -); +$registration->register(implode('/', array('*', '*', 'theme.xml'))); diff --git a/dev/tests/integration/testsuite/Magento/Css/PreProcessor/Adapter/OyejorgeTest.php b/dev/tests/integration/testsuite/Magento/Css/PreProcessor/Adapter/OyejorgeTest.php new file mode 100644 index 0000000000000000000000000000000000000000..e0dac5c361fad4a385b1bd30491d304636aaeec6 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Css/PreProcessor/Adapter/OyejorgeTest.php @@ -0,0 +1,49 @@ +<?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\Css\PreProcessor\Adapter; + +/** + * Oyejorge adapter model + */ +class OyejorgeTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var Oyejorge + */ + protected $model; + + public function setUp() + { + $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); + $this->model = $objectManager->create('Magento\Css\PreProcessor\Adapter\Oyejorge'); + } + + public function testProcess() + { + $sourceFilePath = realpath(__DIR__ . '/../_files/oyejorge.less'); + $resultCss = file_get_contents(__DIR__ . '/../_files/oyejorge.css'); + $this->assertEquals(trim($resultCss), $this->model->process($sourceFilePath)); + } +} diff --git a/dev/tests/integration/testsuite/Magento/Css/PreProcessor/_files/nested/import.less b/dev/tests/integration/testsuite/Magento/Css/PreProcessor/_files/nested/import.less new file mode 100644 index 0000000000000000000000000000000000000000..98e89e191f7e66be08424d1e315c38bfcb660e50 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Css/PreProcessor/_files/nested/import.less @@ -0,0 +1 @@ +@body-bg-img: url(Magento_Theme::validation_advice_bg.gif); diff --git a/dev/tests/integration/testsuite/Magento/Css/PreProcessor/_files/oyejorge.css b/dev/tests/integration/testsuite/Magento/Css/PreProcessor/_files/oyejorge.css new file mode 100644 index 0000000000000000000000000000000000000000..5cfe4bd6f2372f14f137e01e64d649c5f51b9c9f --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Css/PreProcessor/_files/oyejorge.css @@ -0,0 +1,45 @@ +#header { + color: #4d926f; +} +h2 { + color: #4d926f; +} +#header { + -webkit-border-radius: 5px; + -moz-border-radius: 5px; + -ms-border-radius: 5px; + -o-border-radius: 5px; + border-radius: 5px; +} +#footer { + -webkit-border-radius: 10px; + -moz-border-radius: 10px; + -ms-border-radius: 10px; + -o-border-radius: 10px; + border-radius: 10px; +} +#header h1 { + font-size: 26px; + font-weight: bold; +} +#header p { + font-size: 12px; +} +#header p a { + text-decoration: none; +} +#header p a:hover { + border-width: 1px; +} +#header { + color: #333333; + border-left: 1px; + border-right: 2px; +} +#footer { + color: #114411; + border-color: #7d2717; +} +body { + background-image: url(Magento_Theme::validation_advice_bg.gif); +} diff --git a/dev/tests/integration/testsuite/Magento/Css/PreProcessor/_files/oyejorge.less b/dev/tests/integration/testsuite/Magento/Css/PreProcessor/_files/oyejorge.less new file mode 100644 index 0000000000000000000000000000000000000000..447915d0cfaa59caa42af6b259aac82378fcab24 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Css/PreProcessor/_files/oyejorge.less @@ -0,0 +1,69 @@ +// Variables + +@color: #4D926F; + +#header { + color: @color; +} + +h2 { + color: @color; +} + +// Mixins + +.rounded-corners (@radius: 5px) { + -webkit-border-radius: @radius; + -moz-border-radius: @radius; + -ms-border-radius: @radius; + -o-border-radius: @radius; + border-radius: @radius; +} + +#header { + .rounded-corners; +} + +#footer { + .rounded-corners(10px); +} + +// Nested Rules + +#header { + h1 { + font-size: 26px; + font-weight: bold; + } + p { font-size: 12px; + a { + text-decoration: none; + &:hover { + border-width: 1px; + } + } + } +} + +// Functions & Operations + +@the-border: 1px; +@base-color: #111; +@red: #842210; + +#header { + color: (@base-color * 3); + border-left: @the-border; + border-right: (@the-border * 2); +} + +#footer { + color: (@base-color + #003300); + border-color: desaturate(@red, 10%); +} + +@import "nested/import.less"; + +body { + background-image: @body-bg-img; +} diff --git a/dev/tests/integration/testsuite/Magento/Customer/Helper/ViewTest.php b/dev/tests/integration/testsuite/Magento/Customer/Helper/ViewTest.php new file mode 100644 index 0000000000000000000000000000000000000000..6ddbb8e40df160dea41c4dbb8dbb079a1f16b8f4 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Customer/Helper/ViewTest.php @@ -0,0 +1,141 @@ +<?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\Customer\Helper; + +use Magento\TestFramework\Helper\Bootstrap; + +class ViewTest extends \PHPUnit_Framework_TestCase +{ + /** @var \Magento\Customer\Helper\View */ + protected $_helper; + + /** @var \Magento\Customer\Service\V1\CustomerMetadataServiceInterface|\PHPUnit_Framework_MockObject_MockObject */ + protected $_customerMetadataService; + + protected function setUp() + { + $this->_customerMetadataService = $this->getMock( + 'Magento\Customer\Service\V1\CustomerMetadataServiceInterface' + ); + $this->_helper = Bootstrap::getObjectManager()->create( + 'Magento\Customer\Helper\View', + array('customerMetadataService' => $this->_customerMetadataService) + ); + parent::setUp(); + } + + /** + * @param \Magento\Customer\Service\V1\Dto\Customer $customerDto + * @param string $expectedCustomerName + * @param bool $isPrefixAllowed + * @param bool $isMiddleNameAllowed + * @param bool $isSuffixAllowed + * @dataProvider getCustomerNameDataProvider + */ + public function testGetCustomerName( + $customerDto, + $expectedCustomerName, + $isPrefixAllowed = false, + $isMiddleNameAllowed = false, + $isSuffixAllowed = false + ) { + + $visibleAttribute = $this->getMock('Magento\Customer\Service\V1\Dto\Eav\AttributeMetadata', [], [], '', false); + $visibleAttribute->expects($this->any())->method('isVisible')->will($this->returnValue(true)); + + $invisibleAttribute = $this->getMock( + 'Magento\Customer\Service\V1\Dto\Eav\AttributeMetadata', + [], + [], + '', + false + ); + $invisibleAttribute->expects($this->any())->method('isVisible')->will($this->returnValue(false)); + + $this->_customerMetadataService->expects($this->any()) + ->method('getAttributeMetadata') + ->will( + $this->returnValueMap( + [ + ['customer', 'prefix', $isPrefixAllowed ? $visibleAttribute : $invisibleAttribute], + ['customer', 'middlename', $isMiddleNameAllowed ? $visibleAttribute : $invisibleAttribute], + ['customer', 'suffix', $isSuffixAllowed ? $visibleAttribute : $invisibleAttribute], + ] + ) + ); + + $this->assertEquals( + $expectedCustomerName, + $this->_helper->getCustomerName($customerDto), + 'Full customer name is invalid' + ); + } + + public function getCustomerNameDataProvider() + { + /** @var \Magento\Customer\Service\V1\Dto\CustomerBuilder $customerBuilder */ + $customerBuilder = Bootstrap::getObjectManager()->create('Magento\Customer\Service\V1\Dto\CustomerBuilder'); + return [ + 'With disabled prefix, middle name, suffix' => [ + $customerBuilder->setPrefix('prefix') + ->setFirstname('FirstName') + ->setMiddlename('MiddleName') + ->setLastname('LastName') + ->setSuffix('suffix') + ->create(), + 'FirstName LastName' + ], + 'With prefix, middle name, suffix' => [ + $customerBuilder->setPrefix('prefix') + ->setFirstname('FirstName') + ->setMiddlename('MiddleName') + ->setLastname('LastName') + ->setSuffix('suffix') + ->create(), + 'prefix FirstName MiddleName LastName suffix', + true, // $isPrefixAllowed + true, // $isMiddleNameAllowed + true //$isSuffixAllowed + ], + 'Empty prefix, middle name, suffix' => [ + $customerBuilder->setFirstname('FirstName')->setLastname('LastName')->create(), + 'FirstName LastName', + true, // $isPrefixAllowed + true, // $isMiddleNameAllowed + true //$isSuffixAllowed + ], + 'Empty prefix and suffix, not empty middle name' => [ + $customerBuilder->setFirstname('FirstName') + ->setMiddlename('MiddleName') + ->setLastname('LastName') + ->create(), + 'FirstName MiddleName LastName', + true, // $isPrefixAllowed + true, // $isMiddleNameAllowed + true //$isSuffixAllowed + ], + ]; + } +} diff --git a/dev/tests/integration/testsuite/Magento/Customer/Model/Metadata/FormTest.php b/dev/tests/integration/testsuite/Magento/Customer/Model/Metadata/FormTest.php new file mode 100644 index 0000000000000000000000000000000000000000..06d02c8b2a54fa18f92536057692f289854a4f51 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Customer/Model/Metadata/FormTest.php @@ -0,0 +1,139 @@ +<?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_Customer + * @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\Customer\Model\Metadata; + +class FormTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Customer\Model\Metadata\FormFactory + */ + protected $_formFactory; + + /** + * @var array + */ + protected $_attributes = []; + + /** + * @var \Magento\App\RequestInterface + */ + protected $_request; + + /** @var array */ + protected $_expected = []; + + public function setUp() + { + $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); + $this->_formFactory = $objectManager + ->create('Magento\Customer\Model\Metadata\FormFactory'); + + $this->_requestData = [ + 'id' => 14, + 'default_shipping' => true, + 'default_billing' => false, + 'company' => 'Company Name', + 'fax' => '(555) 555-5555', + 'middlename' => 'Mid', + 'prefix' => 'Mr.', + 'suffix' => 'Esq.', + 'vat_id' => 'S45', + 'firstname' => 'Jane', + 'lastname' => 'Doe', + 'street' => ['7700 W Parmer Ln'], + 'city' => 'Austin', + 'country_id' => 'US', + 'postcode' => '78620', + 'telephone' => '5125125125', + 'region_id' => 0, + 'region' => 'Texas', + ]; + + $this->_expected = $this->_requestData; + /** Unset data which is not part of the form */ + unset($this->_expected['id']); + unset($this->_expected['default_shipping']); + unset($this->_expected['default_billing']); + unset($this->_expected['middlename']); + unset($this->_expected['prefix']); + unset($this->_expected['suffix']); + + $this->_request = $objectManager->get('Magento\App\RequestInterface'); + $this->_request->setParams($this->_requestData); + } + + public function testCompactData() + { + $addressForm = $this->_formFactory->create( + 'customer_address', + 'customer_address_edit', + [] + ); + $addressData = $addressForm->extractData($this->_request); + $attributeValues = $addressForm->compactData($addressData); + $this->assertEquals($this->_expected, $attributeValues); + } + + public function testGetAttributes() + { + $expectedAttributes = [ + 'prefix', 'firstname', 'middlename', 'lastname', 'suffix', 'company', 'street', 'city', 'country_id', + 'region', 'region_id', 'postcode', 'telephone', 'fax', 'vat_id' + ]; + $addressForm = $this->_formFactory->create( + 'customer_address', + 'customer_address_edit', + [] + ); + $this->assertEquals($expectedAttributes, array_keys($addressForm->getAttributes())); + } + + public function testGetSystemAttributes() + { + $addressForm = $this->_formFactory->create( + 'customer_address', + 'customer_address_edit', + [] + ); + $this->assertCount(15, $addressForm->getSystemAttributes()); + } + + /** + * @magentoDataFixture Magento/Customer/_files/attribute_user_defined.php + */ + public function testGetUserAttributes() + { + $expectedAttributes = ['user_attribute']; + $addressForm = $this->_formFactory->create( + 'customer_address', + 'customer_address_edit', + [] + ); + $this->assertEquals($expectedAttributes, array_keys($addressForm->getUserAttributes())); + } +} \ No newline at end of file diff --git a/dev/tests/integration/testsuite/Magento/Customer/Service/CustomerTest.php b/dev/tests/integration/testsuite/Magento/Customer/Service/CustomerTest.php deleted file mode 100644 index db32c7fcd5daa6cff16921cdf1e728cc10d96422..0000000000000000000000000000000000000000 --- a/dev/tests/integration/testsuite/Magento/Customer/Service/CustomerTest.php +++ /dev/null @@ -1,612 +0,0 @@ -<?php -/** - * Integration test for service layer \Magento\Customer\Service\Customer - * - * 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\Customer\Service; - -class CustomerTest extends \PHPUnit_Framework_TestCase -{ - /** - * @var \Magento\Customer\Service\Customer - */ - protected $_model; - - /** - * @var \Magento\ObjectManager - */ - protected $_objectManager = null; - - /** - * @var \Magento\Customer\Model\Customer - */ - protected $_createdCustomer; - - /** - * @var \Magento\Customer\Model\CustomerFactory - */ - protected $_customerFactory = null; - - protected function setUp() - { - $this->_objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); - $this->_customerFactory = $this->_objectManager->get('Magento\Customer\Model\CustomerFactory'); - $this->_model = $this->_objectManager->create('Magento\Customer\Service\Customer'); - \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\App\State')->setAreaCode('frontend'); - } - - protected function tearDown() - { - $previousStoreId = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() - ->get('Magento\Core\Model\StoreManagerInterface')->getStore(); - if ($this->_createdCustomer && $this->_createdCustomer->getId() > 0) { - \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Core\Model\App') - ->loadArea(\Magento\Backend\App\Area\FrontNameResolver::AREA_CODE); - $this->_createdCustomer->getAddressesCollection()->delete(); - $this->_createdCustomer->delete(); - } - \Magento\TestFramework\Helper\Bootstrap::getObjectManager() - ->get('Magento\Core\Model\StoreManagerInterface') - ->setCurrentStore($previousStoreId); - - $this->_model = null; - } - - /** - * @param array $customerData - * @dataProvider createDataProvider - * @magentoAppArea adminhtml - */ - public function testCreate($customerData) - { - $this->_createdCustomer = $this->_model->create($customerData); - $this->assertInstanceOf('Magento\Customer\Model\Customer', $this->_createdCustomer); - $this->assertNotEmpty($this->_createdCustomer->getId()); - - $loadedCustomer = $this->_customerFactory->create() - ->load($this->_createdCustomer->getId()); - if (array_key_exists('sendemail', $customerData)) { - unset($customerData['sendemail']); - } - $expectedData = $customerData; - $actualData = $loadedCustomer->toArray(array_keys($customerData)); - if (isset($expectedData['password'])) { - // TODO Add assertions for password if needed - unset($expectedData['password'], $actualData['password']); - } - $this->assertEquals($expectedData, $actualData); - } - - /** - * @return array - */ - public function createDataProvider() - { - return array( - 'Valid data' => array(array( - 'website_id' => 1, - 'sendemail' => true, - 'group_id' => 1, - 'disable_auto_group_change' => 0, - 'prefix' => 'Prefix', - 'firstname' => 'Service', - 'middlename' => 'Middlename', - 'lastname' => 'CreateValid', - 'suffix' => 'Suffix', - 'email' => 'test' . mt_rand(1000, 9999) . '@mail.com', - 'dob' => date('Y-m-d H:i:s'), - 'taxvat' => null, - 'gender' => 1, - 'password' => '123123q', - 'default_billing' => null, - 'default_shipping' => null, - 'store_id' => \Magento\Core\Model\Store::DEFAULT_STORE_ID - )), - 'Mandatory data' => array(array( - 'firstname' => 'SomeName', - 'lastname' => 'CreateMandatory', - 'email' => 'test' . mt_rand(1000, 9999) . '@mail.com', - )), - ); - } - - /** - * @param array $customerData - * @param string $exceptionName - * @param string $exceptionText - * @dataProvider createExceptionsDataProvider - */ - public function testCreateExceptions($customerData, $exceptionName, $exceptionText = '') - { - $this->setExpectedException($exceptionName, $exceptionText); - $this->_createdCustomer = $this->_model->create($customerData); - } - - /** - * @return array - */ - public function createExceptionsDataProvider() - { - return array( - 'First name is required field' => array(array( - 'website_id' => 0, - 'group_id' => 1, - 'disable_auto_group_change' => 0, - 'prefix' => null, - 'firstname' => null, - 'lastname' => 'ServiceTestCreateExceptionFNR', - 'suffix' => null, - 'email' => 'test' . mt_rand(1000, 9999) . '@mail.com', - 'password' => '123123q', - 'store_id' => \Magento\Core\Model\Store::DEFAULT_STORE_ID - ), 'Magento\Validator\ValidatorException'), - 'Invalid email' => array(array( - 'website_id' => 0, - 'group_id' => 1, - 'disable_auto_group_change' => 0, - 'prefix' => null, - 'firstname' => 'ServiceTestCreate', - 'lastname' => 'ExceptionInvalidEmail', - 'suffix' => null, - 'email' => '111@111', - 'password' => '123123q', - 'store_id' => \Magento\Core\Model\Store::DEFAULT_STORE_ID - ), 'Magento\Validator\ValidatorException'), - 'Invalid password' => array(array( - 'website_id' => 0, - 'group_id' => 1, - 'disable_auto_group_change' => 0, - 'prefix' => null, - 'firstname' => 'ServiceTestCreate', - 'lastname' => 'ExceptionPassword', - 'suffix' => null, - 'email' => 'test' . mt_rand(1000, 9999) . '@mail.com', - 'password' => '123', - 'store_id' => \Magento\Core\Model\Store::DEFAULT_STORE_ID - ), 'Magento\Eav\Model\Entity\Attribute\Exception', 'The password must have at least 6 characters.') - ); - } - - /** - * @param array $addressesData - * @dataProvider createWithAddressesDataProvider - */ - public function testCreateWithAddresses($addressesData) - { - $customerData = array( - 'firstname' => 'ServiceTest', - 'lastname' => 'CreateWithAddress', - 'email' => 'test' . mt_rand(1000, 9999) . '@mail.com', - ); - - $this->_createdCustomer = $this->_model->create($customerData, $addressesData); - $this->assertCount(count($addressesData), $this->_createdCustomer->getAddresses()); - - /** @var \Magento\Customer\Model\Customer $loadedCustomer */ - $loadedCustomer = $this->_customerFactory->create() - ->load($this->_createdCustomer->getId()); - - $createdData = array(); - /** @var \Magento\Customer\Model\Address $address */ - foreach ($loadedCustomer->getAddresses() as $address) { - $addressData = current($addressesData); - $createdData[] = $address->toArray(array_keys($addressData)); - next($addressesData); - } - - $this->assertEquals( - $this->_getSortedByKey($createdData, 'firstname'), - $this->_getSortedByKey($addressesData, 'firstname') - ); - } - - /** - * @param array $data - * @param string $sortKey - * @return array - */ - protected function _getSortedByKey($data, $sortKey) - { - $callback = function ($elementOne, $elementTwo) use ($sortKey) { - return strcmp($elementOne[$sortKey], $elementTwo[$sortKey]); - }; - usort($data, $callback); - return $data; - } - - /** - * @return array - */ - public function createWithAddressesDataProvider() - { - return array( - 'Two addresses' => array( - array( - array( - 'prefix' => 'Mrs.', - 'firstname' => 'Linda', - 'middlename' => 'G.', - 'lastname' => 'Jones', - 'suffix' => 'Suffix', - 'company' => 'Vitagee', - 'street' => "3083 Eagles Nest Drive\nHoopa", - 'country_id' => 'US', - 'region_id' => '12', // California - 'city' => 'Los Angeles', - 'postcode' => '95546', - 'fax' => '55512450056', - 'telephone' => '55512450000', - 'vat_id' => '556-70-1739', - ), - array( - 'firstname' => 'John', - 'lastname' => 'Smith', - 'street' => 'Green str, 67', - 'country_id' => 'AL', - 'city' => 'CityM', - 'postcode' => '75477', - 'telephone' => '3468676', - ) - ) - ), - 'One address' => array( - array( - array( - 'firstname' => 'John', - 'lastname' => 'Smith', - 'street' => 'Green str, 67', - 'country_id' => 'AL', - 'city' => 'CityM', - 'postcode' => '75477', - 'telephone' => '3468676', - ) - ) - ) - ); - } - - /** - * @expectedException \Magento\Core\Exception - * @expectedExceptionMessage The address with the specified ID not found. - */ - public function testCreateWithInvalidAddressId() - { - $customerData = array( - 'firstname' => 'ServiceTest', - 'lastname' => 'InvalidAddress', - 'email' => 'test' . mt_rand(1000, 9999) . '@mail.com', - ); - - $addressData = array( - 'entity_id' => 'fake', - 'firstname' => 'John', - 'lastname' => 'Smith', - 'street' => 'Green str, 67', - 'country_id' => 'AL', - 'city' => 'CityM', - 'postcode' => '75477', - 'telephone' => '3468676', - ); - - $this->_createdCustomer = $this->_model->create($customerData, array($addressData)); - } - - /** - * @param array $customerData - * @magentoDataFixture Magento/Customer/_files/customer.php - * @dataProvider updateDataProvider - * @magentoAppArea frontend - */ - public function testUpdate($customerData) - { - \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Core\Model\App') - ->getArea(\Magento\Core\Model\App\Area::AREA_FRONTEND)->load(); - $expected = $this->_customerFactory->create() - ->load(1); - - $updatedCustomer = $this->_model->update($expected->getId(), $customerData); - - $this->assertInstanceOf('Magento\Customer\Model\Customer', $updatedCustomer); - $this->assertFalse($updatedCustomer->isObjectNew()); - $actualData = $this->_customerFactory->create() - ->load($expected->getId())->getData(); - $expectedData = array_merge($updatedCustomer->toArray(array_keys($actualData)), $customerData); - unset($expectedData['updated_at'], $actualData['updated_at']); - if (isset($expectedData['password'])) { - // TODO Add assertions for password if needed - unset($expectedData['password'], $actualData['password']); - } - $this->assertEquals($expectedData, $actualData); - } - - /** - * @return array - */ - public function updateDataProvider() - { - return array( - 'Change name' => array(array( - 'firstname' => 'SomeName2', - )), - 'Change password' => array(array( - 'password' => '111111' - )), - 'Multiple properties' => array(array( - 'disable_auto_group_change' => 0, - 'prefix' => 'Prefix', - 'firstname' => 'ServiceTest', - 'middlename' => 'Middlename', - 'lastname' => 'UpdateMultiple', - 'suffix' => 'Suffix', - 'email' => 'test' . mt_rand(1000, 9999) . '@mail.com', - 'dob' => date('Y-m-d H:i:s'), - 'gender' => 1, - 'store_id' => \Magento\Core\Model\Store::DEFAULT_STORE_ID - )) - ); - } - - /** - * @magentoDataFixture Magento/Customer/_files/customer.php - */ - public function testUpdateFirstname() - { - $customer = $this->_customerFactory->create()->load(1); - // This call to getAttributes will cause our test to fail if the - // customer fixture was using attribute set 0 instead of 1 - $customer->getAttributes(); - - $updatedCustomer = $this->_model->update(1, ['firstname' => 'new_name']); - - $customer = $this->_customerFactory->create()->load(1); - - $this->assertEquals('new_name', $customer->getFirstname()); - $this->assertEquals('new_name', $updatedCustomer->getFirstname()); - } - - /** - * @param array $customerData - * @param string $exceptionName - * @param string $exceptionMessage - * @magentoDataFixture Magento/Customer/_files/customer.php - * @dataProvider updateExceptionsDataProvider - */ - public function testUpdateExceptions($customerData, $exceptionName, $exceptionMessage = '') - { - \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Core\Model\App') - ->getArea(\Magento\Core\Model\App\Area::AREA_FRONTEND)->load(); - $this->setExpectedException($exceptionName, $exceptionMessage); - $this->_model->update(1, $customerData); - } - - /** - * @return array - */ - public function updateExceptionsDataProvider() - { - return array( - 'Invalid password' => array( - array( - 'password' => '111' - ), - 'Magento\Eav\Model\Entity\Attribute\Exception' - ), - 'Invalid name' => array( - array( - 'firstname' => null - ), - 'Magento\Validator\ValidatorException' - ), - 'Invalid email' => array( - array( - 'email' => '3434@23434' - ), - 'Magento\Validator\ValidatorException' - ) - ); - } - - /** - * @expectedException \Magento\Core\Exception - * @expectedExceptionMessage The customer with the specified ID not found. - */ - public function testUpdateInvalidCustomerId() - { - $this->_model->update(1, array('firstname' => 'Foo')); - } - - /** - * @magentoDataFixture Magento/Customer/_files/customer.php - * @appAreaCode adminhtml - */ - public function testAutoGeneratePassword() - { - $oldPasswordHash = $this->_customerFactory->create() - ->load(1) - ->getPasswordHash(); - $updatedCustomer = $this->_model->update( - 1, - array('autogenerate_password' => true,) - ); - $this->assertNotEquals($oldPasswordHash, $updatedCustomer->getPasswordHash()); - } - - /** - * @param array $addressesData - * @dataProvider customerAddressDataProvider - * @magentoDataFixture Magento/Customer/_files/customer.php - * @magentoDataFixture Magento/Customer/_files/customer_two_addresses.php - */ - public function testCustomerAddressManipulation($addressesData) - { - /** @var \Magento\Customer\Model\Customer $customer */ - $customer = $this->_customerFactory->create() - ->load(1); - $this->assertCount(2, $customer->getAddresses(), 'Not all customer addresses were created.'); - $updatedCustomer = $this->_model->update(1, array(), $addressesData); - $this->assertCount( - count($addressesData), - $updatedCustomer->getAddresses(), - 'Customer address was not deleted.' - ); - - /** @var \Magento\Customer\Model\Customer $actualCustomer */ - $actualCustomer = $this->_customerFactory->create() - ->load(1); - $actualAddresses = $actualCustomer->getAddresses(); - $this->assertCount(count($addressesData), $actualAddresses, 'Customer address was not actually deleted.'); - - // Check that all addresses were updated correctly - $updatedData = array(); - /** @var \Magento\Customer\Model\Address $address */ - $addressesData = $this->_getSortedByKey($addressesData, 'postcode'); - foreach ($this->_getSortedByKey($actualAddresses, 'postcode') as $address) { - $addressData = current($addressesData); - $updatedData[] = $address->toArray(array_keys($addressData)); - next($addressesData); - } - $this->assertEquals($addressesData, $updatedData, 'Customer addresses are incorrect.'); - } - - /** - * @return array - */ - public function customerAddressDataProvider() - { - return array( - 'Addresses update' => array( - array( - array('entity_id' => 1, 'postcode' => '1000001'), - array('entity_id' => 2, 'postcode' => '1000002') - ) - ), - 'First address delete' => array( - array( - array('entity_id' => 2) - ) - ), - 'First address update, second delete' => array( - array( - array('entity_id' => 1, 'city' => 'Updated city', 'postcode' => '1000001') - ) - ), - 'All addresses delete' => array( - array() - ), - 'Addresses updated and one created' => array( - array( - array('entity_id' => 1, 'postcode' => '1000001'), - array('entity_id' => 2, 'city' => 'Updated city', 'postcode' => '1000002') - ) - ), - 'Address updated, deleted and created' => array( - array( - array( - 'firstname' => 'John', - 'lastname' => 'Smith', - 'street' => 'Green str, 67', - 'country_id' => 'AL', - 'city' => 'CityM', - 'postcode' => '1000001', - 'telephone' => '3468676' - ), - array('entity_id' => 2, 'city' => 'Updated city', 'postcode' => '1000002') - ) - ) - ); - } - - /** - * Test beforeSave and afterSave callback - * - * @magentoDataFixture Magento/Customer/_files/customer.php - */ - public function testCallback() - { - $customer = $this->_customerFactory->create() - ->load(1); - $customerData = array('firstname' => 'Updated name'); - $customer->addData($customerData); - $addressData = array( - array( - 'firstname' => 'John', - 'lastname' => 'Smith', - 'street' => 'Green str, 67', - 'country_id' => 'AL', - 'city' => 'CityM', - 'postcode' => '75477', - 'telephone' => '3468676', - ) - ); - - $callbackCount = 0; - $callback = function ($actualCustomer, $actualData, $actualAddresses) use ($customer, $customerData, - $addressData, &$callbackCount - ) { - $callbackCount++; - // Remove updated_at as in afterSave updated_at may be changed - $expectedCustomerData = $customer->getData(); - unset($expectedCustomerData['updated_at']); - \PHPUnit_Framework_Assert::assertEquals( - $expectedCustomerData, - $actualCustomer->toArray(array_keys($expectedCustomerData)) - ); - \PHPUnit_Framework_Assert::assertEquals($customerData, $actualData); - \PHPUnit_Framework_Assert::assertEquals($addressData, $actualAddresses); - }; - - $this->_model->setBeforeSaveCallback($callback); - $this->_model->setAfterSaveCallback($callback); - $this->_model->update(1, $customerData, $addressData); - $this->assertEquals(2, $callbackCount, 'Not all expected callbacks were called.'); - } - - /** - * @param bool $isAdminStore - * @param boolean $isConfirmed - * @dataProvider forceConfirmedDataProvider - */ - public function testCustomerSetForceConfirmed($isAdminStore, $isConfirmed) - { - $this->_model->setIsAdminStore($isAdminStore); - $customerData = array( - 'firstname' => 'ServiceTest', - 'lastname' => 'ForceConfirmed', - 'email' => 'test' . mt_rand(1000, 9999) . '@mail.com', - 'password' => '123123q' - ); - $this->_createdCustomer = $this->_model->create($customerData); - $this->assertEquals($isConfirmed, $this->_createdCustomer->getForceConfirmed()); - } - - /** - * @return array - */ - public function forceConfirmedDataProvider() - { - return array( - 'admin store' => array(true, true), - 'distro store' => array(false, false), - ); - } -} diff --git a/dev/tests/integration/testsuite/Magento/Customer/Service/V1/CustomerAddressServiceTest.php b/dev/tests/integration/testsuite/Magento/Customer/Service/V1/CustomerAddressServiceTest.php index 91fbe7dd24af90d1f0741d365336083627d94eb3..79fe6c642b857f1b20b059974b6f47977f75e906 100644 --- a/dev/tests/integration/testsuite/Magento/Customer/Service/V1/CustomerAddressServiceTest.php +++ b/dev/tests/integration/testsuite/Magento/Customer/Service/V1/CustomerAddressServiceTest.php @@ -560,9 +560,9 @@ class CustomerAddressServiceTest extends \PHPUnit_Framework_TestCase // Either both set or both unset $this->assertTrue(!(isset($expectedRegion) xor isset($actualRegion))); if (isset($expectedRegion) && isset($actualRegion)) { - $this->assertInstanceOf('Magento\Customer\Service\V1\Dto\Region', $expectedRegion); - $this->assertInstanceOf('Magento\Customer\Service\V1\Dto\Region', $actualRegion); - $this->assertEquals($expectedRegion->__toArray(), $actualRegion->__toArray()); + $this->assertTrue(is_array($expectedRegion)); + $this->assertTrue(is_array($actualRegion)); + $this->assertEquals($expectedRegion, $actualRegion); } } } diff --git a/dev/tests/integration/testsuite/Magento/Customer/_files/attribute_user_defined.php b/dev/tests/integration/testsuite/Magento/Customer/_files/attribute_user_defined.php new file mode 100644 index 0000000000000000000000000000000000000000..2665b589a29d5b1c4114bf53a4401fb75d17a696 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Customer/_files/attribute_user_defined.php @@ -0,0 +1,41 @@ +<?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_Catalog + * @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) + */ + +$model = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + ->create('Magento\Customer\Model\Attribute'); +$model->setName('user_attribute') + ->setEntityTypeId(2) + ->setIsUserDefined(1); +$model->save(); + +/** @var \Magento\Customer\Model\Resource\Setup $setupResource */ +$setupResource = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + ->create('Magento\Customer\Model\Resource\Setup', ['resourceName' => 'customer_setup']); +$data = [ + ['form_code' => 'customer_address_edit', 'attribute_id' => $model->getAttributeId()] +]; +$setupResource->getConnection()->insertMultiple($setupResource->getTable('customer_form_attribute'), $data); diff --git a/dev/tests/integration/testsuite/Magento/Customer/_files/attribute_user_defined_customer.php b/dev/tests/integration/testsuite/Magento/Customer/_files/attribute_user_defined_customer.php new file mode 100644 index 0000000000000000000000000000000000000000..bd39d53312165c5c2469942fa258feabecb6db8c --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Customer/_files/attribute_user_defined_customer.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) + */ + +define('FIXTURE_ATTRIBUTE_USER_DEFINED_CUSTOMER_NAME', 'user_attribute'); +define('FIXTURE_ATTRIBUTE_USER_DEFINED_CUSTOMER_FRONTEND_LABEL', 'frontend_label'); + +/** @var Magento\Customer\Model\Attribute $model */ +$model = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\Customer\Model\Attribute'); + +$model->setName(FIXTURE_ATTRIBUTE_USER_DEFINED_CUSTOMER_NAME) + ->setEntityTypeId(1) + ->setIsUserDefined(1) + ->setAttributeSetId(1) + ->setAttributeGroupId(1) + ->setFrontendInput('text') + ->setFrontendLabel(FIXTURE_ATTRIBUTE_USER_DEFINED_CUSTOMER_FRONTEND_LABEL); + +$model->save(); diff --git a/dev/tests/integration/testsuite/Magento/Customer/_files/customer.php b/dev/tests/integration/testsuite/Magento/Customer/_files/customer.php index 3f29b8530339b22410dfc7cde2fa339a84d2ca57..2406dd079fa420c492ca8e7056a0a3c29888a106 100644 --- a/dev/tests/integration/testsuite/Magento/Customer/_files/customer.php +++ b/dev/tests/integration/testsuite/Magento/Customer/_files/customer.php @@ -26,6 +26,7 @@ */ $customer = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() ->create('Magento\Customer\Model\Customer'); +/** @var Magento\Customer\Model\Customer $customer */ $customer ->setWebsiteId(1) ->setId(1) diff --git a/dev/tests/integration/testsuite/Magento/Email/Model/TemplateTest.php b/dev/tests/integration/testsuite/Magento/Email/Model/TemplateTest.php index 97dcaed5a057c54442da1e32c0421c211be71db8..17e2c6923cb2f5d00fcc8a717e7a043cac0e477d 100644 --- a/dev/tests/integration/testsuite/Magento/Email/Model/TemplateTest.php +++ b/dev/tests/integration/testsuite/Magento/Email/Model/TemplateTest.php @@ -57,7 +57,7 @@ class TemplateTest extends \PHPUnit_Framework_TestCase $objectManager->create('Magento\View\Url'), $objectManager->create('Magento\View\FileSystem'), $objectManager->create('Magento\Core\Model\Store\Config'), - $objectManager->create('Magento\Core\Model\Config'), + $objectManager->create('Magento\App\ConfigInterface'), $objectManager->get('Magento\Email\Model\Template\FilterFactory'), $objectManager->get('Magento\Email\Model\Template\Config'), )) @@ -241,4 +241,15 @@ class TemplateTest extends \PHPUnit_Framework_TestCase array('name' => 'Sender Name', 'email' => 'sender@example.com'), 'recipient@example.com', 'Recipient Name' ); } + + /** + * @magentoAppIsolation enabled + */ + public function testGetDefaultEmailLogo() + { + $this->assertStringEndsWith( + 'static/frontend/magento_plushe/en_US/Magento_Email/logo_email.gif', + $this->_model->getDefaultEmailLogo() + ); + } } diff --git a/dev/tests/integration/testsuite/Magento/ImportExport/Model/Export/AbstractStubEntity.php b/dev/tests/integration/testsuite/Magento/ImportExport/Model/Export/AbstractStubEntity.php index a2c28a7d51d9f827db54ee249d97ad419a6905a5..aa1df9dd650ce2c7f9e4906ccb30e0df1bc05c78 100644 --- a/dev/tests/integration/testsuite/Magento/ImportExport/Model/Export/AbstractStubEntity.php +++ b/dev/tests/integration/testsuite/Magento/ImportExport/Model/Export/AbstractStubEntity.php @@ -33,13 +33,14 @@ namespace Magento\ImportExport\Model\Export; abstract class AbstractStubEntity extends \Magento\ImportExport\Model\Export\AbstractEntity { - public function __construct() - { - /** @var \Magento\TestFramework\ObjectManager $objectManager */ - $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); - - $storeConfig = $objectManager->get('Magento\Core\Model\Store\Config'); - parent::__construct($storeConfig); + public function __construct( + \Magento\Core\Model\Store\Config $coreStoreConfig, + \Magento\Core\Model\StoreManagerInterface $storeManager, + \Magento\ImportExport\Model\Export\Factory $collectionFactory, + \Magento\ImportExport\Model\Resource\CollectionByPagesIteratorFactory $resourceColFactory, + array $data = array() + ) { + parent::__construct($coreStoreConfig, $storeManager, $collectionFactory, $resourceColFactory, $data); $this->_disabledAttrs = array('default_billing', 'default_shipping'); } } diff --git a/dev/tests/integration/testsuite/Magento/ImportExport/Model/Export/Entity/AbstractEavTest.php b/dev/tests/integration/testsuite/Magento/ImportExport/Model/Export/Entity/AbstractEavTest.php index 9c33325ee8d9c319028bb9d1077cc8cded216846..58ce685b183106b3bee929f6d982c11cb1dd0f97 100644 --- a/dev/tests/integration/testsuite/Magento/ImportExport/Model/Export/Entity/AbstractEavTest.php +++ b/dev/tests/integration/testsuite/Magento/ImportExport/Model/Export/Entity/AbstractEavTest.php @@ -69,7 +69,7 @@ class AbstractEavTest extends \PHPUnit_Framework_TestCase ->will($this->returnValue($customerAttributes)); $this->_model->__construct( $objectManager->get('Magento\Core\Model\Store\Config'), - $objectManager->get('Magento\Core\Model\App'), + $objectManager->get('Magento\Core\Model\StoreManager'), $objectManager->get('Magento\ImportExport\Model\Export\Factory'), $objectManager->get('Magento\ImportExport\Model\Resource\CollectionByPagesIteratorFactory'), $objectManager->get('Magento\Core\Model\LocaleInterface'), diff --git a/dev/tests/integration/testsuite/Magento/ImportExport/Model/Export/EntityAbstractTest.php b/dev/tests/integration/testsuite/Magento/ImportExport/Model/Export/EntityAbstractTest.php index f138f680278fdadbd5968e259f18ba19b1c4bbb2..e6c5e995a2bfb7aa3e980681b20e64350c833a67 100644 --- a/dev/tests/integration/testsuite/Magento/ImportExport/Model/Export/EntityAbstractTest.php +++ b/dev/tests/integration/testsuite/Magento/ImportExport/Model/Export/EntityAbstractTest.php @@ -46,7 +46,7 @@ class EntityAbstractTest extends \PHPUnit_Framework_TestCase $this->_model = $this->getMockForAbstractClass( 'Magento\ImportExport\Model\Export\AbstractEntity', array( $objectManager->get('Magento\Core\Model\Store\Config'), - $objectManager->get('Magento\Core\Model\App'), + $objectManager->get('Magento\Core\Model\StoreManager'), $objectManager->get('Magento\ImportExport\Model\Export\Factory'), $objectManager->get('Magento\ImportExport\Model\Resource\CollectionByPagesIteratorFactory'), ) @@ -124,12 +124,12 @@ abstract class Stub_Magento_ImportExport_Model_Export_AbstractEntity { public function __construct( \Magento\Core\Model\Store\Config $coreStoreConfig, - \Magento\Core\Model\App $app, + \Magento\Core\Model\StoreManagerInterface $storeManager, \Magento\ImportExport\Model\Export\Factory $collectionFactory, \Magento\ImportExport\Model\Resource\CollectionByPagesIteratorFactory $resourceColFactory, array $data = array() ) { - parent::__construct($coreStoreConfig, $app, $collectionFactory, $resourceColFactory, $data); + parent::__construct($coreStoreConfig, $storeManager, $collectionFactory, $resourceColFactory, $data); $this->_disabledAttrs = array('default_billing', 'default_shipping'); } } diff --git a/dev/tests/integration/testsuite/Magento/Indexer/Model/ShellTest.php b/dev/tests/integration/testsuite/Magento/Indexer/Model/ShellTest.php new file mode 100644 index 0000000000000000000000000000000000000000..026cedae4229e2f53c17fa394b377b8652567da9 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Indexer/Model/ShellTest.php @@ -0,0 +1,111 @@ +<?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\Indexer\Model; + +class ShellTest extends \PHPUnit_Framework_TestCase +{ + /** + * Returns prepared model + * + * @param string $entryPoint + * @return \Magento\Indexer\Model\Shell + */ + protected function getModel($entryPoint = 'fake.php') + { + return \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + ->create('Magento\Indexer\Model\Shell', array('entryPoint' => $entryPoint)); + } + + /** + * Returns result of running model - can be real model or mocked one + * + * @param \Magento\Indexer\Model\Shell $model Can be mock + * @return string + */ + protected function runModel($model) + { + ob_start(); + $model->run(); + $result = ob_get_contents(); + ob_end_clean(); + return $result; + } + + public function testGetUsageHelp() + { + $model = $this->getModel('testme.php'); + $this->assertContains('testme.php', $model->getUsageHelp()); + } + + public function testRunWithoutParams() + { + $model = $this->getModel('testme.php'); + $result = $this->runModel($model); + $this->assertContains('testme.php', $result); + $this->assertContains('index', $result); // Something about indexes + } + + public function testRunIndexList() + { + $model = $this->getModel('testme.php'); + $model->setRawArgs(array('testme.php', '--', 'status')); + $result = $this->runModel($model); + + $this->assertNotContains('testme.php', $result); + $this->assertNotContains('Usage:', $result); + + /** @var \Magento\Indexer\Model\Config $config */ + $config = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Indexer\Model\Config'); + foreach ($config->getAll() as $indexerData) { + $this->assertContains($indexerData['title'], $result); + } + } + + /** + * @param string $param + * @param bool $expectedHasErrors + * + * @dataProvider hasErrorsDataProvider + */ + public function testHasErrors($param, $expectedHasErrors) + { + $model = $this->getModel('testme.php'); + $model->setRawArgs(array('testme.php', '--', $param)); + $this->runModel($model); + + $this->assertEquals($expectedHasErrors, $model->hasErrors()); + } + + /** + * @return array + */ + public function hasErrorsDataProvider() + { + return array( + 'execution without issues' => array('info', false), + 'issue with wrong index' => array('--reindex=wrong_index_code', true), + ); + } +} diff --git a/dev/tests/integration/testsuite/Magento/Less/File/Source/AggregatedTest.php b/dev/tests/integration/testsuite/Magento/Less/File/Source/AggregatedTest.php new file mode 100644 index 0000000000000000000000000000000000000000..42d0350ff8ebe824808602185c166cac4a3358d2 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Less/File/Source/AggregatedTest.php @@ -0,0 +1,166 @@ +<?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\Less\File\Source; + +class AggregatedTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Less\File\Source\Aggregated + */ + protected $model; + + /** + * @var \Magento\ObjectManager + */ + protected $objectManager; + + protected function setUp() + { + \Magento\TestFramework\Helper\Bootstrap::getInstance()->reinitialize(array( + \Magento\App\Filesystem::PARAM_APP_DIRS => array( + \Magento\App\Filesystem::PUB_LIB_DIR => array('path' => dirname(dirname(__DIR__)) . '/_files/lib'), + \Magento\App\Filesystem::THEMES_DIR => array('path' => dirname(dirname(__DIR__)) . '/_files/design'), + ) + )); + $this->objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); + $this->objectManager->get('Magento\App\State')->setAreaCode('frontend'); + + /** @var \Magento\Filesystem $filesystem */ + $filesystem = $this->objectManager->create( + 'Magento\App\Filesystem', + array('directoryList' => $this->objectManager->create( + 'Magento\Filesystem\DirectoryList', + array( + 'root' => BP, + 'directories' => array( + \Magento\App\Filesystem::MODULES_DIR + => array('path' => dirname(dirname(__DIR__)) . '/_files/code') + ) + ) + )) + ); + + /** @var \Magento\Less\File\Source\Base $sourceBase */ + $sourceBase = $this->objectManager->create('Magento\Less\File\Source\Base', array('filesystem' => $filesystem)); + $this->model = $this->objectManager->create( + 'Magento\Less\File\Source\Aggregated', + array('baseFiles' => $sourceBase) + ); + } + + /** + * @magentoDataFixture Magento/Less/_files/themes.php + * @magentoAppIsolation enabled + * @magentoAppArea frontend + * @param string $path + * @param string $themeName + * @param string[] $expectedFiles + * @dataProvider getFilesDataProvider + */ + public function testGetFiles($path, $themeName, $expectedFiles) + { + /** @var \Magento\View\Design\Theme\FlyweightFactory $themeFactory */ + $themeFactory = $this->objectManager->get('Magento\View\Design\Theme\FlyweightFactory'); + $theme = $themeFactory->create($themeName); + if (!count($expectedFiles)) { + $this->setExpectedException('LogicException', 'magento_import returns empty result by path doesNotExist'); + } + $files = $this->model->getFiles($theme, $path); + $this->assertCount(count($expectedFiles), $files, 'Files number doesn\'t match'); + + /** @var $file \Magento\View\Layout\File */ + foreach ($files as $file) { + if (!in_array($file->getFilename(), $expectedFiles)) { + $this->fail(sprintf('File "%s" is not expected but found', $file->getFilename())); + } + } + } + + /** + * @return array + */ + public function getFilesDataProvider() + { + return array( + array( + '1.file', + 'test_default', + array( + str_replace( + '\\', + '/', + dirname(dirname(__DIR__)) . '/_files/design/frontend/test_default/1.file' + ), + str_replace( + '\\', + '/', + dirname(dirname(__DIR__)) . '/_files/design/frontend/test_default/Magento_Module/1.file' + ), + str_replace( + '\\', + '/', + dirname(dirname(__DIR__)) . '/_files/design/frontend/test_parent/Magento_Second/1.file' + ) + ) + ), + array( + '2.file', + 'test_default', + array( + str_replace( + '\\', + '/', + dirname(dirname(__DIR__)) . '/_files/lib/2.file' + ) + ) + ), + array( + 'doesNotExist', + 'test_default', + array() + ), + array( + '3', + 'test_default', + array( + str_replace( + '\\', + '/', + dirname(dirname(__DIR__)) . '/_files/lib/3.less' + ), + str_replace( + '\\', + '/', + dirname(dirname(__DIR__)) . '/_files/code/Magento/Other/view/frontend/3.less' + ), + str_replace( + '\\', + '/', + dirname(dirname(__DIR__)) . '/_files/design/frontend/test_default/Magento_Third/3.less' + ) + ) + ), + ); + } +} diff --git a/dev/tests/integration/testsuite/Magento/Less/PreProcessorTest.php b/dev/tests/integration/testsuite/Magento/Less/PreProcessorTest.php new file mode 100644 index 0000000000000000000000000000000000000000..338b380c4da36afb16fb5b8f8e5d414c9181af2d --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Less/PreProcessorTest.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\Less; + +class PreProcessorTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Css\PreProcessor\Less + */ + protected $model; + + /** + * @var \Magento\ObjectManager + */ + protected $objectManager; + + protected function setUp() + { + \Magento\TestFramework\Helper\Bootstrap::getInstance()->reinitialize(array( + \Magento\App\Filesystem::PARAM_APP_DIRS => array( + \Magento\App\Filesystem::PUB_LIB_DIR => array('path' => __DIR__ . '/_files/lib'), + \Magento\App\Filesystem::THEMES_DIR => array('path' => __DIR__ . '/_files/design') + ) + )); + $this->objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); + $this->objectManager->get('Magento\App\State')->setAreaCode('frontend'); + $this->model = $this->objectManager->create('Magento\Css\PreProcessor\Less'); + } + + /** + * @magentoDataFixture Magento/Less/_files/themes.php + * @magentoAppIsolation enabled + * @magentoAppArea frontend + */ + public function testProcess() + { + /** @var $filesystem \Magento\Filesystem */ + $filesystem = $this->objectManager->get('Magento\Filesystem'); + $targetDirectory = $filesystem->getDirectoryWrite(\Magento\App\Filesystem::TMP_DIR); + $designParams = array('area' => 'frontend', 'theme' => 'test_pre_process'); + $cssTargetFile = $this->model->process('source.css', $designParams, $targetDirectory); + /** @var $viewFilesystem \Magento\View\FileSystem */ + $viewFilesystem = $this->objectManager->get('Magento\View\FileSystem'); + $this->assertFileEquals($viewFilesystem->getViewFile('source.css', $designParams), $cssTargetFile); + } +} diff --git a/dev/tests/integration/testsuite/Magento/Less/_files/code/Magento/Other/view/frontend/3.less b/dev/tests/integration/testsuite/Magento/Less/_files/code/Magento/Other/view/frontend/3.less new file mode 100644 index 0000000000000000000000000000000000000000..8a382383c31ab38f13ca9b7058a4b5f78f714ad2 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Less/_files/code/Magento/Other/view/frontend/3.less @@ -0,0 +1,25 @@ +/** + * 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. + * + * @category design + * @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) + */ + +// dummy less file for module diff --git a/dev/tests/integration/testsuite/Magento/Less/_files/code/Magento/Third/view/frontend/3.less b/dev/tests/integration/testsuite/Magento/Less/_files/code/Magento/Third/view/frontend/3.less new file mode 100644 index 0000000000000000000000000000000000000000..8a382383c31ab38f13ca9b7058a4b5f78f714ad2 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Less/_files/code/Magento/Third/view/frontend/3.less @@ -0,0 +1,25 @@ +/** + * 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. + * + * @category design + * @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) + */ + +// dummy less file for module diff --git a/dev/tests/integration/testsuite/Magento/Less/_files/design/frontend/test_default/1.file b/dev/tests/integration/testsuite/Magento/Less/_files/design/frontend/test_default/1.file new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/dev/tests/integration/testsuite/Magento/Less/_files/design/frontend/test_default/Magento_Module/1.file b/dev/tests/integration/testsuite/Magento/Less/_files/design/frontend/test_default/Magento_Module/1.file new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/dev/tests/integration/testsuite/Magento/Less/_files/design/frontend/test_default/Magento_Third/3.less b/dev/tests/integration/testsuite/Magento/Less/_files/design/frontend/test_default/Magento_Third/3.less new file mode 100644 index 0000000000000000000000000000000000000000..8a382383c31ab38f13ca9b7058a4b5f78f714ad2 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Less/_files/design/frontend/test_default/Magento_Third/3.less @@ -0,0 +1,25 @@ +/** + * 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. + * + * @category design + * @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) + */ + +// dummy less file for module diff --git a/dev/tests/integration/testsuite/Magento/Less/_files/design/frontend/test_default/theme.xml b/dev/tests/integration/testsuite/Magento/Less/_files/design/frontend/test_default/theme.xml new file mode 100644 index 0000000000000000000000000000000000000000..195d325c8a0464578dea4888b0e53944627f96cd --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Less/_files/design/frontend/test_default/theme.xml @@ -0,0 +1,30 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- +/** + * 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) + */ +--> +<theme> + <title>Test Default</title> + <version>2.0.0.0</version> + <parent>test_parent</parent> +</theme> diff --git a/dev/tests/integration/testsuite/Magento/Less/_files/design/frontend/test_parent/Magento_Module/1.file b/dev/tests/integration/testsuite/Magento/Less/_files/design/frontend/test_parent/Magento_Module/1.file new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/dev/tests/integration/testsuite/Magento/Less/_files/design/frontend/test_parent/Magento_Second/1.file b/dev/tests/integration/testsuite/Magento/Less/_files/design/frontend/test_parent/Magento_Second/1.file new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/dev/tests/integration/testsuite/Magento/Less/_files/design/frontend/test_parent/theme.xml b/dev/tests/integration/testsuite/Magento/Less/_files/design/frontend/test_parent/theme.xml new file mode 100644 index 0000000000000000000000000000000000000000..3c145f9932e6a8e32be116756f8c95f0dda17243 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Less/_files/design/frontend/test_parent/theme.xml @@ -0,0 +1,29 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- +/** + * 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) + */ +--> +<theme> + <title>Test Parent</title> + <version>2.0.0.0</version> +</theme> diff --git a/dev/tests/integration/testsuite/Magento/Less/_files/design/frontend/test_pre_process/Magento_Test/magento_import.less b/dev/tests/integration/testsuite/Magento/Less/_files/design/frontend/test_pre_process/Magento_Test/magento_import.less new file mode 100644 index 0000000000000000000000000000000000000000..c30ba74d7675809632b490ccd8a06cf7c89a8666 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Less/_files/design/frontend/test_pre_process/Magento_Test/magento_import.less @@ -0,0 +1,3 @@ +div.test { + color: white; +} diff --git a/dev/tests/integration/testsuite/Magento/Less/_files/design/frontend/test_pre_process/Magento_Test2/magento_import.less b/dev/tests/integration/testsuite/Magento/Less/_files/design/frontend/test_pre_process/Magento_Test2/magento_import.less new file mode 100644 index 0000000000000000000000000000000000000000..6a3e9e2b391910b12b03be85a7868345cc1254b6 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Less/_files/design/frontend/test_pre_process/Magento_Test2/magento_import.less @@ -0,0 +1,3 @@ +div.test2 { + color: black; +} diff --git a/dev/tests/integration/testsuite/Magento/Less/_files/design/frontend/test_pre_process/Magento_Test3/import.less b/dev/tests/integration/testsuite/Magento/Less/_files/design/frontend/test_pre_process/Magento_Test3/import.less new file mode 100644 index 0000000000000000000000000000000000000000..f3aa4e7b32d5dc31c11824e61bec1a91399af090 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Less/_files/design/frontend/test_pre_process/Magento_Test3/import.less @@ -0,0 +1,3 @@ +div.module_test { + color: red; +} diff --git a/dev/tests/integration/testsuite/Magento/Less/_files/design/frontend/test_pre_process/less/import1.less b/dev/tests/integration/testsuite/Magento/Less/_files/design/frontend/test_pre_process/less/import1.less new file mode 100644 index 0000000000000000000000000000000000000000..b4478b6c352c65a8dc63194fff2dfd2c72c12801 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Less/_files/design/frontend/test_pre_process/less/import1.less @@ -0,0 +1,4 @@ +.class { + @import "less/import1/import1-1.less" screen and (max-width: 400px); + font-size: @importedSize; // use imported variable +} diff --git a/dev/tests/integration/testsuite/Magento/Less/_files/design/frontend/test_pre_process/less/import1/import1-1.less b/dev/tests/integration/testsuite/Magento/Less/_files/design/frontend/test_pre_process/less/import1/import1-1.less new file mode 100644 index 0000000000000000000000000000000000000000..f8f0233a38035eaa0f10785bffebfa2d5113345e --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Less/_files/design/frontend/test_pre_process/less/import1/import1-1.less @@ -0,0 +1,2 @@ +@importedSize: 12pt; +h1 { color: green; } diff --git a/dev/tests/integration/testsuite/Magento/Less/_files/design/frontend/test_pre_process/less/import2.less b/dev/tests/integration/testsuite/Magento/Less/_files/design/frontend/test_pre_process/less/import2.less new file mode 100644 index 0000000000000000000000000000000000000000..22c610b26f033399f8f58422220575f96d270d6d --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Less/_files/design/frontend/test_pre_process/less/import2.less @@ -0,0 +1 @@ +// empty less file diff --git a/dev/tests/integration/testsuite/Magento/Less/_files/design/frontend/test_pre_process/source.css b/dev/tests/integration/testsuite/Magento/Less/_files/design/frontend/test_pre_process/source.css new file mode 100644 index 0000000000000000000000000000000000000000..a7563807b03a44e5143a179a33e40e7c0c4e646e --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Less/_files/design/frontend/test_pre_process/source.css @@ -0,0 +1,21 @@ +.class { + font-size: 12pt; +} +.class h1 { + color: green; +} +div.module_test { + color: red; +} +div.magento_import_lib { + color: green; +} +div.test { + color: white; +} +div.test2 { + color: black; +} +.end_class { + color: white; +} \ No newline at end of file diff --git a/dev/tests/integration/testsuite/Magento/Less/_files/design/frontend/test_pre_process/source.less b/dev/tests/integration/testsuite/Magento/Less/_files/design/frontend/test_pre_process/source.less new file mode 100644 index 0000000000000000000000000000000000000000..3a4243a100d7e573aabc57a9a35695f61baefe0a --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Less/_files/design/frontend/test_pre_process/source.less @@ -0,0 +1,10 @@ +@import "less/import1.less"; +@import (less) "less/import2"; +@import "Magento_Test3::import"; +@import "less/not_existed_file.less"; +//@magento_import "magento_import.less"; +//@magento_import "not_existed_magento_import.less"; + +.end_class { + color: white; +} diff --git a/dev/tests/integration/testsuite/Magento/Less/_files/design/frontend/test_pre_process/theme.xml b/dev/tests/integration/testsuite/Magento/Less/_files/design/frontend/test_pre_process/theme.xml new file mode 100644 index 0000000000000000000000000000000000000000..443fe26456d1c73ddf8048fb68097aa1209cb7b9 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Less/_files/design/frontend/test_pre_process/theme.xml @@ -0,0 +1,5 @@ +<?xml version="1.0" encoding="UTF-8"?> +<theme> + <title>Test Pre-Processor</title> + <version>2.0.0.0</version> +</theme> diff --git a/dev/tests/integration/testsuite/Magento/Less/_files/lib/1.file b/dev/tests/integration/testsuite/Magento/Less/_files/lib/1.file new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/dev/tests/integration/testsuite/Magento/Less/_files/lib/2.file b/dev/tests/integration/testsuite/Magento/Less/_files/lib/2.file new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/dev/tests/unit/testsuite/Magento/Core/Model/Layout/_files/layout/catalog_product_view_type_grouped.xml b/dev/tests/integration/testsuite/Magento/Less/_files/lib/3.less similarity index 95% rename from dev/tests/unit/testsuite/Magento/Core/Model/Layout/_files/layout/catalog_product_view_type_grouped.xml rename to dev/tests/integration/testsuite/Magento/Less/_files/lib/3.less index 72b04db7c2eb3dfd96773987b166091d3304733b..6be86a0cd54761d98340e363d59249bf9b515211 100644 --- a/dev/tests/unit/testsuite/Magento/Core/Model/Layout/_files/layout/catalog_product_view_type_grouped.xml +++ b/dev/tests/integration/testsuite/Magento/Less/_files/lib/3.less @@ -1,5 +1,3 @@ -<?xml version="1.0"?> -<!-- /** * Magento * @@ -19,8 +17,9 @@ * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * + * @category design * @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) */ ---> -<layout/> + +// dummy less file diff --git a/dev/tests/integration/testsuite/Magento/Less/_files/lib/magento_import.less b/dev/tests/integration/testsuite/Magento/Less/_files/lib/magento_import.less new file mode 100644 index 0000000000000000000000000000000000000000..4fb146ecbca0406b6379d135308c2c689caf2934 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Less/_files/lib/magento_import.less @@ -0,0 +1,3 @@ +div.magento_import_lib { + color: green; +} diff --git a/dev/tests/integration/testsuite/Magento/Less/_files/themes.php b/dev/tests/integration/testsuite/Magento/Less/_files/themes.php new file mode 100644 index 0000000000000000000000000000000000000000..4128e99dac866d299d89b8c82056b316e49c1c53 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Less/_files/themes.php @@ -0,0 +1,33 @@ +<?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) + */ +\Magento\TestFramework\Helper\Bootstrap::getInstance()->reinitialize(array( + \Magento\App\Filesystem::PARAM_APP_DIRS => array( + \Magento\App\Filesystem::THEMES_DIR => array('path' => __DIR__ . '/design') + ) +)); +$objectManger = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); + +/** @var $registration \Magento\Core\Model\Theme\Registration */ +$registration = $objectManger->create('Magento\Core\Model\Theme\Registration'); +$registration->register('*/*/theme.xml'); diff --git a/dev/tests/integration/testsuite/Magento/Multishipping/Block/Checkout/OverviewTest.php b/dev/tests/integration/testsuite/Magento/Multishipping/Block/Checkout/OverviewTest.php index 8be11c8f1876d0b16bdf07f8c42c0a7532d0ebf6..fe6a690fbe95d1c687650ef262de8ff6c6275be0 100644 --- a/dev/tests/integration/testsuite/Magento/Multishipping/Block/Checkout/OverviewTest.php +++ b/dev/tests/integration/testsuite/Magento/Multishipping/Block/Checkout/OverviewTest.php @@ -45,7 +45,22 @@ class OverviewTest extends \PHPUnit_Framework_TestCase $this->_objectManager->get('Magento\Core\Model\App') ->loadArea(\Magento\Core\Model\App\Area::AREA_FRONTEND); $this->_block = $this->_objectManager->get('Magento\View\LayoutInterface') - ->createBlock('Magento\Multishipping\Block\Checkout\Overview'); + ->createBlock('Magento\Multishipping\Block\Checkout\Overview', + 'checkout_overview', + array('data' => array( + 'renderer_template' => 'Magento_Multishipping::checkout/item/default.phtml', + 'row_renderer_template' => 'Magento_Multishipping::checkout/overview/item.phtml' + ), + ) + ); + + $this->_block->addChild('renderer.list', '\Magento\View\Element\RendererList'); + $this->_block->getChildBlock('renderer.list') + ->addChild( + 'default', + '\Magento\Checkout\Block\Cart\Item\Renderer', + array('template' => 'cart/item/default.phtml') + ); } public function testGetRowItemHtml() diff --git a/dev/tests/integration/testsuite/Magento/Mview/View/ChangelogTest.php b/dev/tests/integration/testsuite/Magento/Mview/View/ChangelogTest.php new file mode 100644 index 0000000000000000000000000000000000000000..953b3e8fff0be4f02a5f7b4bda0d1d23337d4835 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Mview/View/ChangelogTest.php @@ -0,0 +1,149 @@ +<?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. + * + * @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\Mview\View; +/** + * Test Class for \Magento\Mview\View\Changelog + */ +class ChangelogTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\ObjectManager + */ + protected $objectManager; + + /** + * @var \Magento\App\Resource + */ + protected $resource; + + /** + * Write connection adapter + * + * @var \Magento\DB\Adapter\AdapterInterface + */ + protected $connection; + + /** + * @var \Magento\Mview\View\Changelog + */ + protected $model; + + public function setUp() + { + $this->objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); + $this->resource = $this->objectManager->get('Magento\App\Resource'); + $this->connection = $this->resource->getConnection('core_write'); + + $this->model = $this->objectManager->create('Magento\Mview\View\Changelog', array( + 'resource' => $this->resource)); + $this->model->setViewId('test_view_id_1'); + $this->model->create(); + } + + public function tearDown() + { + $this->model->drop(); + } + + /** + * Test for create() and drop() methods + */ + public function testCreateAndDrop() + { + $model = $this->objectManager->create('Magento\Mview\View\Changelog', array( + 'resource' => $this->resource)); + $model->setViewId('test_view_id_2'); + $changelogName = $this->connection->getTableName($model->getName()); + $this->assertFalse($this->connection->isTableExists($changelogName)); + $model->create(); + $this->assertTrue($this->connection->isTableExists($changelogName)); + $model->drop(); + $this->assertFalse($this->connection->isTableExists($changelogName)); + } + + /** + * Test for getVersion() method + */ + public function testGetVersion() + { + $model = $this->objectManager->create('Magento\Mview\View\Changelog', array( + 'resource' => $this->resource)); + $model->setViewId('test_view_id_2'); + $model->create(); + $this->assertEquals(0, $model->getVersion()); + $changelogName = $this->connection->getTableName($model->getName()); + $this->connection->insert( + $changelogName, + array($model->getColumnName() => mt_rand(1, 200)) + ); + $this->assertEquals($this->connection->lastInsertId($changelogName, 'version_id'), $model->getVersion()); + $model->drop(); + } + + /** + * Test for clear() method + */ + public function testClear() + { + $this->assertEquals(0, $this->model->getVersion());//the same that a table is empty + $changelogName = $this->connection->getTableName($this->model->getName()); + $this->connection->insert( + $changelogName, + array('version_id' => 1, 'entity_id' => 1) + ); + $this->assertEquals(1, $this->model->getVersion()); + $this->model->clear(1); + $this->assertEquals(0, $this->model->getVersion());//the same that a table is empty + } + + /** + * Test for getList() method + */ + public function testGetList() + { + $this->assertEquals(0, $this->model->getVersion());//the same that a table is empty + $changelogName = $this->connection->getTableName($this->model->getName()); + $testChengelogData = array( + array('version_id' => 1, 'entity_id' => 1), + array('version_id' => 2, 'entity_id' => 1), + array('version_id' => 3, 'entity_id' => 2), + array('version_id' => 4, 'entity_id' => 3), + array('version_id' => 5, 'entity_id' => 1) + ); + foreach ($testChengelogData as $data) { + $this->connection->insert( + $changelogName, + $data + ); + } + $this->assertEquals(5, $this->model->getVersion()); + $this->assertEquals(3, count($this->model->getList(0, 5)));//distinct entity_ids + $this->assertEquals(3, count($this->model->getList(2, 5)));//distinct entity_ids + $this->assertEquals(2, count($this->model->getList(0, 3)));//distinct entity_ids + $this->assertEquals(1, count($this->model->getList(0, 2)));//distinct entity_ids + $this->assertEquals(1, count($this->model->getList(2, 3)));//distinct entity_ids + $this->assertEquals(0, count($this->model->getList(4, 3)));//because fromVersionId > toVersionId + } +} diff --git a/dev/tests/integration/testsuite/Magento/Newsletter/Model/QueueTest.php b/dev/tests/integration/testsuite/Magento/Newsletter/Model/QueueTest.php index 098a317fe9b9b27b354079109db6b285367a8542..9be42c395e3d313be14c4785de66436c22fc9e8b 100644 --- a/dev/tests/integration/testsuite/Magento/Newsletter/Model/QueueTest.php +++ b/dev/tests/integration/testsuite/Magento/Newsletter/Model/QueueTest.php @@ -82,7 +82,7 @@ class QueueTest extends \PHPUnit_Framework_TestCase $objectManager->get('Magento\View\Url'), $objectManager->get('Magento\View\FileSystem'), $objectManager->get('Magento\Core\Model\Store\ConfigInterface'), - $objectManager->get('Magento\Core\Model\ConfigInterface'), + $objectManager->get('Magento\App\ConfigInterface'), $objectManager->get('Magento\Email\Model\Template\FilterFactory'), $objectManager->get('Magento\Email\Model\Template\Config'), ) @@ -128,7 +128,7 @@ class QueueTest extends \PHPUnit_Framework_TestCase $objectManager->get('Magento\View\Url'), $objectManager->get('Magento\View\FileSystem'), $objectManager->get('Magento\Core\Model\Store\ConfigInterface'), - $objectManager->get('Magento\Core\Model\ConfigInterface'), + $objectManager->get('Magento\App\ConfigInterface'), $objectManager->get('Magento\Email\Model\Template\FilterFactory'), $objectManager->get('Magento\Email\Model\Template\Config'), ) diff --git a/dev/tests/integration/testsuite/Magento/Newsletter/Model/TemplateTest.php b/dev/tests/integration/testsuite/Magento/Newsletter/Model/TemplateTest.php index 6a5d6d79101472f21de06834954287237df7b338..5e9b04ea05afbcf3c5212c841c2e25aa43b46c57 100644 --- a/dev/tests/integration/testsuite/Magento/Newsletter/Model/TemplateTest.php +++ b/dev/tests/integration/testsuite/Magento/Newsletter/Model/TemplateTest.php @@ -56,7 +56,7 @@ class TemplateTest extends \PHPUnit_Framework_TestCase { $this->_model->setTemplateText('{{view url="Magento_Theme::favicon.ico"}}'); if ($store != 'default') { - \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Core\Model\Config') + \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\App\ConfigInterface') ->setValue(\Magento\Core\Model\View\Design::XML_PATH_THEME_ID, $design, 'store', $store); } $this->_model->emulateDesign($store, 'frontend'); diff --git a/dev/tests/integration/testsuite/Magento/ObjectManager/Config/Reader/DomTest.php b/dev/tests/integration/testsuite/Magento/ObjectManager/Config/Reader/DomTest.php index c4b9030ca36f4041de25c89174e2990dbb73eddc..2348135b9cb1524e10c5472fbfc8489be4b3918c 100644 --- a/dev/tests/integration/testsuite/Magento/ObjectManager/Config/Reader/DomTest.php +++ b/dev/tests/integration/testsuite/Magento/ObjectManager/Config/Reader/DomTest.php @@ -36,7 +36,7 @@ class DomTest extends \PHPUnit_Framework_TestCase protected $_fileList; /** - * @var \Magento\App\Config\FileResolver\Primary + * @var \Magento\App\Arguments\FileResolver\Primary */ protected $_fileResolverMock; @@ -46,7 +46,7 @@ class DomTest extends \PHPUnit_Framework_TestCase protected $_mergedConfig; /** - * @var \Magento\App\Config\ValidationState + * @var \Magento\App\Arguments\ValidationState */ protected $_validationState; @@ -69,12 +69,12 @@ class DomTest extends \PHPUnit_Framework_TestCase ); $this->_fileResolverMock = $this->getMock( - 'Magento\App\Config\FileResolver\Primary', array(), array(), '', false + 'Magento\App\Arguments\FileResolver\Primary', array(), array(), '', false ); $this->_fileResolverMock->expects($this->once())->method('get')->will($this->returnValue($this->_fileList)); $this->_mapper = new \Magento\ObjectManager\Config\Mapper\Dom(); $this->_validationState = - new \Magento\App\Config\ValidationState(\Magento\App\State::MODE_DEFAULT); + new \Magento\App\Arguments\ValidationState(\Magento\App\State::MODE_DEFAULT); $this->_schemaLocator = new \Magento\ObjectManager\Config\SchemaLocator(); $this->_mergedConfig = new \DOMDocument(); diff --git a/dev/tests/integration/testsuite/Magento/ObjectManager/_files/config_merged.xml b/dev/tests/integration/testsuite/Magento/ObjectManager/_files/config_merged.xml index 5f8aeca041936be0b4853ef202cac5be8c2b9f14..b5df256812e82f2242fadaeafa43806f406e111b 100644 --- a/dev/tests/integration/testsuite/Magento/ObjectManager/_files/config_merged.xml +++ b/dev/tests/integration/testsuite/Magento/ObjectManager/_files/config_merged.xml @@ -26,22 +26,22 @@ <config> <preference for="Magento\Module\UpdaterInterface" type="Magento\Module\UpdaterOne" /> <preference for="Magento\Module\UpdaterInterfaceTwo" type="Magento\Module\UpdaterTwo"/> - <type name="Magento\App\Config\Loader" shared="false"> + <type name="Magento\App\Arguments\Loader" shared="false"> <param name="customFile"> - <value type="argument">Magento\App\Config\Loader::PARAM_CUSTOM_FILE</value> + <value type="argument">Magento\App\Arguments\Loader::PARAM_CUSTOM_FILE</value> </param> <param name="customConfig"> - <instance shared="false" type="Magento\Core\Model\Config\Storage_Modules" /> + <instance shared="false" type="Magento\Core\Model\Config\Storage\Modules" /> </param> <param name="customValue"> <value>someCustomValue</value> </param> <param name="customComplexValue"> - <value transalte="three" module="Some_Module"> - <one>one</one> - <two>two</two> - <three>three</three> - </value> + <array> + <item key="one"><value>one</value></item> + <item key="two"><value>two</value></item> + <item key="three"><value>three</value></item> + </array> </param> <plugin name="one" type="somePluginOne" sortOrder="800"/> <plugin name="two" type="somePluginTwo" sortOrder="20" disabled="true"/> @@ -50,21 +50,21 @@ </param> <plugin name="three" type="somePluginThree"/> </type> - <virtualType name="Magento\App\Config\LoaderVirtual" type="Magento\App\Config\Loader\Local" shared="true"> + <virtualType name="Magento\App\Arguments\LoaderVirtual" type="Magento\App\Arguments\Loader\Local" shared="true"> <param name="customFile"> - <value type="argument">Magento\App\Config\Loader::PARAM_CUSTOM_FILE</value> + <value type="argument">Magento\App\Arguments\Loader::PARAM_CUSTOM_FILE</value> </param> <param name="customConfig"> - <instance type="Magento\Core\Model\Config\Storage_Modules" /> + <instance type="Magento\Core\Model\Config\Storage\Modules" /> </param> <param name="customValue"> <value>someValue</value> </param> <param name="customComplexValue"> - <value transalte="one,two" module="Some_Module"> - <one>one</one> - <two>one</two> - </value> + <array> + <item key="one"><value>one</value></item> + <item key="two"><value>one</value></item> + </array> </param> <plugin name="one" type="somePluginOne" sortOrder="800" /> <plugin name="two" type="somePluginTwo" sortOrder="20" disabled="true"/> @@ -74,16 +74,17 @@ <param name="cacheIdPrefix"><value><![CDATA[collection_]]></value></param> <param name="cacheLifetime"><value>86400</value></param> <param name="cacheTags"> - <value> - <const type='const'>Magento\Core\Model\Website::CACHE_TAG</const> - <boolFalse type='bool'>1</boolFalse> - <boolTrue type='int'>10</boolTrue> - <boolOne type='string' pattern="[0-9]*">1</boolOne> - <boolZero type='bool'>0</boolZero> - <intValue type='int'>100500</intValue> - <nullValue type='null' /> - <stringPattern type='string' pattern="[a-zA-Z\-]*">Az-Value</stringPattern> - </value> + <array> + <item key="const"><value type="const">Magento\Core\Model\Website::CACHE_TAG</value></item> + <item key="boolFalse"><value type="bool">1</value></item> + <item key="boolTrue"><value type="int">10</value></item> + <item key="boolOne"><value type="string" pattern="[0-9]*">1</value></item> + <item key="boolZero"><value type="bool">0</value></item> + <item key="intValue"><value type="int">100500</value></item> + <item key="nullValue"><value type="null"/> + </item> + <item key="stringPattern"><value type="string" pattern="[a-zA-Z\-]*">Az-Value</value></item> + </array> </param> <param name="constParam"> <value type='const'>Magento\Core\Model\Website::CACHE_TAG</value> diff --git a/dev/tests/integration/testsuite/Magento/ObjectManager/_files/config_one.xml b/dev/tests/integration/testsuite/Magento/ObjectManager/_files/config_one.xml index fa6ba1d3c619c580d7b16bf4397c38f67e47eb23..537a259f5d98be827496cf6871988fc3ea10ddd7 100644 --- a/dev/tests/integration/testsuite/Magento/ObjectManager/_files/config_one.xml +++ b/dev/tests/integration/testsuite/Magento/ObjectManager/_files/config_one.xml @@ -25,40 +25,40 @@ --> <config> <preference for="Magento\Module\UpdaterInterface" type="Magento\Module\Updater" /> - <type name="Magento\App\Config\Loader"> + <type name="Magento\App\Arguments\Loader"> <param name="customFile"> - <value type="argument">Magento\App\Config\Loader::PARAM_CUSTOM_FILE</value> + <value type="argument">Magento\App\Arguments\Loader::PARAM_CUSTOM_FILE</value> </param> <param name="customConfig"> - <instance shared="true" type="Magento\Core\Model\Config\Storage_Modules" /> + <instance shared="true" type="Magento\Core\Model\Config\Storage\Modules" /> </param> <param name="customValue"> <value>someValue</value> </param> <param name="customComplexValue"> - <value transalte="one,two" module="Some_Module"> - <one>one</one> - <two>two</two> - </value> + <array> + <item key="one"><value>one</value></item> + <item key="two"><value>two</value></item> + </array> </param> <plugin name="one" type="somePluginOne"/> <plugin name="two" type="somePluginTwo" sortOrder="15"/> </type> - <virtualType name="Magento\App\Config\LoaderVirtual" type="Magento\App\Config\Loader\Local" shared="false"> + <virtualType name="Magento\App\Arguments\LoaderVirtual" type="Magento\App\Arguments\Loader\Local" shared="false"> <param name="customFile"> - <value type="argument">Magento\App\Config\Loader::PARAM_CUSTOM_FILE</value> + <value type="argument">Magento\App\Arguments\Loader::PARAM_CUSTOM_FILE</value> </param> <param name="customConfig"> - <instance type="Magento\Core\Model\Config\Storage_Modules" /> + <instance type="Magento\Core\Model\Config\Storage\Modules" /> </param> <param name="customValue"> <value>someValue</value> </param> <param name="customComplexValue"> - <value transalte="one,two" module="Some_Module"> - <one>one</one> - <two>one</two> - </value> + <array> + <item key="one"><value>one</value></item> + <item key="two"><value>one</value></item> + </array> </param> <plugin name="one" type="somePluginOne" sortOrder="10" /> <plugin name="two" type="somePluginTwo"/> @@ -67,16 +67,17 @@ <param name="cacheIdPrefix"><value><![CDATA[collection_]]></value></param> <param name="cacheLifetime"><value>86400</value></param> <param name="cacheTags"> - <value> - <const type='const'>Magento\Core\Model\Website::CACHE_TAG</const> - <boolFalse type='bool'>false</boolFalse> - <boolTrue type='bool'>true</boolTrue> - <boolOne type='bool'>1</boolOne> - <boolZero type='bool'>0</boolZero> - <intValue type='int'>100500</intValue> - <nullValue type='null' /> - <stringPattern type='string' pattern="[a-z\-]*">az-value</stringPattern> - </value> + <array> + <item key="const"><value type="const">Magento\Core\Model\Website::CACHE_TAG</value></item> + <item key="boolFalse"><value type="bool">false</value></item> + <item key="boolTrue"><value type="bool">true</value></item> + <item key="boolOne"><value type="bool">1</value></item> + <item key="boolZero"><value type="bool">0</value></item> + <item key="intValue"><value type="int">100500</value></item> + <item key="nullValue"><value type="null"/> + </item> + <item key="stringPattern"><value type="string" pattern="[a-z\-]*">az-value</value></item> + </array> </param> <param name="constParam"> <value type='const'>Magento\Core\Model\Website::CACHE_TAG</value> diff --git a/dev/tests/integration/testsuite/Magento/ObjectManager/_files/config_two.xml b/dev/tests/integration/testsuite/Magento/ObjectManager/_files/config_two.xml index d042d171b992dae35959208b0ab266ced9e7eaf7..ec263ed2e08d3cfcb4cfd6e487db30f7a95a58a3 100644 --- a/dev/tests/integration/testsuite/Magento/ObjectManager/_files/config_two.xml +++ b/dev/tests/integration/testsuite/Magento/ObjectManager/_files/config_two.xml @@ -26,43 +26,43 @@ <config> <preference for="Magento\Module\UpdaterInterfaceTwo" type="Magento\Module\UpdaterTwo" /> <preference for="Magento\Module\UpdaterInterface" type="Magento\Module\UpdaterOne" /> - <type name="Magento\App\Config\Loader" shared="false"> + <type name="Magento\App\Arguments\Loader" shared="false"> <param name="customFile"> - <value type="argument">Magento\App\Config\Loader::PARAM_CUSTOM_FILE</value> + <value type="argument">Magento\App\Arguments\Loader::PARAM_CUSTOM_FILE</value> </param> <param name="newParam"> <value>paramValue</value> </param> <param name="customConfig"> - <instance shared="false" type="Magento\Core\Model\Config\Storage_Modules" /> + <instance shared="false" type="Magento\Core\Model\Config\Storage\Modules" /> </param> <param name="customValue"> <value>someCustomValue</value> </param> <param name="customComplexValue"> - <value transalte="three" module="Some_Module"> - <three>three</three> - </value> + <array> + <item key="three"><value>three</value></item> + </array> </param> <plugin name="three" type="somePluginThree"/> <plugin name="two" type="somePluginTwo" sortOrder="20" disabled="true"/> <plugin name="one" sortOrder="800"/> </type> - <virtualType name="Magento\App\Config\LoaderVirtual" shared="true"> + <virtualType name="Magento\App\Arguments\LoaderVirtual" shared="true"> <plugin name="three" type="somePluginThree"/> <plugin name="two" type="somePluginTwo" sortOrder="20" disabled="true"/> <plugin name="one" sortOrder="800"/> </virtualType> <type name="Magento\Data\Collection\Db\FetchStrategy\Cache"> <param name="cacheTags"> - <value> - <const type='const'>Magento\Core\Model\Website::CACHE_TAG</const> - <boolFalse type='bool'>1</boolFalse> - <boolTrue type='int'>10</boolTrue> - <boolOne type='string' pattern="[0-9]*">1</boolOne> - <boolZero type='bool'>0</boolZero> - <stringPattern pattern="[a-zA-Z\-]*">Az-Value</stringPattern> - </value> + <array> + <item key="const"><value type="const">Magento\Core\Model\Website::CACHE_TAG</value></item> + <item key="boolFalse"><value type="bool">1</value></item> + <item key="boolTrue"><value type="int">10</value></item> + <item key="boolOne"><value type="string" pattern="[0-9]*">1</value></item> + <item key="boolZero"><value type="bool">0</value></item> + <item key="stringPattern"><value pattern="[a-zA-Z\-]*">Az-Value</value></item> + </array> </param> <param name="constParam"> <value type='const'>Magento\Core\Model\Website::CACHE_TAG</value> diff --git a/dev/tests/integration/testsuite/Magento/Payment/Model/ObserverTest.php b/dev/tests/integration/testsuite/Magento/Payment/Model/ObserverTest.php index 44079d3929f91df537eae39495b7ef923dc2aef6..c4f04d7fa79b595ae27b8ab0674c24b3e6ab831f 100644 --- a/dev/tests/integration/testsuite/Magento/Payment/Model/ObserverTest.php +++ b/dev/tests/integration/testsuite/Magento/Payment/Model/ObserverTest.php @@ -147,7 +147,7 @@ class ObserverTest extends \PHPUnit_Framework_TestCase */ protected function _resetConfig() { - $this->_objectManager->get('Magento\Core\Model\Config')->reinit(); + $this->_objectManager->get('Magento\App\ReinitableConfigInterface')->reinit(); $this->_objectManager->create('Magento\Core\Model\StoreManagerInterface')->reinitStores(); } } diff --git a/dev/tests/integration/testsuite/Magento/Paypal/Model/VoidTest.php b/dev/tests/integration/testsuite/Magento/Paypal/Model/VoidTest.php index 04ff1b1024a638e6801861294281629ecd86e4de..045ff23643a33859a5c1454f4d4f3f663542fd9c 100644 --- a/dev/tests/integration/testsuite/Magento/Paypal/Model/VoidTest.php +++ b/dev/tests/integration/testsuite/Magento/Paypal/Model/VoidTest.php @@ -31,7 +31,7 @@ class VoidTest extends \PHPUnit_Framework_TestCase { /** * @magentoDataFixture Magento/Paypal/_files/order_payflowpro.php - * @magentoConfigFixture current_store payment/verisign/active 1 + * @magentoConfigFixture current_store payment/payflowpro/active 1 */ public function testPayflowProVoid() { diff --git a/dev/tests/integration/testsuite/Magento/Rss/Controller/CatalogTest.php b/dev/tests/integration/testsuite/Magento/Rss/Controller/CatalogTest.php index df036d6566db02acd06ed5f2729afd9c614d69d6..bcf967df8f3e24ace2298f2ba7f6a56354fb1a2a 100644 --- a/dev/tests/integration/testsuite/Magento/Rss/Controller/CatalogTest.php +++ b/dev/tests/integration/testsuite/Magento/Rss/Controller/CatalogTest.php @@ -89,7 +89,7 @@ class CatalogTest extends \Magento\TestFramework\TestCase\AbstractController */ public function testAuthorizationFailed($action) { - \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Backend\Model\Url') + \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Backend\Model\UrlInterface') ->turnOffSecretKey(); $this->dispatch("backend/rss/catalog/{$action}"); $this->assertHeaderPcre('Http/1.1', '/^401 Unauthorized$/'); @@ -172,7 +172,7 @@ class CatalogTest extends \Magento\TestFramework\TestCase\AbstractController 'PHP_AUTH_USER' => \Magento\TestFramework\Bootstrap::ADMIN_NAME, 'PHP_AUTH_PW' => \Magento\TestFramework\Bootstrap::ADMIN_PASSWORD )); - \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Backend\Model\Url') + \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Backend\Model\UrlInterface') ->turnOffSecretKey(); } } diff --git a/dev/tests/integration/testsuite/Magento/Sales/Block/Adminhtml/Billing/Agreement/View/Tab/InfoTest.php b/dev/tests/integration/testsuite/Magento/Sales/Block/Adminhtml/Billing/Agreement/View/Tab/InfoTest.php new file mode 100644 index 0000000000000000000000000000000000000000..3681157a1edf7adeddfd7c873f73edfea47fb1cd --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Sales/Block/Adminhtml/Billing/Agreement/View/Tab/InfoTest.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_Sales + * @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\Sales\Block\Adminhtml\Billing\Agreement\View\Tab; + +class InfoTest extends \Magento\Backend\Utility\Controller +{ + /** + * @magentoDataFixture Magento/Customer/_files/customer.php + * @magentoDataFixture Magento/Sales/_files/billing_agreement.php + */ + public function testCustomerGridAction() + { + /** @var \Magento\Sales\Model\Resource\Billing\Agreement\Collection $billingAgreementCollection */ + $billingAgreementCollection = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + ->create('Magento\Sales\Model\Resource\Billing\Agreement\Collection') + ->load(); + $agreementId = $billingAgreementCollection->getFirstItem()->getId(); + $this->dispatch('backend/sales/billing_agreement/view/agreement/' . $agreementId); + + $this->assertSelectCount('a[name="billing_agreement_info"]', 1, $this->getResponse()->getBody(), + 'Response for billing agreement info doesn\'t contain billing agreement info tab'); + + $this->assertSelectRegExp('a', '/customer\@example.com/', 1, $this->getResponse()->getBody(), + 'Response for billing agreement info doesn\'t contain Customer info'); + } +} diff --git a/dev/tests/integration/testsuite/Magento/Sales/Block/Adminhtml/Order/Create/Form/AbstractTest.php b/dev/tests/integration/testsuite/Magento/Sales/Block/Adminhtml/Order/Create/Form/AbstractTest.php index cec7372bb0db00c90216a4e052117fbe441b857a..87ad1531c123ba113f0e2d05e9ebba162197e138 100644 --- a/dev/tests/integration/testsuite/Magento/Sales/Block/Adminhtml/Order/Create/Form/AbstractTest.php +++ b/dev/tests/integration/testsuite/Magento/Sales/Block/Adminhtml/Order/Create/Form/AbstractTest.php @@ -68,11 +68,11 @@ class AbstractTest 'data' => array( 'attribute_code' => 'date', 'backend_type' => 'datetime', - 'frontend_input' => 'date', + 'front_end_input' => 'date', 'frontend_label' => 'Date', ) ); - $dateAttribute = $objectManager->create('Magento\Customer\Model\Attribute', $arguments); + $dateAttribute = $objectManager->create('\Magento\Customer\Service\V1\Dto\Eav\AttributeMetadata', $arguments); $attributes = array('date' => $dateAttribute); $method->invoke($block, $attributes, $fieldset); diff --git a/dev/tests/integration/testsuite/Magento/Sales/Block/Adminhtml/Order/Create/Form/AccountTest.php b/dev/tests/integration/testsuite/Magento/Sales/Block/Adminhtml/Order/Create/Form/AccountTest.php new file mode 100644 index 0000000000000000000000000000000000000000..81fd50b4e49dcf1e314c6fc34eea1c97d74560fb --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Sales/Block/Adminhtml/Order/Create/Form/AccountTest.php @@ -0,0 +1,83 @@ +<?php +/** + * Test class for \Magento\Sales\Block\Adminhtml\Order\Create\Form\Account + * + * 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\Block\Adminhtml\Order\Create\Form; + +/** + * @magentoAppArea adminhtml + */ +class AccountTest extends \PHPUnit_Framework_TestCase +{ + /** @var \Magento\Sales\Block\Adminhtml\Order\Create\Form\Account */ + protected $_accountBlock; + + /** + * @magentoDataFixture Magento/Sales/_files/quote.php + */ + protected function setUp() + { + $this->_objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); + $quote = $this->_objectManager->create('Magento\Sales\Model\Quote')->load(1); + $sessionQuoteMock = $this->getMockBuilder('Magento\Backend\Model\Session\Quote') + ->disableOriginalConstructor() + ->setMethods(['getCustomerId', 'getStore', 'getStoreId', 'getQuote']) + ->getMock(); + $sessionQuoteMock->expects($this->any()) + ->method('getCustomerId') + ->will($this->returnValue(1)); + $sessionQuoteMock->expects($this->any()) + ->method('getQuote') + ->will($this->returnValue($quote)); + /** @var \Magento\View\LayoutInterface $layout */ + $layout = $this->_objectManager->get('Magento\View\LayoutInterface'); + $this->_accountBlock = $layout->createBlock( + 'Magento\Sales\Block\Adminhtml\Order\Create\Form\Account', + 'address_block' . rand(), + ['sessionQuote' => $sessionQuoteMock] + ); + parent::setUp(); + } + + /** + * @magentoDataFixture Magento/Customer/_files/customer.php + */ + public function testGetForm() + { + $expectedFields = ['group_id', 'email']; + $form = $this->_accountBlock->getForm(); + $this->assertEquals(1, $form->getElements()->count(), "Form has invalid number of fieldsets"); + $fieldset = $form->getElements()[0]; + + $this->assertEquals(count($expectedFields), $fieldset->getElements()->count()); + + foreach ($fieldset->getElements() as $element) { + $this->assertTrue( + in_array($element->getId(), $expectedFields), + sprintf('Unexpected field "%s" in form.', $element->getId()) + ); + } + } +} \ No newline at end of file diff --git a/dev/tests/integration/testsuite/Magento/Sales/Block/Adminhtml/Order/Create/Form/AddressTest.php b/dev/tests/integration/testsuite/Magento/Sales/Block/Adminhtml/Order/Create/Form/AddressTest.php new file mode 100644 index 0000000000000000000000000000000000000000..f49275b3c382854d987fa9c25138ae936cf76474 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Sales/Block/Adminhtml/Order/Create/Form/AddressTest.php @@ -0,0 +1,181 @@ +<?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\Block\Adminhtml\Order\Create\Form; + +/** + * Test class for \Magento\Sales\Block\Adminhtml\Order\Create\Form\Address + * + * @magentoAppArea adminhtml + */ +class AddressTest extends \PHPUnit_Framework_TestCase +{ + /** @var \Magento\ObjectManager */ + protected $_objectManager; + + /** @var \Magento\Sales\Block\Adminhtml\Order\Create\Form\Address */ + protected $_addressBlock; + + /** @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Customer\Service\V1\CustomerAddressServiceInterface */ + protected $_addressService; + + protected function setUp() + { + $this->_objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); + $this->_addressService = $this->getMock( + 'Magento\Customer\Service\V1\CustomerAddressServiceInterface' + ); + /** @var \Magento\View\LayoutInterface $layout */ + $layout = $this->_objectManager->get('Magento\View\LayoutInterface'); + $sessionQuoteMock = $this->getMockBuilder('Magento\Backend\Model\Session\Quote') + ->disableOriginalConstructor() + ->setMethods(['getCustomerId', 'getStore', 'getStoreId', 'getQuote']) + ->getMock(); + $sessionQuoteMock->expects($this->any()) + ->method('getCustomerId') + ->will($this->returnValue(1)); + + $this->_addressBlock = $layout->createBlock( + 'Magento\Sales\Block\Adminhtml\Order\Create\Form\Address', + 'address_block' . rand(), + array('addressService' => $this->_addressService, 'sessionQuote' => $sessionQuoteMock) + ); + parent::setUp(); + } + + public function testGetAddressCollection() + { + $addressDtos = $this->_getAddresses(); + $this->_addressService->expects($this->any())->method('getAddresses')->will($this->returnValue($addressDtos)); + $this->assertEquals($addressDtos, $this->_addressBlock->getAddressCollection()); + } + + public function testGetAddressCollectionJson() + { + $addressDtos = $this->_getAddresses(); + $this->_addressService->expects($this->any())->method('getAddresses')->will($this->returnValue($addressDtos)); + $expectedOutput = '[ + { + "firstname": false, + "lastname": false, + "company": false, + "street": "", + "city": false, + "country_id": "US", + "region": false, + "region_id": false, + "postcode": false, + "telephone": false, + "fax": false, + "vat_id": false + }, + { + "firstname": "FirstName1", + "lastname": "LastName1", + "company": false, + "street": "Street1", + "city": false, + "country_id": false, + "region": false, + "region_id": false, + "postcode": false, + "telephone": false, + "fax": false, + "vat_id": false + }, + { + "firstname": "FirstName2", + "lastname": "LastName2", + "company": false, + "street": "Street2", + "city": false, + "country_id": false, + "region": false, + "region_id": false, + "postcode": false, + "telephone": false, + "fax": false, + "vat_id": false + } + ]'; + $expectedOutput = str_replace(array(' ', "\n", "\r"), '', $expectedOutput); + $expectedOutput = str_replace(': ', ':', $expectedOutput); + + $this->assertEquals($expectedOutput, $this->_addressBlock->getAddressCollectionJson()); + } + + public function testGetAddressAsString() + { + $address = $this->_getAddresses()[0]; + $expectedResult = "FirstName1 LastName1, Street1, , , "; + $this->assertEquals($expectedResult, $this->_addressBlock->getAddressAsString($address)); + } + + /** + * Test \Magento\Sales\Block\Adminhtml\Order\Create\Form\Address::_prepareForm() indirectly. + */ + public function testGetForm() + { + $expectedFields = ['prefix', 'firstname', 'middlename', 'lastname', 'suffix', 'company', 'street', 'city', + 'country_id', 'region', 'region_id', 'postcode', 'telephone', 'fax', 'vat_id']; + $form = $this->_addressBlock->getForm(); + $this->assertEquals(1, $form->getElements()->count(), "Form has invalid number of fieldsets"); + /** @var \Magento\Data\Form\Element\Fieldset $fieldset */ + $fieldset = $form->getElements()[0]; + $this->assertEquals( + count($expectedFields), + $fieldset->getElements()->count(), + "Form has invalid number of fields" + ); + /** @var \Magento\Data\Form\Element\AbstractElement $element */ + foreach ($fieldset->getElements() as $element) { + $this->assertTrue( + in_array($element->getId(), $expectedFields), + sprintf('Unexpected field "%s" in form.', $element->getId()) + ); + } + + /** @var \Magento\Data\Form\Element\Select $countryIdField */ + $countryIdField = $fieldset->getElements()->searchById('country_id'); + $this->assertSelectCount('option', 247, $countryIdField->getElementHtml()); + } + + /** + * @return \Magento\Customer\Service\V1\Dto\Address[] + */ + protected function _getAddresses() + { + /** @var \Magento\Customer\Service\V1\Dto\AddressBuilder $addressBuilder */ + $addressBuilder = $this->_objectManager->create('Magento\Customer\Service\V1\Dto\AddressBuilder'); + $addressBuilder->populateWithArray( + array('id' => 1, 'street' => 'Street1', 'firstname' => 'FirstName1', 'lastname' => 'LastName1') + ); + $addressDtos[] = $addressBuilder->create(); + $addressBuilder->populateWithArray( + array('id' => 2, 'street' => 'Street2', 'firstname' => 'FirstName2', 'lastname' => 'LastName2') + ); + $addressDtos[] = $addressBuilder->create(); + return $addressDtos; + } +} diff --git a/dev/tests/integration/testsuite/Magento/Sales/Block/Adminhtml/Order/Create/FormTest.php b/dev/tests/integration/testsuite/Magento/Sales/Block/Adminhtml/Order/Create/FormTest.php new file mode 100644 index 0000000000000000000000000000000000000000..c59abe386d0b465d1bd62fa75cdc1be85a691de0 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Sales/Block/Adminhtml/Order/Create/FormTest.php @@ -0,0 +1,163 @@ +<?php +/** + * Test class for \Magento\Sales\Block\Adminhtml\Order\Create\Form + * + * 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\Block\Adminhtml\Order\Create; + +use Magento\Customer\Service\V1; + +/** + * @magentoAppArea adminhtml + */ +class FormTest extends \PHPUnit_Framework_TestCase +{ + /** @var \Magento\Sales\Block\Adminhtml\Order\Create\Form */ + protected $_orderCreateBlock; + + /** + * @magentoDataFixture Magento/Sales/_files/quote.php + */ + protected function setUp() + { + $this->_objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); + + $sessionMock = $this->getMockBuilder('Magento\Backend\Model\Session\Quote') + ->disableOriginalConstructor() + ->setMethods(['getCustomerId', 'getQuote', 'getStoreId', 'getStore']) + ->getMock(); + $sessionMock->expects($this->any()) + ->method('getCustomerId') + ->will($this->returnValue(1)); + + $quote = $this->_objectManager->create('Magento\Sales\Model\Quote')->load(1); + $sessionMock->expects($this->any()) + ->method('getQuote') + ->will($this->returnValue($quote)); + + $sessionMock->expects($this->any()) + ->method('getStoreId') + ->will($this->returnValue(1)); + + $storeMock = $this->getMockBuilder('\Magento\Core\Model\Store') + ->disableOriginalConstructor() + ->setMethods(['getCurrentCurrencyCode']) + ->getMock(); + $storeMock->expects($this->any()) + ->method('getCurrentCurrencyCode') + ->will($this->returnValue('USD')); + $sessionMock->expects($this->any()) + ->method('getStore') + ->will($this->returnValue($storeMock)); + + /** @var \Magento\View\LayoutInterface $layout */ + $layout = $this->_objectManager->get('Magento\View\LayoutInterface'); + $this->_orderCreateBlock = $layout->createBlock( + 'Magento\Sales\Block\Adminhtml\Order\Create\Form', + 'order_create_block' . rand(), + ['sessionQuote' => $sessionMock] + ); + parent::setUp(); + } + + /** + * @magentoDataFixture Magento/Customer/_files/customer.php + */ + public function testOrderDataJson() + { + /** @var array $addressIds */ + $addressIds = $this->setUpMockAddress(); + $orderDataJson = $this->_orderCreateBlock->getOrderDataJson(); + $expectedOrderDataJson = <<< ORDER_DATA_JSON + { + "customer_id":1, + "addresses": + {"{$addressIds[0]}": + {"firstname":"John","lastname":"Smith","company":false,"street":"Green str, 67","city":"CityM", + "country_id":"US", + "region":{"region_code":"AL","region":"Alabama","region_id":1}, + "region_id":false,"postcode":"75477","telephone":"3468676","fax":false,"vat_id":false}, + "{$addressIds[1]}": + {"firstname":"John","lastname":"Smith","company":false,"street":"Black str, 48","city":"CityX", + "country_id":"US", + "region":{"region_code":"AL","region":"Alabama","region_id":1}, + "region_id":false,"postcode":"47676","telephone":"3234676","fax":false,"vat_id":false} + }, + "store_id":1,"currency_symbol":"$","shipping_method_reseted":true,"payment_method":null + } +ORDER_DATA_JSON; + + $this->assertEquals(json_decode($expectedOrderDataJson), json_decode($orderDataJson)); + } + + private function setUpMockAddress() + { + /** @var \Magento\Customer\Service\V1\Dto\AddressBuilder $addressBuilder */ + $addressBuilder = $this->_objectManager->create('Magento\Customer\Service\V1\Dto\AddressBuilder'); + /** @var \Magento\Customer\Service\V1\CustomerAddressServiceInterface $addressService */ + $addressService = $this->_objectManager->create('Magento\Customer\Service\V1\CustomerAddressServiceInterface'); + + $addressDto1 = $addressBuilder->setId(1) + ->setCountryId('US') + ->setCustomerId(1) + ->setDefaultBilling(true) + ->setDefaultShipping(true) + ->setPostcode('75477') + ->setRegion( + new V1\Dto\Region([ + 'region_code' => 'AL', + 'region' => 'Alabama', + 'region_id' => 1 + ]) + ) + ->setStreet(['Green str, 67']) + ->setTelephone('3468676') + ->setCity('CityM') + ->setFirstname('John') + ->setLastname('Smith') + ->create(); + + $addressDto2 = $addressBuilder->setId(2) + ->setCountryId('US') + ->setCustomerId(1) + ->setDefaultBilling(false) + ->setDefaultShipping(false) + ->setPostcode('47676') + ->setRegion( + new V1\Dto\Region([ + 'region_code' => 'AL', + 'region' => 'Alabama', + 'region_id' => 1 + ]) + ) + ->setStreet(['Black str, 48']) + ->setCity('CityX') + ->setTelephone('3234676') + ->setFirstname('John') + ->setLastname('Smith') + ->create(); + + return $addressService->saveAddresses(1, [$addressDto1, $addressDto2]); + } +} \ No newline at end of file diff --git a/dev/tests/integration/testsuite/Magento/Sales/Block/Adminhtml/Order/Create/HeaderTest.php b/dev/tests/integration/testsuite/Magento/Sales/Block/Adminhtml/Order/Create/HeaderTest.php new file mode 100644 index 0000000000000000000000000000000000000000..1bb447d55b06cf8142b5b205805e880de0475f4e --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Sales/Block/Adminhtml/Order/Create/HeaderTest.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) + */ + +namespace Magento\Sales\Block\Adminhtml\Order\Create; + +use Magento\TestFramework\Helper\Bootstrap; + +/** + * @magentoAppArea adminhtml + */ +class HeaderTest extends \PHPUnit_Framework_TestCase +{ + /** @var \Magento\Sales\Block\Adminhtml\Order\Create\Header */ + protected $_block; + + protected function setUp() + { + $this->_block = Bootstrap::getObjectManager()->create('Magento\Sales\Block\Adminhtml\Order\Create\Header'); + parent::setUp(); + } + + /** + * @param int|null $customerId + * @param int|null $storeId + * @param string $expectedResult + * @magentoDataFixture Magento/Customer/_files/customer.php + * @dataProvider toHtmlDataProvider + */ + public function testToHtml($customerId, $storeId, $expectedResult) + { + /** @var \Magento\Backend\Model\Session\Quote $session */ + $session = Bootstrap::getObjectManager()->get('Magento\Backend\Model\Session\Quote'); + $session->setCustomerId($customerId); + $session->setStoreId($storeId); + $this->assertEquals($expectedResult, $this->_block->toHtml()); + } + + public function toHtmlDataProvider() + { + $customerIdFromFixture = 1; + $defaultStoreView = 1; + return [ + 'Customer and store' => [ + $customerIdFromFixture, + $defaultStoreView, + 'Create New Order for Firstname Lastname in Default Store View' + ], + 'No store' => [$customerIdFromFixture, null, 'Create New Order for Firstname Lastname'], + 'No customer' => [null, $defaultStoreView, 'Create New Order for New Customer in Default Store View'], + 'No customer, no store' => [null, null, 'Create New Order for New Customer'], + ]; + } +} diff --git a/dev/tests/integration/testsuite/Magento/Sales/Block/Adminhtml/Order/View/InfoTest.php b/dev/tests/integration/testsuite/Magento/Sales/Block/Adminhtml/Order/View/InfoTest.php new file mode 100644 index 0000000000000000000000000000000000000000..1f2280124068bedee19ff9d3f496c5e725fc87b2 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Sales/Block/Adminhtml/Order/View/InfoTest.php @@ -0,0 +1,116 @@ +<?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\Block\Adminhtml\Order\View; + +/** + * Test class for \Magento\Sales\Block\Adminhtml\Order\View\Info + */ +class InfoTest extends \Magento\Backend\Utility\Controller +{ + /** + * Value for the user defined custom attribute, which is created by attribute_user_defined.php fixture. + */ + const ORDER_USER_DEFINED_ATTRIBUTE_VALUE = 'custom_attr_value'; + + public function testCustomerGridAction() + { + $layout = $this->_objectManager->get('Magento\View\LayoutInterface'); + /** @var \Magento\Sales\Block\Adminhtml\Order\View\Info $infoBlock */ + $infoBlock = $layout->createBlock( + 'Magento\Sales\Block\Adminhtml\Order\View\Info', 'info_block' . mt_rand(), [] + ); + + $result = $infoBlock->getCustomerAccountData(); + $this->assertEquals([], $result, 'Customer has additional account data.'); + } + + /** + * @magentoDataFixture Magento/Sales/_files/order.php + */ + public function testGetCustomerGroupName() + { + $layout = $this->_objectManager->get('Magento\View\LayoutInterface'); + /** @var \Magento\Sales\Block\Adminhtml\Order\View\Info $customerGroupBlock */ + $customerGroupBlock = $layout->createBlock( + 'Magento\Sales\Block\Adminhtml\Order\View\Info', + 'info_block' . mt_rand(), + ['registry' => $this->_putOrderIntoRegistry()] + ); + + $result = $customerGroupBlock->getCustomerGroupName(); + $this->assertEquals('NOT LOGGED IN', $result); + } + + /** + * @magentoDataFixture Magento/Sales/_files/order.php + * @magentoDataFixture Magento/Customer/_files/attribute_user_defined_customer.php + */ + public function testGetCustomerAccountData() + { + $layout = $this->_objectManager->get('Magento\View\LayoutInterface'); + + $orderData = [ + 'customer_' . FIXTURE_ATTRIBUTE_USER_DEFINED_CUSTOMER_NAME => self::ORDER_USER_DEFINED_ATTRIBUTE_VALUE + ]; + /** @var \Magento\Sales\Block\Adminhtml\Order\View\Info $customerGroupBlock */ + $customerGroupBlock = $layout->createBlock( + 'Magento\Sales\Block\Adminhtml\Order\View\Info', + 'info_block' . mt_rand(), + ['registry' => $this->_putOrderIntoRegistry($orderData)] + ); + + $this->assertEquals( + [ + 200 => [ + 'label' => FIXTURE_ATTRIBUTE_USER_DEFINED_CUSTOMER_FRONTEND_LABEL, + 'value' => self::ORDER_USER_DEFINED_ATTRIBUTE_VALUE + ] + ], + $customerGroupBlock->getCustomerAccountData() + ); + } + + /** + * @param array $additionalOrderData + * @return \Magento\Core\Model\Registry|\PHPUnit_Framework_MockObject_MockObject + */ + protected function _putOrderIntoRegistry(array $additionalOrderData = []) + { + $registry = $this->getMockBuilder('Magento\Core\Model\Registry') + ->disableOriginalConstructor() + ->getMock(); + + $order = $this->_objectManager->get('Magento\Sales\Model\Order') + ->load('100000001') + ->setData(array_merge(['customer_group_id' => 0], $additionalOrderData)); + + $registry->expects($this->any()) + ->method('registry') + ->with('current_order') + ->will($this->returnValue($order)); + + return $registry; + } +} diff --git a/dev/tests/integration/testsuite/Magento/Sales/Block/Billing/Agreement/ViewTest.php b/dev/tests/integration/testsuite/Magento/Sales/Block/Billing/Agreement/ViewTest.php new file mode 100644 index 0000000000000000000000000000000000000000..465c31d5ddb3ed003d1ab16b5e760df1d700b7f9 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Sales/Block/Billing/Agreement/ViewTest.php @@ -0,0 +1,96 @@ +<?php +/** + * Test for \Magento\Sales\Block\Billing\Agreement\View + * + * 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\Block\Billing\Agreement; + +use \Magento\TestFramework\Helper\Bootstrap; + +class ViewTest extends \Magento\Backend\Utility\Controller +{ + /** @var \Magento\Sales\Block\Billing\Agreement\View */ + protected $_block; + + protected function setUp() + { + $this->_block = Bootstrap::getObjectManager()->create('Magento\Sales\Block\Billing\Agreement\View'); + parent::setUp(); + } + + /** + * Test getting orders associated with specified billing agreement. + * + * Create two identical orders, associate one of them with billing agreement and invoke testGetRelatedOrders() + * + * @magentoDataFixture Magento/Customer/_files/customer.php + * @magentoDataFixture Magento/Sales/_files/billing_agreement.php + * @magentoDataFixture Magento/Sales/_files/order.php + * @magentoDbIsolation enabled + * @magentoAppIsolation enabled + */ + public function testGetRelatedOrders() + { + /** Customer ID declared in the fixture */ + $customerId = 1; + /** Assign first order to the active customer */ + /** @var \Magento\Sales\Model\Order $orderA */ + $orderA = Bootstrap::getObjectManager()->create('Magento\Sales\Model\Order'); + $orderA->loadByIncrementId('100000001'); + $orderA->setCustomerIsGuest(false)->setCustomerId($customerId)->save(); + /** @var \Magento\Customer\Model\Session $customerSession */ + $customerSession = Bootstrap::getObjectManager()->create('Magento\Customer\Model\Session'); + $customerSession->setCustomerId($customerId); + + /** Assign second order to the active customer */ + $orderB = clone $orderA; + $orderB->setId(null) + ->setIncrementId('100000002') + ->setCustomerIsGuest(false) + ->setCustomerId($customerId) + ->save(); + + /** @var \Magento\Customer\Model\Session $customerSession */ + $customerSession = Bootstrap::getObjectManager()->create('Magento\Customer\Model\Session'); + $customerSession->setCustomerId($customerId); + + /** @var \Magento\Sales\Model\Resource\Billing\Agreement\Collection $billingAgreementCollection */ + $billingAgreementCollection = Bootstrap::getObjectManager() + ->create('Magento\Sales\Model\Resource\Billing\Agreement\Collection'); + /** @var \Magento\Sales\Model\Billing\Agreement $billingAgreement */ + $billingAgreement = $billingAgreementCollection->getFirstItem(); + $billingAgreement->addOrderRelation($orderA->getId())->save(); + + $registry = Bootstrap::getObjectManager()->get('Magento\Core\Model\Registry'); + $registry->register('current_billing_agreement', $billingAgreement); + + $relatedOrders = $this->_block->getRelatedOrders(); + $this->assertEquals(1, $relatedOrders->count(), "Only one order must be returned."); + $this->assertEquals( + $orderA->getId(), + $relatedOrders->getFirstItem()->getId(), + "Invalid order returned as associated with billing agreement." + ); + } +} diff --git a/dev/tests/integration/testsuite/Magento/Sales/Controller/Adminhtml/Billing/AgreementTest.php b/dev/tests/integration/testsuite/Magento/Sales/Controller/Adminhtml/Billing/AgreementTest.php new file mode 100644 index 0000000000000000000000000000000000000000..624fa891809723747ac40bc0cd2715082869e81d --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Sales/Controller/Adminhtml/Billing/AgreementTest.php @@ -0,0 +1,86 @@ +<?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\Controller\Adminhtml\Billing; + +use Magento\TestFramework\Helper\Bootstrap; + +/** + * Test class for \Magento\Sales\Controller\Adminhtml\Billing\Agreement + * + * @magentoAppArea adminhtml + */ +class AgreementTest extends \Magento\Backend\Utility\Controller +{ + /** + * @magentoDataFixture Magento/Customer/_files/customer.php + * @magentoDataFixture Magento/Sales/_files/billing_agreement.php + */ + public function testCustomerGridAction() + { + /** @var $session \Magento\Backend\Model\Session */ + Bootstrap::getObjectManager()->create('Magento\Backend\Model\Session'); + + $this->dispatch('backend/sales/billing_agreement/grid'); + $response = $this->getResponse(); + + $this->assertSelectCount('button[type="button"][title="Reset Filter"]', 1, $response->getBody(), + "Response for billing agreement grid doesn't contain 'Reset Filter' button"); + + $this->assertSelectCount('[id="billing_agreements"]', 1, $response->getBody(), + "Response for billing agreement grid doesn't contain grid"); + } + + /** + * @magentoDataFixture Magento/Customer/_files/customer.php + * @magentoDataFixture Magento/Sales/_files/billing_agreement.php + */ + public function testCustomerInfoTabs() + { + /** @var \Magento\Sales\Model\Resource\Billing\Agreement\Collection $billingAgreementCollection */ + $billingAgreementCollection = Bootstrap::getObjectManager() + ->create('Magento\Sales\Model\Resource\Billing\Agreement\Collection'); + $agreementId = $billingAgreementCollection->getFirstItem()->getId(); + $this->dispatch('backend/sales/billing_agreement/view/agreement/' . $agreementId); + + $this->assertSelectCount('a[name="billing_agreement_info"]', 1, $this->getResponse()->getBody(), + "Response for billing agreement info doesn't contain billing agreement info tab"); + + $this->assertSelectRegExp('a', '/customer\@example.com/', 1, $this->getResponse()->getBody(), + "Response for billing agreement info doesn't contain Customer info"); + } + + /** + * @magentoDataFixture Magento/Customer/_files/customer.php + * @magentoDataFixture Magento/Sales/_files/billing_agreement.php + */ + public function testCustomerGrid() + { + $this->dispatch('backend/sales/billing_agreement/customergrid/id/1'); + $this->assertSelectCount('td[class="col-reference_id"]', 1, $this->getResponse()->getBody(), + "Response for billing agreement orders doesn't contain billing agreement customers grid"); + $this->assertSelectRegExp('td', '/REF-ID-TEST-678/', 1, $this->getResponse()->getBody(), + "Response for billing agreement info doesn't contain reference ID"); + } +} diff --git a/dev/tests/integration/testsuite/Magento/Sales/Controller/Adminhtml/Recurring/ProfileTest.php b/dev/tests/integration/testsuite/Magento/Sales/Controller/Adminhtml/Recurring/ProfileTest.php new file mode 100644 index 0000000000000000000000000000000000000000..068332d50b90eda656909372167f3b55062e9818 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Sales/Controller/Adminhtml/Recurring/ProfileTest.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\Sales\Controller\Adminhtml\Recurring; + +class ProfileTest extends \Magento\Backend\Utility\Controller +{ + /** + * @magentoDataFixture Magento/Sales/_files/quote.php + * @magentoDataFixture Magento/Customer/_files/customer.php + * @magentoDataFixture Magento/Sales/_files/recurring_profile.php + */ + public function testCustomerGridAction() + { + $this->getRequest()->setParam(Profile::PARAM_CUSTOMER_ID, 1); + $this->dispatch('backend/sales/recurring_profile/customerGrid'); + $this->assertContains(FIXTURE_RECURRING_PROFILE_SCHEDULE_DESCRIPTION, $this->getResponse()->getBody()); + } +} diff --git a/dev/tests/integration/testsuite/Magento/Sales/Model/AdminOrder/CreateTest.php b/dev/tests/integration/testsuite/Magento/Sales/Model/AdminOrder/CreateTest.php index 3234f843c9d4f58fbf54d8db47c648e5acb26388..6d85d335c6b5552ba7066b7a73f00e4d82416da6 100644 --- a/dev/tests/integration/testsuite/Magento/Sales/Model/AdminOrder/CreateTest.php +++ b/dev/tests/integration/testsuite/Magento/Sales/Model/AdminOrder/CreateTest.php @@ -112,7 +112,7 @@ class CreateTest extends \PHPUnit_Framework_TestCase } /** - * @magentoDataFixture Magento/Sales/_files/order_paid_with_verisign.php + * @magentoDataFixture Magento/Sales/_files/order_paid_with_payflowpro.php */ public function testInitFromOrderCcInformationDeleted() { diff --git a/dev/tests/integration/testsuite/Magento/Sales/_files/billing_agreement.php b/dev/tests/integration/testsuite/Magento/Sales/_files/billing_agreement.php new file mode 100644 index 0000000000000000000000000000000000000000..60a9392e4f98f786ca3baa883052c3728a23c8af --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Sales/_files/billing_agreement.php @@ -0,0 +1,36 @@ +<?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_Sales + * @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) + */ +/** @var \Magento\Sales\Model\Billing\Agreement $billingAgreement */ +$billingAgreement = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + ->create('Magento\Sales\Model\Billing\Agreement') + ->setAgreementLabel('TEST') + ->setCustomerId(1) + ->setMethodCode('paypal_express') + ->setReferenceId('REF-ID-TEST-678') + ->setStatus(Magento\Sales\Model\Billing\Agreement::STATUS_ACTIVE) + ->setStoreId(1) + ->save(); diff --git a/dev/tests/integration/testsuite/Magento/Sales/_files/invoice_verisign.php b/dev/tests/integration/testsuite/Magento/Sales/_files/invoice_payflowpro.php similarity index 97% rename from dev/tests/integration/testsuite/Magento/Sales/_files/invoice_verisign.php rename to dev/tests/integration/testsuite/Magento/Sales/_files/invoice_payflowpro.php index a96504e26067a61b2b139559171449416eb46881..8987d643251cd3e0dbd62e099512b204e2543790 100644 --- a/dev/tests/integration/testsuite/Magento/Sales/_files/invoice_verisign.php +++ b/dev/tests/integration/testsuite/Magento/Sales/_files/invoice_payflowpro.php @@ -24,7 +24,7 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -require 'order_paid_with_verisign.php'; +require 'order_paid_with_payflowpro.php'; /** @var \Magento\Sales\Model\Order $order */ $orderService = \Magento\TestFramework\ObjectManager::getInstance()->create('Magento\Sales\Model\Service\Order', diff --git a/dev/tests/integration/testsuite/Magento/Sales/_files/order_paid_with_verisign.php b/dev/tests/integration/testsuite/Magento/Sales/_files/order_paid_with_payflowpro.php similarity index 98% rename from dev/tests/integration/testsuite/Magento/Sales/_files/order_paid_with_verisign.php rename to dev/tests/integration/testsuite/Magento/Sales/_files/order_paid_with_payflowpro.php index 3b8d8d8d1340233e83bdd4910860d661b21f347e..752be317e8b1377962c18459b492fad84a7d50cf 100644 --- a/dev/tests/integration/testsuite/Magento/Sales/_files/order_paid_with_verisign.php +++ b/dev/tests/integration/testsuite/Magento/Sales/_files/order_paid_with_payflowpro.php @@ -37,7 +37,7 @@ $shippingAddress->setId(null) $payment = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() ->create('Magento\Sales\Model\Order\Payment'); -$payment->setMethod('verisign') +$payment->setMethod('payflowpro') ->setCcExpMonth('5') ->setCcLast4('0005') ->setCcType('AE') diff --git a/dev/tests/integration/testsuite/Magento/Sales/_files/recurring_profile.php b/dev/tests/integration/testsuite/Magento/Sales/_files/recurring_profile.php new file mode 100644 index 0000000000000000000000000000000000000000..82f8242f12db579c6debbb3505d3160d7af2c0f9 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Sales/_files/recurring_profile.php @@ -0,0 +1,43 @@ +<?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) + */ + +// Requires Magento/Sales/_files/quote.php +// Requires Magento/Customer/_files/customer.php +use Magento\TestFramework\Helper\Bootstrap; + +define('FIXTURE_RECURRING_PROFILE_SCHEDULE_DESCRIPTION', 'fixture-recurring-profile-schedule'); + +/** @var Magento\Sales\Model\Recurring\Profile $profile */ +$profile = Bootstrap::getObjectManager()->create('Magento\Sales\Model\Recurring\Profile'); +$profile + ->setQuote(Bootstrap::getObjectManager()->create('Magento\Sales\Model\Quote')->load(1)) + ->setPeriodUnit('year') + ->setPeriodFrequency(1) + ->setScheduleDescription(FIXTURE_RECURRING_PROFILE_SCHEDULE_DESCRIPTION) + ->setBillingAmount(1) + ->setCurrencyCode('USD') + ->setMethodCode('paypal_express') + ->setInternalReferenceId('rp-1') + ->setCustomerId(1) + ->save(); diff --git a/dev/tests/integration/testsuite/Magento/Sitemap/Helper/DataTest.php b/dev/tests/integration/testsuite/Magento/Sitemap/Helper/DataTest.php index f545ff152881ee4f9dc70fd779d562395f246f3d..1df7a33c9b153c1a4c376620d676a3bfee2f9d86 100644 --- a/dev/tests/integration/testsuite/Magento/Sitemap/Helper/DataTest.php +++ b/dev/tests/integration/testsuite/Magento/Sitemap/Helper/DataTest.php @@ -51,7 +51,7 @@ class DataTest extends \PHPUnit_Framework_TestCase ); $this->assertEquals( 10, - $this->_helper->getMaximumLinesNumber(\Magento\Core\Model\AppInterface::DISTRO_STORE_ID) + $this->_helper->getMaximumLinesNumber(\Magento\Core\Model\Store::DISTRO_STORE_ID) ); } @@ -65,7 +65,7 @@ class DataTest extends \PHPUnit_Framework_TestCase ); $this->assertEquals( 1024, - $this->_helper->getMaximumFileSize(\Magento\Core\Model\AppInterface::DISTRO_STORE_ID) + $this->_helper->getMaximumFileSize(\Magento\Core\Model\Store::DISTRO_STORE_ID) ); } @@ -78,7 +78,7 @@ class DataTest extends \PHPUnit_Framework_TestCase 'daily', $this->_helper->getCategoryChangefreq(\Magento\Core\Model\Store::DEFAULT_STORE_ID) ); $this->assertEquals( - 'montly', $this->_helper->getCategoryChangefreq(\Magento\Core\Model\AppInterface::DISTRO_STORE_ID) + 'montly', $this->_helper->getCategoryChangefreq(\Magento\Core\Model\Store::DISTRO_STORE_ID) ); } @@ -91,7 +91,7 @@ class DataTest extends \PHPUnit_Framework_TestCase 'daily', $this->_helper->getProductChangefreq(\Magento\Core\Model\Store::DEFAULT_STORE_ID) ); $this->assertEquals( - 'montly', $this->_helper->getProductChangefreq(\Magento\Core\Model\AppInterface::DISTRO_STORE_ID) + 'montly', $this->_helper->getProductChangefreq(\Magento\Core\Model\Store::DISTRO_STORE_ID) ); } @@ -106,7 +106,7 @@ class DataTest extends \PHPUnit_Framework_TestCase ); $this->assertEquals( 'montly', - $this->_helper->getPageChangefreq(\Magento\Core\Model\AppInterface::DISTRO_STORE_ID) + $this->_helper->getPageChangefreq(\Magento\Core\Model\Store::DISTRO_STORE_ID) ); } @@ -121,7 +121,7 @@ class DataTest extends \PHPUnit_Framework_TestCase ); $this->assertEquals( 100, - $this->_helper->getCategoryPriority(\Magento\Core\Model\AppInterface::DISTRO_STORE_ID) + $this->_helper->getCategoryPriority(\Magento\Core\Model\Store::DISTRO_STORE_ID) ); } @@ -134,7 +134,7 @@ class DataTest extends \PHPUnit_Framework_TestCase 1, $this->_helper->getProductPriority(\Magento\Core\Model\Store::DEFAULT_STORE_ID) ); - $this->assertEquals(100, $this->_helper->getProductPriority(\Magento\Core\Model\AppInterface::DISTRO_STORE_ID)); + $this->assertEquals(100, $this->_helper->getProductPriority(\Magento\Core\Model\Store::DISTRO_STORE_ID)); } /** @@ -146,7 +146,7 @@ class DataTest extends \PHPUnit_Framework_TestCase 0.25, $this->_helper->getPagePriority(\Magento\Core\Model\Store::DEFAULT_STORE_ID) ); - $this->assertEquals(100, $this->_helper->getPagePriority(\Magento\Core\Model\AppInterface::DISTRO_STORE_ID)); + $this->assertEquals(100, $this->_helper->getPagePriority(\Magento\Core\Model\Store::DISTRO_STORE_ID)); } /** @@ -159,7 +159,7 @@ class DataTest extends \PHPUnit_Framework_TestCase $this->_helper->getEnableSubmissionRobots(\Magento\Core\Model\Store::DEFAULT_STORE_ID) ); $this->assertEquals( - 1, $this->_helper->getEnableSubmissionRobots(\Magento\Core\Model\AppInterface::DISTRO_STORE_ID) + 1, $this->_helper->getEnableSubmissionRobots(\Magento\Core\Model\Store::DISTRO_STORE_ID) ); } @@ -172,7 +172,7 @@ class DataTest extends \PHPUnit_Framework_TestCase 'all', $this->_helper->getProductImageIncludePolicy(\Magento\Core\Model\Store::DEFAULT_STORE_ID) ); $this->assertEquals( - 'base', $this->_helper->getProductImageIncludePolicy(\Magento\Core\Model\AppInterface::DISTRO_STORE_ID) + 'base', $this->_helper->getProductImageIncludePolicy(\Magento\Core\Model\Store::DISTRO_STORE_ID) ); } } diff --git a/dev/tests/integration/testsuite/Magento/Sitemap/Model/Resource/Catalog/ProductTest.php b/dev/tests/integration/testsuite/Magento/Sitemap/Model/Resource/Catalog/ProductTest.php index d8efc558ec40f1afaa166547878963dfb3e3b107..3f834f4f04ac9ded012757414e99d1fdcfbfcecc 100644 --- a/dev/tests/integration/testsuite/Magento/Sitemap/Model/Resource/Catalog/ProductTest.php +++ b/dev/tests/integration/testsuite/Magento/Sitemap/Model/Resource/Catalog/ProductTest.php @@ -47,7 +47,7 @@ class ProductTest extends \PHPUnit_Framework_TestCase { $model = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() ->create('Magento\Sitemap\Model\Resource\Catalog\Product'); - $products = $model->getCollection(\Magento\Core\Model\AppInterface::DISTRO_STORE_ID); + $products = $model->getCollection(\Magento\Core\Model\Store::DISTRO_STORE_ID); $this->_checkProductCollection($products, 3, array(1, 4, 5)); @@ -73,7 +73,7 @@ class ProductTest extends \PHPUnit_Framework_TestCase { $model = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() ->create('Magento\Sitemap\Model\Resource\Catalog\Product'); - $products = $model->getCollection(\Magento\Core\Model\AppInterface::DISTRO_STORE_ID); + $products = $model->getCollection(\Magento\Core\Model\Store::DISTRO_STORE_ID); $this->_checkProductCollection($products, 3, array(1, 4, 5)); @@ -125,7 +125,7 @@ class ProductTest extends \PHPUnit_Framework_TestCase { $model = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() ->create('Magento\Sitemap\Model\Resource\Catalog\Product'); - $products = $model->getCollection(\Magento\Core\Model\AppInterface::DISTRO_STORE_ID); + $products = $model->getCollection(\Magento\Core\Model\Store::DISTRO_STORE_ID); $this->_checkProductCollection($products, 3, array(1, 4, 5)); diff --git a/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/MviewConfigFilesTest.php b/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/MviewConfigFilesTest.php new file mode 100644 index 0000000000000000000000000000000000000000..2eb1fc4b62c75996575dbeef2b750d1c0ce5cd08 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/MviewConfigFilesTest.php @@ -0,0 +1,84 @@ +<?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_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\Test\Integrity\Modular; + +class MviewConfigFilesTest extends \PHPUnit_Framework_TestCase +{ + /** + * Configuration acl file list + * + * @var array + */ + protected $_fileList = array(); + + /** + * Path to scheme file + * + * @var string + */ + protected $_schemeFile; + + protected function setUp() + { + $this->markTestIncomplete('Will enable after first indexer will be implemented'); + $this->_schemeFile = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Filesystem') + ->getPath(\Magento\App\Filesystem::LIB_DIR) . '/Magento/Mview/etc/mview.xsd'; + } + + /** + * Test each acl configuration file + * @param string $file + */ + public function testIndexerConfigFile($file) + { + $this->markTestIncomplete('Will enable after first indexer will be implemented'); + $domConfig = new \Magento\Config\Dom(file_get_contents($file)); + $result = $domConfig->validate($this->_schemeFile, $errors); + $message = "Invalid XML-file: {$file}\n"; + foreach ($errors as $error) { + $message .= "$error\n"; + } + $this->assertTrue($result, $message); + } + + /** + * @return array + */ + public function indexerConfigFileDataProvider() + { + $fileList = glob( + \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Filesystem') + ->getPath(\Magento\App\Filesystem::APP_DIR) . '/*/*/*/etc/mview.xml' + ); + $dataProviderResult = array(); + foreach ($fileList as $file) { + $dataProviderResult[$file] = array($file); + } + return $dataProviderResult; + } +} diff --git a/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/NewIndexerConfigFilesTest.php b/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/NewIndexerConfigFilesTest.php new file mode 100644 index 0000000000000000000000000000000000000000..e674c4ec5614c6ecf81934b1f404196b229ca903 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/NewIndexerConfigFilesTest.php @@ -0,0 +1,83 @@ +<?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_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\Test\Integrity\Modular; + +class NewIndexerConfigFilesTest extends \PHPUnit_Framework_TestCase +{ + /** + * Configuration acl file list + * + * @var array + */ + protected $_fileList = array(); + + /** + * Path to scheme file + * + * @var string + */ + protected $_schemeFile; + + protected function setUp() + { + $this->markTestIncomplete('Will enable after first indexer will be implemented'); + $this->_schemeFile = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Filesystem') + ->getPath(\Magento\App\Filesystem::APP_DIR) . '/code/Magento/Indexer/etc/indexer.xsd'; + } + + /** + * Test each acl configuration file + * @param string $file + */ + public function testIndexerConfigFile($file) + { + $domConfig = new \Magento\Config\Dom(file_get_contents($file)); + $result = $domConfig->validate($this->_schemeFile, $errors); + $message = "Invalid XML-file: {$file}\n"; + foreach ($errors as $error) { + $message .= "$error\n"; + } + $this->assertTrue($result, $message); + } + + /** + * @return array + */ + public function indexerConfigFileDataProvider() + { + $fileList = glob( + \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Filesystem') + ->getPath(\Magento\App\Filesystem::APP_DIR) . '/*/*/*/etc/indexer.xml' + ); + $dataProviderResult = array(); + foreach ($fileList as $file) { + $dataProviderResult[$file] = array($file); + } + return $dataProviderResult; + } +} diff --git a/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/ResourcesConfigFilesTest.php b/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/ResourcesConfigFilesTest.php index 3bf8f0fe9fd73e25bdb73a8a7c0c44cb84c94042..90e8b4f4e4ac74b8ecabcc944167a3d53089c279 100644 --- a/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/ResourcesConfigFilesTest.php +++ b/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/ResourcesConfigFilesTest.php @@ -48,7 +48,7 @@ class ResourcesConfigFilesTest extends \PHPUnit_Framework_TestCase $validationStateMock->expects($this->any()) ->method('isValidated') ->will($this->returnValue(true)); - $localConfigMock = $this->getMock('Magento\App\Config', array(), array(), '', false); + $localConfigMock = $this->getMock('Magento\App\Arguments', array(), array(), '', false); $localConfigMock->expects($this->any())->method('getConfiguration')->will($this->returnValue(array())); $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); $this->_model = $objectManager->create('Magento\App\Resource\Config\Reader', array( diff --git a/dev/tests/integration/testsuite/Magento/Theme/Block/HtmlTest.php b/dev/tests/integration/testsuite/Magento/Theme/Block/HtmlTest.php index 68cef40f3d8847d565092bb39bb88b06fa2a92f6..1bd1534dafd0aeeebddac2c9930eeb66fd5dee32 100644 --- a/dev/tests/integration/testsuite/Magento/Theme/Block/HtmlTest.php +++ b/dev/tests/integration/testsuite/Magento/Theme/Block/HtmlTest.php @@ -42,21 +42,24 @@ class HtmlTest extends \PHPUnit_Framework_TestCase ->method('getConfig') ->will($this->returnValueMap($configData)); - $securityInfoMock = $this->getMock('Magento\Core\Model\Url\SecurityInfoInterface'); + $securityInfoMock = $this->getMock('Magento\Url\SecurityInfoInterface'); $codeData = $this->getMock('Magento\Core\Helper\Data', array(), array(), '', false); $urlBuilder = $this->getMock( - 'Magento\Core\Model\Url', + 'Magento\Url', array('getBaseUrl'), array( $this->getMock('Magento\App\Route\ConfigInterface'), $this->getMock('Magento\App\Request\Http', array(), array(), '', false), $securityInfoMock, - $storeConfig, - $this->getMock('Magento\Core\Model\App', array(), array(), '', false), - $this->getMock('Magento\Core\Model\StoreManager', array(), array(), '', false), + $this->getMock('Magento\Url\ScopeResolverInterface', array(), array(), '', false), $this->getMock('Magento\Core\Model\Session', array(), array(), '', false), $this->getMock('Magento\Session\SidResolverInterface', array(), array(), '', false), - null, + $this->getMock( + 'Magento\Url\RouteParamsResolverFactory', array(), array(), '', false + ), + $this->getMock( + 'Magento\Url\QueryParamsResolver', array(), array(), '', false + ), array() ) ); diff --git a/dev/tests/integration/testsuite/Magento/Url/QueryParamsResolverTest.php b/dev/tests/integration/testsuite/Magento/Url/QueryParamsResolverTest.php new file mode 100644 index 0000000000000000000000000000000000000000..6b8fcbbf2977ad647616f94549cb7d9528492a15 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Url/QueryParamsResolverTest.php @@ -0,0 +1,52 @@ +<?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_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\Url; + +class QueryParamsResolverTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Url\QueryParamsResolver + */ + protected $_model; + + protected function setUp() + { + $this->_model = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + ->create('Magento\Url\QueryParamsResolver'); + } + + public function testSetGetPurgeQueryParams() + { + $params = array('one' => 1, 'two' => 2); + $this->_model->setQueryParams($params); + $this->assertEquals($params, $this->_model->getQueryParams()); + + $this->_model->purgeQueryParams(); + $this->assertEquals(array(), $this->_model->getQueryParams()); + } +} diff --git a/dev/tests/integration/testsuite/Magento/Core/Model/UrlTest.php b/dev/tests/integration/testsuite/Magento/UrlTest.php similarity index 65% rename from dev/tests/integration/testsuite/Magento/Core/Model/UrlTest.php rename to dev/tests/integration/testsuite/Magento/UrlTest.php index e5c1b7bfe5cdc0266dd5a5eded8771a884aef258..6b7d72c7c3ba8a6118a22524577769bd0b504921 100644 --- a/dev/tests/integration/testsuite/Magento/Core/Model/UrlTest.php +++ b/dev/tests/integration/testsuite/Magento/UrlTest.php @@ -25,45 +25,19 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Core\Model; +namespace Magento; class UrlTest extends \PHPUnit_Framework_TestCase { /** - * @var \Magento\Core\Model\Url + * @var \Magento\UrlInterface */ protected $_model; protected function setUp() { $this->_model = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() - ->create('Magento\Core\Model\Url'); - } - - public function testParseUrl() - { - $url = 'http://user:password@www.example.com:80/manual/3.5/?one=1&two=2#skeleton-generator.test'; - $this->assertInstanceOf(get_class($this->_model), $this->_model->parseUrl($url)); - $this->assertEquals('http', $this->_model->getScheme()); - $this->assertEquals('www.example.com', $this->_model->getHost()); - $this->assertEquals('80', $this->_model->getPort()); - $this->assertEquals('user', $this->_model->getUser()); - $this->assertEquals('password', $this->_model->getPassword()); - $this->assertEquals('/manual/3.5/', $this->_model->getPath()); - $this->assertEquals('one=1&two=2', $this->_model->getQuery()); - $this->assertEquals('skeleton-generator.test', $this->_model->getFragment()); - } - - public function testGetDefaultControllerName() - { - $this->assertEquals('index', $this->_model->getDefaultControllerName()); - } - - public function testSetUseUrlCache() - { - $value = '2'; - $this->_model->setUseUrlCache($value); - $this->assertEquals($value, $this->_model->getData('use_url_cache')); + ->create('Magento\Url'); } public function testSetGetUseSession() @@ -80,53 +54,11 @@ class UrlTest extends \PHPUnit_Framework_TestCase $this->assertEquals($value, $this->_model->getData('route_front_name')); } - public function testGetDefaultActionName() - { - $this->assertEquals('index', $this->_model->getDefaultActionName()); - } - public function testGetConfigData() { $this->assertEquals('http://localhost/', $this->_model->getConfigData('base_url')); } - public function testSetGetRequest() - { - $this->assertInstanceOf('\Magento\App\RequestInterface', $this->_model->getRequest()); - /** @var $objectManager \Magento\TestFramework\ObjectManager */ - $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); - /** @var $request \Magento\TestFramework\Request */ - $request = $objectManager->get('Magento\TestFramework\Request'); - $this->_model->setRequest($request); - $this->assertSame($request, $this->_model->getRequest()); - } - - public function testGetType() - { - $this->assertEquals(\Magento\Core\Model\Store::URL_TYPE_LINK, $this->_model->getType()); - } - - /** - * @magentoAppIsolation enabled - */ - public function testIsSecure() - { - $this->assertFalse($this->_model->isSecure()); - $this->_model->setSecureIsForced(1); - $this->assertTrue(is_bool($this->_model->isSecure())); - $this->assertFalse($this->_model->isSecure()); - } - - public function testSetGetStore() - { - $this->assertInstanceOf('Magento\Core\Model\Store', $this->_model->getStore()); - - $store = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() - ->create('Magento\Core\Model\Store'); - $this->_model->setStore($store); - $this->assertSame($store, $this->_model->getStore()); - } - /** * Note: isolation should be raised to flush the URL memory cache maintained by the store model * @magentoAppIsolation enabled @@ -179,7 +111,7 @@ class UrlTest extends \PHPUnit_Framework_TestCase /** * Set specified type */ - $this->_model->setType(\Magento\Core\Model\Store::URL_TYPE_WEB); + $this->_model->setType(\Magento\UrlInterface::URL_TYPE_WEB); $webUrl = $this->_model->getBaseUrl(); $this->assertEquals('http://localhost/', $webUrl, 'Incorrect web url'); $this->assertEquals('http://localhost/index.php/', $this->_model->getBaseUrl(), 'Incorrect link url'); @@ -187,7 +119,7 @@ class UrlTest extends \PHPUnit_Framework_TestCase /** * Get url with type specified in params */ - $mediaUrl = $this->_model->getBaseUrl(array('_type' => \Magento\Core\Model\Store::URL_TYPE_MEDIA)); + $mediaUrl = $this->_model->getBaseUrl(array('_type' => \Magento\UrlInterface::URL_TYPE_MEDIA)); $this->assertEquals('http://localhost/pub/media/', $mediaUrl, 'Incorrect media url'); $this->assertEquals('http://localhost/index.php/', $this->_model->getBaseUrl(), 'Incorrect link url'); } @@ -196,65 +128,20 @@ class UrlTest extends \PHPUnit_Framework_TestCase { return array( array( - array('_type' => \Magento\Core\Model\Store::URL_TYPE_WEB), + array('_type' => \Magento\UrlInterface::URL_TYPE_WEB), 'http://sample.com/base_path/' ), array( - array('_type' => \Magento\Core\Model\Store::URL_TYPE_LINK), + array('_type' => \Magento\UrlInterface::URL_TYPE_LINK), 'http://sample.com/base_link_path/index.php/' ), array( - array('_type' => \Magento\Core\Model\Store::URL_TYPE_LINK, '_secure' => 1), + array('_type' => \Magento\UrlInterface::URL_TYPE_LINK, '_secure' => 1), 'https://sample.com/base_link_path/index.php/' ), ); } - public function testSetRoutePath() - { - // * - $this->_model->setRoutePath('catalog'); - $this->assertEquals('catalog', $this->_model->getRouteName()); - - // */* - $this->_model->setRoutePath('catalog/product'); - $this->assertEquals('catalog', $this->_model->getRouteName()); - $this->assertEquals('product', $this->_model->getControllerName()); - - // */*/* - $this->_model->setRoutePath('catalog/product/view'); - $this->assertEquals('catalog', $this->_model->getRouteName()); - $this->assertEquals('product', $this->_model->getControllerName()); - $this->assertEquals('view', $this->_model->getActionName()); - - // */*/*/param/value - $this->_model->setRoutePath('catalog/product/view/id/50'); - $this->assertEquals('catalog', $this->_model->getRouteName()); - $this->assertEquals('product', $this->_model->getControllerName()); - $this->assertEquals('view', $this->_model->getActionName()); - $this->assertEquals('50', $this->_model->getRouteParam('id')); - } - - public function testGetActionPath() - { - $this->assertEquals('', $this->_model->getActionPath()); - - $this->_model->setRoutePath('catalog/product/view/id/50'); - $this->assertEquals('catalog/product/view/', $this->_model->getActionPath()); - } - - public function testGetRoutePath() - { - $this->assertEquals('', $this->_model->getRoutePath()); - - $this->_model->setRoutePath('catalog/product/view/id/50'); - $this->assertEquals('catalog/product/view/id/50/', $this->_model->getRoutePath()); - - $this->_model->setRoutePath('catalog/product/view'); - $this->_model->setRouteParams(array('id' => 50)); - $this->assertEquals('catalog/product/view/id/50/', $this->_model->getRoutePath()); - } - public function testSetGetRouteName() { $this->_model->setRouteName('catalog'); @@ -263,12 +150,6 @@ class UrlTest extends \PHPUnit_Framework_TestCase $this->markTestIncomplete('setRouteName() logic is unclear.'); } - public function testGetRouteFrontName() - { - $this->_model->setRouteName('catalog'); - $this->assertEquals('catalog', $this->_model->getRouteFrontName()); - } - public function testSetGetControllerName() { $this->_model->setControllerName('product'); @@ -285,32 +166,6 @@ class UrlTest extends \PHPUnit_Framework_TestCase $this->markTestIncomplete('setActionName() logic is unclear.'); } - public function testSetGetRouteParams() - { - $this->_model->setRouteParams(array( - '_type' => 1, - '_store' => 1, - '_forced_secure' => 1, - '_absolute' => 1, - '_current' => 0, - '_use_rewrite' => 1, - '_store_to_url' => true, - 'param1' => 'value1', - )); - $this->assertEquals(array('param1' => 'value1'), $this->_model->getRouteParams()); - - $this->_model->setRouteParams(array('param2' => 'value2'), false); - $this->assertEquals(array('param1' => 'value1', 'param2' => 'value2'), $this->_model->getRouteParams()); - } - - public function testSetGetRouteParam() - { - $this->_model->setRouteParam('id', 100); - $this->assertEquals(100, $this->_model->getRouteParam('id')); - $this->_model->setRouteParam('parent_id', 50); - $this->assertEquals(array('id' => 100, 'parent_id' => 50), $this->_model->getRouteParams()); - } - /** * Note: isolation flushes the URL memory cache * @magentoAppIsolation enabled @@ -326,33 +181,6 @@ class UrlTest extends \PHPUnit_Framework_TestCase ); } - public function testSetGetQuery() - { - $this->_model->setQuery('one=1&two=2'); - $this->assertEquals('one=1&two=2', $this->_model->getQuery()); - - // here comes the funny part - $this->_model->unsQuery(); - $this->_model->setQueryParams(array('three' => 3, 'four' => 4)); - $this->assertEquals('four=4&three=3', $this->_model->getQuery(true)); - } - - public function testSetGetPurgeQueryParams() - { - $params = array('one' => 1, 'two' => 2); - $this->_model->setQueryParams($params); - $this->assertEquals($params, $this->_model->getQueryParams()); - - $this->_model->purgeQueryParams(); - $this->assertEquals(array(), $this->_model->getQueryParams()); - } - - public function testSetGetQueryParam() - { - $this->_model->setQueryParam('key', 'value'); - $this->assertEquals('value', $this->_model->getQueryParam('key')); - } - public function testSetGetFragment() { $this->_model->setFragment('value'); @@ -395,7 +223,7 @@ class UrlTest extends \PHPUnit_Framework_TestCase /** * Note: isolation flushes the URL memory cache * @magentoAppIsolation enabled - * @covers \Magento\Core\Model\Url::getUrl + * @covers \Magento\Url::getUrl */ public function testGetUrlDoesntAddFragmentOnConsequentCalls() { @@ -422,7 +250,7 @@ class UrlTest extends \PHPUnit_Framework_TestCase * @param array $secondRouteParams * @param string $firstExpectedUrl * @param string $secondExpectedUrl - * @covers \Magento\Core\Model\Url::getUrl + * @covers \Magento\Url::getUrl */ public function testGetUrlOnConsequentCalls($firstCallUrl, $secondCallUrl, $firstRouteParams, $secondRouteParams, $firstExpectedUrl, $secondExpectedUrl @@ -613,24 +441,6 @@ class UrlTest extends \PHPUnit_Framework_TestCase $this->assertFalse($this->_model->useSessionIdForUrl(false)); } - /** - * Note: isolation flushes the URL memory cache - * @magentoAppIsolation enabled - */ - public function testSessionVarCallback() - { - $this->_model->setData('use_session_id_for_url_0', false); - $this->_model->setData('use_session_id_for_url_1', false); - - // evidence of cyclomatic complexity - $this->assertEquals('?', $this->_model->sessionVarCallback(array('', '?', '', ''))); - $this->assertEquals('', $this->_model->sessionVarCallback(array('', '?', ''))); - $this->assertEquals('', $this->_model->sessionVarCallback(array('', '&', ''))); - $this->assertEquals('', $this->_model->sessionVarCallback(array('', '&', ''))); - $this->assertEquals('', $this->_model->sessionVarCallback(array('', '&', '', ''))); - $this->assertEquals('', $this->_model->sessionVarCallback(array('', '&', '', ''))); - } - /** * Note: isolation flushes the URL memory cache * @magentoAppIsolation enabled diff --git a/dev/tests/integration/testsuite/Magento/Webapi/Model/Config/_files/webapi.php b/dev/tests/integration/testsuite/Magento/Webapi/Model/Config/_files/webapi.php index 3e08a3edff068d4cce29d57bf8bdcdd795c64bb5..27c21c68be28c3512c455f1c1529d71a83be28ca 100644 --- a/dev/tests/integration/testsuite/Magento/Webapi/Model/Config/_files/webapi.php +++ b/dev/tests/integration/testsuite/Magento/Webapi/Model/Config/_files/webapi.php @@ -22,8 +22,8 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ return array( - '\Magento\TestModule1\Service\AllSoapAndRestV1Interface' => array( - 'class' => '\Magento\TestModule1\Service\AllSoapAndRestV1Interface', + '\Magento\TestModule1\Service\V1\AllSoapAndRestInterface' => array( + 'class' => '\Magento\TestModule1\Service\V1\AllSoapAndRestInterface', 'methods' => array( 'item' => array( 'httpMethod' => 'GET', @@ -42,8 +42,8 @@ return array( ), 'baseUrl' => '/V1/testmodule1', ), - '\Magento\TestModule1\Service\AllSoapAndRestV2Interface' => array( - 'class' => '\Magento\TestModule1\Service\AllSoapAndRestV2Interface', + '\Magento\TestModule1\Service\V2\AllSoapAndRestInterface' => array( + 'class' => '\Magento\TestModule1\Service\V2\AllSoapAndRestInterface', 'methods' => array( 'item' => array( 'httpMethod' => 'GET', @@ -69,8 +69,8 @@ return array( ), 'baseUrl' => '/V2/testmodule1', ), - '\Magento\TestModule2\Service\AllSoapAndRestV2Interface' => array( - 'class' => '\Magento\TestModule2\Service\AllSoapAndRestV2Interface', + '\Magento\TestModule2\Service\V2\AllSoapAndRestInterface' => array( + 'class' => '\Magento\TestModule2\Service\V2\AllSoapAndRestInterface', 'methods' => array( 'update' => array( 'httpMethod' => 'PUT', diff --git a/dev/tests/integration/testsuite/Magento/Webapi/Model/Config/_files/webapiA.xml b/dev/tests/integration/testsuite/Magento/Webapi/Model/Config/_files/webapiA.xml index 882ebb5546af2bfd91252206ba44335b7a03242a..f07d0019a9c6f2564faac494fb59c2f891a40a1d 100644 --- a/dev/tests/integration/testsuite/Magento/Webapi/Model/Config/_files/webapiA.xml +++ b/dev/tests/integration/testsuite/Magento/Webapi/Model/Config/_files/webapiA.xml @@ -24,11 +24,11 @@ */ --> <config> - <service class="\Magento\TestModule1\Service\AllSoapAndRestV1Interface" baseUrl="/V1/testmodule1"> + <service class="\Magento\TestModule1\Service\V1\AllSoapAndRestInterface" baseUrl="/V1/testmodule1"> <rest-route httpMethod="GET" method="item" resources="Magento_TestModule1::resource1">/:id</rest-route> </service> - <service class="\Magento\TestModule1\Service\AllSoapAndRestV2Interface" baseUrl="/V2/testmodule1"> + <service class="\Magento\TestModule1\Service\V2\AllSoapAndRestInterface" baseUrl="/V2/testmodule1"> <rest-route httpMethod="GET" method="item" resources="Magento_TestModule1::resource1">/:id</rest-route> <rest-route httpMethod="POST" method="create" resources="Magento_TestModule1::resource1, Magento_TestModule1::resource2"></rest-route> <rest-route httpMethod="DELETE" method="delete" isSecure="true" resources="Magento_TestModule1::resource2">/:id</rest-route> diff --git a/dev/tests/integration/testsuite/Magento/Webapi/Model/Config/_files/webapiB.xml b/dev/tests/integration/testsuite/Magento/Webapi/Model/Config/_files/webapiB.xml index 2c073f8df05e5accc5f88dea842044ac1d4e33c8..40f51078bdcf82abbe375aa95152fdc078fb2429 100644 --- a/dev/tests/integration/testsuite/Magento/Webapi/Model/Config/_files/webapiB.xml +++ b/dev/tests/integration/testsuite/Magento/Webapi/Model/Config/_files/webapiB.xml @@ -24,12 +24,12 @@ */ --> <config> - <service class="\Magento\TestModule1\Service\AllSoapAndRestV1Interface" baseUrl="/V1/testmodule1"> + <service class="\Magento\TestModule1\Service\V1\AllSoapAndRestInterface" baseUrl="/V1/testmodule1"> <!--Extension of service declared in webapiA.xml--> <rest-route httpMethod="POST" method="create" resources="Magento_TestModule1::resource2"></rest-route> </service> - <service class="\Magento\TestModule2\Service\AllSoapAndRestV2Interface" baseUrl="/V2/testmodule2"> + <service class="\Magento\TestModule2\Service\V2\AllSoapAndRestInterface" baseUrl="/V2/testmodule2"> <rest-route httpMethod="PUT" method="update" resources="Magento_TestModule1::resource1"></rest-route> <rest-route httpMethod="DELETE" method="delete" isSecure="true" resources="Magento_TestModule1::resource2">/:id</rest-route> </service> diff --git a/dev/tests/integration/testsuite/Magento/Webapi/Model/Soap/ServerTest.php b/dev/tests/integration/testsuite/Magento/Webapi/Model/Soap/ServerTest.php index 6cef42825dbffb617d1a5ac734342e899cf619e2..129b902ccdd7870eaa1201f770846535d81b17f8 100644 --- a/dev/tests/integration/testsuite/Magento/Webapi/Model/Soap/ServerTest.php +++ b/dev/tests/integration/testsuite/Magento/Webapi/Model/Soap/ServerTest.php @@ -52,6 +52,9 @@ class ServerTest extends \PHPUnit_Framework_TestCase /** @var \Magento\Webapi\Model\Soap\Server\Factory */ protected $_soapServerFactory; + /** @var \Magento\Webapi\Model\Config\ClassReflector\TypeProcessor */ + protected $_typeProcessor; + protected function setUp() { $this->_storeManagerMock = $this->getMockBuilder('Magento\Core\Model\StoreManager') @@ -69,6 +72,13 @@ class ServerTest extends \PHPUnit_Framework_TestCase ->disableOriginalConstructor()->getMock(); $this->_soapServerFactory = $this->getMockBuilder('Magento\Webapi\Model\Soap\Server\Factory') ->disableOriginalConstructor()->getMock(); + $this->_typeProcessor = $this->getMock( + 'Magento\Webapi\Model\Config\ClassReflector\TypeProcessor', + [], + [], + '', + false + ); parent::setUp(); } @@ -88,7 +98,8 @@ class ServerTest extends \PHPUnit_Framework_TestCase $this->_requestMock, $this->_domDocumentFactory, $this->_storeManagerMock, - $this->_soapServerFactory + $this->_soapServerFactory, + $this->_typeProcessor ); /** Assert that SOAP WSDL caching option was enabled after SOAP server initialization. */ $this->assertTrue((bool)ini_get('soap.wsdl_cache_enabled'), 'WSDL caching was not enabled.'); @@ -109,7 +120,8 @@ class ServerTest extends \PHPUnit_Framework_TestCase $this->_requestMock, $this->_domDocumentFactory, $this->_storeManagerMock, - $this->_soapServerFactory + $this->_soapServerFactory, + $this->_typeProcessor ); /** Assert that SOAP WSDL caching option was disabled after SOAP server initialization. */ $this->assertFalse((bool)ini_get('soap.wsdl_cache_enabled'), 'WSDL caching was not disabled.'); diff --git a/dev/tests/integration/testsuite/Magento/Webapi/ServiceNameCollisionTest.php b/dev/tests/integration/testsuite/Magento/Webapi/ServiceNameCollisionTest.php index cc17c8f8f0844275599f7cfc7746ad5980023723..c1c676f1950aa73491a4e89a0be5bc7fb5802570 100644 --- a/dev/tests/integration/testsuite/Magento/Webapi/ServiceNameCollisionTest.php +++ b/dev/tests/integration/testsuite/Magento/Webapi/ServiceNameCollisionTest.php @@ -34,20 +34,20 @@ class ServiceNameCollisionTest extends \PHPUnit_Framework_TestCase /** * Test there are no collisions between service names. * - * @see \Magento\Webapi\Model\Soap\Config::getServiceName() + * @see \Magento\Webapi\Helper\Data::getServiceName() * @SuppressWarnings(PHPMD.UnusedLocalVariable) */ public function testServiceNameCollisions() { $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); - /** @var \Magento\Webapi\Model\Soap\Config $soapConfig */ - $soapConfig = $objectManager->get('Magento\Webapi\Model\Soap\Config'); + /** @var \Magento\Webapi\Helper\Data $helper */ + $helper = $objectManager->get('Magento\Webapi\Helper\Data'); /** @var \Magento\Webapi\Model\Config $webapiConfig */ $webapiConfig = $objectManager->get('Magento\Webapi\Model\Config'); $serviceNames = array(); foreach ($webapiConfig->getServices() as $serviceClassName => $serviceData) { - $newServiceName = $soapConfig->getServiceName($serviceClassName); + $newServiceName = $helper->getServiceName($serviceClassName); $this->assertFalse(in_array($newServiceName, $serviceNames)); $serviceNames[] = $newServiceName; } diff --git a/dev/tests/performance/benchmark_logs_merge.php b/dev/tests/performance/benchmark_logs_merge.php deleted file mode 100644 index 4c6aeb020c9fe29c5660c33952f897f1179f856a..0000000000000000000000000000000000000000 --- a/dev/tests/performance/benchmark_logs_merge.php +++ /dev/null @@ -1,88 +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. - * - * @category Magento - * @package performance_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) - */ - -$magentoBaseDir = realpath(__DIR__ . '/../../../'); -require_once $magentoBaseDir. '/lib/Zend/Console/Getopt.php'; - -$shell = new Zend_Console_Getopt(array( - 'xml=s' => 'xml', - 'csv=s' => 'csv', - 'logs=s' => 'logs' -)); - -$args = $shell->getOptions(); -if (empty($args)) { - echo $shell->getUsageMessage(); - exit(1); -} - -$xmlUrl = $shell->getOption('xml'); -$scvUrl = $shell->getOption('csv'); -$newLogsUrl = $shell->getOption('logs'); - -if (!file_exists($xmlUrl)) { - echo 'xml does not exist'; - exit(1); -} - -if (!file_exists($scvUrl)) { - echo 'csv does not exist'; - exit(1); -} - -$xml = simplexml_load_file($xmlUrl); -$scv = readCsv($scvUrl); - -foreach ($xml as $key => $value) { - unset($value->httpSample); - unset($value->assertionResult); -} - -foreach ($scv as $key => $value) { - $httpSample = $xml->addChild('httpSample'); - - $httpSample->addAttribute('t', $value[1]); - $httpSample->addAttribute('lt', $value[1]); - $httpSample->addAttribute('ts', $value[0]); - $httpSample->addAttribute('s', 'true'); - $httpSample->addAttribute('lb', $value[2]); - $httpSample->addAttribute('rc', '200'); - $httpSample->addAttribute('rm', 'OK'); - $httpSample->addAttribute('tn', $value[2]); -} - -$xml->asXML($newLogsUrl); - -function readCsv($csvFile) -{ - $fileHandle = fopen($csvFile, 'r'); - $lineOfText = array(); - while (!feof($fileHandle) ) { - $lineOfText[] = fgetcsv($fileHandle, 1024); - } - fclose($fileHandle); - return $lineOfText; -} diff --git a/dev/tests/performance/testsuite/fixtures/shipping_flatrate_enabled.php b/dev/tests/performance/testsuite/fixtures/shipping_flatrate_enabled.php index e63c2895b011c35fcdbc18e4c683dca5a3edd90d..6d44bbf086f812ba6019c27c3123ca6be09c20eb 100644 --- a/dev/tests/performance/testsuite/fixtures/shipping_flatrate_enabled.php +++ b/dev/tests/performance/testsuite/fixtures/shipping_flatrate_enabled.php @@ -25,11 +25,11 @@ /** @var \Magento\TestFramework\Application $this */ /** - * @var \Magento\Core\Model\Config\Value $configData + * @var \Magento\App\Config\ValueInterface $configData */ -$configData = $this->getObjectManager()->create('Magento\Core\Model\Config\Value'); +$configData = $this->getObjectManager()->create('Magento\App\Config\ValueInterface'); $configData->setPath('carriers/flatrate/active') - ->setScope(\Magento\Core\Model\Config::SCOPE_DEFAULT) + ->setScope(\Magento\Core\Model\ScopeInterface::SCOPE_DEFAULT) ->setScopeId(0) ->setValue(1) ->save(); 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 3b20d86ee64b9eb49d428e3d503818dc179e0867..7f7a1b13b40a652072c908fcba5f577842a7c117 100644 --- a/dev/tests/static/framework/Magento/TestFramework/CodingStandard/Tool/CodeSniffer.php +++ b/dev/tests/static/framework/Magento/TestFramework/CodingStandard/Tool/CodeSniffer.php @@ -95,10 +95,11 @@ class CodeSniffer * @param array $whiteList Files/directories to be inspected * @param array $blackList Files/directories to be excluded from the inspection * @param array $extensions Array of alphanumeric strings, for example: 'php', 'xml', 'phtml', 'css'... + * @param int $warningSeverity Severity level of warnings, default is 0 * * @return int */ - public function run(array $whiteList, array $blackList = array(), array $extensions = array()) + public function run(array $whiteList, array $blackList = array(), array $extensions = array(), $warningSeverity = 0) { $whiteList = array_map(function ($item) { return $item; @@ -115,7 +116,7 @@ class CodeSniffer $settings['ignored'] = $blackList; $settings['extensions'] = $extensions; $settings['reportFile'] = $this->_reportFile; - $settings['warningSeverity'] = 0; + $settings['warningSeverity'] = $warningSeverity; $settings['reports']['checkstyle'] = null; $this->_wrapper->setValues($settings); diff --git a/dev/tests/static/testsuite/Magento/Test/Integrity/ConcreteImplementationTest.php b/dev/tests/static/testsuite/Magento/Test/Integrity/ConcreteImplementationTest.php new file mode 100644 index 0000000000000000000000000000000000000000..6e9dbec4f5116d1823f9379fb21723154875fe15 --- /dev/null +++ b/dev/tests/static/testsuite/Magento/Test/Integrity/ConcreteImplementationTest.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. + * + * @category tests + * @package static + * @subpackage Integrity + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +namespace Magento\Test\Integrity; + +/** + * Scan source code for dependency of blacklisted classes + */ +class ConcreteImplementationTest extends \PHPUnit_Framework_TestCase +{ + /** + * Classes that should not be injected as dependency in app code + * + * @var array + */ + protected static $_classesBlacklist = null; + + public function testWrongConcreteImplementation() + { + self::$_classesBlacklist = file(__DIR__ . '/_files/classes/blacklist.txt', FILE_IGNORE_NEW_LINES); + + $invoker = new \Magento\TestFramework\Utility\AggregateInvoker($this); + $invoker( + /** + * @param string $file + */ + function ($file) { + $content = file_get_contents($file); + + $result = (bool)preg_match( + '/function __construct\(([^\)]*)\)/iS', + $content, + $matches + ); + if ($result && !empty($matches[1])) { + $arguments = explode(',', $matches[1]); + foreach ($arguments as $argument) { + $type = explode(' ', trim($argument)); + if (in_array(trim($type[0]), self::$_classesBlacklist)) { + $this->fail("Incorrect class dependency found in $file:" . trim($type[0])); + } + } + } + }, + \Magento\TestFramework\Utility\Files::init()->getClassFiles(true, false, false, false, false, false) + ); + } +} diff --git a/dev/tests/static/testsuite/Magento/Test/Integrity/_files/blacklist/namespace.txt b/dev/tests/static/testsuite/Magento/Test/Integrity/_files/blacklist/namespace.txt index 274783b42c9a3316e3cbfdad6f0c6829a55beae4..46b39e01a382074598cc366261f1a09b84273a20 100644 --- a/dev/tests/static/testsuite/Magento/Test/Integrity/_files/blacklist/namespace.txt +++ b/dev/tests/static/testsuite/Magento/Test/Integrity/_files/blacklist/namespace.txt @@ -63,4 +63,5 @@ dev/tests/unit/testsuite/Magento/Code/Validator/_files/ClassesForConstructorInte dev/tests/unit/testsuite/Magento/Code/Validator/_files/ClassesForContextAggregation.php dev/tests/unit/testsuite/Magento/Code/Reader/_files/ClassesForArgumentsReader.php dev/tests/unit/testsuite/Magento/Code/Validator/_files/ClassesForArgumentSequence.php -dev/tests/unit/testsuite/Magento/Code/Validator/_files/ClassesForTypeDuplication.php \ No newline at end of file +dev/tests/unit/testsuite/Magento/Code/Validator/_files/ClassesForTypeDuplication.php +dev/tests/static/testsuite/Magento/Test/Php/_files/phpcs/Magento/Sniffs/Annotations/RequireAnnotatedMethodsSniff.php 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 new file mode 100644 index 0000000000000000000000000000000000000000..1f94e467559bb55fae0e5107ba6af6e23fd4e738 --- /dev/null +++ b/dev/tests/static/testsuite/Magento/Test/Integrity/_files/classes/blacklist.txt @@ -0,0 +1,6 @@ +\Magento\Backend\Model\Url +\Magento\Core\Model\Url\RouteParamsResolver +\Magento\Core\Model\Url\SecurityInfo +\Magento\Core\Model\Url\ScopeResolver +\Magento\Url +\Magento\Core\Model\Config diff --git a/dev/tests/static/testsuite/Magento/Test/Legacy/LayoutTest.php b/dev/tests/static/testsuite/Magento/Test/Legacy/LayoutTest.php index e3688f440cd6a0693b8b356d4ef0fb2118986a8a..d36e5d29a613fef02675571cf94c77440dd1f29f 100644 --- a/dev/tests/static/testsuite/Magento/Test/Legacy/LayoutTest.php +++ b/dev/tests/static/testsuite/Magento/Test/Legacy/LayoutTest.php @@ -321,7 +321,7 @@ class LayoutTest extends \PHPUnit_Framework_TestCase 'setPageLayout', 'setPageTitle', 'setParentType', - 'setPaypalActionPrefix', + 'setControllerPath', 'setPosition', 'setPositioned', 'setRewardMessage', diff --git a/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_classes.php b/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_classes.php index 8e548d12698edce0465b49eea235bfca179bdedf..d3f1f58b232ed2f50a27ca888281b2e284798e56 100644 --- a/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_classes.php +++ b/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_classes.php @@ -597,7 +597,7 @@ return array( 'Magento\Backend\Model\Config\Source\Yesnocustom' ), array('Mage_Adminhtml_Model_System_Store', 'Magento\Core\Model\System\Store'), - array('Mage_Adminhtml_Model_Url', 'Magento\Backend\Model\Url'), + array('Mage_Adminhtml_Model_Url', 'Magento\Backend\Model\UrlInterface'), array('Mage_Adminhtml_Rss_CatalogController'), array('Mage_Adminhtml_Rss_OrderController'), array('Mage_Adminhtml_SystemController', 'Magento\Backend\Controller\Adminhtml\System'), @@ -1467,6 +1467,10 @@ return array( array('Magento\Core\Model\Theme\FlyweightFactory', 'Magento\View\Design\Theme\FlyweightFactory'), array('Magento\Core\Model\Image\AdapterFactory', 'Magento\Image\AdapterFactory'), array('Magento\Core\Model\EntryPoint\Cron', 'Magento\App\Cron'), + array( + 'Magento\Checkout\Block\Cart\Item\Renderer\Grouped', + 'Magento\GroupedProduct\Block\Cart\Item\Renderer\Grouped' + ), array('Magento\Log\Model\EntryPoint\Shell', 'Magento\Log\App\Shell'), array('Magento\Index\Model\EntryPoint\Shell', 'Magento\Index\App\Shell'), array('Magento\Index\Model\EntryPoint\Indexer', 'Magento\Index\App\Indexer'), @@ -1802,6 +1806,7 @@ return array( array('Magento\Catalog\Model\Resource\Convert'), array('Magento\Reminder\Model\Resource\HelperFactory'), array('Magento\Reminder\Model\Resource\Helper'), + array('Magento\Core\Model\ConfigInterface', 'Magento\App\ConfigInterface'), array('Magento\CatalogRule\Block\Adminhtml\Promo\Widget\Chooser'), array( 'Magento\Catalog\Model\Product\Type\Grouped\Backend', @@ -1842,6 +1847,26 @@ return array( 'Magento\Catalog\Block\Product\View\Type\Grouped', 'Magento\GroupedProduct\Block\Product\View\Type\Grouped' ), + array( + 'Magento\Sales\Block\Adminhtml\Items\Column\Name\Grouped', + 'Magento\GroupedProduct\Block\Adminhtml\Items\Column\Name\Grouped' + ), + array( + 'Magento\Sales\Model\Order\Pdf\Items\Invoice\Grouped', + 'Magento\GroupedProduct\Model\Order\Pdf\Items\Invoice\Grouped' + ), + array( + 'Magento\Sales\Block\Order\Item\Renderer\Grouped', + 'Magento\GroupedProduct\Block\Order\Item\Renderer\Grouped' + ), + array( + 'Magento\ImportExport\Model\Export\Entity\Product\Type\Grouped', + 'Magento\GroupedProduct\Model\Export\Entity\Product\Type\Grouped' + ), + array( + 'Magento\ImportExport\Model\Import\Entity\Product\Type\Grouped', + 'Magento\GroupedProduct\Model\Import\Entity\Product\Type\Grouped' + ), ['CollFactory', 'CollectionFactory'], // no need to shorten anymore ['Magento\Shipping\Model\Rate\Result\AbstractResult', 'Magento\Sales\Model\Quote\Address\RateResult\AbstractResult'], ['Magento\Shipping\Model\Rate\Result\Error', 'Magento\Sales\Model\Quote\Address\RateResult\Error'], @@ -1857,5 +1882,7 @@ return array( array('Magento\PageCache\Model\Control\Zend'), array('Magento\PageCache\Model\System\Config\Source\Controls'), array('Magento\PageCache\Model\CacheControlFactory'), - array('Magento\PageCache\Model\Observer'), + array('Magento\Config\Dom\Converter\ArrayConverter'), + array('Magento\Acl\Resource\Config\Dom'), + array('Magento\GoogleShopping\Helper\Price', 'Magento\Catalog\Model\Product\CatalogPrice'), ); 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 620f02e6d0a08b6b03a7f3bc1f86436cc4cfce90..982d56711acfd1b844c36451b6411779ac8f3e32 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 @@ -26,12 +26,12 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ return array( - array('ADMIN_STORE_ID', 'Magento\Core\Model\AppInterface'), + array('ADMIN_STORE_ID', 'Magento\AppInterface'), array('BACKORDERS_BELOW'), array('DS'), array('BACKORDERS_YES'), array('CACHE_TAG', 'Magento\Api\Model\Config', 'Magento_Api_Model_Cache_Type::CACHE_TAG'), - array('CACHE_TAG', 'Magento\Core\Model\AppInterface'), + array('CACHE_TAG', 'Magento\AppInterface'), array( 'CACHE_TAG', 'Magento\Core\Model\Resource\Db\Collection\AbstractCollection', @@ -94,7 +94,7 @@ return array( array('INIT_OPTION_RESPONSE', 'Magento\Core\Model\App'), array('INIT_OPTION_SCOPE_CODE', 'Magento\Core\Model\App', 'Magento_Core_Model_App::PARAM_RUN_CODE'), array('INIT_OPTION_SCOPE_TYPE', 'Magento\Core\Model\App', 'Magento_Core_Model_App::PARAM_RUN_TYPE'), - array('INIT_OPTION_URIS', 'Magento\Core\Model\App', 'Magento_Core_Model_App::PARAM_APP_URIS'), + array('INIT_OPTION_URIS', 'Magento\Core\Model\App'), array('INSTALLER_HOST_RESPONSE', 'Magento\Install\Model\Installer'), array( 'LAYOUT_GENERAL_CACHE_TAG', @@ -104,6 +104,7 @@ return array( array('LOCALE_CACHE_KEY', 'Magento\Backend\Block\Page\Footer'), array('LOCALE_CACHE_LIFETIME', 'Magento\Backend\Block\Page\Footer'), array('LOCALE_CACHE_TAG', 'Magento\Backend\Block\Page\Footer'), + array('PARAM_CACHE_OPTIONS', '\Magento\Core\Model\App', '\Magento\Core\Model\App::PARAM_CACHE_FORCED_OPTIONS'), array('PATH_PREFIX_CUSTOMIZATION', 'Magento\Core\Model\Theme'), array('PATH_PREFIX_CUSTOMIZED', 'Magento\Core\Model\Theme\Files'), array('PUBLIC_BASE_THEME_DIR', 'Magento\Core\Model\Design\PackageInterface'), @@ -505,7 +506,7 @@ return array( ), array( 'USE_PARENT_IMAGE', - 'Magento\Checkout\Block\Cart\Item\Renderer\Grouped', + 'Magento\GroupedProduct\Block\Cart\Item\Renderer\Grouped', 'Magento\Catalog\Model\Config\Source\Product\Thumbnail::OPTION_USE_PARENT_IMAGE' ), array( @@ -515,8 +516,8 @@ return array( ), array( 'GROUPED_PRODUCT_IMAGE', - 'Magento\Checkout\Block\Cart\Item\Renderer\Grouped', - 'Magento\Checkout\Block\Cart\Item\Renderer\Grouped::CONFIG_THUMBNAIL_SOURCE' + 'Magento\GroupedProduct\Block\Cart\Item\Renderer\Grouped', + 'Magento\GroupedProduct\Block\Cart\Item\Renderer\Grouped::CONFIG_THUMBNAIL_SOURCE' ), array('TYPE_BLOCK', '\Magento\Core\Model\Layout', '\Magento\View\Layout\Element'), array('TYPE_CONTAINER', '\Magento\Core\Model\Layout', '\Magento\View\Layout\Element'), 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 a1b18f18361fa9d343fcc2647679116c47522569..b4ac933e9ce510d7e88b17399d1068c9d5301872 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 @@ -147,6 +147,8 @@ return array( array('_needToAddDummy'), array('_needToAddDummyForShipment'), array('_outTemplate', 'Magento\Backend\App\AbstractAction'), + array('getCustomer', 'Magento\Sales\Block\Adminhtml\Order\Create\AbstractCreate', 'getCustomerId'), + array('_getAddressForm', 'Magento\Sales\Block\Adminhtml\Order\Create\Form\Address'), array('_parseDescription', 'Magento\Sales\Model\Order\Pdf\Items\AbstractItems'), array('_parsePackageTheme', 'Magento\Widget\Model\Widget\Instance'), array('_parseXmlTrackingResponse', 'Magento\Usa\Model\Shipping\Carrier\Fedex'), @@ -287,6 +289,7 @@ return array( array('countChildren', 'Magento\Core\Block\AbstractBlock'), array('crear'), array('createDirIfNotExists', '', 'mkdir()'), + array('createEntityTables', 'Magento\Eav\Model\Entity\Setup'), array('createOrderItem', 'Magento\CatalogInventory\Model\Observer'), array('debugRequest', 'Magento\Paypal\Model\Api\Standard'), array('decorateArray', 'Magento\Core\Helper\Data', 'Magento\Stdlib\ArrayUtils::decorateArray'), @@ -345,7 +348,7 @@ return array( array('getConfigDataModel', 'Magento\Core\Model\Config'), array('getConnectionTypeInstance', 'Magento\App\Resource'), array('getContainers', 'Magento\Core\Model\Layout\Update', 'Magento\Core\Model\Layout\Merge'), - array('getCurrentUrl', 'Magento\Core\Helper\Url', 'Magento\Core\Model\Url'), + array('getCurrentUrl', 'Magento\Core\Helper\Url', 'Magento\Url'), array('getCustomerData', 'Magento\Sales\Block\Adminhtml\Order\Create\Form\Account'), array('getDataForSave', 'Magento\Wishlist\Model\Item'), array('getDataMaxSize'), @@ -503,8 +506,8 @@ return array( array('getRowId', 'Magento\Backend\Block\Widget\Grid'), array('getSaveTemplateFlag', 'Magento\Newsletter\Model\Queue'), array('getSectionNode', 'Magento\Core\Model\Config'), - array('getSecure', 'Magento\Backend\Model\Url', 'isSecure'), - array('getSecure', 'Magento\Core\Model\Url', 'isSecure'), + array('getSecure', 'Magento\Backend\Model\UrlInterface', 'isSecure'), + array('getSecure', 'Magento\Url', 'isSecure'), array('getSelectionFinalPrice', 'Magento\Bundle\Model\Product\Price'), array('getShipId', 'Magento\Shipping\Block\Tracking\Popup'), array('getShippingCarrier', 'Magento\Sales\Model\Order', 'Magento\Shipping\Model\CarrierFactory::create'), @@ -889,7 +892,7 @@ return array( array('run', '\Magento\Core\Model\App'), array('_initFrontController', '\Magento\Core\Model\App'), array('_getFrontControllerByCurrentArea', '\Magento\Core\Model\App'), - array('run', '\Magento\Core\Model\AppInterface'), + array('run', '\Magento\AppInterface'), array('setModuleDir', 'Magento\Module\Dir\Reader'), array('setModuleDir', 'Magento\Core\Model\Config'), array('getAreaConfig', 'Magento\Core\Model\Config'), @@ -1189,4 +1192,10 @@ return array( array('getUpdateUrl', 'Magento\Wishlist\Helper\Data'), array('getItemRemoveUrl', 'Magento\Wishlist\Block\AbstractBlock'), array('_getUrlParams', 'Magento\Catalog\Helper\Product\Compare'), + array('getFileIdentifier', 'Magento\View\Layout\File\FileList', 'Magento\View\Layout\File'), + array('_getInitialXml', 'Magento\Config\Theme'), + array('_getIdAttributes', 'Magento\Config\Theme'), + array('_getSession', 'Magento\CatalogSearch\Controller\Result'), + array('addPriceBlockType', 'Magento\Rss\Block\Catalog\AbstractCatalog'), + array('getAttributeDisabledTypes', 'Magento\Catalog\Helper\Data'), ); diff --git a/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_properties.php b/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_properties.php index bbdd9b45e7692daeb05142d161b1f709d2199e25..27369667fcae29d25a595fee90d36256a161814d 100644 --- a/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_properties.php +++ b/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_properties.php @@ -50,6 +50,9 @@ return array( array('_currency', 'Magento\GoogleCheckout\Model\Api\Xml\Checkout'), array('_currencyNameTable'), array('_customEtcDir', 'Magento\Core\Model\Config'), + array('_customerFactory ', '\Magento\Sales\Block\Adminhtml\Billing\Agreement\View\Tab\Info'), + array('_customerFactory ', '\Magento\Sales\Block\Adminhtml\Order\Create\Form\Account'), + array('_customerFormFactory', '\Magento\Sales\Block\Adminhtml\Order\Create\Form\Account'), array('_defaultTemplates', 'Magento\Email\Model\Template'), array('_designProductSettingsApplied'), array('_directOutput', 'Magento\Core\Model\Layout'), @@ -105,6 +108,8 @@ return array( array('decoratedIsOdd', null, 'getDecoratedIsOdd'), array('decoratedIsLast', null, 'getDecoratedIsLast'), array('static', 'Magento\Email\Model\Template\Filter'), + array('_addressForm', 'Magento\Sales\Block\Adminhtml\Order\Create\Form\Address'), + array('_adminhtmlAddresses', 'Magento\Sales\Block\Adminhtml\Order\Create\Form\Address'), array('_useAnalyticFunction'), array('_defaultIndexer', 'Magento\CatalogInventory\Model\Resource\Indexer\Stock'), array('_engine', 'Magento\CatalogSearch\Model\Resource\Fulltext'), @@ -267,4 +272,5 @@ return array( array('_messagesBlock', 'Magento\View\Element\AbstractBlock'), array('_messagesBlock', 'Magento\Connect\Helper\Data'), array('escapeMessageFlag', 'Magento\View\Block\Messages'), + array('fileIteratorFactory', 'Magento\Core\Model\Theme\Collection') ); diff --git a/dev/tests/static/testsuite/Magento/Test/Php/LiveCodeTest.php b/dev/tests/static/testsuite/Magento/Test/Php/LiveCodeTest.php index e72132c4f240e86cba057cc80b6f4995c96d4f5c..7d2bb7b346e73ab8162a379d3df81a2987921349 100644 --- a/dev/tests/static/testsuite/Magento/Test/Php/LiveCodeTest.php +++ b/dev/tests/static/testsuite/Magento/Test/Php/LiveCodeTest.php @@ -23,8 +23,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\Test\Php; + use Magento\TestFramework\Utility; /** @@ -119,6 +119,29 @@ class LiveCodeTest extends \PHPUnit_Framework_TestCase ); } + public function testAnnotationStandard() + { + $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'), + $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); + $this->markTestIncomplete("PHP Code Sniffer has found $result error(s): See detailed report in $reportFile"); + $this->assertEquals( + 0, + $result, + "PHP Code Sniffer has found $result error(s): See detailed report in $reportFile" + ); + } + public function testCodeMess() { $reportFile = self::$_reportDir . '/phpmd_report.xml'; diff --git a/dev/tests/static/testsuite/Magento/Test/Php/_files/phpcpd/blacklist/common.txt b/dev/tests/static/testsuite/Magento/Test/Php/_files/phpcpd/blacklist/common.txt index f7aabbe67971c161b3f31a2075261966bd275a3c..a6b13a3d4d0bcd7eb26afa2f63b7cd26488e7b22 100644 --- a/dev/tests/static/testsuite/Magento/Test/Php/_files/phpcpd/blacklist/common.txt +++ b/dev/tests/static/testsuite/Magento/Test/Php/_files/phpcpd/blacklist/common.txt @@ -98,6 +98,7 @@ lib/Magento/Acl lib/PEAR lib/phpseclib lib/Magento/Convert +lib/Magento/App/Config Magento/Cron/Model Magento/SalesRule/Model/Resource/Report/Rule Magento/SalesRule/Model/Resource/Rule 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 new file mode 100644 index 0000000000000000000000000000000000000000..6bee378ab18a3e4b5e06d422a6eadd2825159930 --- /dev/null +++ b/dev/tests/static/testsuite/Magento/Test/Php/_files/phpcs/Magento/Sniffs/Annotations/RequireAnnotatedMethodsSniff.php @@ -0,0 +1,1022 @@ +<?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/app/code/Magento/PaypalUk/view/frontend/layout/catalogsearch_advanced_result.xml b/dev/tests/static/testsuite/Magento/Test/Php/_files/phpcs/Magento/ruleset.xml similarity index 89% rename from app/code/Magento/PaypalUk/view/frontend/layout/catalogsearch_advanced_result.xml rename to dev/tests/static/testsuite/Magento/Test/Php/_files/phpcs/Magento/ruleset.xml index 40668f6fc4bdb5a327cbd5c2ec348b2ef6af9d60..2bd399650eb07789070a506776c7cf7ca1958444 100644 --- a/app/code/Magento/PaypalUk/view/frontend/layout/catalogsearch_advanced_result.xml +++ b/dev/tests/static/testsuite/Magento/Test/Php/_files/phpcs/Magento/ruleset.xml @@ -23,6 +23,6 @@ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */ --> -<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> - <update handle="SHORTCUT_uk_popup"/> -</layout> +<ruleset name="Magento"> + <description>A custom coding standard.</description> +</ruleset> diff --git a/dev/tests/static/testsuite/Magento/Test/Php/_files/whitelist/common.txt b/dev/tests/static/testsuite/Magento/Test/Php/_files/whitelist/common.txt index a6edf3e83f09e2c4cd0c2b90ba0313e4b3ebeac3..4ebad2069b10d9c20e3a17dd0a3de802ec21142d 100644 --- a/dev/tests/static/testsuite/Magento/Test/Php/_files/whitelist/common.txt +++ b/dev/tests/static/testsuite/Magento/Test/Php/_files/whitelist/common.txt @@ -51,7 +51,6 @@ app/code/Magento/Core/Model/AbstractShell.php app/code/Magento/Core/Model/Theme app/code/Magento/Core/Model/Theme.php app/code/Magento/Core/Model/Url/SecurityInfo.php -app/code/Magento/Core/Model/Url/SecurityInfoInterface.php app/code/Magento/Core/sql/core_setup/upgrade-1.6.0.3-1.6.0.4.php app/code/Magento/Cron/Model/Config/Converter app/code/Magento/Cron/Model/Config/Reader @@ -139,4 +138,5 @@ lib/Magento/Stdlib/DateTime.php lib/Magento/Object.php lib/Magento/App lib/Magento/ObjectManager +lib/Magento/Url/SecurityInfoInterface.php lib/Magento/View diff --git a/dev/tests/unit/framework/tests/unit/testsuite/Magento/TestFramework/Helper/ObjectManagerTest.php b/dev/tests/unit/framework/tests/unit/testsuite/Magento/TestFramework/Helper/ObjectManagerTest.php index 238e43291ee09a6982ad23caed66f7b5ac5ca5ef..f31f70507164f5daadb57075f18717f85086e10c 100644 --- a/dev/tests/unit/framework/tests/unit/testsuite/Magento/TestFramework/Helper/ObjectManagerTest.php +++ b/dev/tests/unit/framework/tests/unit/testsuite/Magento/TestFramework/Helper/ObjectManagerTest.php @@ -92,7 +92,7 @@ class ObjectManagerTest extends \PHPUnit_Framework_TestCase public function testGetModel() { $objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); - /** @var $model \Magento\Core\Model\Config\Value */ + /** @var $model \Magento\App\Config\ValueInterface */ $model = $objectManager->getObject('Magento\Core\Model\Config\Value'); $this->assertInstanceOf('Magento\Core\Model\Config\Value', $model); foreach ($this->_modelDependencies as $propertyName => $propertyType) { diff --git a/dev/tests/unit/testsuite/Magento/Acl/Loader/ResourceTest.php b/dev/tests/unit/testsuite/Magento/Acl/Loader/ResourceTest.php index c4837175aec27167949a1212ea6a2aad70ed565d..86402187103a94d0279ab08ac75236aebc3b27d5 100644 --- a/dev/tests/unit/testsuite/Magento/Acl/Loader/ResourceTest.php +++ b/dev/tests/unit/testsuite/Magento/Acl/Loader/ResourceTest.php @@ -41,7 +41,6 @@ class ResourceTest extends \PHPUnit_Framework_TestCase $acl->expects($this->at(0))->method('addResource')->with($aclResource, null)->will($this->returnSelf()); $acl->expects($this->at(1))->method('addResource')->with($aclResource, $aclResource)->will($this->returnSelf()); - /** @var $factoryObject \Magento\Core\Model\Config */ $factoryObject = $this->getMock('Magento\Acl\ResourceFactory', array('createResource'), array(), '', false); $factoryObject->expects($this->any())->method('createResource')->will($this->returnValue($aclResource)); diff --git a/dev/tests/unit/testsuite/Magento/App/Config/FileResolver/PrimaryTest.php b/dev/tests/unit/testsuite/Magento/App/Arguments/FileResolver/PrimaryTest.php similarity index 94% rename from dev/tests/unit/testsuite/Magento/App/Config/FileResolver/PrimaryTest.php rename to dev/tests/unit/testsuite/Magento/App/Arguments/FileResolver/PrimaryTest.php index 6bc14536aefd53ec9e56a2c5c497d020b607bda0..cdda0a87155a1a5d5ee5944346e59dee27127e14 100644 --- a/dev/tests/unit/testsuite/Magento/App/Config/FileResolver/PrimaryTest.php +++ b/dev/tests/unit/testsuite/Magento/App/Arguments/FileResolver/PrimaryTest.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\App\Config\FileResolver; +namespace Magento\App\Arguments\FileResolver; class PrimaryTest extends \PHPUnit_Framework_TestCase { @@ -52,7 +52,7 @@ class PrimaryTest extends \PHPUnit_Framework_TestCase ->method('create') ->will($this->returnValue(true)); - $model = new \Magento\App\Config\FileResolver\Primary($filesystem, $iteratorFactory); + $model = new \Magento\App\Arguments\FileResolver\Primary($filesystem, $iteratorFactory); $this->assertTrue($model->get($filename, $scope)); } diff --git a/dev/tests/unit/testsuite/Magento/App/Config/FileResolver/_files/app/etc/config.xml b/dev/tests/unit/testsuite/Magento/App/Arguments/FileResolver/_files/app/etc/config.xml similarity index 100% rename from dev/tests/unit/testsuite/Magento/App/Config/FileResolver/_files/app/etc/config.xml rename to dev/tests/unit/testsuite/Magento/App/Arguments/FileResolver/_files/app/etc/config.xml diff --git a/dev/tests/unit/testsuite/Magento/App/Config/FileResolver/_files/app/etc/custom/config.xml b/dev/tests/unit/testsuite/Magento/App/Arguments/FileResolver/_files/app/etc/custom/config.xml similarity index 100% rename from dev/tests/unit/testsuite/Magento/App/Config/FileResolver/_files/app/etc/custom/config.xml rename to dev/tests/unit/testsuite/Magento/App/Arguments/FileResolver/_files/app/etc/custom/config.xml diff --git a/dev/tests/unit/testsuite/Magento/App/Config/FileResolver/_files/primary/app/etc/di.xml b/dev/tests/unit/testsuite/Magento/App/Arguments/FileResolver/_files/primary/app/etc/di.xml similarity index 100% rename from dev/tests/unit/testsuite/Magento/App/Config/FileResolver/_files/primary/app/etc/di.xml rename to dev/tests/unit/testsuite/Magento/App/Arguments/FileResolver/_files/primary/app/etc/di.xml diff --git a/dev/tests/unit/testsuite/Magento/App/Config/FileResolver/_files/primary/app/etc/some_config/di.xml b/dev/tests/unit/testsuite/Magento/App/Arguments/FileResolver/_files/primary/app/etc/some_config/di.xml similarity index 100% rename from dev/tests/unit/testsuite/Magento/App/Config/FileResolver/_files/primary/app/etc/some_config/di.xml rename to dev/tests/unit/testsuite/Magento/App/Arguments/FileResolver/_files/primary/app/etc/some_config/di.xml diff --git a/dev/tests/unit/testsuite/Magento/App/Config/LoaderTest.php b/dev/tests/unit/testsuite/Magento/App/Arguments/LoaderTest.php similarity index 84% rename from dev/tests/unit/testsuite/Magento/App/Config/LoaderTest.php rename to dev/tests/unit/testsuite/Magento/App/Arguments/LoaderTest.php index 19ca14435fe4d584e651970b20162dcb429ac106..403daed7dee4285b85065dc07bd420f0e861d106 100644 --- a/dev/tests/unit/testsuite/Magento/App/Config/LoaderTest.php +++ b/dev/tests/unit/testsuite/Magento/App/Arguments/LoaderTest.php @@ -23,7 +23,7 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\App\Config; +namespace Magento\App\Arguments; class LoaderTest extends \PHPUnit_Framework_TestCase { @@ -46,11 +46,7 @@ class LoaderTest extends \PHPUnit_Framework_TestCase { $this->_dirs->expects($this->once())->method('getDir')->will($this->returnValue(__DIR__ . '/_files')); $this->_model = new Loader($this->_dirs); - $expected = array( - 'resource' => 'resource name', - 'connection' => 'connection name', - 'other' => 'other value', - ); + $expected = require __DIR__ . '/_files/local.php'; $this->assertEquals($expected, $this->_model->load()); } @@ -58,12 +54,7 @@ class LoaderTest extends \PHPUnit_Framework_TestCase { $this->_dirs->expects($this->once())->method('getDir')->will($this->returnValue(__DIR__ . '/_files')); $this->_model = new Loader($this->_dirs, 'other/local_developer.xml'); - $expected = array( - 'resource' => 'resource name2', - 'connection' => 'connection name2', - 'other' => 'new other value', - 'new' => 'new value', - ); + $expected = require __DIR__ . '/_files/other/local_developer_merged.php'; $this->assertEquals($expected, $this->_model->load()); } diff --git a/dev/tests/unit/testsuite/Magento/App/Arguments/_files/local.php b/dev/tests/unit/testsuite/Magento/App/Arguments/_files/local.php new file mode 100644 index 0000000000000000000000000000000000000000..51f56cf2b532d510be98f71af77c06831e73d6e3 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/App/Arguments/_files/local.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) + */ + +return array( + 'connection' => array( + 'connection_one' => array( + 'name' => 'connection_one', + 'dbName' => 'db_one', + ), + 'connection_two' => array( + 'name' => 'connection_two', + 'dbName' => 'db_two', + ), + ), + 'resource' => array( + 'resource_one' => array( + 'name' => 'resource_one', + 'connection' => 'connection_one', + ), + 'resource_two' => array( + 'name' => 'resource_two', + 'connection' => 'connection_two', + ), + ), + 'cache' => array( + 'frontend' => array( + 'cache_frontend_one' => array( + 'name' => 'cache_frontend_one', + 'backend' => 'blackHole', + ), + 'cache_frontend_two' => array( + 'name' => 'cache_frontend_two', + 'backend' => 'file', + ), + ), + 'type' => array( + 'cache_type_one' => array( + 'name' => 'cache_type_one', + 'frontend' => 'cache_frontend_one', + ), + 'cache_type_two' => array( + 'name' => 'cache_type_two', + 'frontend' => 'cache_frontend_two', + ), + ), + ), + 'arbitrary_one' => 'Value One', + 'arbitrary_two' => 'Value Two', +); diff --git a/dev/tests/unit/testsuite/Magento/App/Config/_files/local.xml b/dev/tests/unit/testsuite/Magento/App/Arguments/_files/local.xml similarity index 55% rename from dev/tests/unit/testsuite/Magento/App/Config/_files/local.xml rename to dev/tests/unit/testsuite/Magento/App/Arguments/_files/local.xml index 8deb84e968824768a546630d42a0842e2abec45b..d8c9e0ef4c36d5cd3d9577f4a7a82e14b4ee3089 100644 --- a/dev/tests/unit/testsuite/Magento/App/Config/_files/local.xml +++ b/dev/tests/unit/testsuite/Magento/App/Arguments/_files/local.xml @@ -24,7 +24,24 @@ */ --> <config> - <resource>resource name</resource> - <connection>connection name</connection> - <other>other value</other> + <connection name="connection_one"> + <dbName>db_one</dbName> + </connection> + <connection name="connection_two"> + <dbName>db_two</dbName> + </connection> + <resource name="resource_one" connection="connection_one"/> + <resource name="resource_two" connection="connection_two"/> + <cache> + <frontend name="cache_frontend_one"> + <backend>blackHole</backend> + </frontend> + <frontend name="cache_frontend_two"> + <backend>file</backend> + </frontend> + <type name="cache_type_one" frontend="cache_frontend_one"/> + <type name="cache_type_two" frontend="cache_frontend_two"/> + </cache> + <arbitrary_one>Value One</arbitrary_one> + <arbitrary_two>Value Two</arbitrary_two> </config> diff --git a/dev/tests/unit/testsuite/Magento/App/Arguments/_files/other/local_developer.php b/dev/tests/unit/testsuite/Magento/App/Arguments/_files/other/local_developer.php new file mode 100644 index 0000000000000000000000000000000000000000..ba13dbaa04910151f00b19b2bfc7d0e7ce73b75c --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/App/Arguments/_files/other/local_developer.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) + */ + +return array( + 'connection' => array( + 'connection_one' => array( + 'name' => 'connection_one', + 'dbName' => 'overridden_db_one', + ), + 'connection_new' => array( + 'name' => 'connection_new', + 'dbName' => 'db_new', + ), + ), + 'resource' => array( + 'resource_one' => array( + 'name' => 'resource_one', + 'connection' => 'connection_new', + ), + 'resource_new' => array( + 'name' => 'resource_new', + 'connection' => 'connection_two', + ), + ), + 'cache' => array( + 'frontend' => array( + 'cache_frontend_one' => array( + 'name' => 'cache_frontend_one', + 'backend' => 'memcached', + ), + 'cache_frontend_new' => array( + 'name' => 'cache_frontend_new', + 'backend' => 'apc', + ), + ), + 'type' => array( + 'cache_type_one' => array( + 'name' => 'cache_type_one', + 'frontend' => 'cache_frontend_new', + ), + 'cache_type_new' => array( + 'name' => 'cache_type_new', + 'frontend' => 'cache_frontend_two', + ), + ), + ), + 'arbitrary_one' => 'Overridden Value One', + 'arbitrary_new' => 'Value New', +); diff --git a/dev/tests/unit/testsuite/Magento/App/Config/_files/other/local_developer.xml b/dev/tests/unit/testsuite/Magento/App/Arguments/_files/other/local_developer.xml similarity index 55% rename from dev/tests/unit/testsuite/Magento/App/Config/_files/other/local_developer.xml rename to dev/tests/unit/testsuite/Magento/App/Arguments/_files/other/local_developer.xml index 09884201752723127ae9d64e7459f1bc5cbf5c93..53dc25e4d5bb0baabea2b585aa0b3cb014303af6 100644 --- a/dev/tests/unit/testsuite/Magento/App/Config/_files/other/local_developer.xml +++ b/dev/tests/unit/testsuite/Magento/App/Arguments/_files/other/local_developer.xml @@ -24,8 +24,24 @@ */ --> <config> - <resource>resource name2</resource> - <connection>connection name2</connection> - <other>new other value</other> - <new>new value</new> + <connection name="connection_one"> + <dbName>overridden_db_one</dbName> + </connection> + <connection name="connection_new"> + <dbName>db_new</dbName> + </connection> + <resource name="resource_one" connection="connection_new"/> + <resource name="resource_new" connection="connection_two"/> + <cache> + <frontend name="cache_frontend_one"> + <backend>memcached</backend> + </frontend> + <frontend name="cache_frontend_new"> + <backend>apc</backend> + </frontend> + <type name="cache_type_one" frontend="cache_frontend_new"/> + <type name="cache_type_new" frontend="cache_frontend_two"/> + </cache> + <arbitrary_one>Overridden Value One</arbitrary_one> + <arbitrary_new>Value New</arbitrary_new> </config> diff --git a/dev/tests/unit/testsuite/Magento/App/Arguments/_files/other/local_developer_merged.php b/dev/tests/unit/testsuite/Magento/App/Arguments/_files/other/local_developer_merged.php new file mode 100644 index 0000000000000000000000000000000000000000..d88e6973f40c1494c8d7c7d770c18f93fe820d84 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/App/Arguments/_files/other/local_developer_merged.php @@ -0,0 +1,87 @@ +<?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) + */ + +return array( + 'connection' => array( + 'connection_one' => array( + 'name' => 'connection_one', + 'dbName' => 'overridden_db_one', + ), + 'connection_two' => array( + 'name' => 'connection_two', + 'dbName' => 'db_two', + ), + 'connection_new' => array( + 'name' => 'connection_new', + 'dbName' => 'db_new', + ), + ), + 'resource' => array( + 'resource_one' => array( + 'name' => 'resource_one', + 'connection' => 'connection_new', + ), + 'resource_two' => array( + 'name' => 'resource_two', + 'connection' => 'connection_two', + ), + 'resource_new' => array( + 'name' => 'resource_new', + 'connection' => 'connection_two', + ), + ), + 'cache' => array( + 'frontend' => array( + 'cache_frontend_one' => array( + 'name' => 'cache_frontend_one', + 'backend' => 'memcached', + ), + 'cache_frontend_two' => array( + 'name' => 'cache_frontend_two', + 'backend' => 'file', + ), + 'cache_frontend_new' => array( + 'name' => 'cache_frontend_new', + 'backend' => 'apc', + ), + ), + 'type' => array( + 'cache_type_one' => array( + 'name' => 'cache_type_one', + 'frontend' => 'cache_frontend_new', + ), + 'cache_type_two' => array( + 'name' => 'cache_type_two', + 'frontend' => 'cache_frontend_two', + ), + 'cache_type_new' => array( + 'name' => 'cache_type_new', + 'frontend' => 'cache_frontend_two', + ), + ), + ), + 'arbitrary_one' => 'Overridden Value One', + 'arbitrary_two' => 'Value Two', + 'arbitrary_new' => 'Value New', +); diff --git a/dev/tests/unit/testsuite/Magento/App/ArgumentsTest.php b/dev/tests/unit/testsuite/Magento/App/ArgumentsTest.php new file mode 100644 index 0000000000000000000000000000000000000000..0c3588ed02f314859d36b9d9ddfa7c47b00829c6 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/App/ArgumentsTest.php @@ -0,0 +1,141 @@ +<?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; + +class ArgumentsTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var array + */ + protected static $fixtureConfig; + + /** + * @var array + */ + protected static $fixtureConfigMerged; + + /** + * @var \Magento\App\Arguments + */ + protected $_arguments; + + /** + * @var \Magento\App\Arguments + */ + protected $_argumentsMerged; + + public static function setUpBeforeClass() + { + self::$fixtureConfig = require __DIR__ . '/Arguments/_files/local.php'; + self::$fixtureConfigMerged = require __DIR__ . '/Arguments/_files/other/local_developer_merged.php'; + } + + protected function setUp() + { + $loader = $this->getMock('Magento\App\Arguments\Loader', array(), array(), '', false); + $loader->expects($this->atLeastOnce())->method('load')->will($this->returnValue(self::$fixtureConfig)); + + $this->_arguments = new \Magento\App\Arguments(array(), $loader); + $this->_argumentsMerged = new \Magento\App\Arguments( + require __DIR__ . '/Arguments/_files/other/local_developer.php', + $loader + ); + } + + /** + * @param string $connectionName + * @param bool $testMerged + * @param array|null $expectedResult + * @dataProvider getConnectionDataProvider + */ + public function testGetConnection($connectionName, $testMerged, $expectedResult) + { + $arguments = $testMerged ? $this->_argumentsMerged : $this->_arguments; + $this->assertEquals($expectedResult, $arguments->getConnection($connectionName)); + } + + public function getConnectionDataProvider() + { + return array( + 'existing connection' => array( + 'connection_one', false, array('name' => 'connection_one', 'dbName' => 'db_one') + ), + 'unknown connection' => array( + 'connection_new', false, null + ), + 'existing connection, added' => array( + 'connection_new', true, array('name' => 'connection_new', 'dbName' => 'db_new') + ), + 'existing connection, overridden' => array( + 'connection_one', true, array('name' => 'connection_one', 'dbName' => 'overridden_db_one') + ), + ); + } + + public function testGetConnections() + { + $this->assertEquals(self::$fixtureConfig['connection'], $this->_arguments->getConnections()); + $this->assertEquals(self::$fixtureConfigMerged['connection'], $this->_argumentsMerged->getConnections()); + } + + public function testGetResources() + { + $this->assertEquals(self::$fixtureConfig['resource'], $this->_arguments->getResources()); + $this->assertEquals(self::$fixtureConfigMerged['resource'], $this->_argumentsMerged->getResources()); + } + + public function testGetCacheFrontendSettings() + { + $this->assertEquals( + self::$fixtureConfig['cache']['frontend'], + $this->_arguments->getCacheFrontendSettings() + ); + $this->assertEquals( + self::$fixtureConfigMerged['cache']['frontend'], + $this->_argumentsMerged->getCacheFrontendSettings() + ); + } + + /** + * @param string $cacheType + * @param bool $testMerged + * @param string|null $expectedResult + * @dataProvider getCacheTypeFrontendIdDataProvider + */ + public function testGetCacheTypeFrontendId($cacheType, $testMerged, $expectedResult) + { + $arguments = $testMerged ? $this->_argumentsMerged : $this->_arguments; + $this->assertEquals($expectedResult, $arguments->getCacheTypeFrontendId($cacheType)); + } + + public function getCacheTypeFrontendIdDataProvider() + { + return array( + 'existing cache type' => array('cache_type_one', false, 'cache_frontend_one'), + 'unknown cache type' => array('cache_type_new', false, null), + 'existing cache type, added' => array('cache_type_new', true, 'cache_frontend_two'), + 'existing cache type, overridden' => array('cache_type_one', true, 'cache_frontend_new'), + ); + } +} diff --git a/dev/tests/unit/testsuite/Magento/App/Cache/Frontend/PoolTest.php b/dev/tests/unit/testsuite/Magento/App/Cache/Frontend/PoolTest.php index e3f97b3b1e3ca58f4b8f45475b1b15377d44d5a3..3d6a700120c11c73a2a5af7b661fd3ddeeaac313 100644 --- a/dev/tests/unit/testsuite/Magento/App/Cache/Frontend/PoolTest.php +++ b/dev/tests/unit/testsuite/Magento/App/Cache/Frontend/PoolTest.php @@ -32,45 +32,40 @@ class PoolTest extends \PHPUnit_Framework_TestCase /** * Array of frontend cache instances stubs, used to verify, what is stored inside the pool + * + * @var \PHPUnit_Framework_MockObject_MockObject[] */ protected $_frontendInstances = array(); protected function setUp() { - // Init frontend factory - $frontendFactory = $this->getMock('Magento\App\Cache\Frontend\Factory', array(), array(), '', false); - $this->_frontendInstances = array( - \Magento\App\Cache\Frontend\Pool::DEFAULT_FRONTEND_ID - => $this->getMock('Magento\Cache\FrontendInterface'), + Pool::DEFAULT_FRONTEND_ID => $this->getMock('Magento\Cache\FrontendInterface'), 'resource1' => $this->getMock('Magento\Cache\FrontendInterface'), 'resource2' => $this->getMock('Magento\Cache\FrontendInterface'), ); - $frontendFactory->expects($this->any()) - ->method('create') - ->will( - $this->returnValueMap(array( - array( - array('data1' => 'value1', 'data2' => 'value2'), - $this->_frontendInstances[\Magento\App\Cache\Frontend\Pool::DEFAULT_FRONTEND_ID] - ), - array(array('r1d1' => 'value1', 'r1d2' => 'value2'), $this->_frontendInstances['resource1']), - array(array('r2d1' => 'value1', 'r2d2' => 'value2'), $this->_frontendInstances['resource2']), - )) - ); - - $advancedOptions = array( - 'resource1' => array('r1d1' => 'value1', 'r1d2' => 'value2'), - 'resource2' => array('r2d1' => 'value1', 'r2d2' => 'value2'), + + $frontendFactoryMap = array( + array( + array('data1' => 'value1', 'data2' => 'value2'), $this->_frontendInstances[Pool::DEFAULT_FRONTEND_ID] + ), + array(array('r1d1' => 'value1', 'r1d2' => 'value2'), $this->_frontendInstances['resource1']), + array(array('r2d1' => 'value1', 'r2d2' => 'value2'), $this->_frontendInstances['resource2']), ); + $frontendFactory = $this->getMock('Magento\App\Cache\Frontend\Factory', array(), array(), '', false); + $frontendFactory->expects($this->any())->method('create')->will($this->returnValueMap($frontendFactoryMap)); + + $arguments = $this->getMock('Magento\App\Arguments', array(), array(), '', false); + $arguments->expects($this->any())->method('getCacheFrontendSettings')->will($this->returnValue(array( + 'resource2' => array('r2d1' => 'value1', 'r2d2' => 'value2'), + ))); - $defaultOptions = array( - 'data1' => 'value1', - 'data2' => 'value2', + $frontendSettings = array( + Pool::DEFAULT_FRONTEND_ID => array('data1' => 'value1', 'data2' => 'value2'), + 'resource1' => array('r1d1' => 'value1', 'r1d2' => 'value2'), ); - // Create model - $this->_model = new \Magento\App\Cache\Frontend\Pool( - $frontendFactory, $defaultOptions, $advancedOptions); + + $this->_model = new \Magento\App\Cache\Frontend\Pool($arguments, $frontendFactory, $frontendSettings); } /** @@ -78,56 +73,83 @@ class PoolTest extends \PHPUnit_Framework_TestCase */ public function testConstructorNoInitialization() { + $arguments = $this->getMock('Magento\App\Arguments', array(), array(), '', false); $frontendFactory = $this->getMock('Magento\App\Cache\Frontend\Factory', array(), array(), '', false); $frontendFactory ->expects($this->never()) ->method('create') ; - new \Magento\App\Cache\Frontend\Pool($frontendFactory); + new \Magento\App\Cache\Frontend\Pool($arguments, $frontendFactory); } - public function testCurrent() + /** + * @param array $fixtureCacheConfig + * @param array $frontendSettings + * @param array $expectedFactoryArg + * + * @dataProvider initializationParamsDataProvider + */ + public function testInitializationParams( + array $fixtureCacheConfig, array $frontendSettings, array $expectedFactoryArg + ) { + $arguments = $this->getMock('Magento\App\Arguments', array(), array(), '', false); + $arguments + ->expects($this->once())->method('getCacheFrontendSettings')->will($this->returnValue($fixtureCacheConfig)); + + $frontendFactory = $this->getMock('Magento\App\Cache\Frontend\Factory', array(), array(), '', false); + $frontendFactory->expects($this->at(0))->method('create')->with($expectedFactoryArg); + + $model = new \Magento\App\Cache\Frontend\Pool($arguments, $frontendFactory, $frontendSettings); + $model->current(); + } + + public function initializationParamsDataProvider() { - $this->assertEquals( - $this->_frontendInstances[\Magento\App\Cache\Frontend\Pool::DEFAULT_FRONTEND_ID], - $this->_model->current() + return array( + 'default frontend, default settings' => array( + array(), + array(Pool::DEFAULT_FRONTEND_ID => array('default_option' => 'default_value')), + array('default_option' => 'default_value'), + ), + 'default frontend, overridden settings' => array( + array(Pool::DEFAULT_FRONTEND_ID => array('configured_option' => 'configured_value')), + array(Pool::DEFAULT_FRONTEND_ID => array('ignored_option' => 'ignored_value')), + array('configured_option' => 'configured_value'), + ), + 'custom frontend, default settings' => array( + array(), + array('custom' => array('default_option' => 'default_value')), + array('default_option' => 'default_value'), + ), + 'custom frontend, overridden settings' => array( + array('custom' => array('configured_option' => 'configured_value')), + array('custom' => array('ignored_option' => 'ignored_value')), + array('configured_option' => 'configured_value'), + ), ); } + public function testCurrent() + { + $this->assertSame($this->_frontendInstances[Pool::DEFAULT_FRONTEND_ID], $this->_model->current()); + } + public function testKey() { - $this->assertEquals( - \Magento\App\Cache\Frontend\Pool::DEFAULT_FRONTEND_ID, - $this->_model->key() - ); + $this->assertEquals(Pool::DEFAULT_FRONTEND_ID, $this->_model->key()); } public function testNext() { - $this->assertEquals( - \Magento\App\Cache\Frontend\Pool::DEFAULT_FRONTEND_ID, - $this->_model->key() - ); + $this->assertEquals(Pool::DEFAULT_FRONTEND_ID, $this->_model->key()); $this->_model->next(); - $this->assertEquals( - 'resource1', - $this->_model->key() - ); - $this->assertSame( - $this->_frontendInstances['resource1'], - $this->_model->current() - ); + $this->assertEquals('resource1', $this->_model->key()); + $this->assertSame($this->_frontendInstances['resource1'], $this->_model->current()); $this->_model->next(); - $this->assertEquals( - 'resource2', - $this->_model->key() - ); - $this->assertSame( - $this->_frontendInstances['resource2'], - $this->_model->current() - ); + $this->assertEquals('resource2', $this->_model->key()); + $this->assertSame($this->_frontendInstances['resource2'], $this->_model->current()); $this->_model->next(); $this->assertNull($this->_model->key()); @@ -137,16 +159,10 @@ class PoolTest extends \PHPUnit_Framework_TestCase public function testRewind() { $this->_model->next(); - $this->assertNotEquals( - \Magento\App\Cache\Frontend\Pool::DEFAULT_FRONTEND_ID, - $this->_model->key() - ); + $this->assertNotEquals(Pool::DEFAULT_FRONTEND_ID, $this->_model->key()); $this->_model->rewind(); - $this->assertEquals( - \Magento\App\Cache\Frontend\Pool::DEFAULT_FRONTEND_ID, - $this->_model->key() - ); + $this->assertEquals(Pool::DEFAULT_FRONTEND_ID, $this->_model->key()); } public function testValid() @@ -166,10 +182,17 @@ class PoolTest extends \PHPUnit_Framework_TestCase public function testGet() { - $this->assertSame($this->_frontendInstances[\Magento\App\Cache\Frontend\Pool::DEFAULT_FRONTEND_ID], - $this->_model->get(\Magento\App\Cache\Frontend\Pool::DEFAULT_FRONTEND_ID)); - $this->assertSame($this->_frontendInstances['resource1'], $this->_model->get('resource1')); - $this->assertSame($this->_frontendInstances['resource2'], $this->_model->get('resource2')); + foreach ($this->_frontendInstances as $frontendId => $frontendInstance) { + $this->assertSame($frontendInstance, $this->_model->get($frontendId)); + } } + /** + * @expectedException \InvalidArgumentException + * @expectedExceptionMessage Cache frontend 'unknown' is not recognized + */ + public function testGetUnknownFrontendId() + { + $this->_model->get('unknown'); + } } diff --git a/dev/tests/unit/testsuite/Magento/App/Cache/Type/FrontendPoolTest.php b/dev/tests/unit/testsuite/Magento/App/Cache/Type/FrontendPoolTest.php index e1f7a14337bf0db6cda42ae7ee30c2170b6a0579..d92012ecba75ad29619705a0aac5381ecf0157b9 100644 --- a/dev/tests/unit/testsuite/Magento/App/Cache/Type/FrontendPoolTest.php +++ b/dev/tests/unit/testsuite/Magento/App/Cache/Type/FrontendPoolTest.php @@ -31,91 +31,77 @@ class FrontendPoolTest extends \PHPUnit_Framework_TestCase protected $_model; /** - * @var \Magento\ObjectManager|PHPUnit_Framework_MockObject_MockObject + * @var \Magento\ObjectManager|\PHPUnit_Framework_MockObject_MockObject */ protected $_objectManager; /** - * @var \Magento\App\Cache\Frontend\Pool|PHPUnit_Framework_MockObject_MockObject + * @var \Magento\App\Arguments|\PHPUnit_Framework_MockObject_MockObject + */ + protected $_arguments; + + /** + * @var \Magento\App\Cache\Frontend\Pool|\PHPUnit_Framework_MockObject_MockObject */ protected $_cachePool; protected function setUp() { $this->_objectManager = $this->getMock('Magento\ObjectManager', array(), array(), '', false); + $this->_arguments = $this->getMock('Magento\App\Arguments', array(), array(), '', false); $this->_cachePool = $this->getMock('Magento\App\Cache\Frontend\Pool', array(), array(), '', false); - $this->_model = new \Magento\App\Cache\Type\FrontendPool($this->_objectManager, $this->_cachePool); + $this->_model = new FrontendPool($this->_objectManager, $this->_arguments, $this->_cachePool, array( + 'fixture_cache_type' => 'fixture_frontend_id', + )); } - public function testGet() + /** + * @param string|null $fixtureFrontendId + * @param string $inputCacheType + * @param string $expectedFrontendId + * + * @dataProvider getDataProvider + */ + public function testGet($fixtureFrontendId, $inputCacheType, $expectedFrontendId) { - $instanceMock = $this->getMock('Magento\Cache\FrontendInterface'); + $this->_arguments + ->expects($this->once()) + ->method('getCacheTypeFrontendId') + ->with($inputCacheType) + ->will($this->returnValue($fixtureFrontendId)); + + $cacheFrontend = $this->getMock('Magento\Cache\FrontendInterface'); $this->_cachePool->expects($this->once()) ->method('get') - ->with('cache_type') - ->will($this->returnValue($instanceMock)); + ->with($expectedFrontendId) + ->will($this->returnValue($cacheFrontend)); - $accessMock = $this->getMock('Magento\App\Cache\Type\AccessProxy', array(), array(), '', false); + $accessProxy = $this->getMock('Magento\App\Cache\Type\AccessProxy', array(), array(), '', false); $this->_objectManager->expects($this->once()) ->method('create') - ->with('Magento\App\Cache\Type\AccessProxy', - array('frontend' => $instanceMock, 'identifier' => 'cache_type')) - ->will($this->returnValue($accessMock)); - - $instance = $this->_model->get('cache_type'); - $this->assertSame($accessMock, $instance); + ->with( + 'Magento\App\Cache\Type\AccessProxy', + $this->identicalTo(array('frontend' => $cacheFrontend, 'identifier' => $inputCacheType)) + ) + ->will($this->returnValue($accessProxy)); - // And must be cached - $instance = $this->_model->get('cache_type'); - $this->assertSame($accessMock, $instance); + $this->assertSame($accessProxy, $this->_model->get($inputCacheType)); + // Result has to be cached in memory + $this->assertSame($accessProxy, $this->_model->get($inputCacheType)); } - public function testGetFallbackToDefaultId() + public function getDataProvider() { - /** - * Setup cache pool to have knowledge only about default cache instance. Also check appropriate sequence - * of calls. - */ - $defaultInstance = $this->getMock('Magento\Cache\FrontendInterface'); - $this->_cachePool->expects($this->at(0)) - ->method('get') - ->with('cache_type') - ->will($this->returnValue(null)); - $this->_cachePool->expects($this->at(1)) - ->method('get') - ->with(\Magento\App\Cache\Frontend\Pool::DEFAULT_FRONTEND_ID) - ->will($this->returnValue($defaultInstance)); - - $this->_cachePool->expects($this->at(2)) - ->method('get') - ->with('another_cache_type') - ->will($this->returnValue(null)); - $this->_cachePool->expects($this->at(3)) - ->method('get') - ->with(\Magento\App\Cache\Frontend\Pool::DEFAULT_FRONTEND_ID) - ->will($this->returnValue($defaultInstance)); - - /** - * Setup object manager to create new access proxies. We expect two calls. - */ - $this->_objectManager->expects($this->at(0)) - ->method('create') - ->with('Magento\App\Cache\Type\AccessProxy', - array('frontend' => $defaultInstance, 'identifier' => 'cache_type')) - ->will($this->returnValue( - $this->getMock('Magento\App\Cache\Type\AccessProxy', array(), array(), '', false) - )); - $this->_objectManager->expects($this->at(1)) - ->method('create') - ->with('Magento\App\Cache\Type\AccessProxy', - array('frontend' => $defaultInstance, 'identifier' => 'another_cache_type')) - ->will($this->returnValue( - $this->getMock('Magento\App\Cache\Type\AccessProxy', array(), array(), '', false) - )); - - $cacheInstance = $this->_model->get('cache_type'); - $anotherInstance = $this->_model->get('another_cache_type'); - $this->assertNotSame($cacheInstance, $anotherInstance, - 'Different cache instances must be returned for different identifiers'); + return array( + 'retrieval from config' => array( + 'configured_frontend_id', 'fixture_cache_type', 'configured_frontend_id', + ), + 'retrieval from map' => array( + null, 'fixture_cache_type', 'fixture_frontend_id', + ), + 'fallback to default id' => array( + null, 'unknown_cache_type', \Magento\App\Cache\Frontend\Pool::DEFAULT_FRONTEND_ID, + ), + ); } } diff --git a/dev/tests/unit/testsuite/Magento/App/ConfigTest.php b/dev/tests/unit/testsuite/Magento/App/ConfigTest.php deleted file mode 100644 index 3dab8547ccf2ab537e08624198bfc04c1a826038..0000000000000000000000000000000000000000 --- a/dev/tests/unit/testsuite/Magento/App/ConfigTest.php +++ /dev/null @@ -1,79 +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\App; - -class ConfigTest extends \PHPUnit_Framework_TestCase -{ - /** - * @var \Magento\App\Config - */ - protected $_config; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $_loaderMock; - - protected function setUp() - { - $this->_loaderMock = $this->getMock('Magento\App\Config\Loader', array(), array(), '', false); - $params = array( - 'connection' => array('default' => array('connection_name')), - 'resource' => array('name' => array('default_setup')) - ); - $this->_loaderMock->expects($this->any())->method('load')->will($this->returnValue($params)); - $this->_config = new \Magento\App\Config( - array(), - $this->_loaderMock - ); - } - - /** - * @param string $connectionName - * @param array|null $connectionDetail - * @dataProvider getConnectionDataProvider - */ - public function testGetConnection($connectionDetail, $connectionName) - { - $this->assertEquals($connectionDetail, $this->_config->getConnection($connectionName)); - } - - public function getConnectionDataProvider() - { - return array( - 'connection_name_exist' => array(array('connection_name'), 'default'), - 'connection_name_not_exist' => array(null, 'new_default') - ); - } - - public function testGetConnections() - { - $this->assertEquals(array('default' => array('connection_name')), $this->_config->getConnections()); - } - - public function testGetResources() - { - $this->assertEquals(array('name' => array('default_setup')), $this->_config->getResources()); - } -} diff --git a/dev/tests/unit/testsuite/Magento/App/CronTest.php b/dev/tests/unit/testsuite/Magento/App/CronTest.php index c08e2d4fdf7a9bbd5e24549cb63f7a8c3bac7c6b..e5d3aaa24e765bbc6fbd77c36f47b73d45599da3 100644 --- a/dev/tests/unit/testsuite/Magento/App/CronTest.php +++ b/dev/tests/unit/testsuite/Magento/App/CronTest.php @@ -62,11 +62,11 @@ class CronTest extends \PHPUnit_Framework_TestCase ); } - public function testExecuteDispatchesCronEvent() + public function testLaunchDispatchesCronEvent() { $this->_stateMock->expects($this->once())->method('setAreaCode')->with('crontab'); $this->_eventManagerMock->expects($this->once())->method('dispatch')->with('default'); $this->_responseMock->expects($this->once())->method('setCode')->with(0); - $this->assertEquals($this->_responseMock, $this->_model->execute()); + $this->assertEquals($this->_responseMock, $this->_model->launch()); } } diff --git a/dev/tests/unit/testsuite/Magento/App/EntryPoint/EntryPointTest.php b/dev/tests/unit/testsuite/Magento/App/EntryPoint/EntryPointTest.php index e0ca6964362e2f2ff120edbf5c1632e689b3b142..d89f129df187a919d74083444f278542349e1dd0 100644 --- a/dev/tests/unit/testsuite/Magento/App/EntryPoint/EntryPointTest.php +++ b/dev/tests/unit/testsuite/Magento/App/EntryPoint/EntryPointTest.php @@ -68,8 +68,8 @@ class EntryPointTest extends \PHPUnit_Framework_TestCase public function testRunExecutesApplication() { $applicationName = '\Magento\App\TestApplication'; - $applicationMock = $this->getMock('\Magento\AppInterface'); - $applicationMock->expects($this->once())->method('execute')->will($this->returnValue($this->_responseMock)); + $applicationMock = $this->getMock('\Magento\LauncherInterface'); + $applicationMock->expects($this->once())->method('launch')->will($this->returnValue($this->_responseMock)); $this->_objectManagerMock->expects($this->once())->method('create')->with($applicationName, array()) ->will($this->returnValue($applicationMock)); $this->assertNull($this->_model->run($applicationName)); @@ -78,14 +78,17 @@ class EntryPointTest extends \PHPUnit_Framework_TestCase public function testRunCatchesExceptionThrownByApplication() { $applicationName = '\Magento\App\TestApplication'; - $applicationMock = $this->getMock('\Magento\AppInterface'); + $applicationMock = $this->getMock('\Magento\LauncherInterface'); $applicationMock->expects($this->once()) - ->method('execute') + ->method('launch') ->will($this->throwException(new \Exception('Something went wrong.'))); $this->_objectManagerMock->expects($this->once()) ->method('create') ->with($applicationName, array()) ->will($this->returnValue($applicationMock)); + // clean output + ob_start(); $this->assertNull($this->_model->run($applicationName)); + ob_end_clean(); } } diff --git a/dev/tests/unit/testsuite/Magento/App/Resource/Config/ReaderTest.php b/dev/tests/unit/testsuite/Magento/App/Resource/Config/ReaderTest.php index 955e7a4ee5131c37c670202d7d2722840a6edc21..6c3d80a492d681dbd0e1c37af0d8f0099ee4eea3 100644 --- a/dev/tests/unit/testsuite/Magento/App/Resource/Config/ReaderTest.php +++ b/dev/tests/unit/testsuite/Magento/App/Resource/Config/ReaderTest.php @@ -74,7 +74,7 @@ class ReaderTest extends \PHPUnit_Framework_TestCase ); $this->_configLocalMock = $this->getMock( - 'Magento\App\Config', array(), array(), '', false + 'Magento\App\Arguments', array(), array(), '', false ); $this->_model = new \Magento\App\Resource\Config\Reader( diff --git a/dev/tests/unit/testsuite/Magento/Backend/App/ConfigTest.php b/dev/tests/unit/testsuite/Magento/Backend/App/ConfigTest.php index 710ef232a97c95a09f67dca4e7e23ed1f5f662b1..97aa355f4fc73351f0419e0fbd4e220e8a504bf8 100644 --- a/dev/tests/unit/testsuite/Magento/Backend/App/ConfigTest.php +++ b/dev/tests/unit/testsuite/Magento/Backend/App/ConfigTest.php @@ -91,9 +91,9 @@ class ConfigTest extends \PHPUnit_Framework_TestCase /** * @param mixed $configValue * @param bool $expectedResult - * @dataProvider getFlagDataProvider + * @dataProvider isSetFlagDataProvider */ - public function testGetFlag($configValue, $expectedResult) + public function testIsSetFlag($configValue, $expectedResult) { $path = 'some path'; $configData = $this->getConfigDataMock('getValue'); @@ -107,10 +107,10 @@ class ConfigTest extends \PHPUnit_Framework_TestCase ->method('getSection') ->with($this->equalTo('default'), $this->isNull()) ->will($this->returnValue($configData)); - $this->assertEquals($expectedResult, $this->model->getFlag($path)); + $this->assertEquals($expectedResult, $this->model->isSetFlag($path)); } - public function getFlagDataProvider() + public function isSetFlagDataProvider() { return array( array(0, false), diff --git a/dev/tests/unit/testsuite/Magento/Backend/Block/Page/System/Config/Robots/ResetTest.php b/dev/tests/unit/testsuite/Magento/Backend/Block/Page/System/Config/Robots/ResetTest.php index 93c408a101b9a86b0ed13f05c5745d4ae56bd874..32e19a2466ba9599ea64339c272f2877ef38a802 100644 --- a/dev/tests/unit/testsuite/Magento/Backend/Block/Page/System/Config/Robots/ResetTest.php +++ b/dev/tests/unit/testsuite/Magento/Backend/Block/Page/System/Config/Robots/ResetTest.php @@ -38,14 +38,14 @@ class ResetTest extends \PHPUnit_Framework_TestCase private $_resetRobotsBlock; /** - * @var \Magento\Core\Model\ConfigInterface|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\App\ConfigInterface|\PHPUnit_Framework_MockObject_MockObject */ protected $coreConfigMock; protected function setUp() { $this->coreConfigMock = $this->getMock( - 'Magento\Core\Model\Config', array('getValue'), array(), '', false + 'Magento\App\ConfigInterface', array(), array(), '', false ); $this->_resetRobotsBlock = new Reset( diff --git a/dev/tests/unit/testsuite/Magento/Backend/Block/System/Config/Form/FieldTest.php b/dev/tests/unit/testsuite/Magento/Backend/Block/System/Config/Form/FieldTest.php index 00954fd9eac00b5515d164117e04b30ce07f83be..b845948c2cddaa1eb9219fecc7b6e32868255299 100644 --- a/dev/tests/unit/testsuite/Magento/Backend/Block/System/Config/Form/FieldTest.php +++ b/dev/tests/unit/testsuite/Magento/Backend/Block/System/Config/Form/FieldTest.php @@ -47,7 +47,7 @@ class FieldTest extends \PHPUnit_Framework_TestCase /** * @var \PHPUnit_Framework_MockObject_MockObject */ - protected $_appModelMock; + protected $_storeManagerMock; /** * @var \PHPUnit_Framework_MockObject_MockObject @@ -56,10 +56,16 @@ class FieldTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_appModelMock = $this->getMock('Magento\Core\Model\App', array(), array(), '', false, false); + $this->_storeManagerMock = $this->getMock('Magento\Core\Model\StoreManager', + array(), + array(), + '', + false, + false + ); $data = array( - 'app' => $this->_appModelMock, + 'storeManager' => $this->_storeManagerMock, 'urlBuilder' => $this->getMock('Magento\Backend\Model\Url', array(), array(), '', false) ); $helper = new \Magento\TestFramework\Helper\ObjectManager($this); @@ -128,7 +134,7 @@ class FieldTest extends \PHPUnit_Framework_TestCase public function testRenderScopeLabel() { - $this->_appModelMock->expects($this->once())->method('isSingleStoreMode')->will($this->returnValue(false)); + $this->_storeManagerMock->expects($this->once())->method('isSingleStoreMode')->will($this->returnValue(false)); $testScopeLabel = 'test_scope_label'; $this->_elementMock->expects($this->any())->method('getScope')->will($this->returnValue(true)); diff --git a/dev/tests/unit/testsuite/Magento/Backend/Block/System/Config/FormTest.php b/dev/tests/unit/testsuite/Magento/Backend/Block/System/Config/FormTest.php index e50edc902e2293274c05cd9764740458aea014bc..1da580c2c90a0debee11c734bf400531c9bd757a 100644 --- a/dev/tests/unit/testsuite/Magento/Backend/Block/System/Config/FormTest.php +++ b/dev/tests/unit/testsuite/Magento/Backend/Block/System/Config/FormTest.php @@ -106,7 +106,7 @@ class FormTest extends \PHPUnit_Framework_TestCase $this->_fieldFactoryMock = $this->getMock('Magento\Backend\Block\System\Config\Form\Field\Factory', array(), array(), '', false, false ); - $this->_coreConfigMock = $this->getMock('Magento\Core\Model\Config', + $this->_coreConfigMock = $this->getMock('Magento\App\ConfigInterface', array(), array(), '', false, false ); diff --git a/dev/tests/unit/testsuite/Magento/Backend/Block/Widget/GridTest.php b/dev/tests/unit/testsuite/Magento/Backend/Block/Widget/GridTest.php index 08169da384823bc6bd01ee1ad56a7697a5b76f42..a5a21d9e0f86c2a4f87a24bd81d795041e9ac97b 100644 --- a/dev/tests/unit/testsuite/Magento/Backend/Block/Widget/GridTest.php +++ b/dev/tests/unit/testsuite/Magento/Backend/Block/Widget/GridTest.php @@ -50,7 +50,7 @@ class GridTest extends \PHPUnit_Framework_TestCase */ public function testAddGetClearRss($isUseStoreInUrl) { - $urlMock = $this->getMock('Magento\Core\Model\Url', array(), array(), '', false); + $urlMock = $this->getMock('Magento\Url', array(), array(), '', false); $storeMock = $this->getMock('Magento\Core\Model\Store', array(), array(), '', false); $storeMock->expects($this->any()) diff --git a/dev/tests/unit/testsuite/Magento/Backend/Helper/DataTest.php b/dev/tests/unit/testsuite/Magento/Backend/Helper/DataTest.php index e83305050f342c55ec2c4ce38493f9026749e88e..57aa5b99124371ea4ca7a0100381a8d08777d408 100644 --- a/dev/tests/unit/testsuite/Magento/Backend/Helper/DataTest.php +++ b/dev/tests/unit/testsuite/Magento/Backend/Helper/DataTest.php @@ -34,11 +34,6 @@ class DataTest extends \PHPUnit_Framework_TestCase */ protected $_helper; - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $_configMock; - /** * @var \PHPUnit_Framework_MockObject_MockObject */ @@ -46,7 +41,6 @@ class DataTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_configMock = $this->getMock('Magento\Core\Model\Config', array(), array(), '', false, false); $this->_frontResolverMock = $this->getMock('\Magento\Backend\App\Area\FrontNameResolver', array(), array(), '', false); $this->_helper = new \Magento\Backend\Helper\Data( diff --git a/dev/tests/unit/testsuite/Magento/Backend/Model/AuthTest.php b/dev/tests/unit/testsuite/Magento/Backend/Model/AuthTest.php index a51e667c66023d62b56d6bbb1ab0b3a23816fcf5..87b0ed3b300fef3764878276c184e21ec4bb7c25 100644 --- a/dev/tests/unit/testsuite/Magento/Backend/Model/AuthTest.php +++ b/dev/tests/unit/testsuite/Magento/Backend/Model/AuthTest.php @@ -25,7 +25,7 @@ namespace Magento\Backend\Model; class AuthTest extends \PHPUnit_Framework_TestCase { /** - * @var Magento\Backend\Model\Auth + * @var \Magento\Backend\Model\Auth */ protected $_model; @@ -52,9 +52,9 @@ class AuthTest extends \PHPUnit_Framework_TestCase $this->_model = new \Magento\Backend\Model\Auth( $this->_eventManagerMock, $this->getMock('\Magento\Backend\Helper\Data', array(), array(), '', false), - $this->_authStorageMock = $this->getMock('\Magento\Backend\Model\Auth\StorageInterface'), + $this->getMock('\Magento\Backend\Model\Auth\StorageInterface'), $this->_credentialStorage, - $this->_coreConfigMock = $this->getMock('\Magento\Core\Model\Config', array(), array(), '', false), + $this->getMock('\Magento\App\ConfigInterface', array(), array(), '', false), $this->_modelFactoryMock ); } diff --git a/dev/tests/unit/testsuite/Magento/Backend/Model/Config/Backend/BaseurlTest.php b/dev/tests/unit/testsuite/Magento/Backend/Model/Config/Backend/BaseurlTest.php index a9dafc523604d293e5fa54723c7e735080dd5e42..396682bdd3975d94b26db739434af3850828dff1 100644 --- a/dev/tests/unit/testsuite/Magento/Backend/Model/Config/Backend/BaseurlTest.php +++ b/dev/tests/unit/testsuite/Magento/Backend/Model/Config/Backend/BaseurlTest.php @@ -47,7 +47,7 @@ class BaseurlTest extends \PHPUnit_Framework_TestCase $resourceCollection = $this->getMock('Magento\Data\Collection\Db', array(), array(), '', false); $mergeService = $this->getMock('Magento\View\Asset\MergeService', array(), array(), '', false); $coreRegistry = $this->getMock('Magento\Core\Model\Registry', array(), array(), '', false); - $coreConfig = $this->getMock('Magento\Core\Model\Config', array(), array(), '', false); + $coreConfig = $this->getMock('Magento\App\ConfigInterface', array(), array(), '', false); $storeManager = $this->getMock('Magento\Core\Model\StoreManager', array(), array(), '', false); $model = $this->getMock( diff --git a/dev/tests/unit/testsuite/Magento/Backend/Model/Config/Backend/EncryptedTest.php b/dev/tests/unit/testsuite/Magento/Backend/Model/Config/Backend/EncryptedTest.php index d1ef973df641da4333dc65527d50e90c2c5a673a..bfef911e3465a3e670cf6335f9aa9bd5e243d052 100644 --- a/dev/tests/unit/testsuite/Magento/Backend/Model/Config/Backend/EncryptedTest.php +++ b/dev/tests/unit/testsuite/Magento/Backend/Model/Config/Backend/EncryptedTest.php @@ -54,7 +54,7 @@ class EncryptedTest extends \PHPUnit_Framework_TestCase ), array(), '', false ); - $this->_configMock = $this->getMock('Magento\Core\Model\Config', array(), array(), '', false); + $this->_configMock = $this->getMock('Magento\App\ConfigInterface', array(), array(), '', false); $this->_helperMock = $this->getMock('Magento\Core\Helper\Data', array(), array(), '', false); $this->_encryptorMock = $this->getMock('Magento\Encryption\EncryptorInterface', array(), array(), '', false); $this->_model = $helper->getObject('Magento\Backend\Model\Config\Backend\Encrypted', array( diff --git a/dev/tests/unit/testsuite/Magento/Backend/Model/Config/Backend/SecureTest.php b/dev/tests/unit/testsuite/Magento/Backend/Model/Config/Backend/SecureTest.php index 3dd4831b9e17fcd2e265bf078c5e4f1dccc8c9c3..da180a917c9efa9844e168629847bf8f8f9737f6 100644 --- a/dev/tests/unit/testsuite/Magento/Backend/Model/Config/Backend/SecureTest.php +++ b/dev/tests/unit/testsuite/Magento/Backend/Model/Config/Backend/SecureTest.php @@ -47,7 +47,7 @@ class SecureTest extends \PHPUnit_Framework_TestCase $resourceCollection = $this->getMock('Magento\Data\Collection\Db', array(), array(), '', false); $mergeService = $this->getMock('Magento\View\Asset\MergeService', array(), array(), '', false); $coreRegistry = $this->getMock('Magento\Core\Model\Registry', array(), array(), '', false); - $coreConfig = $this->getMock('Magento\Core\Model\Config', array(), array(), '', false); + $coreConfig = $this->getMock('Magento\App\ConfigInterface', array(), array(), '', false); $storeManager = $this->getMock('Magento\Core\Model\StoreManager', array(), array(), '', false); $model = $this->getMock( diff --git a/dev/tests/unit/testsuite/Magento/Backend/Model/Config/Source/Storage/Media/DatabaseTest.php b/dev/tests/unit/testsuite/Magento/Backend/Model/Config/Source/Storage/Media/DatabaseTest.php index 2f8ae685764212f2d398d429cfa49d88242732f0..51dd190ecb18776162f213698ca9d4d27dbfb2b0 100644 --- a/dev/tests/unit/testsuite/Magento/Backend/Model/Config/Source/Storage/Media/DatabaseTest.php +++ b/dev/tests/unit/testsuite/Magento/Backend/Model/Config/Source/Storage/Media/DatabaseTest.php @@ -39,13 +39,13 @@ class DatabaseTest extends \PHPUnit_Framework_TestCase protected $mediaDatabase; /** - * @var \Magento\App\Config|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\App\Arguments|\PHPUnit_Framework_MockObject_MockObject */ protected $configMock; protected function setUp() { - $this->configMock = $this->getMock('Magento\App\Config', array(), array(), '', false); + $this->configMock = $this->getMock('Magento\App\Arguments', array(), array(), '', false); $this->configMock->expects($this->any()) ->method('getResources') ->will($this->returnValue(array( diff --git a/dev/tests/unit/testsuite/Magento/Backend/Model/Config/Structure/AbstractElementTest.php b/dev/tests/unit/testsuite/Magento/Backend/Model/Config/Structure/AbstractElementTest.php index 2b57d514084f51a6ac708595dd78282d7dd0dbe9..1185dfcd520dcdd9b296f3587e0e92a5ed939a12 100644 --- a/dev/tests/unit/testsuite/Magento/Backend/Model/Config/Structure/AbstractElementTest.php +++ b/dev/tests/unit/testsuite/Magento/Backend/Model/Config/Structure/AbstractElementTest.php @@ -37,22 +37,22 @@ class AbstractElementTest extends \PHPUnit_Framework_TestCase /** * @var \PHPUnit_Framework_MockObject_MockObject */ - protected $_applicationMock; + protected $_storeManager; protected function setUp() { - $this->_applicationMock = $this->getMock('Magento\Core\Model\App', array(), array(), '', false); + $this->_storeManager = $this->getMock('Magento\Core\Model\StoreManager', array(), array(), '', false); $this->_model = $this->getMockForAbstractClass( 'Magento\Backend\Model\Config\Structure\AbstractElement', - array($this->_applicationMock) + array($this->_storeManager) ); } protected function tearDown() { unset($this->_model); - unset($this->_applicationMock); + unset($this->_storeManager); } public function testGetId() @@ -98,7 +98,7 @@ class AbstractElementTest extends \PHPUnit_Framework_TestCase public function testIsVisibleReturnsTrueInSingleStoreModeForNonHiddenElements() { - $this->_applicationMock->expects($this->once())->method('isSingleStoreMode')->will($this->returnValue(true)); + $this->_storeManager->expects($this->once())->method('isSingleStoreMode')->will($this->returnValue(true)); $this->_model->setData(array('showInDefault' => 1, 'showInStore' => 0, 'showInWebsite' => 0), \Magento\Backend\Model\Config\ScopeDefiner::SCOPE_DEFAULT); $this->assertTrue($this->_model->isVisible()); @@ -106,7 +106,7 @@ class AbstractElementTest extends \PHPUnit_Framework_TestCase public function testIsVisibleReturnsFalseInSingleStoreModeForHiddenElements() { - $this->_applicationMock->expects($this->once())->method('isSingleStoreMode')->will($this->returnValue(true)); + $this->_storeManager->expects($this->once())->method('isSingleStoreMode')->will($this->returnValue(true)); $this->_model->setData( array('hide_in_single_store_mode' => 1, 'showInDefault' => 1, 'showInStore' => 0, 'showInWebsite' => 0), \Magento\Backend\Model\Config\ScopeDefiner::SCOPE_DEFAULT @@ -119,7 +119,7 @@ class AbstractElementTest extends \PHPUnit_Framework_TestCase */ public function testIsVisibleReturnsFalseInSingleStoreModeForInvisibleElements() { - $this->_applicationMock->expects($this->once())->method('isSingleStoreMode')->will($this->returnValue(true)); + $this->_storeManager->expects($this->once())->method('isSingleStoreMode')->will($this->returnValue(true)); $this->_model->setData(array('showInDefault' => 0, 'showInStore' => 0, 'showInWebsite' => 0), \Magento\Backend\Model\Config\ScopeDefiner::SCOPE_DEFAULT ); diff --git a/dev/tests/unit/testsuite/Magento/Backend/Model/Config/Structure/Element/AbstractCompositeTest.php b/dev/tests/unit/testsuite/Magento/Backend/Model/Config/Structure/Element/AbstractCompositeTest.php index 76bce7427118c52b25ccecbae8e19c3ec33f5307..56bdbc5f8f00b126b29e6b78db152b5ba0f4d12b 100644 --- a/dev/tests/unit/testsuite/Magento/Backend/Model/Config/Structure/Element/AbstractCompositeTest.php +++ b/dev/tests/unit/testsuite/Magento/Backend/Model/Config/Structure/Element/AbstractCompositeTest.php @@ -37,7 +37,7 @@ class AbstractCompositeTest extends \PHPUnit_Framework_TestCase /** * @var \PHPUnit_Framework_MockObject_MockObject */ - protected $_applicationMock; + protected $_storeManagerMock; /** * @var \PHPUnit_Framework_MockObject_MockObject @@ -63,18 +63,18 @@ class AbstractCompositeTest extends \PHPUnit_Framework_TestCase $this->_iteratorMock = $this->getMock( 'Magento\Backend\Model\Config\Structure\Element\Iterator', array(), array(), '', false ); - $this->_applicationMock = $this->getMock('Magento\Core\Model\App', array(), array(), '', false); + $this->_storeManagerMock = $this->getMock('Magento\Core\Model\StoreManager', array(), array(), '', false); $this->_model = $this->getMockForAbstractClass( 'Magento\Backend\Model\Config\Structure\Element\AbstractComposite', - array($this->_applicationMock, $this->_iteratorMock) + array($this->_storeManagerMock, $this->_iteratorMock) ); } protected function tearDown() { unset($this->_iteratorMock); - unset($this->_applicationMock); + unset($this->_storeManagerMock); unset($this->_model); } @@ -106,7 +106,7 @@ class AbstractCompositeTest extends \PHPUnit_Framework_TestCase public function testIsVisibleReturnsTrueIfThereAreVisibleChildren() { - $this->_applicationMock->expects($this->once())->method('isSingleStoreMode')->will($this->returnValue(true)); + $this->_storeManagerMock->expects($this->once())->method('isSingleStoreMode')->will($this->returnValue(true)); $this->_iteratorMock->expects($this->once())->method('current')->will($this->returnValue(true)); $this->_iteratorMock->expects($this->once())->method('valid')->will($this->returnValue(true)); $this->_model->setData(array('showInDefault' => 'true'), 'default'); @@ -115,7 +115,7 @@ class AbstractCompositeTest extends \PHPUnit_Framework_TestCase public function testIsVisibleReturnsTrueIfElementHasFrontEndModel() { - $this->_applicationMock->expects($this->once())->method('isSingleStoreMode')->will($this->returnValue(true)); + $this->_storeManagerMock->expects($this->once())->method('isSingleStoreMode')->will($this->returnValue(true)); $this->_model->setData(array( 'showInDefault' => 'true', 'frontend_model' => 'Model_Name' @@ -125,7 +125,7 @@ class AbstractCompositeTest extends \PHPUnit_Framework_TestCase public function testIsVisibleReturnsFalseIfElementHasNoChildrenAndFrontendModel() { - $this->_applicationMock->expects($this->once())->method('isSingleStoreMode')->will($this->returnValue(true)); + $this->_storeManagerMock->expects($this->once())->method('isSingleStoreMode')->will($this->returnValue(true)); $this->_model->setData(array('showInDefault' => 'true'), 'default'); $this->assertFalse($this->_model->isVisible()); } diff --git a/dev/tests/unit/testsuite/Magento/Backend/Model/Config/Structure/Element/Dependency/MapperTest.php b/dev/tests/unit/testsuite/Magento/Backend/Model/Config/Structure/Element/Dependency/MapperTest.php index e329e0eaabdcd29452465ceddc3c34373cb9b47b..ae9075c24da047963effe69fafcb74d990ff924a 100644 --- a/dev/tests/unit/testsuite/Magento/Backend/Model/Config/Structure/Element/Dependency/MapperTest.php +++ b/dev/tests/unit/testsuite/Magento/Backend/Model/Config/Structure/Element/Dependency/MapperTest.php @@ -59,7 +59,7 @@ class MapperTest extends \PHPUnit_Framework_TestCase /** * @var \PHPUnit_Framework_MockObject_MockObject */ - protected $_applicationMock; + protected $_storeManagerMock; /** * @var \PHPUnit_Framework_MockObject_MockObject @@ -91,7 +91,7 @@ class MapperTest extends \PHPUnit_Framework_TestCase ), ); - $this->_applicationMock = $this->getMockBuilder('Magento\Core\Model\App') + $this->_storeManagerMock = $this->getMockBuilder('Magento\Core\Model\StoreManager') ->setMethods(array('getStore')) ->disableOriginalConstructor() ->getMock(); @@ -105,14 +105,14 @@ class MapperTest extends \PHPUnit_Framework_TestCase ->disableOriginalConstructor() ->getMock(); $this->_model = new \Magento\Backend\Model\Config\Structure\Element\Dependency\Mapper( - $this->_applicationMock, $this->_configStructureMock, $this->_fieldFactoryMock); + $this->_storeManagerMock, $this->_configStructureMock, $this->_fieldFactoryMock); } protected function tearDown() { unset($this->_model); unset($this->_configStructureMock); - unset($this->_applicationMock); + unset($this->_storeManagerMock); unset($this->_fieldFactoryMock); unset($this->_testData); } @@ -126,7 +126,7 @@ class MapperTest extends \PHPUnit_Framework_TestCase $storeMock = $this->getMockBuilder('Magento\Core\Model\Store') ->disableOriginalConstructor() ->getMock(); - $this->_applicationMock->expects($this->exactly(count($this->_testData))) + $this->_storeManagerMock->expects($this->exactly(count($this->_testData))) ->method('getStore') ->with(self::STORE_CODE) ->will($this->returnValue($storeMock)); @@ -170,7 +170,7 @@ class MapperTest extends \PHPUnit_Framework_TestCase public function testGetDependenciesIsVisible() { - $this->_applicationMock->expects($this->never()) + $this->_storeManagerMock->expects($this->never()) ->method('getStore'); $expected = array(); diff --git a/dev/tests/unit/testsuite/Magento/Backend/Model/Config/Structure/Element/FieldTest.php b/dev/tests/unit/testsuite/Magento/Backend/Model/Config/Structure/Element/FieldTest.php index 277fe207ab522dd53f1a7685849a1bf40cbb8a9b..4532c845fe5d29ff9be2cb65e52325bd048282c3 100644 --- a/dev/tests/unit/testsuite/Magento/Backend/Model/Config/Structure/Element/FieldTest.php +++ b/dev/tests/unit/testsuite/Magento/Backend/Model/Config/Structure/Element/FieldTest.php @@ -41,7 +41,7 @@ class FieldTest extends \PHPUnit_Framework_TestCase /** * @var \PHPUnit_Framework_MockObject_MockObject */ - protected $_applicationMock; + protected $_storeManagerMock; /** * @var \PHPUnit_Framework_MockObject_MockObject @@ -78,7 +78,7 @@ class FieldTest extends \PHPUnit_Framework_TestCase $this->_iteratorMock = $this->getMock( 'Magento\Backend\Model\Config\Structure\Element\Iterator', array(), array(), '', false ); - $this->_applicationMock = $this->getMock('Magento\Core\Model\App', array(), array(), '', false); + $this->_storeManagerMock = $this->getMock('Magento\Core\Model\StoreManager', array(), array(), '', false); $this->_backendFactoryMock = $this->getMock( 'Magento\Backend\Model\Config\BackendFactory', array(), array(), '', false ); @@ -96,7 +96,7 @@ class FieldTest extends \PHPUnit_Framework_TestCase ); $this->_model = new \Magento\Backend\Model\Config\Structure\Element\Field( - $this->_applicationMock, + $this->_storeManagerMock, $this->_backendFactoryMock, $this->_sourceFactoryMock, $this->_commentFactoryMock, @@ -108,7 +108,7 @@ class FieldTest extends \PHPUnit_Framework_TestCase protected function tearDown() { unset($this->_iteratorMock); - unset($this->_applicationMock); + unset($this->_storeManagerMock); unset($this->_backendFactoryMock); unset($this->_sourceFactoryMock); unset($this->_commentFactoryMock); diff --git a/dev/tests/unit/testsuite/Magento/Backend/Model/Config/Structure/Element/GroupTest.php b/dev/tests/unit/testsuite/Magento/Backend/Model/Config/Structure/Element/GroupTest.php index d2074055aef559656ca34bc2a761fbc1d8c5dd2b..b78d026ec87b47bcf3eca73170b2c5f960faf574 100644 --- a/dev/tests/unit/testsuite/Magento/Backend/Model/Config/Structure/Element/GroupTest.php +++ b/dev/tests/unit/testsuite/Magento/Backend/Model/Config/Structure/Element/GroupTest.php @@ -37,7 +37,7 @@ class GroupTest extends \PHPUnit_Framework_TestCase /** * @var \PHPUnit_Framework_MockObject_MockObject */ - protected $_applicationMock; + protected $_storeManagerMock; /** * @var \PHPUnit_Framework_MockObject_MockObject @@ -59,7 +59,7 @@ class GroupTest extends \PHPUnit_Framework_TestCase $this->_iteratorMock = $this->getMock( 'Magento\Backend\Model\Config\Structure\Element\Iterator\Field', array(), array(), '', false ); - $this->_applicationMock = $this->getMock('Magento\Core\Model\App', array(), array(), '', false); + $this->_storeManagerMock = $this->getMock('Magento\Core\Model\StoreManager', array(), array(), '', false); $this->_cloneFactoryMock = $this->getMock( 'Magento\Backend\Model\Config\BackendClone\Factory', array(), array(), '', false ); @@ -68,7 +68,7 @@ class GroupTest extends \PHPUnit_Framework_TestCase ); $this->_model = new \Magento\Backend\Model\Config\Structure\Element\Group( - $this->_applicationMock, + $this->_storeManagerMock, $this->_iteratorMock, $this->_cloneFactoryMock, $this->_depMapperMock ); @@ -78,7 +78,7 @@ class GroupTest extends \PHPUnit_Framework_TestCase { unset($this->_model); unset($this->_iteratorMock); - unset($this->_applicationMock); + unset($this->_storeManagerMock); unset($this->_cloneFactoryMock); unset($this->_depMapperMock); } @@ -104,7 +104,7 @@ class GroupTest extends \PHPUnit_Framework_TestCase public function testGetCloneModelCreatesCloneModel() { - $cloneModel = $this->getMock('Magento\Core\Model\Config\Value', array(), array(), '', false); + $cloneModel = $this->getMock('Magento\App\Config\ValueInterface', array(), array(), '', false); $this->_depMapperMock = $this->getMock( 'Magento\Backend\Model\Config\Structure\Element\Dependency\Mapper', array(), array(), '', false ); diff --git a/dev/tests/unit/testsuite/Magento/Backend/Model/Config/Structure/Element/SectionTest.php b/dev/tests/unit/testsuite/Magento/Backend/Model/Config/Structure/Element/SectionTest.php index 1ff8c8e3aff47dc1a24385bb6ca894b82ad034c2..44835f16a9422a7e59f8485d3c3f3b8a061f7451 100644 --- a/dev/tests/unit/testsuite/Magento/Backend/Model/Config/Structure/Element/SectionTest.php +++ b/dev/tests/unit/testsuite/Magento/Backend/Model/Config/Structure/Element/SectionTest.php @@ -37,7 +37,7 @@ class SectionTest extends \PHPUnit_Framework_TestCase /** * @var \PHPUnit_Framework_MockObject_MockObject */ - protected $_applicationMock; + protected $_storeManagerMock; /** * @var \PHPUnit_Framework_MockObject_MockObject @@ -54,11 +54,11 @@ class SectionTest extends \PHPUnit_Framework_TestCase $this->_iteratorMock = $this->getMock( 'Magento\Backend\Model\Config\Structure\Element\Iterator\Field', array(), array(), '', false ); - $this->_applicationMock = $this->getMock('Magento\Core\Model\App', array(), array(), '', false); + $this->_storeManagerMock = $this->getMock('Magento\Core\Model\StoreManager', array(), array(), '', false); $this->_authorizationMock = $this->getMock('Magento\AuthorizationInterface'); $this->_model = new \Magento\Backend\Model\Config\Structure\Element\Section( - $this->_applicationMock, $this->_iteratorMock, $this->_authorizationMock + $this->_storeManagerMock, $this->_iteratorMock, $this->_authorizationMock ); } @@ -66,7 +66,7 @@ class SectionTest extends \PHPUnit_Framework_TestCase { unset($this->_model); unset($this->_iteratorMock); - unset($this->_applicationMock); + unset($this->_storeManagerMock); unset($this->_authorizationMock); } @@ -88,14 +88,14 @@ class SectionTest extends \PHPUnit_Framework_TestCase public function testIsVisibleFirstChecksIfSectionIsAllowed() { - $this->_applicationMock->expects($this->never())->method('isSingleStoreMode'); + $this->_storeManagerMock->expects($this->never())->method('isSingleStoreMode'); $this->assertFalse($this->_model->isVisible()); } public function testIsVisibleProceedsWithVisibilityCheckIfSectionIsAllowed() { $this->_authorizationMock->expects($this->any())->method('isAllowed')->will($this->returnValue(true)); - $this->_applicationMock->expects($this->once())->method('isSingleStoreMode')->will($this->returnValue(true)); + $this->_storeManagerMock->expects($this->once())->method('isSingleStoreMode')->will($this->returnValue(true)); $this->_model->setData(array('resource' => 'Magento_Adminhtml::all'), 'scope'); $this->_model->isVisible(); } diff --git a/dev/tests/unit/testsuite/Magento/Backend/Model/Config/Structure/Element/TabTest.php b/dev/tests/unit/testsuite/Magento/Backend/Model/Config/Structure/Element/TabTest.php index ec69ca69f238e950397d1be93c587e349f1dbf89..83445656b5a7cb81d7a1968b31aafbfc8ae334a6 100644 --- a/dev/tests/unit/testsuite/Magento/Backend/Model/Config/Structure/Element/TabTest.php +++ b/dev/tests/unit/testsuite/Magento/Backend/Model/Config/Structure/Element/TabTest.php @@ -37,7 +37,7 @@ class TabTest extends \PHPUnit_Framework_TestCase /** * @var \PHPUnit_Framework_MockObject_MockObject */ - protected $_applicationMock; + protected $_storeManagerMock; /** * @var \PHPUnit_Framework_MockObject_MockObject @@ -49,10 +49,10 @@ class TabTest extends \PHPUnit_Framework_TestCase $this->_iteratorMock = $this->getMock( 'Magento\Backend\Model\Config\Structure\Element\Iterator\Field', array(), array(), '', false ); - $this->_applicationMock = $this->getMock('Magento\Core\Model\App', array(), array(), '', false); + $this->_storeManagerMock = $this->getMock('Magento\Core\Model\StoreManager', array(), array(), '', false); $this->_model = new \Magento\Backend\Model\Config\Structure\Element\Tab( - $this->_applicationMock, $this->_iteratorMock + $this->_storeManagerMock, $this->_iteratorMock ); } @@ -60,7 +60,7 @@ class TabTest extends \PHPUnit_Framework_TestCase { unset($this->_model); unset($this->_iteratorMock); - unset($this->_applicationMock); + unset($this->_storeManagerMock); } public function testIsVisibleOnlyChecksPresenceOfChildren() diff --git a/dev/tests/unit/testsuite/Magento/Backend/Model/ConfigTest.php b/dev/tests/unit/testsuite/Magento/Backend/Model/ConfigTest.php index 5a08f64e038efd7445fb1b5def071c4f8802ba56..e51fe8dc724763f37136dae12a23a848b8b4e092 100644 --- a/dev/tests/unit/testsuite/Magento/Backend/Model/ConfigTest.php +++ b/dev/tests/unit/testsuite/Magento/Backend/Model/ConfigTest.php @@ -87,14 +87,12 @@ class ConfigTest extends \PHPUnit_Framework_TestCase $this->_transFactoryMock = $this->getMock( 'Magento\Core\Model\Resource\TransactionFactory', array('create'), array(), '', false ); - $this->_appConfigMock = $this->getMock('Magento\Core\Model\Config', array(), array(), '', false); + $this->_appConfigMock = $this->getMock('Magento\App\ConfigInterface', array(), array(), '', false); $this->_configLoaderMock = $this->getMock('Magento\Backend\Model\Config\Loader', array(), array(), '', false); - $this->_applicationMock = $this->getMock('Magento\Core\Model\App', array(), array(), '', false); $this->_dataFactoryMock = $this->getMock('Magento\Core\Model\Config\ValueFactory', array(), array(), '', false); $this->_storeManager = $this->getMockForAbstractClass('Magento\Core\Model\StoreManagerInterface'); $this->_model = new \Magento\Backend\Model\Config( - $this->_applicationMock, $this->_appConfigMock, $this->_eventManagerMock, $structureMock, 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 ed115468037d8fead87699bfd86c81081ee27f6a..35561948fea71e886958d01492ca06a95ee57253 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 @@ -31,7 +31,7 @@ class ConfigTest extends \PHPUnit_Framework_TestCase $backendConfig = $this->getMockForAbstractClass('Magento\Backend\App\ConfigInterface'); $backendConfig ->expects($this->once()) - ->method('getFlag') + ->method('isSetFlag') ->with($this->equalTo('dev/translate_inline/active_admin')) ->will($this->returnValue($result)); $config = new Config($backendConfig); diff --git a/dev/tests/unit/testsuite/Magento/Backend/Model/UrlTest.php b/dev/tests/unit/testsuite/Magento/Backend/Model/UrlTest.php index a537078f2546baaf28ab0eeeae34a689a74388e5..a52180d9c268f06c9c177adb6300af649212fccf 100644 --- a/dev/tests/unit/testsuite/Magento/Backend/Model/UrlTest.php +++ b/dev/tests/unit/testsuite/Magento/Backend/Model/UrlTest.php @@ -80,6 +80,11 @@ class UrlTest extends \PHPUnit_Framework_TestCase */ protected $_authSessionMock; + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $_paramsResolverMock; + /** * @var \Magento\Encryption\EncryptorInterface */ @@ -126,14 +131,23 @@ class UrlTest extends \PHPUnit_Framework_TestCase '', false, false); $helper = new \Magento\TestFramework\Helper\ObjectManager($this); $this->_encryptor = $this->getMock('Magento\Encryption\Encryptor', null, array(), '', false); + $this->_paramsResolverMock = $this->getMock( + 'Magento\Url\RouteParamsResolverFactory', array(), array(), '', false + ); + $this->_paramsResolverMock->expects($this->any()) + ->method('create') + ->will($this->returnValue($this->getMock( + 'Magento\Core\Model\Url\RouteParamsResolver', array(), array(), '', false + ))); $this->_model = $helper->getObject('Magento\Backend\Model\Url', array( 'coreStoreConfig' => $this->_storeConfigMock, - 'backendHelper' => $helperMock, - 'formKey' => $this->_formKey, - 'menuConfig' => $this->_menuConfigMock, - 'coreData' => $this->_coreDataMock, - 'authSession' => $this->_authSessionMock, - 'encryptor' => $this->_encryptor + 'backendHelper' => $helperMock, + 'formKey' => $this->_formKey, + 'menuConfig' => $this->_menuConfigMock, + 'coreData' => $this->_coreDataMock, + 'authSession' => $this->_authSessionMock, + 'encryptor' => $this->_encryptor, + 'routeParamsResolver' => $this->_paramsResolverMock )); $this->_requestMock = $this->getMock('Magento\App\Request\Http', array(), array(), '', false); @@ -205,57 +219,12 @@ class UrlTest extends \PHPUnit_Framework_TestCase $helper = new \Magento\TestFramework\Helper\ObjectManager($this); $urlModel = $helper->getObject('Magento\Backend\Model\Url', array( 'backendHelper' => $helperMock, - 'authSession' => $this->_authSessionMock + 'authSession' => $this->_authSessionMock, + 'routeParamsResolver' => $this->_paramsResolverMock, )); $urlModel->getAreaFrontName(); } - public function testGetActionPath() - { - $moduleFrontName = 'moduleFrontName'; - $controllerName = 'controllerName'; - $actionName = 'actionName'; - - $this->_model->setRouteName($moduleFrontName); - $this->_model->setRouteFrontName($moduleFrontName); - $this->_model->setControllerName($controllerName); - $this->_model->setActionName($actionName); - - $actionPath = $this->_model->getActionPath(); - - $this->assertNotEmpty($actionPath); - $this->assertStringStartsWith($this->_areaFrontName . '/', $actionPath); - $this->assertStringMatchesFormat($this->_areaFrontName . '/%s/%s/%s', $actionPath); - } - - public function testGetActionPathWhenAreaFrontNameIsEmpty() - { - $helperMock = $this->getMock('Magento\Backend\Helper\Data', array(), array(), '', false); - $helperMock->expects($this->once())->method('getAreaFrontName') - ->will($this->returnValue('')); - - $helper = new \Magento\TestFramework\Helper\ObjectManager($this); - $urlModel = $helper->getObject('Magento\Backend\Model\Url', array( - 'backendHelper' => $helperMock, - 'authSession' => $this->_authSessionMock - )); - - $moduleFrontName = 'moduleFrontName'; - $controllerName = 'controllerName'; - $actionName = 'actionName'; - - $urlModel->setRouteName($moduleFrontName); - $urlModel->setRouteFrontName($moduleFrontName); - $urlModel->setControllerName($controllerName); - $urlModel->setActionName($actionName); - - $actionPath = $urlModel->getActionPath(); - - $this->assertNotEmpty($actionPath); - $this->assertStringStartsWith($moduleFrontName . '/', $actionPath); - $this->assertStringMatchesFormat($moduleFrontName . '/%s/%s', $actionPath); - } - /** * Check that secret key generation is based on usage of routeName passed as method param * Params are not equals diff --git a/dev/tests/unit/testsuite/Magento/Bundle/Model/Product/CatalogPriceTest.php b/dev/tests/unit/testsuite/Magento/Bundle/Model/Product/CatalogPriceTest.php new file mode 100644 index 0000000000000000000000000000000000000000..dc10cf9be9f4443cf9ecf380775ad4ad594bde18 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Bundle/Model/Product/CatalogPriceTest.php @@ -0,0 +1,123 @@ +<?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\Bundle\Model\Product; + +class CatalogPriceTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Bundle\Model\Product\CatalogPrice + */ + protected $catalogPrice; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $storeManagerMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $commonPriceMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $coreRegistryMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $productMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $priceModelMock; + + protected function setUp() + { + $this->storeManagerMock = $this->getMock('Magento\Core\Model\StoreManagerInterface'); + $this->commonPriceMock + = $this->getMock('Magento\Catalog\Model\Product\CatalogPrice', array(), array(), '', false); + $this->coreRegistryMock = $this->getMock('Magento\Core\Model\Registry', array(), array(), '', false); + $methods = array('getStoreId', 'getWebsiteId', 'getCustomerGroupId', 'getPriceModel', '__wakeup'); + $this->productMock = $this->getMock('Magento\Catalog\Model\Product', $methods, array(), '', false); + $this->priceModelMock + = $this->getMock('Magento\Catalog\Model\Product\Type\Price', array('getTotalPrices'), array(), '', false); + $this->catalogPrice = new \Magento\Bundle\Model\Product\CatalogPrice( + $this->storeManagerMock, + $this->commonPriceMock, + $this->coreRegistryMock + ); + } + + public function testGetCatalogPriceWithCurrentStore() + { + $this->coreRegistryMock->expects($this->once())->method('unregister')->with('rule_data'); + $this->productMock->expects($this->once())->method('getStoreId')->will($this->returnValue('store_id')); + $this->productMock->expects($this->once())->method('getWebsiteId')->will($this->returnValue('website_id')); + $this->productMock->expects($this->once())->method('getCustomerGroupId')->will($this->returnValue('group_id')); + $this->coreRegistryMock->expects($this->once())->method('register'); + $this->productMock + ->expects($this->once()) + ->method('getPriceModel') + ->will($this->returnValue($this->priceModelMock)); + $this->priceModelMock + ->expects($this->once()) + ->method('getTotalPrices') + ->with($this->productMock, 'min', false) + ->will($this->returnValue(15)); + $this->storeManagerMock->expects($this->never())->method('getStore'); + $this->storeManagerMock->expects($this->never())->method('setCurrentStore'); + $this->assertEquals(15, $this->catalogPrice->getCatalogPrice($this->productMock)); + } + + public function testGetCatalogPriceWithCustomStore() + { + $storeMock = $this->getMock('Magento\Core\Model\Store', array(), array(), '', false); + $this->coreRegistryMock->expects($this->once())->method('unregister')->with('rule_data'); + $this->productMock->expects($this->once())->method('getStoreId')->will($this->returnValue('store_id')); + $this->productMock->expects($this->once())->method('getWebsiteId')->will($this->returnValue('website_id')); + $this->productMock->expects($this->once())->method('getCustomerGroupId')->will($this->returnValue('group_id')); + $this->coreRegistryMock->expects($this->once())->method('register'); + $this->productMock + ->expects($this->once()) + ->method('getPriceModel') + ->will($this->returnValue($this->priceModelMock)); + $this->priceModelMock + ->expects($this->once()) + ->method('getTotalPrices') + ->with($this->productMock, 'min', true) + ->will($this->returnValue(15)); + $this->storeManagerMock->expects($this->exactly(2))->method('setCurrentStore'); + $this->assertEquals(15, $this->catalogPrice->getCatalogPrice($this->productMock, $storeMock, true)); + } + + public function testGetCatalogRegularPrice() + { + $this->assertEquals(null, $this->catalogPrice->getCatalogRegularPrice($this->productMock)); + } +} + diff --git a/dev/tests/unit/testsuite/Magento/Captcha/Helper/Adminhtml/DataTest.php b/dev/tests/unit/testsuite/Magento/Captcha/Helper/Adminhtml/DataTest.php index 7e7623a55e196deaa16111df914d947b6874d85a..d6bbc494040cde5aa9ab60a23e81463523a8bf23 100644 --- a/dev/tests/unit/testsuite/Magento/Captcha/Helper/Adminhtml/DataTest.php +++ b/dev/tests/unit/testsuite/Magento/Captcha/Helper/Adminhtml/DataTest.php @@ -41,7 +41,7 @@ class DataTest extends \PHPUnit_Framework_TestCase { $backendConfig = $this->getMockBuilder('Magento\Backend\App\ConfigInterface') ->disableOriginalConstructor() - ->setMethods(array('getValue', 'setValue', 'reinit', 'getFlag')) + ->setMethods(array('getValue', 'setValue', 'reinit', 'isSetFlag')) ->getMock(); $backendConfig->expects($this->any()) ->method('getValue') @@ -57,7 +57,7 @@ class DataTest extends \PHPUnit_Framework_TestCase $this->_model = new \Magento\Captcha\Helper\Adminhtml\Data( $this->getMock('Magento\App\Helper\Context', array(), array(), '', false), $this->getMock('Magento\Core\Model\StoreManager', array(), array(), '', false), - $this->getMock('Magento\Core\Model\Config', array(), array(), '', false), + $this->getMock('Magento\App\ConfigInterface', array(), array(), '', false), $filesystemMock, $this->getMock('Magento\Captcha\Model\CaptchaFactory', array(), array(), '', false), $backendConfig diff --git a/dev/tests/unit/testsuite/Magento/Captcha/Helper/DataTest.php b/dev/tests/unit/testsuite/Magento/Captcha/Helper/DataTest.php index 4010ce04559bcb54ac0aa55b18c1e24f1e3759eb..5ccfebf22e7d0991813c78d1b15f81b388c0d9cd 100644 --- a/dev/tests/unit/testsuite/Magento/Captcha/Helper/DataTest.php +++ b/dev/tests/unit/testsuite/Magento/Captcha/Helper/DataTest.php @@ -161,13 +161,13 @@ class DataTest extends \PHPUnit_Framework_TestCase /** * Create Config Stub * - * @return \Magento\Core\Model\Config + * @return \Magento\App\ConfigInterface */ protected function _getConfigStub() { $config = $this->getMock( - 'Magento\Core\Model\Config', - array('getValue'), + 'Magento\App\ConfigInterface', + array(), array(), '', false ); diff --git a/dev/tests/unit/testsuite/Magento/Captcha/Model/ObserverTest.php b/dev/tests/unit/testsuite/Magento/Captcha/Model/ObserverTest.php index 611191c4cb4915a7b40adb6baf36511db8d711f3..f7f6a3f2dbf2512dc72449a53dd81239b3d003c9 100644 --- a/dev/tests/unit/testsuite/Magento/Captcha/Model/ObserverTest.php +++ b/dev/tests/unit/testsuite/Magento/Captcha/Model/ObserverTest.php @@ -112,7 +112,7 @@ class ObserverTest extends \PHPUnit_Framework_TestCase $this->_coreData = $this->getMock('Magento\Core\Helper\Data', array(), array(), '', false); $this->_customerData = $this->getMock('Magento\Customer\Helper\Data', array(), array(), '', false); $this->_helper = $this->getMock('Magento\Captcha\Helper\Data', array(), array(), '', false); - $this->_urlManager = $this->getMock('Magento\Core\Model\Url', array(), array(), '', false); + $this->_urlManager = $this->getMock('Magento\Url', array(), array(), '', false); $this->_actionFlag = $this->getMock('Magento\App\ActionFlag', array(), array(), '', false); $this->_messageManager = $this->getMock('\Magento\Message\ManagerInterface', array(), array(), '', false); $this->redirect = $this->getMock('\Magento\App\Response\RedirectInterface', array(), array(), '', false); diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Helper/UrlTest.php b/dev/tests/unit/testsuite/Magento/Catalog/Helper/UrlTest.php index 688a66ee444665166113acb8e9a4f41ddf3020bb..e253ba82ccfa6d82b8f310d45c83da038cc6f56b 100644 --- a/dev/tests/unit/testsuite/Magento/Catalog/Helper/UrlTest.php +++ b/dev/tests/unit/testsuite/Magento/Catalog/Helper/UrlTest.php @@ -29,7 +29,7 @@ namespace Magento\Catalog\Helper; class UrlTest extends \PHPUnit_Framework_TestCase { - /** @var \Magento\Core\Model\Config */ + /** @var \Magento\App\ConfigInterface */ protected $_configMock; /** @var \Magento\Catalog\Helper\Product\Url */ @@ -38,7 +38,7 @@ class UrlTest extends \PHPUnit_Framework_TestCase protected function setUp() { $contextMock = $this->getMockBuilder('Magento\App\Helper\Context')->disableOriginalConstructor()->getMock(); - $this->_configMock = $this->getMockBuilder('Magento\Core\Model\Config') + $this->_configMock = $this->getMockBuilder('Magento\App\ConfigInterface') ->disableOriginalConstructor()->getMock(); $storeManager = $this->getMock('Magento\Core\Model\StoreManager', array(), array(), '', false); $this->_urlHelper = new \Magento\Catalog\Helper\Product\Url( diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Model/ObserverTest.php b/dev/tests/unit/testsuite/Magento/Catalog/Model/ObserverTest.php index 949acd776316599215c856abcb6e34649914bf11..e1f2b361e93820080e40d0433cfaf6b577e68110 100644 --- a/dev/tests/unit/testsuite/Magento/Catalog/Model/ObserverTest.php +++ b/dev/tests/unit/testsuite/Magento/Catalog/Model/ObserverTest.php @@ -67,7 +67,7 @@ class ObserverTest extends \PHPUnit_Framework_TestCase $this->_catalogCategoryFlat = $this->getMock( 'Magento\Catalog\Helper\Category\Flat', array(), array(), '', false ); - $coreConfig = $this->getMock('Magento\Core\Model\Config', array(), array(), '', false); + $coreConfig = $this->getMock('Magento\App\ReinitableConfigInterface', array(), array(), '', false); $this->_model = $this->_objectHelper->getObject('Magento\Catalog\Model\Observer', array( 'catalogCategory' => $this->_catalogCategory, 'catalogData' => $this->_catalogData, diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Model/Product/Attribute/Backend/Groupprice/AbstractTest.php b/dev/tests/unit/testsuite/Magento/Catalog/Model/Product/Attribute/Backend/Groupprice/AbstractTest.php index 05b69e6d25e18e679b99f2d4a054ec737c743894..773b9c62f8d7fe5772331f6f4c02889b2c7265fa 100644 --- a/dev/tests/unit/testsuite/Magento/Catalog/Model/Product/Attribute/Backend/Groupprice/AbstractTest.php +++ b/dev/tests/unit/testsuite/Magento/Catalog/Model/Product/Attribute/Backend/Groupprice/AbstractTest.php @@ -52,7 +52,7 @@ class AbstractTest extends \PHPUnit_Framework_TestCase $currencyFactoryMock = $this->getMock('Magento\Directory\Model\CurrencyFactory', array(), array(), '', false); $storeManagerMock = $this->getMock('Magento\Core\Model\StoreManagerInterface', array(), array(), '', false); $productTypeMock = $this->getMock('Magento\Catalog\Model\Product\Type', array(), array(), '', false); - $configMock = $this->getMock('Magento\Core\Model\Config', array(), array(), '', false); + $configMock = $this->getMock('Magento\App\ConfigInterface', array(), array(), '', false); $this->_model = $this->getMockForAbstractClass( 'Magento\Catalog\Model\Product\Attribute\Backend\Groupprice\AbstractGroupprice', diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Model/Product/CartConfigurationTest.php b/dev/tests/unit/testsuite/Magento/Catalog/Model/Product/CartConfigurationTest.php new file mode 100644 index 0000000000000000000000000000000000000000..c557a34b1a1c01fc01724d5ad4c895779c8e9b2b --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Catalog/Model/Product/CartConfigurationTest.php @@ -0,0 +1,54 @@ +<?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\Catalog\Model\Product; + +class CartConfigurationTest extends \PHPUnit_Framework_TestCase +{ + /** + * @param string $productType + * @param array $config + * @param boolean $expected + * @dataProvider isProductConfiguredDataProvider + */ + public function testIsProductConfigured($productType, $config, $expected) + { + $cartConfiguration = new \Magento\Catalog\Model\Product\CartConfiguration(); + $productMock = $this->getMock('Magento\Catalog\Model\Product', array(), array(), '', false); + $productMock->expects($this->once())->method('getTypeId')->will($this->returnValue($productType)); + $this->assertEquals($expected, $cartConfiguration->isProductConfigured($productMock, $config)); + } + + public function isProductConfiguredDataProvider() + { + return array( + 'simple' => array('simple', array(), false), + 'virtual' => array('virtual', array('options' => true), true), + 'configurable' => array('configurable',array('super_attribute' => false), true), + 'bundle' => array('bundle', array('bundle_option' => 'option1'), true), + 'some_option_type' => array('some_option_type', array(), false) + ); + } +} + diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Model/Product/CatalogPriceTest.php b/dev/tests/unit/testsuite/Magento/Catalog/Model/Product/CatalogPriceTest.php new file mode 100644 index 0000000000000000000000000000000000000000..7af24994d94b2526f430ef1da6f694dff57340bd --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Catalog/Model/Product/CatalogPriceTest.php @@ -0,0 +1,104 @@ +<?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\Catalog\Model\Product; + +class CatalogPriceTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Catalog\Model\Product\CatalogPrice + */ + protected $model; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $priceFactoryMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $productMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $catalogPriceInterfaceMock; + + public function setUp() + { + $this->priceFactoryMock = $this->getMock('Magento\Catalog\Model\Product\CatalogPriceFactory', + array(), array(), '', false); + $this->productMock = $this->getMock('\Magento\Catalog\Model\Product', array(), array(), '', false); + $this->catalogPriceInterfaceMock = $this->getMock('Magento\Catalog\Model\Product\CatalogPriceInterface'); + $this->model = new \Magento\Catalog\Model\Product\CatalogPrice( + $this->priceFactoryMock, + array('custom_product_type' => 'CustomProduct/Model/CatalogPrice') + ); + } + + public function testGetCatalogPriceWhenPoolContainsPriceModelForGivenProductType() + { + $this->productMock->expects($this->any()) + ->method('getTypeId') + ->will($this->returnValue('custom_product_type')); + $this->priceFactoryMock->expects($this->once()) + ->method('create') + ->with('CustomProduct/Model/CatalogPrice') + ->will($this->returnValue($this->catalogPriceInterfaceMock)); + $this->catalogPriceInterfaceMock->expects($this->once())->method('getCatalogPrice'); + $this->productMock->expects($this->never())->method('getFinalPrice'); + $this->model->getCatalogPrice($this->productMock); + } + + public function testGetCatalogPriceWhenPoolDoesNotContainPriceModelForGivenProductType() + { + $this->productMock->expects($this->any())->method('getTypeId')->will($this->returnValue('test')); + $this->priceFactoryMock->expects($this->never())->method('create'); + $this->productMock->expects($this->once())->method('getFinalPrice'); + $this->catalogPriceInterfaceMock->expects($this->never())->method('getCatalogPrice'); + $this->model->getCatalogPrice($this->productMock); + } + + public function testGetCatalogRegularPriceWhenPoolDoesNotContainPriceModelForGivenProductType() + { + $this->productMock->expects($this->any())->method('getTypeId')->will($this->returnValue('test')); + $this->priceFactoryMock->expects($this->never())->method('create'); + $this->catalogPriceInterfaceMock->expects($this->never())->method('getCatalogRegularPrice'); + $this->productMock->expects($this->once())->method('getPrice'); + $this->model->getCatalogRegularPrice($this->productMock); + } + + public function testGetCatalogRegularPriceWhenPoolContainsPriceModelForGivenProductType() + { + $this->productMock->expects($this->any()) + ->method('getTypeId')->will($this->returnValue('custom_product_type')); + $this->priceFactoryMock->expects($this->once()) + ->method('create')->with('CustomProduct/Model/CatalogPrice') + ->will($this->returnValue($this->catalogPriceInterfaceMock)); + $this->catalogPriceInterfaceMock->expects($this->once())->method('getCatalogRegularPrice'); + $this->productMock->expects($this->never())->method('getPrice'); + $this->model->getCatalogRegularPrice($this->productMock); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Model/ProductTypes/Config/_files/invalidProductTypesMergedXmlArray.php b/dev/tests/unit/testsuite/Magento/Catalog/Model/ProductTypes/Config/_files/invalidProductTypesMergedXmlArray.php index 603ccc4f9861ec75663c1e0572db89df992a9308..32c88ddc8cb4168d988890e0ea48ddeb24a5902d 100644 --- a/dev/tests/unit/testsuite/Magento/Catalog/Model/ProductTypes/Config/_files/invalidProductTypesMergedXmlArray.php +++ b/dev/tests/unit/testsuite/Magento/Catalog/Model/ProductTypes/Config/_files/invalidProductTypesMergedXmlArray.php @@ -23,12 +23,13 @@ */ return array ( - 'without_required_type_handle' => array( - '<?xml version="1.0" encoding="UTF-8"?><config></config>', - array("Element 'config': Missing child element(s). Expected is ( type ).")), 'type_without_required_name' => array( '<?xml version="1.0" encoding="UTF-8"?><config><type label="some label" modelInstance="model_name" /></config>', - array("Element 'type': The attribute 'name' is required but missing.")), + array( + "Element 'type': The attribute 'name' is required but missing.", + "Element 'type': Not all fields of key identity-constraint 'productTypeKey' evaluate to a node." + ) + ), 'type_without_required_label' => array( '<?xml version="1.0" encoding="UTF-8"?><config><type name="some_name" modelInstance="model_name" /></config>', array("Element 'type': The attribute 'label' is required but missing.")), diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Model/ProductTypes/Config/_files/invalidProductTypesXmlArray.php b/dev/tests/unit/testsuite/Magento/Catalog/Model/ProductTypes/Config/_files/invalidProductTypesXmlArray.php index 568c9012c1eebc23d21827ba1b4cfa91e49f3601..45155c4afbc3036329feacbbf39dfddd66b5d505 100644 --- a/dev/tests/unit/testsuite/Magento/Catalog/Model/ProductTypes/Config/_files/invalidProductTypesXmlArray.php +++ b/dev/tests/unit/testsuite/Magento/Catalog/Model/ProductTypes/Config/_files/invalidProductTypesXmlArray.php @@ -23,9 +23,6 @@ */ return array ( - 'without_required_type_handle' => array( - '<?xml version="1.0"?><config></config>', - array("Element 'config': Missing child element(s). Expected is ( type ).")), 'types_with_same_name_attribute_value' => array( '<?xml version="1.0"?><config><type name="some_name" /><type name="some_name" /></config>', array("Element 'type': Duplicate key-sequence ['some_name'] in unique identity-constraint 'uniqueTypeName'.")), diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Model/ProductTypes/Config/_files/product_types.php b/dev/tests/unit/testsuite/Magento/Catalog/Model/ProductTypes/Config/_files/product_types.php index 282ece99d44606bfdd12d8e11047d7277a4e64b3..7b6eadc58aec5072eaea8f20ebd3bfe912ce979c 100644 --- a/dev/tests/unit/testsuite/Magento/Catalog/Model/ProductTypes/Config/_files/product_types.php +++ b/dev/tests/unit/testsuite/Magento/Catalog/Model/ProductTypes/Config/_files/product_types.php @@ -22,46 +22,46 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ return array( - 'type_one' => array( - 'name' => 'type_one', - 'label' => 'Label One', - 'model' => 'Instance_Type', - 'composite' => true, - 'index_priority' => 40, - 'can_use_qty_decimals' => true, - 'is_qty' => true, - 'price_model' => 'Instance_Type_One', - 'price_indexer' => 'Instance_Type_Two', - 'stock_indexer' => 'Instance_Type_Three', - 'allow_product_types' => array( - 'type_one' => 'type_one' + 'types' => array( + 'type_one' => array( + 'name' => 'type_one', + 'label' => 'Label One', + 'model' => 'Instance_Type', + 'composite' => true, + 'index_priority' => 40, + 'can_use_qty_decimals' => true, + 'is_qty' => true, + 'price_model' => 'Instance_Type_One', + 'price_indexer' => 'Instance_Type_Two', + 'stock_indexer' => 'Instance_Type_Three', ), - ), - 'type_two' => array( - 'name' => 'type_two', - 'label' => false, - 'model' => 'Instance_Type', - 'composite' => false, - 'index_priority' => 0, - 'can_use_qty_decimals' => true, - 'is_qty' => false, - 'allowed_selection_types' => array( - 'type_two' => 'type_two' + 'type_two' => array( + 'name' => 'type_two', + 'label' => false, + 'model' => 'Instance_Type', + 'composite' => false, + 'index_priority' => 0, + 'can_use_qty_decimals' => true, + 'is_qty' => false, + 'allowed_selection_types' => array( + 'type_two' => 'type_two' + ), + 'custom_attributes' => array( + 'some_name' => 'some_value' + ), + ), + 'type_three' => array( + 'name' => 'type_three', + 'label' => 'Label Three', + 'model' => 'Instance_Type', + 'composite' => false, + 'index_priority' => 20, + 'can_use_qty_decimals' => false, + 'is_qty' => false, + 'price_model' => 'Instance_Type_Three', + 'price_indexer' => 'Instance_Type_Three', + 'stock_indexer' => 'Instance_Type_Three', ) ), - 'type_three' => array( - 'name' => 'type_three', - 'label' => 'Label Three', - 'model' => 'Instance_Type', - 'composite' => false, - 'index_priority' => 20, - 'can_use_qty_decimals' => false, - 'is_qty' => false, - 'price_model' => 'Instance_Type_Three', - 'price_indexer' => 'Instance_Type_Three', - 'stock_indexer' => 'Instance_Type_Three', - 'allow_product_types' => array( - 'type_three' => 'type_three' - ) - ) + 'composableTypes' => array('type_one' => 'type_one', 'type_three' => 'type_three'), ); diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Model/ProductTypes/Config/_files/product_types.xml b/dev/tests/unit/testsuite/Magento/Catalog/Model/ProductTypes/Config/_files/product_types.xml index b68eaa253d1a9bf2b79fc014c7af7e4245f21404..7437f1e69b7b451a87e6539e0bf4efe67f714ffa 100644 --- a/dev/tests/unit/testsuite/Magento/Catalog/Model/ProductTypes/Config/_files/product_types.xml +++ b/dev/tests/unit/testsuite/Magento/Catalog/Model/ProductTypes/Config/_files/product_types.xml @@ -29,22 +29,23 @@ <indexerModel instance="Instance_Type_Two" /> <false/> <stockIndexerModel instance="Instance_Type_Three" /> - <allowProductTypes> - <type name="type_one" /> - </allowProductTypes> </type> <type name="type_two" modelInstance="Instance_Type"> <allowedSelectionTypes> <type name="type_two" /> </allowedSelectionTypes> + <customAttributes> + <attribute name="some_name" value="some_value" /> + </customAttributes> </type> <type name="type_three" label="Label Three" modelInstance="Instance_Type" composite="false" indexPriority="20" canUseQtyDecimals="false" isQty="false"> <priceModel instance="Instance_Type_Three" /> <indexerModel instance="Instance_Type_Three" /> <false/> <stockIndexerModel instance="Instance_Type_Three" /> - <allowProductTypes> - <type name="type_three" /> - </allowProductTypes> </type> + <composableTypes> + <type name="type_one" /> + <type name="type_three" /> + </composableTypes> </config> diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Model/ProductTypes/Config/_files/valid_product_types_merged.xml b/dev/tests/unit/testsuite/Magento/Catalog/Model/ProductTypes/Config/_files/valid_product_types_merged.xml index 67b7da684451d4cdde6f4f1eb6ccbc6300484d4c..c45846bb8adae27ffb27096279faf84ee6789ac6 100644 --- a/dev/tests/unit/testsuite/Magento/Catalog/Model/ProductTypes/Config/_files/valid_product_types_merged.xml +++ b/dev/tests/unit/testsuite/Magento/Catalog/Model/ProductTypes/Config/_files/valid_product_types_merged.xml @@ -25,9 +25,6 @@ --> <config> <type label="some_label" name="some_name" modelInstance="model_name"> - <allowProductTypes> - <type name="type_name"/> - </allowProductTypes> <allowedSelectionTypes> <type name="some_name" /> </allowedSelectionTypes> @@ -36,9 +33,6 @@ <stockIndexerModel instance="instance_name"/> </type> <type label="some_label" name="some_name2" modelInstance="model_name"> - <allowProductTypes> - <type name="type_name"/> - </allowProductTypes> <allowedSelectionTypes> <type name="some_name" /> </allowedSelectionTypes> @@ -46,4 +40,8 @@ <indexerModel instance="instance_name" /> <stockIndexerModel instance="instance_name"/> </type> + <composableTypes> + <type name="some_name"/> + <type name="some_name2"/> + </composableTypes> </config> diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Model/ProductTypes/ConfigTest.php b/dev/tests/unit/testsuite/Magento/Catalog/Model/ProductTypes/ConfigTest.php index 8dde9c01b1af872d77540f382a017601f8fb2481..51d809d42df427ad63308622cb531588f05f1ea9 100644 --- a/dev/tests/unit/testsuite/Magento/Catalog/Model/ProductTypes/ConfigTest.php +++ b/dev/tests/unit/testsuite/Magento/Catalog/Model/ProductTypes/ConfigTest.php @@ -64,15 +64,17 @@ class ConfigTest extends \PHPUnit_Framework_TestCase public function getTypeDataProvider() { return array( - 'global_key_exist' => array(array('global' => 'value'), 'value'), - 'return_default_value' => array(array('some_key' => 'value'), array()) + 'global_key_exist' => array(array('types' => array('global' => 'value')), 'value'), + 'return_default_value' => array(array('types' => array('some_key' => 'value')), array()) ); } public function testGetAll() { $expected = array('Expected Data'); - $this->cacheMock->expects($this->once())->method('load')->will($this->returnValue(serialize($expected))); + $this->cacheMock->expects($this->once())->method('load')->will($this->returnValue( + serialize(array('types' => $expected))) + ); $this->model = new \Magento\Catalog\Model\ProductTypes\Config( $this->readerMock, $this->cacheMock, diff --git a/dev/tests/unit/testsuite/Magento/CatalogSearch/Block/ResultTest.php b/dev/tests/unit/testsuite/Magento/CatalogSearch/Block/ResultTest.php new file mode 100644 index 0000000000000000000000000000000000000000..2b47bfde9707a3a596946a281a27c59d3058de4c --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/CatalogSearch/Block/ResultTest.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\CatalogSearch\Block; + +/** + * Unit test for \Magento\CatalogSearch\Block\Result + */ +class ResultTest extends \PHPUnit_Framework_TestCase +{ + /** @var \Magento\CatalogSearch\Block\Result */ + protected $model; + + /** @var \Magento\View\Element\Template\Context|\PHPUnit_Framework_MockObject_MockObject */ + protected $contextMock; + + /** @var \Magento\Catalog\Model\Layer|\PHPUnit_Framework_MockObject_MockObject */ + protected $layerMock; + + /** @var \Magento\CatalogSearch\Helper\Data|\PHPUnit_Framework_MockObject_MockObject */ + protected $dataMock; + + /** + * @var \Magento\Catalog\Block\Product\ListProduct|\PHPUnit_Framework_MockObject_MockObject + */ + protected $childBlockMock; + + public function setUp() + { + $this->contextMock = $this->getMock('Magento\View\Element\Template\Context', [], [], '', false); + $this->layerMock = $this->getMock('Magento\Catalog\Model\Layer', [], [], '', false); + $this->dataMock = $this->getMock('Magento\CatalogSearch\Helper\Data', [], [], '', false); + $this->model = new Result($this->contextMock, $this->layerMock, $this->dataMock); + } + + public function testGetSearchQueryText() + { + $this->dataMock->expects($this->once())->method('getEscapedQueryText')->will($this->returnValue('query_text')); + $this->assertEquals('Search results for: \'query_text\'', $this->model->getSearchQueryText()); + } + + public function testGetNoteMessages() + { + $this->dataMock->expects($this->once())->method('getNoteMessages')->will($this->returnValue('SOME-MESSAGE')); + $this->assertEquals('SOME-MESSAGE', $this->model->getNoteMessages()); + } + + /** + * @param bool $isMinQueryLength + * @param string $expectedResult + * @dataProvider getNoResultTextDataProvider + */ + public function testGetNoResultText($isMinQueryLength, $expectedResult) + { + $this->dataMock->expects($this->once()) + ->method('isMinQueryLength') + ->will($this->returnValue($isMinQueryLength)); + if ($isMinQueryLength) { + $queryMock = $this->getMock('Magento\CatalogSearch\Model\Query', [], [], '', false); + $queryMock->expects($this->once())->method('getMinQueryLength')->will($this->returnValue('5')); + + $this->dataMock->expects($this->once()) + ->method('getQuery') + ->will($this->returnValue($queryMock)); + } + $this->assertEquals($expectedResult, $this->model->getNoResultText()); + } + + /** + * @return array + */ + public function getNoResultTextDataProvider() + { + return array( + array(true, 'Minimum Search query length is 5'), + array(false, null), + ); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Centinel/Model/ServiceTest.php b/dev/tests/unit/testsuite/Magento/Centinel/Model/ServiceTest.php index 3ba23c5ffadedb72c3a8addf8c2a2670f069a571..7ec135263921cb3673eef9823992bffad656df30 100644 --- a/dev/tests/unit/testsuite/Magento/Centinel/Model/ServiceTest.php +++ b/dev/tests/unit/testsuite/Magento/Centinel/Model/ServiceTest.php @@ -35,7 +35,7 @@ class ServiceTest extends \PHPUnit_Framework_TestCase */ public function testGetAuthenticationStartUrl() { - $url = $this->getMock('Magento\Core\Model\Url', ['getUrl'], [], '', false); + $url = $this->getMock('Magento\Url', ['getUrl'], [], '', false); $url->expects($this->once()) ->method('getUrl') ->with( diff --git a/dev/tests/unit/testsuite/Magento/Checkout/Block/Cart/AbstractTest.php b/dev/tests/unit/testsuite/Magento/Checkout/Block/Cart/AbstractTest.php index 4724125369f97308947cd2104b87e947ffb84235..24782e9c4e438e989c8d70a1b65de6d9977707c7 100644 --- a/dev/tests/unit/testsuite/Magento/Checkout/Block/Cart/AbstractTest.php +++ b/dev/tests/unit/testsuite/Magento/Checkout/Block/Cart/AbstractTest.php @@ -25,7 +25,9 @@ namespace Magento\Checkout\Block\Cart; class AbstractTest extends \PHPUnit_Framework_TestCase { - /** @var \Magento\TestFramework\Helper\ObjectManager */ + /** + * @var \Magento\TestFramework\Helper\ObjectManager + */ protected $_objectManager; protected function setUp() @@ -35,92 +37,54 @@ class AbstractTest extends \PHPUnit_Framework_TestCase public function testGetItemRenderer() { - $renderer = $this->getMock('Magento\View\Element\AbstractBlock', array('setRenderedBlock'), array(), '', false); + $renderer = $this->getMock('Magento\View\Element\RendererList', array(), array(), '', false); + + $renderer->expects($this->once())->method('getRenderer') + ->with('some-type', AbstractCart::DEFAULT_TYPE)->will($this->returnValue('rendererObject')); + $layout = $this->getMock('Magento\Core\Model\Layout', array( 'getChildName', 'getBlock' ), array(), '', false); - $layout->expects($this->at(0)) + + $layout->expects($this->once()) ->method('getChildName') - ->with(null, 'some-type') - ->will($this->returnValue('some-block-name')); - $layout->expects($this->at(1)) + ->will($this->returnValue('renderer.list')); + + $layout->expects($this->once()) ->method('getBlock') - ->with('some-block-name') + ->with('renderer.list') ->will($this->returnValue($renderer)); - /** @var $block \Magento\Checkout\Block\Cart\AbstractCart */ + /** @var $block \Magento\Sales\Block\Items\AbstractItems */ $block = $this->_objectManager->getObject('Magento\Checkout\Block\Cart\AbstractCart', array( 'context' => $this->_objectManager->getObject('Magento\Backend\Block\Template\Context', array( - 'layout' => $layout, - )) + 'layout' => $layout, + )) )); - $renderer->expects($this->once()) - ->method('setRenderedBlock') - ->with($block); - - $this->assertSame($renderer, $block->getItemRenderer('some-type')); + $this->assertSame('rendererObject', $block->getItemRenderer('some-type')); } /** * @expectedException \RuntimeException - * @expectedExceptionMessage Renderer for type "some-type" does not exist. + * @expectedExceptionMessage Renderer list for block "" is not defined */ public function testGetItemRendererThrowsExceptionForNonexistentRenderer() { - $renderer = $this->getMock('StdClass'); $layout = $this->getMock('Magento\Core\Model\Layout', array( 'getChildName', 'getBlock' ), array(), '', false); - $layout->expects($this->at(0)) - ->method('getChildName') - ->with(null, 'some-type') - ->will($this->returnValue('some-block-name')); - $layout->expects($this->at(1)) - ->method('getBlock') - ->with('some-block-name') - ->will($this->returnValue($renderer)); - - /** @var $block \Magento\Checkout\Block\Cart\AbstractCart */ - $block = $this->_objectManager->getObject('Magento\Checkout\Block\Cart\AbstractCart', array( - 'context' => $this->_objectManager->getObject('Magento\Backend\Block\Template\Context', array( - 'layout' => $layout, - )) - )); - - $block->getItemRenderer('some-type'); - } - - public function testPrepareLayout() - { - $childBlock = $this->getMock('Magento\View\Element\AbstractBlock', array(), array(), '', false); - /** @var $layout \Magento\View\LayoutInterface */ - $layout = $this->getMock('Magento\Core\Model\Layout', array( - 'createBlock', 'getChildName', 'setChild' - ), array(), '', false); $layout->expects($this->once()) - ->method('createBlock') - ->with( - 'Magento\Checkout\Block\Cart\Item\Renderer', - '.default', - array('data' => array('template' => 'cart/item/default.phtml')) - ) - ->will($this->returnValue($childBlock)); - $layout->expects($this->any()) ->method('getChildName') - ->with(null, 'default') - ->will($this->returnValue(false)); - $layout->expects($this->once()) - ->method('setChild') - ->with(null, null, 'default'); + ->will($this->returnValue(null)); /** @var $block \Magento\Checkout\Block\Cart\AbstractCart */ $block = $this->_objectManager->getObject('Magento\Checkout\Block\Cart\AbstractCart', array( 'context' => $this->_objectManager->getObject('Magento\Backend\Block\Template\Context', array( - 'layout' => $layout, - )) + 'layout' => $layout, + )) )); - $block->setLayout($layout); + $block->getItemRenderer('some-type'); } } diff --git a/dev/tests/unit/testsuite/Magento/Checkout/Block/Cart/SidebarTest.php b/dev/tests/unit/testsuite/Magento/Checkout/Block/Cart/SidebarTest.php index f22fcc191336358f13ab597557c86b150b9da548..786bbfd2a2c1c3df1ac47e4570e5347ce66a55d9 100644 --- a/dev/tests/unit/testsuite/Magento/Checkout/Block/Cart/SidebarTest.php +++ b/dev/tests/unit/testsuite/Magento/Checkout/Block/Cart/SidebarTest.php @@ -40,7 +40,17 @@ class SidebarTest extends \PHPUnit_Framework_TestCase $layout = $this->getMock('Magento\Core\Model\Layout', array( 'createBlock', 'getChildName', 'setChild' ), array(), '', false); - $layout->expects($this->once()) + + $rendererList = $this->_objectManager->getObject('Magento\Checkout\Block\Cart\Sidebar', array( + 'context' => $this->_objectManager->getObject('Magento\Backend\Block\Template\Context', array( + 'layout' => $layout, + )) + ));; + $layout->expects($this->at(0)) + ->method('createBlock') + ->with('Magento\View\Element\RendererList') + ->will($this->returnValue($rendererList)); + $layout->expects($this->at(4)) ->method('createBlock') ->with( 'some-block', @@ -48,11 +58,11 @@ class SidebarTest extends \PHPUnit_Framework_TestCase array('data' => array('template' => 'some-type')) ) ->will($this->returnValue($childBlock)); - $layout->expects($this->any()) + $layout->expects($this->at(5)) ->method('getChildName') ->with(null, 'some-template') ->will($this->returnValue(false)); - $layout->expects($this->once()) + $layout->expects($this->at(6)) ->method('setChild') ->with(null, null, 'some-template'); diff --git a/dev/tests/unit/testsuite/Magento/Config/DomTest.php b/dev/tests/unit/testsuite/Magento/Config/DomTest.php index 85a4b5718af6d49e5c6b0abddd448471dd6ea491..5183360eeb95e7a42216e75f569b2b665b571cfa 100644 --- a/dev/tests/unit/testsuite/Magento/Config/DomTest.php +++ b/dev/tests/unit/testsuite/Magento/Config/DomTest.php @@ -40,10 +40,9 @@ class DomTest extends \PHPUnit_Framework_TestCase { $xml = file_get_contents(__DIR__ . "/_files/dom/{$xmlFile}"); $newXml = file_get_contents(__DIR__ . "/_files/dom/{$newXmlFile}"); - $expectedXml = file_get_contents(__DIR__ . "/_files/dom/{$expectedXmlFile}"); $config = new \Magento\Config\Dom($xml, $ids); $config->merge($newXml); - $this->assertXmlStringEqualsXmlString($expectedXml, $config->getDom()->saveXML()); + $this->assertXmlStringEqualsXmlFile(__DIR__ . "/_files/dom/{$expectedXmlFile}", $config->getDom()->saveXML()); } /** @@ -62,41 +61,37 @@ class DomTest extends \PHPUnit_Framework_TestCase ), array('no_ids.xml', 'no_ids_new.xml', array(), 'no_ids_merged.xml'), array('ambiguous_one.xml', 'ambiguous_new_two.xml', array(), 'ambiguous_merged.xml'), - array('namespaced.xml', 'namespaced_new.xml', array( - '/root/node' => 'id', - ), - 'namespaced_merged.xml' - ), + array('namespaced.xml', 'namespaced_new.xml', array('/root/node' => 'id'), 'namespaced_merged.xml'), array('override_node.xml', 'override_node_new.xml', array(), 'override_node_merged.xml'), array('override_node_new.xml', 'override_node.xml', array(), 'override_node_merged.xml'), array('text_node.xml', 'text_node_new.xml', array(), 'text_node_merged.xml'), + array( + 'recursive.xml', 'recursive_new.xml', array( + '/root/(node|another_node)(/param)?' => 'name', + '/root/node/param(/complex/item)+' => 'key', + ), + 'recursive_merged.xml', + ), + array( + 'recursive_deep.xml', 'recursive_deep_new.xml', + array('/root(/node)+' => 'name'), + 'recursive_deep_merged.xml', + ), ); } /** - * @param string $xmlFile - * @param string $newXmlFile - * @dataProvider mergeExceptionDataProvider * @expectedException \Magento\Exception + * @expectedExceptionMessage More than one node matching the query: /root/node/subnode */ - public function testMergeException($xmlFile, $newXmlFile) + public function testMergeException() { - $xml = file_get_contents(__DIR__ . "/_files/dom/{$xmlFile}"); - $newXml = file_get_contents(__DIR__ . "/_files/dom/{$newXmlFile}"); - $config = new \Magento\Config\Dom($xml, array()); + $xml = file_get_contents(__DIR__ . "/_files/dom/ambiguous_two.xml"); + $newXml = file_get_contents(__DIR__ . "/_files/dom/ambiguous_new_one.xml"); + $config = new \Magento\Config\Dom($xml); $config->merge($newXml); } - /** - * @return array - */ - public function mergeExceptionDataProvider() - { - return array( - array('ambiguous_two.xml', 'ambiguous_new_one.xml') - ); - } - /** * @param string $xml * @param array $expectedErrors diff --git a/dev/tests/unit/testsuite/Magento/Config/ThemeTest.php b/dev/tests/unit/testsuite/Magento/Config/ThemeTest.php index 222d2563938d67a1ff12b4747eb1eaa9b088cd21..a36bcb50662b1260f1038002235403d62dee450d 100644 --- a/dev/tests/unit/testsuite/Magento/Config/ThemeTest.php +++ b/dev/tests/unit/testsuite/Magento/Config/ThemeTest.php @@ -29,20 +29,9 @@ namespace Magento\Config; class ThemeTest extends \PHPUnit_Framework_TestCase { - /** - * @expectedException \InvalidArgumentException - */ - public function testConstructException() - { - new \Magento\Config\Theme(array()); - } - public function testGetSchemaFile() { - $config = new \Magento\Config\Theme(array( - file_get_contents(sprintf('%s/_files/area/%s/theme.xml', __DIR__, 'default_default')) - )); - + $config = new \Magento\Config\Theme(file_get_contents(__DIR__ . '/_files/area/default_default/theme.xml')); $this->assertFileExists($config->getSchemaFile()); } @@ -53,9 +42,7 @@ class ThemeTest extends \PHPUnit_Framework_TestCase */ public function testGetThemeTitle($themePath, $expected) { - $config = new \Magento\Config\Theme(array( - file_get_contents(sprintf('%s/_files/area/%s/theme.xml', __DIR__, $themePath)) - )); + $config = new \Magento\Config\Theme(file_get_contents(__DIR__ . "/_files/area/$themePath/theme.xml")); $this->assertSame($expected, $config->getThemeTitle()); } @@ -77,9 +64,7 @@ class ThemeTest extends \PHPUnit_Framework_TestCase */ public function testGetParentTheme($themePath, $expected) { - $config = new \Magento\Config\Theme(array( - file_get_contents(sprintf('%s/_files/area/%s/theme.xml', __DIR__, $themePath)) - )); + $config = new \Magento\Config\Theme(file_get_contents(__DIR__ . "/_files/area/$themePath/theme.xml")); $this->assertSame($expected, $config->getParentTheme()); } diff --git a/dev/tests/unit/testsuite/Magento/Config/ValidationStateTest.php b/dev/tests/unit/testsuite/Magento/Config/ValidationStateTest.php index 5c623862626e57c24fa91692020dc929e1446779..7af38ade1b6fa664892495ce8ebab8a1a0c4e218 100644 --- a/dev/tests/unit/testsuite/Magento/Config/ValidationStateTest.php +++ b/dev/tests/unit/testsuite/Magento/Config/ValidationStateTest.php @@ -32,7 +32,7 @@ class ValidationStateTest extends \PHPUnit_Framework_TestCase */ public function testIsValidated($appMode, $expectedResult) { - $model = new \Magento\App\Config\ValidationState($appMode); + $model = new \Magento\App\Arguments\ValidationState($appMode); $this->assertEquals($model->isValidated(), $expectedResult); } diff --git a/dev/tests/unit/testsuite/Magento/Config/_files/dom/recursive.xml b/dev/tests/unit/testsuite/Magento/Config/_files/dom/recursive.xml new file mode 100644 index 0000000000000000000000000000000000000000..0cb6154e25a7a71d737e59acfe3fb3db1ac846d9 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Config/_files/dom/recursive.xml @@ -0,0 +1,82 @@ +<?xml version="1.0"?> +<!-- +/** + * 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) + */ +--> +<root> + <node name="node1"> + <param name="scalar1"> + <value>scalar1</value> + </param> + <param name="complex"> + <complex> + <item key="scalar2"> + <value>scalar2</value> + </item> + <item key="scalar3"> + <value>scalar3</value> + </item> + </complex> + </param> + </node> + <node name="node2"> + <param name="recursive"> + <complex> + <item key="recursive1"> + <complex> + <item key="nested1"> + <value>scalar4</value> + </item> + <item key="nested2"> + <value>scalar5</value> + </item> + </complex> + </item> + <item key="recursive2"> + <complex> + <item key="recursive1"><!-- intentionally same names as the above --> + <value>scalar6</value> + </item> + <item key="recursive2"> + <value>scalar7</value> + </item> + </complex> + </item> + <item key="nested_l_1"> + <complex> + <item key="nested_l_2"> + <complex> + <item key="nested_l_3"/> + </complex> + </item> + </complex> + </item> + </complex> + </param> + </node> + <another_node name="node3"> + <param name="scalar4"> + <value>scalar3</value> + </param> + </another_node> +</root> diff --git a/dev/tests/unit/testsuite/Magento/Config/_files/dom/recursive_deep.xml b/dev/tests/unit/testsuite/Magento/Config/_files/dom/recursive_deep.xml new file mode 100644 index 0000000000000000000000000000000000000000..ba6e0e960471799e6e3d48b35701c4f59ee06ecd --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Config/_files/dom/recursive_deep.xml @@ -0,0 +1,77 @@ +<?xml version="1.0"?> +<!-- +/** + * 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) + */ +--> +<!-- any reasonably high depth (should be enough for most of real use cases) --> +<root> + <node name="001"> + <node name="002"> + <node name="003"> + <node name="004"> + <node name="005"> + <node name="006"> + <node name="007"> + <node name="008"> + <node name="009"> + <node name="010"> + <node name="011"> + <node name="012"> + <node name="013"> + <node name="014"> + <node name="015"> + <node name="016"> + <node name="017"> + <node name="018"> + <node name="019"> + <node name="020"> + <node name="021"> + <node name="022"> + <node name="023"> + <node name="024"> + <node name="025"/> + </node> + </node> + </node> + </node> + </node> + </node> + </node> + </node> + </node> + </node> + </node> + </node> + </node> + </node> + </node> + </node> + </node> + </node> + </node> + </node> + </node> + </node> + </node> + </node> +</root> diff --git a/dev/tests/unit/testsuite/Magento/Config/_files/dom/recursive_deep_merged.xml b/dev/tests/unit/testsuite/Magento/Config/_files/dom/recursive_deep_merged.xml new file mode 100644 index 0000000000000000000000000000000000000000..39500bd9d18d79ba6a2190204e35a88062753b29 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Config/_files/dom/recursive_deep_merged.xml @@ -0,0 +1,77 @@ +<?xml version="1.0"?> +<!-- +/** + * 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) + */ +--> +<root> + <node name="001"> + <node name="002"> + <node name="003"> + <node name="004"> + <node name="005"> + <node name="006"> + <node name="007"> + <node name="008"> + <node name="009"> + <node name="010"> + <node name="011"> + <node name="012"> + <node name="013"> + <node name="014"> + <node name="015"> + <node name="016"> + <node name="017"> + <node name="018"> + <node name="019"> + <node name="020"> + <node name="021"> + <node name="022"> + <node name="023"> + <node name="024"> + <node name="025"/> + <node name="026"/> + </node> + </node> + </node> + </node> + </node> + </node> + </node> + </node> + </node> + </node> + </node> + </node> + </node> + </node> + </node> + </node> + </node> + </node> + </node> + </node> + </node> + </node> + </node> + </node> +</root> diff --git a/dev/tests/unit/testsuite/Magento/Config/_files/dom/recursive_deep_new.xml b/dev/tests/unit/testsuite/Magento/Config/_files/dom/recursive_deep_new.xml new file mode 100644 index 0000000000000000000000000000000000000000..2104971cc401ad4c2e66ab33dee98431f4393464 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Config/_files/dom/recursive_deep_new.xml @@ -0,0 +1,76 @@ +<?xml version="1.0"?> +<!-- +/** + * 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) + */ +--> +<root> + <node name="001"> + <node name="002"> + <node name="003"> + <node name="004"> + <node name="005"> + <node name="006"> + <node name="007"> + <node name="008"> + <node name="009"> + <node name="010"> + <node name="011"> + <node name="012"> + <node name="013"> + <node name="014"> + <node name="015"> + <node name="016"> + <node name="017"> + <node name="018"> + <node name="019"> + <node name="020"> + <node name="021"> + <node name="022"> + <node name="023"> + <node name="024"> + <node name="026"/> + </node> + </node> + </node> + </node> + </node> + </node> + </node> + </node> + </node> + </node> + </node> + </node> + </node> + </node> + </node> + </node> + </node> + </node> + </node> + </node> + </node> + </node> + </node> + </node> +</root> diff --git a/dev/tests/unit/testsuite/Magento/Config/_files/dom/recursive_merged.xml b/dev/tests/unit/testsuite/Magento/Config/_files/dom/recursive_merged.xml new file mode 100644 index 0000000000000000000000000000000000000000..82a7386edad50b0642d99b6e616e9f07af83919f --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Config/_files/dom/recursive_merged.xml @@ -0,0 +1,91 @@ +<?xml version="1.0"?> +<!-- +/** + * 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) + */ +--> +<root> + <node name="node1" new_attribute="1"> + <param name="scalar1" new_attribute="2"> + <value new_attribute="3">scalar10</value> + </param> + <param name="complex" new_attribute="4"> + <complex new_attribute="5"> + <item key="scalar2" new_attribute="6"> + <value new_attribute="7">scalar20</value> + </item> + <item key="scalar3" new_attribute="8"> + <value new_attribute="9">scalar30</value> + </item> + <item key="scalar41"> + <value>scalar41</value> + </item> + </complex> + </param> + <param name="scalar11"/> + </node> + <node name="node2" new_attribute="10"> + <param name="recursive" new_attribute="11"> + <complex new_attribute="12"> + <item key="recursive1" new_attribute="13"> + <complex new_attribute="14"> + <item key="nested1" new_attribute="15"> + <value new_attribute="16">scalar40</value> + </item> + <item key="nested2" new_attribute="17"> + <value new_attribute="18">scalar50</value> + </item> + <item key="nested31"> + <value>scalar51</value> + </item> + </complex> + </item> + <item key="recursive2" new_attribute="19"> + <complex new_attribute="20"> + <item key="recursive1" new_attribute="21"> + <value new_attribute="22">scalar60</value> + </item> + <item key="recursive2" new_attribute="23"> + <value new_attribute="24">scalar70</value> + </item> + </complex> + </item> + <item key="nested_l_1"> + <complex> + <item key="nested_l_2"> + <complex> + <item key="nested_l_3"/> + <item key="nested_l_3_1"/> + </complex> + </item> + </complex> + </item> + </complex> + </param> + </node> + <another_node name="node3"> + <param name="scalar4"> + <value>scalar4</value> + </param> + </another_node> + <node name="node31"/> +</root> diff --git a/dev/tests/unit/testsuite/Magento/Config/_files/dom/recursive_new.xml b/dev/tests/unit/testsuite/Magento/Config/_files/dom/recursive_new.xml new file mode 100644 index 0000000000000000000000000000000000000000..cbb036e76a21aa3ad75b8e34a0c9cb6fe17b824f --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Config/_files/dom/recursive_new.xml @@ -0,0 +1,96 @@ +<?xml version="1.0"?> +<!-- +/** + * 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) + */ +--> +<!-- +Variations: +1) override all original values by appending 0 +2) add new sibling on each level (where siblings are applicable) +3) add a "new_attribute" to each of the declared nodes +--> +<root> + <node name="node1" new_attribute="1"> + <param name="scalar1" new_attribute="2"> + <value new_attribute="3">scalar10</value> + </param> + <param name="complex" new_attribute="4"> + <complex new_attribute="5"> + <item key="scalar2" new_attribute="6"> + <value new_attribute="7">scalar20</value> + </item> + <item key="scalar3" new_attribute="8"> + <value new_attribute="9">scalar30</value> + </item> + <item key="scalar41"> + <value>scalar41</value> + </item> + </complex> + </param> + <param name="scalar11"/> + </node> + <node name="node2" new_attribute="10"> + <param name="recursive" new_attribute="11"> + <complex new_attribute="12"> + <item key="recursive1" new_attribute="13"> + <complex new_attribute="14"> + <item key="nested1" new_attribute="15"> + <value new_attribute="16">scalar40</value> + </item> + <item key="nested2" new_attribute="17"> + <value new_attribute="18">scalar50</value> + </item> + <item key="nested31"> + <value>scalar51</value> + </item> + </complex> + </item> + <item key="recursive2" new_attribute="19"> + <complex new_attribute="20"> + <item key="recursive1" new_attribute="21"> + <value new_attribute="22">scalar60</value> + </item> + <item key="recursive2" new_attribute="23"> + <value new_attribute="24">scalar70</value> + </item> + </complex> + </item> + <item key="nested_l_1"> + <complex> + <item key="nested_l_2"> + <complex> + <item key="nested_l_3_1"/> + </complex> + </item> + </complex> + </item> + </complex> + </param> + </node> + <node name="node31"/> + <another_node name="node3"> + <param name="scalar4"> + <value>scalar4</value> + </param> + </another_node> +</root> diff --git a/dev/tests/unit/testsuite/Magento/Core/App/Action/Plugin/InstallTest.php b/dev/tests/unit/testsuite/Magento/Core/App/Action/Plugin/InstallTest.php index 2bc25a4159ed28db85daff186472f1436cce7d45..13f6b3fea34836f0f4d03f2869f8f0b988c4aecc 100644 --- a/dev/tests/unit/testsuite/Magento/Core/App/Action/Plugin/InstallTest.php +++ b/dev/tests/unit/testsuite/Magento/Core/App/Action/Plugin/InstallTest.php @@ -54,7 +54,7 @@ class InstallTest extends \PHPUnit_Framework_TestCase { $this->_appStateMock = $this->getMock('Magento\App\State', array(), array(), '', false); $this->_response = $this->getMock('Magento\App\ResponseInterface', array('setRedirect', 'sendResponse')); - $this->_urlMock = $this->getMock('Magento\Core\Model\Url', array(), array(), '', false); + $this->_urlMock = $this->getMock('Magento\Url', array(), array(), '', false); $this->_invocationChainMock = $this->getMock('Magento\Code\Plugin\InvocationChain', array(), array(), '', false); $this->_plugin = new \Magento\Core\App\Action\Plugin\Install( diff --git a/dev/tests/unit/testsuite/Magento/Core/App/Action/Plugin/LastUrlTest.php b/dev/tests/unit/testsuite/Magento/Core/App/Action/Plugin/LastUrlTest.php index 46e4e6e6a08140b3221c1ce2c58324e22d6a677c..2fbafb2aad368414d38b00cbe2cb8e665c16eed5 100644 --- a/dev/tests/unit/testsuite/Magento/Core/App/Action/Plugin/LastUrlTest.php +++ b/dev/tests/unit/testsuite/Magento/Core/App/Action/Plugin/LastUrlTest.php @@ -28,7 +28,7 @@ class LastUrlTest extends \PHPUnit_Framework_TestCase public function testAfterDispatch() { $session = $this->getMock('\Magento\Core\Model\Session', array('setLastUrl'), array(), '', false); - $url = $this->getMock('\Magento\Core\Model\Url', array(), array(), '', false); + $url = $this->getMock('\Magento\Url', array(), array(), '', false); $plugin = new \Magento\Core\App\Action\Plugin\LastUrl($session, $url); $session->expects($this->once())->method('setLastUrl')->with('http://example.com'); $invocationChainMock = $this->getMock('Magento\Code\Plugin\InvocationChain', array(), array(), '', false); diff --git a/dev/tests/unit/testsuite/Magento/Core/App/FrontController/Plugin/RequestPreprocessorTest.php b/dev/tests/unit/testsuite/Magento/Core/App/FrontController/Plugin/RequestPreprocessorTest.php index b41a21b2e3ce92db9f9a1a0d247a6bb5bf2311f0..bc533ef0ea51466a638223178808d25c8a4c35ae 100644 --- a/dev/tests/unit/testsuite/Magento/Core/App/FrontController/Plugin/RequestPreprocessorTest.php +++ b/dev/tests/unit/testsuite/Magento/Core/App/FrontController/Plugin/RequestPreprocessorTest.php @@ -73,7 +73,7 @@ class RequestPreprocessorTest extends \PHPUnit_Framework_TestCase = $this->getMock('\Magento\Code\Plugin\InvocationChain', array(), array(), '', false); $this->_storeManagerMock = $this->getMock('\Magento\Core\Model\StoreManager', array(), array(), '', false); $this->_appStateMock = $this->getMock('\Magento\App\State', array(), array(), '', false); - $this->_urlMock = $this->getMock('\Magento\Core\Model\Url', array(), array(), '', false); + $this->_urlMock = $this->getMock('\Magento\Url', array(), array(), '', false); $this->_storeConfigMock = $this->getMock('\Magento\Core\Model\Store\Config', array(), array(), '', false); $this->_model = new \Magento\Core\App\FrontController\Plugin\RequestPreprocessor( diff --git a/dev/tests/unit/testsuite/Magento/Core/App/MediaTest.php b/dev/tests/unit/testsuite/Magento/Core/App/MediaTest.php index 64e24261e47ba03e6fed7a02b0c2c5ed87732146..b64408addf47c32e46fb1be02b5ddefdd7a9a3fd 100644 --- a/dev/tests/unit/testsuite/Magento/Core/App/MediaTest.php +++ b/dev/tests/unit/testsuite/Magento/Core/App/MediaTest.php @@ -140,7 +140,7 @@ class MediaTest extends \PHPUnit_Framework_TestCase $this->_appState->expects($this->once())->method('isInstalled')->will($this->returnValue(false)); $this->_responseMock->expects($this->once())->method('setHttpResponseCode')->with(404); $this->_requestMock->expects($this->never())->method('getPathInfo'); - $this->assertEquals($this->_responseMock, $this->_model->execute()); + $this->assertEquals($this->_responseMock, $this->_model->launch()); } public function testProcessRequestCreatesConfigFileMediaDirectoryIsNotProvided() @@ -162,7 +162,7 @@ class MediaTest extends \PHPUnit_Framework_TestCase ->with('Magento\Core\Model\File\Storage\Config') ->will($this->returnValue($this->_configMock)); $this->_configMock->expects($this->once())->method('save'); - $this->assertEquals($this->_responseMock, $this->_model->execute()); + $this->assertEquals($this->_responseMock, $this->_model->launch()); } public function testProcessRequestReturnsNotFoundResponseIfResourceIsNotAllowed() @@ -189,7 +189,7 @@ class MediaTest extends \PHPUnit_Framework_TestCase ->with('Magento\Core\Model\File\Storage\Config') ->will($this->returnValue($this->_configMock)); $this->_configMock->expects($this->once())->method('getAllowedResources')->will($this->returnValue(false)); - $this->assertEquals($this->_responseMock, $this->_model->execute()); + $this->assertEquals($this->_responseMock, $this->_model->launch()); } @@ -200,7 +200,7 @@ class MediaTest extends \PHPUnit_Framework_TestCase $this->_requestMock->expects($this->once())->method('getPathInfo'); $this->_responseMock->expects($this->once())->method('setHttpResponseCode')->with(404); $this->_requestMock->expects($this->never())->method('getFilePath'); - $this->assertEquals($this->_responseMock, $this->_model->execute()); + $this->assertEquals($this->_responseMock, $this->_model->launch()); } public function testProcessRequestReturnsFileIfItsProperlySynchronized() @@ -227,7 +227,7 @@ class MediaTest extends \PHPUnit_Framework_TestCase ->expects($this->once()) ->method('setFilePath') ->with($filePath); - $this->assertEquals($this->_responseMock, $this->_model->execute()); + $this->assertEquals($this->_responseMock, $this->_model->launch()); } public function testProcessRequestReturnsNotFoundIfFileIsNotSynchronized() @@ -239,6 +239,6 @@ class MediaTest extends \PHPUnit_Framework_TestCase $this->_requestMock->expects($this->any()) ->method('getFilePath')->will($this->returnValue('non_existing_file_name')); $this->_responseMock->expects($this->once())->method('setHttpResponseCode')->with(404); - $this->assertEquals($this->_responseMock, $this->_model->execute()); + $this->assertEquals($this->_responseMock, $this->_model->launch()); } } diff --git a/dev/tests/unit/testsuite/Magento/Core/App/Request/RewriteServiceTest.php b/dev/tests/unit/testsuite/Magento/Core/App/Request/RewriteServiceTest.php index 1513fb243af75774758f841575e787351ab85f27..350c805fe03c4642f3ab3b40e8d007e5485c3532 100644 --- a/dev/tests/unit/testsuite/Magento/Core/App/Request/RewriteServiceTest.php +++ b/dev/tests/unit/testsuite/Magento/Core/App/Request/RewriteServiceTest.php @@ -52,7 +52,7 @@ class RewriteServiceTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->_routerListMock = $this->getMock('\Magento\App\RouterList', array(), array(), '', false); - $this->_configMock = $this->getMock('\Magento\Core\Model\Config', array(), array(), '', false); + $this->_configMock = $this->getMock('\Magento\App\ConfigInterface', array(), array(), '', false); $this->_requestMock = $this->getMock('\Magento\App\Request\Http', array(), array(), '', false); $this->_rewriteFactoryMock = $this->getMock( '\Magento\Core\Model\Url\RewriteFactory', array('create'), array(), '', false diff --git a/dev/tests/unit/testsuite/Magento/Core/Helper/ThemeTest.php b/dev/tests/unit/testsuite/Magento/Core/Helper/ThemeTest.php index d8e03a009aa2bf4d61539a861be704843835e650..7c2af83762c5073bd84cc7de626f6af7500fb5fc 100644 --- a/dev/tests/unit/testsuite/Magento/Core/Helper/ThemeTest.php +++ b/dev/tests/unit/testsuite/Magento/Core/Helper/ThemeTest.php @@ -29,11 +29,11 @@ namespace Magento\Core\Helper; class ThemeTest extends \PHPUnit_Framework_TestCase { - const ROOT = '/zzz'; - const APP = '/zzz/qqq'; - const MODULES = '/zzz/qqq/code00'; - const THEMES = '/zzz/qqq/design00'; - const PUB_LIB = '/zzz/qqq/js00'; + const ROOT_DIR = '/zzz'; + const APP_DIR = '/zzz/qqq'; + const MODULES_DIR = '/zzz/qqq/code00'; + const THEMES_DIR = '/zzz/qqq/design00'; + const PUB_LIB_DIR = '/zzz/qqq/js00'; /** * @dataProvider getCssFilesDataProvider @@ -492,11 +492,11 @@ class ThemeTest extends \PHPUnit_Framework_TestCase $filesystem->expects($this->any()) ->method('getPath') ->will($this->returnValueMap(array( - array(\Magento\App\Filesystem::ROOT_DIR, self::ROOT), - array(\Magento\App\Filesystem::APP_DIR, self::APP), - array(\Magento\App\Filesystem::MODULES_DIR, self::MODULES), - array(\Magento\App\Filesystem::THEMES_DIR, self::THEMES), - array(\Magento\App\Filesystem::PUB_LIB_DIR, self::PUB_LIB), + array(\Magento\App\Filesystem::ROOT_DIR, self::ROOT_DIR), + array(\Magento\App\Filesystem::APP_DIR, self::APP_DIR), + array(\Magento\App\Filesystem::MODULES_DIR, self::MODULES_DIR), + array(\Magento\App\Filesystem::THEMES_DIR, self::THEMES_DIR), + array(\Magento\App\Filesystem::PUB_LIB_DIR, self::PUB_LIB_DIR), ))); return $filesystem; diff --git a/dev/tests/unit/testsuite/Magento/Core/Model/AppTest.php b/dev/tests/unit/testsuite/Magento/Core/Model/AppTest.php deleted file mode 100644 index 7351d21af25428512e50ccb875197c4450dd31e3..0000000000000000000000000000000000000000 --- a/dev/tests/unit/testsuite/Magento/Core/Model/AppTest.php +++ /dev/null @@ -1,260 +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) - */ - -/** - * Test class for \Magento\Core\Model\App - */ -namespace Magento\Core\Model; - -class AppTest extends \PHPUnit_Framework_TestCase -{ - /** - * @var \Magento\Core\Model\App - */ - protected $_model; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $_configMock; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $_cacheMock; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $_objectManagerMock; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $_storeManagerMock; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $_eventManagerMock; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $_appStateMock; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $_configScopeMock; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $_frontControllerMock; - - protected function setUp() - { - $this->_configMock = $this->getMock('Magento\Core\Model\Config', array(), array(), '', false, false); - $this->_cacheMock = $this->getMock('Magento\App\CacheInterface'); - $this->_objectManagerMock = $this->getMock('Magento\ObjectManager', array(), array(), '', false, false); - $this->_storeManagerMock = $this->getMock('Magento\Core\Model\StoreManagerInterface'); - $this->_eventManagerMock = $this->getMock('Magento\Event\ManagerInterface'); - $this->_appStateMock = $this->getMock('Magento\App\State', array(), array(), '', false, false); - $this->_configScopeMock = $this->getMock('Magento\Config\Scope', array(), array(), '', false); - $this->_frontControllerMock = $this->getMock('Magento\App\FrontControllerInterface'); - - $this->_model = new \Magento\Core\Model\App( - $this->_configMock, - $this->_cacheMock, - $this->_objectManagerMock, - $this->_storeManagerMock, - $this->_eventManagerMock, - $this->_appStateMock, - $this->_configScopeMock, - $this->_frontControllerMock - ); - } - - protected function tearDown() - { - unset($this->_configMock); - unset($this->_cacheMock); - unset($this->_objectManagerMock); - unset($this->_storeManagerMock); - unset($this->_eventManagerMock); - unset($this->_appStateMock); - unset($this->_model); - } - - public function testGetSafeStore() - { - $storeId = 'test'; - $this->_storeManagerMock->expects($this->once()) - ->method('getSafeStore') - ->with($this->equalTo($storeId)) - ->will($this->returnValue('proxy_result')); - $this->assertEquals('proxy_result', $this->_model->getSafeStore($storeId)); - } - - public function testSetIsSingleStoreModeAllowed() - { - $value = true; - $this->_storeManagerMock->expects($this->once()) - ->method('setIsSingleStoreModeAllowed') - ->with($this->equalTo($value)); - $this->_model->setIsSingleStoreModeAllowed($value); - } - - public function testHasSingleStore() - { - $this->_storeManagerMock->expects($this->once()) - ->method('hasSingleStore') - ->will($this->returnValue('proxy_result')); - $this->assertEquals('proxy_result', $this->_model->hasSingleStore()); - } - - public function testIsSingleStoreMode() - { - $this->_storeManagerMock->expects($this->once()) - ->method('isSingleStoreMode') - ->will($this->returnValue('proxy_result')); - $this->assertEquals('proxy_result', $this->_model->isSingleStoreMode()); - } - - public function testThrowStoreException() - { - $this->_storeManagerMock->expects($this->once()) - ->method('throwStoreException'); - $this->_model->throwStoreException(); - } - - public function testGetStore() - { - $storeId = 'some_value'; - $this->_storeManagerMock->expects($this->once()) - ->method('getStore') - ->with($this->equalTo($storeId)) - ->will($this->returnValue('proxy_result')); - $this->assertEquals('proxy_result', $this->_model->getStore($storeId)); - } - - public function testGetStores() - { - $withDefault = true; - $codeKey = true; - $this->_storeManagerMock->expects($this->once()) - ->method('getStores') - ->with($this->equalTo($withDefault), - $this->equalTo($codeKey)) - ->will($this->returnValue('proxy_result')); - $this->assertEquals('proxy_result', $this->_model->getStores($withDefault, $codeKey)); - } - - public function testGetWebsite() - { - $websiteId = 'some_value'; - $this->_storeManagerMock->expects($this->once()) - ->method('getWebsite') - ->with($this->equalTo($websiteId)) - ->will($this->returnValue('proxy_result')); - $this->assertEquals('proxy_result', $this->_model->getWebsite($websiteId)); - } - - public function testGetWebsites() - { - $withDefault = true; - $codeKey = true; - $this->_storeManagerMock->expects($this->once()) - ->method('getWebsites') - ->with($this->equalTo($withDefault), - $this->equalTo($codeKey)) - ->will($this->returnValue('proxy_result')); - $this->assertEquals('proxy_result', $this->_model->getWebsites($withDefault, $codeKey)); - } - - public function testReinitStores() - { - $this->_storeManagerMock->expects($this->once()) - ->method('reinitStores'); - $this->_model->reinitStores(); - } - - public function testSetCurrentStore() - { - $store = 'Test'; - $this->_storeManagerMock->expects($this->once()) - ->method('setCurrentStore') - ->with($this->equalTo($store)); - $this->_model->setCurrentStore($store); - } - - public function testGetDefaultStoreView() - { - $this->_storeManagerMock->expects($this->once()) - ->method('getDefaultStoreView') - ->will($this->returnValue('proxy_result')); - $this->assertEquals('proxy_result', $this->_model->getDefaultStoreView()); - } - - public function testGetGroup() - { - $groupId = 'test'; - $this->_storeManagerMock->expects($this->once()) - ->method('getGroup') - ->will($this->returnValue('proxy_result')) - ->with($this->equalTo($groupId)); - $this->assertEquals('proxy_result', $this->_model->getGroup($groupId)); - } - - public function testGetGroups() - { - $withDefault = true; - $codeKey = true; - $this->_storeManagerMock->expects($this->once()) - ->method('getGroups') - ->with($this->equalTo($withDefault), - $this->equalTo($codeKey)) - ->will($this->returnValue('proxy_result')); - $this->assertEquals('proxy_result', $this->_model->getGroups($withDefault, $codeKey)); - } - - public function testClearWebsiteCache() - { - $websiteId = 'Test'; - $this->_storeManagerMock->expects($this->once()) - ->method('clearWebsiteCache') - ->with($this->equalTo($websiteId)); - $this->_model->clearWebsiteCache($websiteId); - } - - public function testGetAnyStoreView() - { - $this->_storeManagerMock->expects($this->once()) - ->method('getAnyStoreView') - ->will($this->returnValue('proxy_result')); - $this->assertEquals('proxy_result', $this->_model->getAnyStoreView()); - } -} diff --git a/dev/tests/unit/testsuite/Magento/Core/Model/File/Storage/Directory/DatabaseTest.php b/dev/tests/unit/testsuite/Magento/Core/Model/File/Storage/Directory/DatabaseTest.php index 1727a60f65c9ad3f35db4a314b5610b659dec1cd..04013acc91bfa3fd51ef77db35791b2d520d7e5b 100644 --- a/dev/tests/unit/testsuite/Magento/Core/Model/File/Storage/Directory/DatabaseTest.php +++ b/dev/tests/unit/testsuite/Magento/Core/Model/File/Storage/Directory/DatabaseTest.php @@ -73,7 +73,7 @@ class DatabaseTest extends \PHPUnit_Framework_TestCase protected $directoryFactoryMock; /** - * @var \Magento\Core\Model\Config |\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\App\ConfigInterface |\PHPUnit_Framework_MockObject_MockObject */ protected $configMock; @@ -109,7 +109,7 @@ class DatabaseTest extends \PHPUnit_Framework_TestCase array('setPath', 'setName', '__wakeup', 'save', 'getParentId'), array(), '', false); $this->directoryFactoryMock = $this->getMock('Magento\Core\Model\File\Storage\Directory\DatabaseFactory', array('create'), array(), '', false); - $this->configMock = $this->getMock('Magento\Core\Model\Config', array(), array(), '', false); + $this->configMock = $this->getMock('Magento\App\ConfigInterface', array(), array(), '', false); $this->resourceDirectoryDatabaseMock = $this->getMock('Magento\Core\Model\Resource\File\Storage\Directory\Database', array(), array(), '', false); $this->loggerMock = $this->getMock('Magento\Logger', array(), array(), '', false); diff --git a/dev/tests/unit/testsuite/Magento/Core/Model/Layout/Argument/Handler/UrlTest.php b/dev/tests/unit/testsuite/Magento/Core/Model/Layout/Argument/Handler/UrlTest.php index 64f0877322b85b520c956f9258034e5056d03f81..6b51e227481d114dd5f2eb7cf6ddb4060786c62c 100644 --- a/dev/tests/unit/testsuite/Magento/Core/Model/Layout/Argument/Handler/UrlTest.php +++ b/dev/tests/unit/testsuite/Magento/Core/Model/Layout/Argument/Handler/UrlTest.php @@ -45,7 +45,7 @@ class UrlTest extends \PHPUnit_Framework_TestCase protected function setUp() { $helperObjectManager = new \Magento\TestFramework\Helper\ObjectManager($this); - $this->_urlModleMock = $this->getMock('Magento\Core\Model\Url', array(), array(), '', false); + $this->_urlModleMock = $this->getMock('Magento\Url', array(), array(), '', false); $this->_model = $helperObjectManager->getObject( 'Magento\Core\Model\Layout\Argument\Handler\Url', array('urlModel' => $this->_urlModleMock) diff --git a/dev/tests/unit/testsuite/Magento/Core/Model/Layout/_files/merged.xml b/dev/tests/unit/testsuite/Magento/Core/Model/Layout/_files/merged.xml index aeaa907a9faef261227f069254e7bece4af29193..13b2b71bc579d4cdf4637df38ba5a953a8b6f3ba 100644 --- a/dev/tests/unit/testsuite/Magento/Core/Model/Layout/_files/merged.xml +++ b/dev/tests/unit/testsuite/Magento/Core/Model/Layout/_files/merged.xml @@ -34,7 +34,6 @@ <handle id="catalog_product_view_type_configurable"> <container name="product.info.configurable.extra" as="product_type_data_extra" label="Configurable Product Extra Info"/> </handle> - <handle id="catalog_product_view_type_grouped"/> <handle id="catalog_product_view_type_simple"/> <handle id="checkout_onepage_index"/> <handle id="customer_account" label="Customer My Account (All Pages)" design_abstraction="custom"/> diff --git a/dev/tests/unit/testsuite/Magento/Core/Model/ObserverTest.php b/dev/tests/unit/testsuite/Magento/Core/Model/ObserverTest.php index 3199eb359776872952e776b6acffc612eb616a3d..e428c3f587c8db6aeb4094774b06994f7e80616d 100644 --- a/dev/tests/unit/testsuite/Magento/Core/Model/ObserverTest.php +++ b/dev/tests/unit/testsuite/Magento/Core/Model/ObserverTest.php @@ -108,7 +108,7 @@ class ObserverTest extends \PHPUnit_Framework_TestCase $this->_assetsMock = $this->getMock('Magento\View\Asset\GroupedCollection', array(), array(), '', false, false); - $this->_configMock = $this->getMock('Magento\Core\Model\ConfigInterface', + $this->_configMock = $this->getMock('\Magento\App\ReinitableConfigInterface', array(), array(), '', false, false); $this->_assetFactory = $this->getMock('Magento\View\Asset\PublicFileFactory', diff --git a/dev/tests/unit/testsuite/Magento/Core/Model/ReinitableConfigTest.php b/dev/tests/unit/testsuite/Magento/Core/Model/ReinitableConfigTest.php new file mode 100644 index 0000000000000000000000000000000000000000..d63f8857368e97c02033cdd5c7df976059a4003f --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Core/Model/ReinitableConfigTest.php @@ -0,0 +1,42 @@ +<?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 Framework + * @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; + +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()) + ->method('clean'); + /** @var \Magento\Core\Model\ReinitableConfig $config */ + $config = $helper->getObject('Magento\Core\Model\ReinitableConfig', ['sectionPool' => $sectionPool]); + $this->assertInstanceOf('\Magento\App\ReinitableConfigInterface', $config->reinit()); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Core/Model/Resource/Setup/MigrationTest.php b/dev/tests/unit/testsuite/Magento/Core/Model/Resource/Setup/MigrationTest.php index 357f5f052a90b9e44a19ab42841a017eff90d97b..00fa71b1345b323ee019e520ca331f35c8ce99be 100644 --- a/dev/tests/unit/testsuite/Magento/Core/Model/Resource/Setup/MigrationTest.php +++ b/dev/tests/unit/testsuite/Magento/Core/Model/Resource/Setup/MigrationTest.php @@ -245,7 +245,7 @@ class MigrationTest extends \PHPUnit_Framework_TestCase $this->getMock('Magento\Core\Helper\Data', array(), array(), '', false), $this->getMock('Magento\Logger', array(), array(), '', false), $this->getMock('Magento\Event\ManagerInterface', array(), array(), '', false), - $this->getMock('Magento\Core\Model\Config', array(), array(), '', false, false), + $this->getMock('Magento\App\ConfigInterface', array(), array(), '', false, false), $this->getMock('Magento\Module\ModuleListInterface'), $this->getMock('Magento\Module\Dir\Reader', array(), array(), '', false, false), $this->getMock('Magento\Core\Model\Resource\Resource', array(), array(), '', false), diff --git a/dev/tests/unit/testsuite/Magento/Core/Model/Store/StorageFactoryTest.php b/dev/tests/unit/testsuite/Magento/Core/Model/Store/StorageFactoryTest.php index 027c8435a329b4fe9f36930d991f3f5a23f2ab23..eab9a45d7dda0a07ee0fca793df02ba4a6fd7543 100644 --- a/dev/tests/unit/testsuite/Magento/Core/Model/Store/StorageFactoryTest.php +++ b/dev/tests/unit/testsuite/Magento/Core/Model/Store/StorageFactoryTest.php @@ -54,7 +54,7 @@ class StorageFactoryTest extends \PHPUnit_Framework_TestCase /** * @var \PHPUnit_Framework_MockObject_MockObject */ - protected $_appMock; + protected $_sidResolverMock; /** * @var \PHPUnit_Framework_MockObject_MockObject @@ -87,8 +87,8 @@ class StorageFactoryTest extends \PHPUnit_Framework_TestCase $this->_objectManagerMock = $this->getMock('Magento\ObjectManager'); $this->_eventManagerMock = $this->getMock('Magento\Event\ManagerInterface', array(), array(), '', false); $this->_logMock = $this->getMock('Magento\Logger', array(), array(), '', false); - $this->_appMock - = $this->getMock('\Magento\Core\Model\AppInterface'); + $this->_sidResolverMock + = $this->getMock('\Magento\Session\SidResolverInterface', array(), array(), '', false); $this->_appStateMock = $this->getMock('Magento\App\State', array(), array(), '', false); $this->_storage = $this->getMock('Magento\Core\Model\Store\StorageInterface'); @@ -96,7 +96,7 @@ class StorageFactoryTest extends \PHPUnit_Framework_TestCase $this->_objectManagerMock, $this->_eventManagerMock, $this->_logMock, - $this->_appMock, + $this->_sidResolverMock, $this->_appStateMock, $this->_defaultStorage, $this->_dbStorage @@ -115,7 +115,7 @@ class StorageFactoryTest extends \PHPUnit_Framework_TestCase $this->_eventManagerMock->expects($this->never())->method('dispatch'); $this->_logMock->expects($this->never())->method('initForStore'); - $this->_appMock->expects($this->never())->method('setUseSessionInUrl'); + $this->_sidResolverMock->expects($this->never())->method('setUseSessionInUrl'); /** test create instance */ $this->assertEquals($this->_storage, $this->_model->get($this->_arguments)); @@ -159,7 +159,7 @@ class StorageFactoryTest extends \PHPUnit_Framework_TestCase ->expects($this->exactly(2)) ->method('addStreamLog'); - $this->_appMock->expects($this->once()) + $this->_sidResolverMock->expects($this->once()) ->method('setUseSessionInUrl')->with(true); /** test create instance */ @@ -186,7 +186,7 @@ class StorageFactoryTest extends \PHPUnit_Framework_TestCase $this->_eventManagerMock->expects($this->never())->method('dispatch'); $this->_logMock->expects($this->never())->method('initForStore'); - $this->_appMock->expects($this->never())->method('setUseSessionInUrl'); + $this->_sidResolverMock->expects($this->never())->method('setUseSessionInUrl'); /** test create instance */ $this->assertEquals($this->_storage, $this->_model->get($this->_arguments)); diff --git a/dev/tests/unit/testsuite/Magento/Core/Model/Url/ScopeResolverTest.php b/dev/tests/unit/testsuite/Magento/Core/Model/Url/ScopeResolverTest.php new file mode 100644 index 0000000000000000000000000000000000000000..13c0e4730dfc46253da2f593ab9d4f4e6c333d6c --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Core/Model/Url/ScopeResolverTest.php @@ -0,0 +1,90 @@ +<?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\Url; + + +class ScopeResolverTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $_storeManagerMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $_object; + + public function setUp() + { + $objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); + $this->_storeManagerMock = $this->getMockBuilder('Magento\Core\Model\StoreManagerInterface') + ->getMock(); + $this->_object = $objectManager->getObject('Magento\Core\Model\Url\ScopeResolver', array( + 'storeManager' => $this->_storeManagerMock) + ); + } + + /** + * @dataProvider getScopeDataProvider + * @param int|null$scopeId + */ + public function testGetScope($scopeId) + { + $scopeMock = $this->getMockBuilder('\Magento\Url\ScopeInterface')->getMock(); + $this->_storeManagerMock->expects($this->at(0)) + ->method('getStore') + ->with($scopeId) + ->will($this->returnValue($scopeMock)); + $this->_object->getScope($scopeId); + } + + /** + * @expectedException \Magento\Exception + * @expectedExceptionMessage Invalid scope object + */ + public function testGetScopeException() + { + $this->_object->getScope(); + } + + /** + * @return array + */ + public function getScopeDataProvider() + { + return array( + array(null), + array(1), + ); + } + + public function testGetScopes() + { + $this->_storeManagerMock->expects($this->once()) + ->method('getStores'); + $this->_object->getScopes(); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Core/Model/UrlTest.php b/dev/tests/unit/testsuite/Magento/Core/Model/UrlTest.php deleted file mode 100644 index efa0739c608de9c012ac666b9ec6a114ac1c07dc..0000000000000000000000000000000000000000 --- a/dev/tests/unit/testsuite/Magento/Core/Model/UrlTest.php +++ /dev/null @@ -1,153 +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. - * - * @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) - */ - -/** - * Test class for \Magento\Core\Model\Url - */ -namespace Magento\Core\Model; - -class UrlTest extends \PHPUnit_Framework_TestCase -{ - /** - * @var \Magento\Core\Model\Url - */ - protected $_model; - - /** - * @var \Magento\TestFramework\Helper\ObjectManager - */ - protected $_objectManager; - - protected function setUp() - { - $this->_objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); - $this->_model = $this->_objectManager->getObject('\Magento\Core\Model\Url'); - } - - public function testSetRoutePath() - { - $moduleFrontName = 'moduleFrontName'; - $controllerName = 'controllerName'; - $actionName = 'actionName'; - - $this->assertNull($this->_model->getRouteName()); - $this->assertNull($this->_model->getControllerName()); - $this->assertNull($this->_model->getActionName()); - - $this->_model->setRoutePath($moduleFrontName . '/' . $controllerName . '/' . $actionName); - - $this->assertNotNull($this->_model->getRouteName()); - $this->assertEquals($moduleFrontName, $this->_model->getRouteName()); - - $this->assertNotNull($this->_model->getControllerName()); - $this->assertEquals($controllerName, $this->_model->getControllerName()); - - $this->assertNotNull($this->_model->getActionName()); - $this->assertEquals($actionName, $this->_model->getActionName()); - } - - public function testSetRoutePathWhenAsteriskUses() - { - $moduleFrontName = 'moduleFrontName'; - $controllerName = 'controllerName'; - $actionName = 'actionName'; - - $requestMock = $this->getMockForAbstractClass( - 'Magento\App\Request\Http', - array(), - '', - false, - false, - true, - array('getRequestedRouteName', 'getRequestedControllerName', 'getRequestedActionName') - ); - - $requestMock->expects($this->once())->method('getRequestedRouteName') - ->will($this->returnValue($moduleFrontName)); - $requestMock->expects($this->once())->method('getRequestedControllerName') - ->will($this->returnValue($controllerName)); - $requestMock->expects($this->once())->method('getRequestedActionName') - ->will($this->returnValue($actionName)); - - $this->_model->setRequest($requestMock); - - $this->_model->setRoutePath('*/*/*'); - - $this->assertEquals($moduleFrontName, $this->_model->getRouteName()); - $this->assertEquals($controllerName, $this->_model->getControllerName()); - $this->assertEquals($actionName, $this->_model->getActionName()); - } - - public function testSetRoutePathWhenRouteParamsExists() - { - $this->assertNull($this->_model->getControllerName()); - $this->assertNull($this->_model->getActionName()); - - $this->_model->setRoutePath('m/c/a/p1/v1/p2/v2'); - - $this->assertNotNull($this->_model->getControllerName()); - $this->assertNotNull($this->_model->getActionName()); - $this->assertNotEmpty($this->_model->getRouteParams()); - - $this->assertArrayHasKey('p1', $this->_model->getRouteParams()); - $this->assertArrayHasKey('p2', $this->_model->getRouteParams()); - - $this->assertEquals('v1', $this->_model->getRouteParam('p1')); - $this->assertEquals('v2', $this->_model->getRouteParam('p2')); - } - - /** - * @param $port mixed - * @param $url string - * @dataProvider getCurrentUrlProvider - */ - public function testGetCurrentUrl($port, $url) - { - $methods = array('getServer', 'getScheme', 'getHttpHost', 'getModuleName', 'setModuleName', - 'getActionName', 'setActionName', 'getParam'); - $requestMock = $this->getMock('\Magento\App\RequestInterface', $methods); - $requestMock->expects($this->at(0))->method('getServer')->with('SERVER_PORT') - ->will($this->returnValue($port)); - $requestMock->expects($this->at(1))->method('getServer')->with('REQUEST_URI') - ->will($this->returnValue('/fancy_uri')); - $requestMock->expects($this->once())->method('getScheme')->will($this->returnValue('http')); - $requestMock->expects($this->once())->method('getHttpHost')->will($this->returnValue('example.com')); - - /** @var \Magento\Core\Model\Url $model */ - $model = $this->_objectManager->getObject('Magento\Core\Model\Url', array('request' => $requestMock)); - $this->assertEquals($url, $model->getCurrentUrl()); - } - - public function getCurrentUrlProvider() - { - return array( - 'without_port' => array('', 'http://example.com/fancy_uri'), - 'default_port' => array(80, 'http://example.com/fancy_uri'), - 'custom_port' => array(8080, 'http://example.com:8080/fancy_uri') - ); - } -} diff --git a/dev/tests/unit/testsuite/Magento/Cron/App/Cron/Plugin/ApplicationInitializerTest.php b/dev/tests/unit/testsuite/Magento/Cron/App/Cron/Plugin/ApplicationInitializerTest.php index 2a7f358afa0ae67523fc543d5bdfc6dfecedc99a..c4c27b9600e1381d1f7877b412f0b2398c5edcfc 100644 --- a/dev/tests/unit/testsuite/Magento/Cron/App/Cron/Plugin/ApplicationInitializerTest.php +++ b/dev/tests/unit/testsuite/Magento/Cron/App/Cron/Plugin/ApplicationInitializerTest.php @@ -35,18 +35,25 @@ class ApplicationInitializerTest extends \PHPUnit_Framework_TestCase */ protected $_applicationMock; + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $_sidResolverMock; + protected function setUp() { - $this->_applicationMock = $this->getMock('Magento\Core\Model\AppInterface'); + $this->_applicationMock = $this->getMock('Magento\AppInterface'); + $this->_sidResolverMock = $this->getMock('\Magento\Session\SidResolverInterface', array(), array(), '', false); $this->_model = new ApplicationInitializer( - $this->_applicationMock + $this->_applicationMock, + $this->_sidResolverMock ); } public function testBeforeExecutePerformsRequiredChecks() { $this->_applicationMock->expects($this->once())->method('requireInstalledInstance'); - $this->_applicationMock->expects($this->once())->method('setUseSessionInUrl')->with(false); + $this->_sidResolverMock->expects($this->once())->method('setUseSessionInUrl')->with(false); $this->_model->beforeExecute(array()); } } 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 22c702a5585a4f7f0f1080779b61fd38b4ba3e3c..8e4769018e72d8b462508e917ac4d478a00ade8a 100644 --- a/dev/tests/unit/testsuite/Magento/Customer/Controller/Adminhtml/IndexTest.php +++ b/dev/tests/unit/testsuite/Magento/Customer/Controller/Adminhtml/IndexTest.php @@ -247,7 +247,7 @@ class IndexTest extends \PHPUnit_Framework_TestCase ->method('generateResetPasswordLinkToken') ->will($this->returnValue($token)); - $coreHelperMock = $this->getMockBuilder('Magento\Core\Model\Url') + $coreHelperMock = $this->getMockBuilder('Magento\Url') ->disableOriginalConstructor() ->setMethods(array('getUrl', '__wakeup')) ->getMock(); @@ -265,7 +265,7 @@ class IndexTest extends \PHPUnit_Framework_TestCase $this->_objectManager->expects($this->at(2)) ->method('create') - ->with($this->equalTo('Magento\Core\Model\Url')) + ->with($this->equalTo('Magento\UrlInterface')) ->will($this->returnValue($coreHelperMock)); $this->messageManager->expects($this->once()) diff --git a/dev/tests/unit/testsuite/Magento/Customer/Service/CustomerTest.php b/dev/tests/unit/testsuite/Magento/Customer/Service/CustomerTest.php deleted file mode 100644 index 065658c71339e57b0147327c95ec52d870549e80..0000000000000000000000000000000000000000 --- a/dev/tests/unit/testsuite/Magento/Customer/Service/CustomerTest.php +++ /dev/null @@ -1,696 +0,0 @@ -<?php -/** - * \Magento\Customer\Service\Customer - * - * 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\Customer\Service; - -class CustomerTest extends \PHPUnit_Framework_TestCase -{ - /** - * @var \Magento\Customer\Service\Customer|\PHPUnit_Framework_MockObject_MockObject - */ - protected $_service; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $_customerFactory; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $_addressFactory; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $_customer; - - /** @var \Magento\Customer\Helper\Data|\PHPUnit_Framework_MockObject_MockObject */ - protected $_helperMock; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $_address; - - protected function setUp() - { - $this->_helperMock = $this->getMockBuilder('Magento\Customer\Helper\Data') - ->disableOriginalConstructor() - ->setMethods(array('generateResetPasswordLinkToken')) - ->getMock(); - - $this->_customerFactory = $this->getMockBuilder('Magento\Customer\Model\CustomerFactory') - ->disableOriginalConstructor() - ->setMethods(array('create')) - ->getMock(); - $this->_addressFactory = $this->getMockBuilder('Magento\Customer\Model\AddressFactory') - ->disableOriginalConstructor() - ->setMethods(array('create')) - ->getMock(); - - $this->_customer = $this->getMockBuilder('Magento\Customer\Model\Customer') - ->setMethods(array('save', 'generatePassword', 'getOrigData', 'sendNewAccountEmail', 'getConfirmation', - 'getPrimaryAddress', 'getAddresses', 'getAdditionalAddresses', 'load', 'getId', 'changePassword', - 'sendPasswordReminderEmail', 'addAddress', 'getAddressItemById', 'getAddressesCollection', - 'hashPassword', 'changeResetPasswordLinkToken', '__wakeup') - ) - ->disableOriginalConstructor() - ->getMock(); - - $this->_customerFactory->expects($this->any()) - ->method('create') - ->will($this->returnValue($this->_customer)); - - $this->_address = $this->_createAddress(true, null); - $this->_addressFactory->expects($this->any()) - ->method('create') - ->will($this->returnValue($this->_address)); - - $this->_service = new \Magento\Customer\Service\Customer($this->_helperMock, $this->_customerFactory, - $this->_addressFactory - ); - } - - /** - * Create mock address for use in tests - * - * @param bool $hasChanges - * @param int $addressId - * @return \PHPUnit_Framework_MockObject_MockObject - */ - protected function _createAddress($hasChanges, $addressId) - { - $address = $this->getMockBuilder('Magento\Customer\Model\Address') - ->disableOriginalConstructor() - ->setMethods(array('hasDataChanges', 'getId', 'addData', 'setData', 'setCustomerId', 'setPostIndex', - '__sleep', '__wakeup')) - ->getMock(); - $address->expects($this->any()) - ->method('hasDataChanges') - ->will($this->returnValue($hasChanges)); - if ($addressId) { - $address->expects($this->any()) - ->method('getId') - ->will($this->returnValue($addressId)); - } - return $address; - } - - protected function tearDown() - { - unset($this->_service); - } - - /** - * Test for setSendRemainderEmail - * - * @param bool $set - * @param bool $expected - * @dataProvider setSendRemainderDataProvider - */ - public function testSetSendRemainderEmail($set, $expected) - { - $this->_service->setSendRemainderEmail($set); - $this->assertAttributeEquals($expected, '_sendRemainderEmail', $this->_service); - } - - /** - * @return array - */ - public function setSendRemainderDataProvider() - { - return array( - array(true, true), - array(false, false) - ); - } - - /** - * Test beforeSave and afterSave callback are set correctly - */ - public function testSetBeforeSaveCallback() - { - $this->assertInstanceOf('Magento\Customer\Service\Customer', $this->_service->setBeforeSaveCallback('intval')); - $this->assertAttributeEquals('intval', '_beforeSaveCallback', $this->_service); - } - - /** - * Check beforeSave and afterSave callbacks for create and update methods - * - * @param string $method - * @dataProvider methodsDataProvider - */ - public function testCallback($method) - { - $customerData = array('firstname' => 'test'); - $addressData = null; - $callback = $this->getMockBuilder('stdClass') - ->setMethods(array('beforeSave', 'afterSave')) - ->getMock(); - $callback->expects($this->once()) - ->method('beforeSave') - ->with($this->_customer, $customerData, $addressData); - $callback->expects($this->once()) - ->method('afterSave') - ->with($this->_customer, $customerData, $addressData); - - $this->_service->setBeforeSaveCallback(array($callback, 'beforeSave')); - $this->_service->setAfterSaveCallback(array($callback, 'afterSave')); - if ($method == 'create') { - $this->assertInstanceOf('Magento\Customer\Model\Customer', - $this->_service->create($customerData, $addressData)); - } else { - $this->_customer->expects($this->once()) - ->method('getId') - ->will($this->returnValue(1)); - $this->assertInstanceOf('Magento\Customer\Model\Customer', - $this->_service->update(1, $customerData, $addressData)); - } - } - - /** - * @return array - */ - public function methodsDataProvider() - { - return array( - array('create'), - array('update') - ); - } - - public function testSetAfterSaveCallback() - { - $this->assertInstanceOf('Magento\Customer\Service\Customer', $this->_service->setAfterSaveCallback('intval')); - $this->assertAttributeEquals('intval', '_afterSaveCallback', $this->_service); - } - - /** - * Test setIsAdminStore setter - */ - public function testSetIsAdminStore() - { - $this->assertInstanceOf('Magento\Customer\Service\Customer', $this->_service->setIsAdminStore(true)); - $this->assertAttributeEquals(true, '_isAdminStore', $this->_service); - } - - /** - * @param bool $isAdminStore - * @param array $customerData - * @param array $expectedData - * @dataProvider forceConfirmedDataProvider - */ - public function testCreateForceConfirmed($isAdminStore, array $customerData, array $expectedData) - { - if (array_key_exists('autogenerate_password', $customerData)) { - $this->_customer->expects($this->once()) - ->method('generatePassword') - ->will($this->returnValue('generated_password')); - } - - $this->_customer->expects($this->once()) - ->method('save'); - - $this->_service->setIsAdminStore($isAdminStore); - $this->assertInstanceOf('Magento\Customer\Model\Customer', - $this->_service->create($customerData)); - $this->assertEquals($expectedData, $this->_customer->toArray(array_keys($expectedData))); - } - - /** - * @return array - */ - public function forceConfirmedDataProvider() - { - return array( - 'force confirmed not set #1' => array( - 'isAdminStore' => false, - 'customerData' => array( - 'password' => '123123q' - ), - 'expectedData' => array( - 'password' => '123123q', - 'force_confirmed' => null - ), - ), - 'force confirmed not set #2' => array( - 'isAdminStore' => true, - 'customerData' => array(), - 'expectedData' => array( - 'force_confirmed' => null - ), - ), - 'force confirmed is set' => array( - 'isAdminStore' => true, - 'customerData' => array( - 'password' => '123123q' - ), - 'expectedData' => array( - 'password' => '123123q', - 'force_confirmed' => true - ), - ), - 'auto generated password' => array( - 'isAdminStore' => true, - 'customerData' => array( - 'autogenerate_password' => true - ), - 'expectedData' => array( - 'password' => 'generated_password', - 'force_confirmed' => true - ), - ) - ); - } - - /** - * @param array $customerData - * @param string $type - * @param int|null $origId - * @dataProvider welcomeEmailDataProvider - */ - public function testSendWelcomeEmail(array $customerData, $type, $origId) - { - $this->_customer->expects($this->once()) - ->method('sendNewAccountEmail') - ->with($type, '', $customerData['sendemail_store_id']); - $this->_customer->expects($this->once()) - ->method('save'); - $this->_customer->expects($this->once()) - ->method('getOrigData') - ->will($this->returnValue($origId)); - $this->_customer->expects($this->any()) - ->method('getConfirmation') - ->will($this->returnValue(false)); - - $this->assertInstanceOf('Magento\Customer\Model\Customer', $this->_service->create($customerData)); - } - - /** - * Test that email is send for registered users - */ - public function testSendWelcomeEmailRegistered() - { - $storeId = 1; - $type = 'registered'; - $customerData = array( - 'sendemail_store_id' => $storeId, - 'website_id' => 1, - 'sendemail' => true, - 'autogenerate_password' => true - ); - $hash = 1234567890; - - $this->_customer->expects($this->once()) - ->method('sendNewAccountEmail') - ->with($type, '', $storeId); - $this->_customer->expects($this->once()) - ->method('save'); - $this->_customer->expects($this->any()) - ->method('getOrigData') - ->with($this->equalTo('id')) - ->will($this->returnValue(false)); - - $this->_helperMock->expects($this->once()) - ->method('generateResetPasswordLinkToken') - ->will($this->returnValue($hash)); - - $this->_customer->expects($this->once())->method('changeResetPasswordLinkToken')->with($this->equalTo($hash)); - $this->_customer->expects($this->once()) - ->method('sendNewAccountEmail') - ->with( - $this->equalTo($type), - $this->equalTo(''), - $this->equalTo($storeId) - ); - - $this->assertInstanceOf('Magento\Customer\Model\Customer', $this->_service->create($customerData)); - } - - /** - * Test that email is send in case when user is confirmed - */ - public function testSendWelcomeEmailConfirmed() - { - $storeId = 1; - $type = 'confirmed'; - $customerData = array( - 'sendemail_store_id' => $storeId, - 'website_id' => 1, - 'sendemail' => true, - 'autogenerate_password' => true - ); - - $this->_customer->expects($this->once()) - ->method('sendNewAccountEmail') - ->with($type, '', $storeId); - $this->_customer->expects($this->once()) - ->method('save'); - $this->_customer->expects($this->any()) - ->method('getOrigData') - ->with($this->equalTo('id')) - ->will($this->returnValue(true)); - - $this->_customer->expects($this->once()) - ->method('sendNewAccountEmail') - ->with( - $this->equalTo($type), - $this->equalTo(''), - $this->equalTo($storeId) - ); - - $this->assertInstanceOf('Magento\Customer\Model\Customer', $this->_service->create($customerData)); - } - - /** - * @return array - */ - public function welcomeEmailDataProvider() - { - return array( - 'new customer new password' => array( - array( - 'sendemail_store_id' => 1, - 'website_id' => 1, - 'sendemail' => true - ), - 'registered', - null - ), - 'new customer auto generated password' => array( - array( - 'sendemail_store_id' => 1, - 'website_id' => 1, - 'autogenerate_password' => true - ), - 'registered', - null - ), - 'existing customer new password' => array( - array( - 'sendemail_store_id' => 1, - 'website_id' => 1, - 'sendemail' => true - ), - 'confirmed', - 1 - ), - 'existing customer auto generated password' => array( - array( - 'sendemail_store_id' => 1, - 'website_id' => 1, - 'autogenerate_password' => true - ), - 'confirmed', - 1 - ), - ); - } - - /** - * @param array $customerData - * @param int|null $origId - * @dataProvider welcomeEmailNotCalledDataProvider - */ - public function testSendWelcomeEmailNotCalled(array $customerData, $origId) - { - $this->_customer->expects($this->never()) - ->method('sendNewAccountEmail'); - $this->_customer->expects($this->once()) - ->method('save'); - $this->_customer->expects($this->any()) - ->method('getOrigData') - ->will($this->returnValue($origId)); - if (array_key_exists('confirmation', $customerData)) { - $this->_customer->expects($this->any()) - ->method('getConfirmation') - ->will($this->returnValue($customerData['confirmation'])); - } - - $this->assertInstanceOf('Magento\Customer\Model\Customer', $this->_service->create($customerData)); - } - - /** - * @return array - */ - public function welcomeEmailNotCalledDataProvider() - { - return array( - 'unchanged password' => array( - array( - 'website_id' => 1, - ), - null - ), - 'no website new customer send email' => array( - array( - 'website_id' => 0, - 'sendemail' => true - ), - null - ), - 'no website new customer auto generated password' => array( - array( - 'website_id' => 0, - 'autogenerate_password' => true - ), - null - ), - 'no website existing customer new password' => array( - array( - 'website_id' => 0, - 'sendemail' => true - ), - 1 - ), - 'existing customer auto generated password' => array( - array( - 'website_id' => 0, - 'autogenerate_password' => true - ), - 1 - ), - 'not new no confirmation' => array( - array( - 'sendemail_store_id' => 1, - 'website_id' => 1, - 'sendemail' => true, - 'confirmation' => true - ), - 1 - ) - ); - } - - /** - * @expectedException \Magento\Core\Exception - * @expectedExceptionMessage The customer with the specified ID not found. - */ - public function testLoadCustomerByIdException() - { - $this->_customer->expects($this->never()) - ->method('save'); - $this->_customer->expects($this->once()) - ->method('load') - ->with(1); - $this->_customer->expects($this->once()) - ->method('getId') - ->will($this->returnValue(false)); - - $this->_service->update(1, array('firstname' => 'test')); - } - - /** - * @param array $customerData - * @dataProvider changePasswordDataProvider - */ - public function testChangePassword(array $customerData) - { - $password = isset($customerData['password']) ? $customerData['password'] : 'generated_password'; - $this->_customer->expects($this->once()) - ->method('save'); - $this->_customer->expects($this->once()) - ->method('getId') - ->will($this->returnValue(1)); - $this->_customer->expects($this->once()) - ->method('changePassword') - ->with($password) - ->will($this->returnSelf()); - $this->_customer->expects($this->once()) - ->method('sendPasswordReminderEmail') - ->will($this->returnSelf()); - if (array_key_exists('autogenerate_password', $customerData)) { - $this->_customer->expects($this->once()) - ->method('generatePassword') - ->will($this->returnValue('generated_password')); - } - - $this->assertInstanceOf('Magento\Customer\Model\Customer', $this->_service->update(1, $customerData)); - } - - /** - * @return array - */ - public function changePasswordDataProvider() - { - return array( - 'new password' => array( - array('password' => '123123q') - ), - 'auto generated password' => array( - array('autogenerate_password' => true) - ) - ); - } - - /** - * @param array $addressData - * @param \Magento\Customer\Model\Address|null $newAddress - * @param \Magento\Customer\Model\Address|null $existingAddress - * @param array $addressCollection - * @param bool $dataChanged - * @param bool $expectedDataChange - * @dataProvider addressesDataProvider - */ - public function testPrepareCustomerAddressForSave(array $addressData, $newAddress, $existingAddress, - array $addressCollection, $dataChanged, $expectedDataChange - ) { - $this->_customer->setDataChanges($dataChanged); - - $this->_customer->expects($this->any()) - ->method('getId') - ->will($this->returnValue(1)); - - $this->_customer->expects($this->once()) - ->method('getAddressesCollection') - ->will($this->returnValue($addressCollection)); - - if ($newAddress) { - // Check that customer_id is set for new addresses - $newAddress->expects($this->once()) - ->method('setCustomerId') - ->with(1); - // Check that new address is added to customer address collection - $this->_customer->expects($this->once()) - ->method('addAddress'); - - // Check that new address is not deleted - $newAddress->expects($this->never()) - ->method('setData') - ->with('_deleted', true); - } - - // Check that address loaded from customer address collection - if ($existingAddress && $addressData) { - $this->_customer->expects($this->once()) - ->method('getAddressItemById') - ->with($existingAddress->getId()) - ->will($this->returnValue($existingAddress)); - } - - // Check that new data is added - $hasExistingAddress = false; - foreach ($addressData as $data) { - if (array_key_exists('entity_id', $addressData)) { - unset($data['entity_id']); - $existingAddress->expects($this->once()) - ->method('addData') - ->with($data); - $hasExistingAddress = true; - } elseif ($newAddress) { - $newAddress->expects($this->once()) - ->method('addData') - ->with($data); - } - } - // Check that addresses is deleted - if (in_array($existingAddress, $addressCollection) && !$hasExistingAddress) { - $existingAddress->expects($this->atLeastOnce()) - ->method('setData') - ->with('_deleted', true); - } - - $this->assertInstanceOf('Magento\Customer\Model\Customer', $this->_service->update(1, array(), $addressData), - 'Incorrect instance returned'); - - $this->assertEquals($expectedDataChange, $this->_customer->hasDataChanges(), - 'Customer change data status is incorrect'); - } - - /** - * @return array - */ - public function addressesDataProvider() - { - $newAddress = $this->_createAddress(true, null); - $existingAddress = $this->_createAddress(true, 2); - return array( - 'no addresses #1' => array( - array(), null, null, array(), false, false - ), - 'no addresses #2' => array( - array(), null, null, array(), true, true - ), - 'new address' => array( - array(array('city' => 'test')), - $newAddress, null, - array($newAddress), false, true - ), - 'existing address' => array( - array(array('entity_id' => 2, 'city' => 'test')), - null, $existingAddress, - array($existingAddress), false, true - ), - 'new added, existing deleted' => array( - array(array('city' => 'test')), - $newAddress, null, - array($newAddress, $existingAddress), false, true - ), - 'all addresses deleted' => array( - array(), - null, $existingAddress, - array($existingAddress), false, true - ) - ); - } - - /** - * @expectedException \Magento\Core\Exception - * @expectedExceptionMessage The address with the specified ID not found. - */ - public function testPrepareCustomerAddressForSaveException() - { - $this->_customer->expects($this->any()) - ->method('getId') - ->will($this->returnValue(1)); - $address = $this->_createAddress(true, 1); - $this->_customer->expects($this->once()) - ->method('getAddressItemById') - ->with($address->getId()) - ->will($this->returnValue(false)); - $this->_service->update(1, array(), array(array('entity_id' => 1, 'city' => 'test'))); - } -} diff --git a/dev/tests/unit/testsuite/Magento/Customer/Service/V1/CustomerAddressServiceTest.php b/dev/tests/unit/testsuite/Magento/Customer/Service/V1/CustomerAddressServiceTest.php index 4f49ff8ff4a63a36a3955e9004117324ad66e296..84c8387aa610700e142506e0e744d7cb519f3864 100644 --- a/dev/tests/unit/testsuite/Magento/Customer/Service/V1/CustomerAddressServiceTest.php +++ b/dev/tests/unit/testsuite/Magento/Customer/Service/V1/CustomerAddressServiceTest.php @@ -258,11 +258,11 @@ class CustomerAddressServiceTest extends \PHPUnit_Framework_TestCase 'default_billing' => true, 'default_shipping' => false, 'customer_id' => self::ID, - 'region' => new Dto\Region([ + 'region' => [ 'region_id' => self::REGION_ID, 'region_code' => '', 'region' => self::REGION - ]), + ], 'country_id' => self::COUNTRY_ID, 'street' => [self::STREET], 'telephone' => self::TELEPHONE, @@ -304,11 +304,11 @@ class CustomerAddressServiceTest extends \PHPUnit_Framework_TestCase 'default_shipping' => true, 'default_billing' => false, 'customer_id' => self::ID, - 'region' => new Dto\Region([ + 'region' => [ 'region_id' => self::REGION_ID, 'region_code' => '', 'region' => self::REGION - ]), + ], 'country_id' => self::COUNTRY_ID, 'street' => [self::STREET], 'telephone' => self::TELEPHONE, @@ -351,11 +351,11 @@ class CustomerAddressServiceTest extends \PHPUnit_Framework_TestCase 'default_shipping' => true, 'default_billing' => false, 'customer_id' => self::ID, - 'region' => new Dto\Region([ + 'region' => [ 'region_id' => self::REGION_ID, 'region_code' => '', 'region' => self::REGION - ]), + ], 'country_id' => self::COUNTRY_ID, 'street' => [self::STREET], 'telephone' => self::TELEPHONE, @@ -401,11 +401,11 @@ class CustomerAddressServiceTest extends \PHPUnit_Framework_TestCase 'default_shipping' => true, 'default_billing' => false, 'customer_id' => self::ID, - 'region' => new Dto\Region([ + 'region' => [ 'region_id' => self::REGION_ID, 'region_code' => '', 'region' => self::REGION - ]), + ], 'country_id' => self::COUNTRY_ID, 'street' => [self::STREET], 'telephone' => self::TELEPHONE, @@ -418,11 +418,11 @@ class CustomerAddressServiceTest extends \PHPUnit_Framework_TestCase 'default_billing' => true, 'default_shipping' => false, 'customer_id' => self::ID, - 'region' => new Dto\Region([ + 'region' => [ 'region_id' => self::REGION_ID, 'region_code' => '', 'region' => self::REGION - ]), + ], 'country_id' => self::COUNTRY_ID, 'street' => [self::STREET], 'telephone' => self::TELEPHONE, diff --git a/dev/tests/unit/testsuite/Magento/Customer/Service/V1/CustomerMetadataServiceTest.php b/dev/tests/unit/testsuite/Magento/Customer/Service/V1/CustomerMetadataServiceTest.php index ebbb52560e3a11f28cc2de57253dfe94802b7cd3..f0d2e40049cf8dabcf6c566f693adc2f93336d37 100644 --- a/dev/tests/unit/testsuite/Magento/Customer/Service/V1/CustomerMetadataServiceTest.php +++ b/dev/tests/unit/testsuite/Magento/Customer/Service/V1/CustomerMetadataServiceTest.php @@ -25,18 +25,15 @@ */ namespace Magento\Customer\Service\V1; -use Magento\Customer\Service\V1\CustomerMetadataService; -use Magento\Customer\Service\V1\Dto\Eav\AttributeMetadata; -use Magento\Customer\Service\V1\Dto\Eav\Option; - class CustomerMetadataServiceTest extends \PHPUnit_Framework_TestCase { /** Sample values for testing */ const ATTRIBUTE_CODE = 1; - const FRONTEND_INPUT = 'frontend input'; + const FRONTEND_INPUT = 'select'; const INPUT_FILTER = 'input filter'; const STORE_LABEL = 'store label'; const VALIDATE_RULES = 'validate rules'; + const FRONTEND_CLASS = 'frontend class'; /** * @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Eav\Model\Config @@ -69,6 +66,8 @@ class CustomerMetadataServiceTest extends \PHPUnit_Framework_TestCase 'getStoreLabel', 'getValidateRules', 'getSource', + 'getFrontend', + 'usesSource', '__wakeup', ) ) @@ -80,6 +79,16 @@ class CustomerMetadataServiceTest extends \PHPUnit_Framework_TestCase ->disableOriginalConstructor() ->getMock(); + $frontendMock = $this->getMockBuilder('\Magento\Eav\Model\Entity\Attribute\Frontend\AbstractFrontend') + ->disableOriginalConstructor() + ->setMethods(array('getClass')) + ->getMock(); + + $frontendMock + ->expects($this->any()) + ->method('getClass') + ->will($this->returnValue(self::FRONTEND_CLASS)); + $this->_mockReturnValue( $this->_attributeEntityMock, array( @@ -88,6 +97,7 @@ class CustomerMetadataServiceTest extends \PHPUnit_Framework_TestCase 'getInputFilter' => self::INPUT_FILTER, 'getStoreLabel' => self::STORE_LABEL, 'getValidateRules' => self::VALIDATE_RULES, + 'getFrontend' => $frontendMock, ) ); } @@ -98,6 +108,10 @@ class CustomerMetadataServiceTest extends \PHPUnit_Framework_TestCase ->method('getAttribute') ->will($this->returnValue($this->_attributeEntityMock)); + $this->_attributeEntityMock->expects($this->any()) + ->method('usesSource') + ->will($this->returnValue(true)); + $this->_attributeEntityMock->expects($this->any()) ->method('getSource') ->will($this->returnValue($this->_sourceMock)); @@ -116,10 +130,10 @@ class CustomerMetadataServiceTest extends \PHPUnit_Framework_TestCase ->method('getAllOptions') ->will($this->returnValue($allOptions)); - $attributeColMock = $this->getMockBuilder('\\Magento\\Customer\\Model\\Resource\\Form\\Attribute\\Collection') + $attributeColMock = $this->getMockBuilder('\Magento\Customer\Model\Resource\Form\Attribute\CollectionFactory') ->disableOriginalConstructor() ->getMock(); - $storeManagerMock = $this->getMockBuilder('\\Magento\\Core\\Model\\StoreManager') + $storeManagerMock = $this->getMockBuilder('\Magento\Core\Model\StoreManager') ->disableOriginalConstructor() ->getMock(); @@ -131,11 +145,7 @@ class CustomerMetadataServiceTest extends \PHPUnit_Framework_TestCase $optionBuilder, $attributeMetadataBuilder); $attributeMetadata = $service->getAttributeMetadata('entityCode', 'attributeId'); - $this->assertEquals(self::ATTRIBUTE_CODE, $attributeMetadata->getAttributeCode()); - $this->assertEquals(self::FRONTEND_INPUT, $attributeMetadata->getFrontendInput()); - $this->assertEquals(self::INPUT_FILTER, $attributeMetadata->getInputFilter()); - $this->assertEquals(self::STORE_LABEL, $attributeMetadata->getStoreLabel()); - $this->assertEquals(self::VALIDATE_RULES, $attributeMetadata->getValidationRules()); + $this->assertMetadataAttributes($attributeMetadata); $options = $attributeMetadata->getOptions(); $this->assertNotEquals(array(), $options); @@ -159,10 +169,10 @@ class CustomerMetadataServiceTest extends \PHPUnit_Framework_TestCase ->method('getAllOptions') ->will($this->returnValue(array())); - $attributeColMock = $this->getMockBuilder('\\Magento\\Customer\\Model\\Resource\\Form\\Attribute\\Collection') + $attributeColMock = $this->getMockBuilder('\Magento\Customer\Model\Resource\Form\Attribute\CollectionFactory') ->disableOriginalConstructor() ->getMock(); - $storeManagerMock = $this->getMockBuilder('\\Magento\\Core\\Model\\StoreManager') + $storeManagerMock = $this->getMockBuilder('\Magento\Core\Model\StoreManager') ->disableOriginalConstructor() ->getMock(); @@ -174,11 +184,7 @@ class CustomerMetadataServiceTest extends \PHPUnit_Framework_TestCase $optionBuilder, $attributeMetadataBuilder); $attributeMetadata = $service->getAttributeMetadata('entityCode', 'attributeId'); - $this->assertEquals(self::ATTRIBUTE_CODE, $attributeMetadata->getAttributeCode()); - $this->assertEquals(self::FRONTEND_INPUT, $attributeMetadata->getFrontendInput()); - $this->assertEquals(self::INPUT_FILTER, $attributeMetadata->getInputFilter()); - $this->assertEquals(self::STORE_LABEL, $attributeMetadata->getStoreLabel()); - $this->assertEquals(self::VALIDATE_RULES, $attributeMetadata->getValidationRules()); + $this->assertMetadataAttributes($attributeMetadata); $options = $attributeMetadata->getOptions(); $this->assertEquals(0, count($options)); @@ -191,13 +197,13 @@ class CustomerMetadataServiceTest extends \PHPUnit_Framework_TestCase ->will($this->returnValue($this->_attributeEntityMock)); $this->_attributeEntityMock->expects($this->any()) - ->method('getSource') - ->will($this->throwException(new \Exception('exception message'))); + ->method('usesSource') + ->will($this->returnValue(false)); - $attributeColMock = $this->getMockBuilder('\\Magento\\Customer\\Model\\Resource\\Form\\Attribute\\Collection') + $attributeColMock = $this->getMockBuilder('\Magento\Customer\Model\Resource\Form\Attribute\CollectionFactory') ->disableOriginalConstructor() ->getMock(); - $storeManagerMock = $this->getMockBuilder('\\Magento\\Core\\Model\\StoreManager') + $storeManagerMock = $this->getMockBuilder('\Magento\Core\Model\StoreManager') ->disableOriginalConstructor() ->getMock(); @@ -209,11 +215,7 @@ class CustomerMetadataServiceTest extends \PHPUnit_Framework_TestCase $optionBuilder, $attributeMetadataBuilder); $attributeMetadata = $service->getAttributeMetadata('entityCode', 'attributeId'); - $this->assertEquals(self::ATTRIBUTE_CODE, $attributeMetadata->getAttributeCode()); - $this->assertEquals(self::FRONTEND_INPUT, $attributeMetadata->getFrontendInput()); - $this->assertEquals(self::INPUT_FILTER, $attributeMetadata->getInputFilter()); - $this->assertEquals(self::STORE_LABEL, $attributeMetadata->getStoreLabel()); - $this->assertEquals(self::VALIDATE_RULES, $attributeMetadata->getValidationRules()); + $this->assertMetadataAttributes($attributeMetadata); $options = $attributeMetadata->getOptions(); $this->assertEquals(0, count($options)); @@ -231,4 +233,17 @@ class CustomerMetadataServiceTest extends \PHPUnit_Framework_TestCase ->will($this->returnValue($value)); } } + + /** + * @param $attributeMetadata + */ + private function assertMetadataAttributes($attributeMetadata) + { + $this->assertEquals(self::ATTRIBUTE_CODE, $attributeMetadata->getAttributeCode()); + $this->assertEquals(self::FRONTEND_INPUT, $attributeMetadata->getFrontendInput()); + $this->assertEquals(self::INPUT_FILTER, $attributeMetadata->getInputFilter()); + $this->assertEquals(self::STORE_LABEL, $attributeMetadata->getStoreLabel()); + $this->assertEquals(self::VALIDATE_RULES, $attributeMetadata->getValidationRules()); + $this->assertEquals(self::FRONTEND_CLASS, $attributeMetadata->getFrontendClass()); + } } diff --git a/dev/tests/unit/testsuite/Magento/DB/Ddl/TriggerTest.php b/dev/tests/unit/testsuite/Magento/DB/Ddl/TriggerTest.php new file mode 100644 index 0000000000000000000000000000000000000000..ddacd25f284ef3c5bdd1a318749179885a648828 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/DB/Ddl/TriggerTest.php @@ -0,0 +1,239 @@ +<?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. + * + * @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\DB\Ddl; + +class TriggerTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\DB\Ddl\Trigger + */ + protected $_object; + + public function setUp() + { + $this->_object = new \Magento\DB\Ddl\Trigger(); + } + + /** + * Test getListOfEvents() method + */ + public function testGetListOfEvents() + { + $actualEventTypes = \Magento\DB\Ddl\Trigger::getListOfEvents(); + $this->assertInternalType('array', $actualEventTypes); + $this->assertCount(3, $actualEventTypes); + $this->assertTrue(in_array(\Magento\DB\Ddl\Trigger::EVENT_INSERT, $actualEventTypes)); + $this->assertTrue(in_array(\Magento\DB\Ddl\Trigger::EVENT_UPDATE, $actualEventTypes)); + $this->assertTrue(in_array(\Magento\DB\Ddl\Trigger::EVENT_DELETE, $actualEventTypes)); + } + + /** + * Test getListOfTimes() method + */ + public function testGetListOfTimes() + { + $actualTimeTypes = \Magento\DB\Ddl\Trigger::getListOfTimes(); + $this->assertInternalType('array', $actualTimeTypes); + $this->assertCount(2, $actualTimeTypes); + $this->assertTrue(in_array(\Magento\DB\Ddl\Trigger::TIME_AFTER, $actualTimeTypes)); + $this->assertTrue(in_array(\Magento\DB\Ddl\Trigger::TIME_BEFORE, $actualTimeTypes)); + } + + /** + * Test case for getName() after setName() + */ + public function testGetNameWithSetName() + { + $triggerName = 'TEST_TRIGGER_NAME' . mt_rand(100, 999); + + $this->_object->setName($triggerName); + $this->assertEquals(strtolower($triggerName), $this->_object->getName()); + } + + /** + * Test case for setName() with exception + * + * @expectedException \InvalidArgumentException + * @expectedExceptionMessage Trigger name should be a string + */ + public function testSetNameWithException() + { + $triggerName = new \stdClass();//non string + + $this->_object->setName($triggerName); + } + + /** + * Test case for setTable() with exception + * + * @expectedException \InvalidArgumentException + * @expectedExceptionMessage Trigger table name should be a string + */ + public function testSetTableWithException() + { + $tableName = new \stdClass();//non string + + $this->_object->setTable($tableName); + } + + /** + * Test case for getName() + * + * @expectedException \Zend_Db_Exception + * @expectedExceptionMessage Trigger name is not defined + */ + public function testGetNameWithException() + { + $tableName = 'TEST_TABLE_NAME_' . mt_rand(100, 999); + $event = \Magento\DB\Ddl\Trigger::EVENT_INSERT; + + $this->_object + ->setTable($tableName) + ->setTime(\Magento\DB\Ddl\Trigger::TIME_AFTER) + ->setEvent($event); + + $this->_object->getName(); + } + + /** + * Test case for getTime() with Exception + * + * @expectedException \Zend_Db_Exception + * @expectedExceptionMessage Trigger time is not defined + */ + public function testGetTimeWithException() + { + $tableName = 'TEST_TABLE_NAME_' . mt_rand(100, 999); + $event = \Magento\DB\Ddl\Trigger::EVENT_INSERT; + + $this->_object + ->setTable($tableName) + ->setEvent($event); + + $this->_object->getTime(); + } + + /** + * Test case for getTable() + * + * @expectedException \Zend_Db_Exception + * @expectedExceptionMessage Trigger table name is not defined + */ + public function testGetTableWithException() + { + $event = \Magento\DB\Ddl\Trigger::EVENT_INSERT; + + $this->_object + ->setTime(\Magento\DB\Ddl\Trigger::TIME_AFTER) + ->setEvent($event); + + $this->_object->getTable(); + } + + /** + * Test case for getEvent() with Exception + * + * @expectedException \Zend_Db_Exception + * @expectedExceptionMessage Trigger event is not defined + */ + public function testGetEventWithException() + { + $tableName = 'TEST_TABLE_NAME_' . mt_rand(100, 999); + + $this->_object + ->setTable($tableName) + ->setTime(\Magento\DB\Ddl\Trigger::TIME_AFTER); + + $this->_object->getEvent(); + } + + /** + * @expectedException InvalidArgumentException + * @expectedExceptionMessage Trigger unsupported event type + */ + public function testWrongEventTypeException() + { + $this->_object->setEvent('UNSUPORT EVENT TYPE'); + } + + /** + * @expectedException InvalidArgumentException + * @expectedExceptionMessage Trigger unsupported time type + */ + public function testWrongTimeTypeException() + { + $this->_object->setTime('UNSUPORT TIME TYPE'); + } + + /** + * Test case for setTable() with exception + * + * @expectedException \InvalidArgumentException + * @expectedExceptionMessage Trigger statement should be a string + */ + public function testAddStatementWithException() + { + $statement = new \stdClass();//non string + + $this->_object->addStatement($statement); + } + + /** + * Data provider for setBody function + */ + public function getStatementsDataProvider() + { + return array( + array( + 'SQL', + array('SQL;') + ), + array( + 'SQL;', + array('SQL;') + ), + ); + } + + /** + * Test addStatement and getStatements for trigger + * + * @dataProvider getStatementsDataProvider + */ + public function testAddStatement($param, $expected) + { + $this->_object->addStatement($param); + $this->assertEquals($expected, $this->_object->getStatements()); + } + + /** + * Test getStatements method + */ + public function testGetStatements() + { + $this->assertEquals(array(), $this->_object->getStatements()); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Data/CollectionTest.php b/dev/tests/unit/testsuite/Magento/Data/CollectionTest.php index 2ff7f18c9b15e2d683922b52bcd174a602b2be22..fd990c1f0b64a52efab142e009109d9e7bfb2208 100644 --- a/dev/tests/unit/testsuite/Magento/Data/CollectionTest.php +++ b/dev/tests/unit/testsuite/Magento/Data/CollectionTest.php @@ -62,7 +62,7 @@ class CollectionTest extends \PHPUnit_Framework_TestCase public function setItemObjectClassDataProvider() { return array( - array('Magento\Core\Model\Url'), + array('Magento\Url'), array('Magento\Object'), ); } diff --git a/dev/tests/unit/testsuite/Magento/DesignEditor/Block/Adminhtml/Editor/Toolbar/Buttons/SaveTest.php b/dev/tests/unit/testsuite/Magento/DesignEditor/Block/Adminhtml/Editor/Toolbar/Buttons/SaveTest.php index 0b7f7f64640c021b1c22176066598564a23784d6..7f7b8181c047066ecfd08c92686c3ed717b60463 100644 --- a/dev/tests/unit/testsuite/Magento/DesignEditor/Block/Adminhtml/Editor/Toolbar/Buttons/SaveTest.php +++ b/dev/tests/unit/testsuite/Magento/DesignEditor/Block/Adminhtml/Editor/Toolbar/Buttons/SaveTest.php @@ -53,7 +53,7 @@ class SaveTest extends \PHPUnit_Framework_TestCase ->will($this->returnArgument(0)); /** @var $urlBuilder \Magento\Core\Model\Url|\PHPUnit_Framework_MockObject_MockObject */ - $urlBuilder = $this->getMock('Magento\Core\Model\Url', array('getUrl'), array(), '', false); + $urlBuilder = $this->getMock('Magento\Url', array('getUrl'), array(), '', false); $urlBuilder->expects($this->any()) ->method('getUrl') ->will($this->returnValue($this->_url)); diff --git a/dev/tests/unit/testsuite/Magento/DesignEditor/Block/Adminhtml/Editor/Tools/Code/CustomTest.php b/dev/tests/unit/testsuite/Magento/DesignEditor/Block/Adminhtml/Editor/Tools/Code/CustomTest.php index ff11fb7fdb1e465ecea980222e468c72beb6fa2e..01a0107613ceda0d1e6d2b459383f990c73a81b1 100644 --- a/dev/tests/unit/testsuite/Magento/DesignEditor/Block/Adminhtml/Editor/Tools/Code/CustomTest.php +++ b/dev/tests/unit/testsuite/Magento/DesignEditor/Block/Adminhtml/Editor/Tools/Code/CustomTest.php @@ -75,7 +75,7 @@ class CustomTest extends \PHPUnit_Framework_TestCase $this->_model = $objectManagerHelper->getObject( 'Magento\DesignEditor\Block\Adminhtml\Editor\Tools\Code\Custom', array( - 'config' => $this->getMock('Magento\Core\Model\Config', array(), array(), '', false), + 'config' => $this->getMock('Magento\App\ConfigInterface', array(), array(), '', false), 'formFactory' => $this->getMock('Magento\Data\FormFactory', array(), array(), '', false), 'urlBuilder' => $this->_urlBuilder, 'themeContext' => $this->_themeContext 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 059ad34a8560e44bd9641f0a5fa8ea42810d3d98..d995b7fc0298856d9319ff5951bcbf960b698ddc 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 @@ -194,7 +194,7 @@ class EditorTest extends \PHPUnit_Framework_TestCase ->will($this->returnSelf()); $eventManager = $this->getMock('Magento\Event\ManagerInterface', array(), array(), '', false); - $configMock = $this->getMock('Magento\Core\Model\Config', array(), array(), '', false); + $configMock = $this->getMock('Magento\App\ConfigInterface', array(), array(), '', false); $authMock = $this->getMock('Magento\AuthorizationInterface'); $authMock->expects($this->any())->method('filterAclNodes')->will($this->returnSelf()); $backendSession = $this->getMock('Magento\Backend\Model\Session', array('getMessages', 'getEscapeMessages'), @@ -212,7 +212,7 @@ class EditorTest extends \PHPUnit_Framework_TestCase $this->_getThemeCollectionFactory($countCustomization) ), array('Magento\Core\Model\Translate', $translate), - array('Magento\Core\Model\Config', $configMock), + array('Magento\App\ConfigInterface', $configMock), array('Magento\Event\ManagerInterface', $eventManager), array('Magento\Core\Model\StoreManager', $storeManager), array('Magento\AuthorizationInterface', $authMock), diff --git a/dev/tests/unit/testsuite/Magento/DesignEditor/Controller/Varien/Router/StandardTest.php b/dev/tests/unit/testsuite/Magento/DesignEditor/Controller/Varien/Router/StandardTest.php index 37d97981de1b0fdb0ce2390d1051c790a6545bba..fdaa041697e9918d15ba187306861ca3d5815731 100644 --- a/dev/tests/unit/testsuite/Magento/DesignEditor/Controller/Varien/Router/StandardTest.php +++ b/dev/tests/unit/testsuite/Magento/DesignEditor/Controller/Varien/Router/StandardTest.php @@ -236,7 +236,7 @@ class StandardTest extends \PHPUnit_Framework_TestCase $this->getMock('Magento\UrlInterface'), $this->getMock('Magento\Core\Model\StoreManagerInterface'), $this->getMock('Magento\Core\Model\Store\Config', array(), array(), '', false), - $this->getMock('Magento\Core\Model\Url\SecurityInfoInterface'), + $this->getMock('Magento\Url\SecurityInfoInterface'), 'frontend', $routerListMock, $objectManager, diff --git a/dev/tests/unit/testsuite/Magento/DesignEditor/Model/StateTest.php b/dev/tests/unit/testsuite/Magento/DesignEditor/Model/StateTest.php index 67429a88cd20647d99a9daffeff2967f5c9858b9..c1c745efc1ceb0f0d2411fbb5ebb1a07b701d0f1 100644 --- a/dev/tests/unit/testsuite/Magento/DesignEditor/Model/StateTest.php +++ b/dev/tests/unit/testsuite/Magento/DesignEditor/Model/StateTest.php @@ -34,7 +34,7 @@ class StateTest extends \PHPUnit_Framework_TestCase const LAYOUT_NAVIGATION_CLASS_NAME = 'Magento\Core\Model\Layout'; /** - * Url model classes that will be used instead of \Magento\Core\Model\Url in different vde modes + * Url model classes that will be used instead of \Magento\UrlInterface in different vde modes */ const URL_MODEL_NAVIGATION_MODE_CLASS_NAME = 'Magento\DesignEditor\Model\Url\NavigationMode'; @@ -148,11 +148,7 @@ class StateTest extends \PHPUnit_Framework_TestCase ) ->will($this->returnSelf()); - $this->_application->expects($this->any()) - ->method('getStore') - ->will($this->returnValue($storeManager)); - - $configMock = $this->getMock('Magento\Core\Model\Config', array('setNode'), array(), '', false); + $configMock = $this->getMock('Magento\App\ConfigInterface', array(), array(), '', false); $configMock->expects($this->any()) ->method('setNode') ->with( @@ -184,7 +180,8 @@ class StateTest extends \PHPUnit_Framework_TestCase $this->_dataHelper, $this->_objectManager, $this->_application, - $this->_themeContext + $this->_themeContext, + $storeManager ); } diff --git a/dev/tests/unit/testsuite/Magento/DesignEditor/Model/Url/FactoryTest.php b/dev/tests/unit/testsuite/Magento/DesignEditor/Model/Url/FactoryTest.php index 9ce761e32b25164bb974936792f01caf5c457ab3..4a85990f2f677aa5538d98af23064601a4c737e8 100644 --- a/dev/tests/unit/testsuite/Magento/DesignEditor/Model/Url/FactoryTest.php +++ b/dev/tests/unit/testsuite/Magento/DesignEditor/Model/Url/FactoryTest.php @@ -53,7 +53,7 @@ class FactoryTest extends \PHPUnit_Framework_TestCase { $this->_objectManager->expects($this->once()) ->method('configure') - ->with(array('preferences' => array('Magento\Core\Model\Url' => 'TestClass'))); + ->with(array('preferences' => array('Magento\UrlInterface' => 'TestClass'))); $this->assertEquals($this->_model, $this->_model->replaceClassName('TestClass')); } @@ -62,7 +62,7 @@ class FactoryTest extends \PHPUnit_Framework_TestCase { $this->_objectManager->expects($this->once()) ->method('create') - ->with('Magento\Core\Model\Url', array()) + ->with('Magento\UrlInterface', array()) ->will($this->returnValue('ModelInstance')); $this->assertEquals('ModelInstance', $this->_model->create()); diff --git a/dev/tests/unit/testsuite/Magento/DesignEditor/Model/Url/NavigationModeTest.php b/dev/tests/unit/testsuite/Magento/DesignEditor/Model/Url/NavigationModeTest.php index c9cbd71bf55c746b27daaa38e8898bcd77a07ae6..c4d9a9e119e40d61f90beb472035650b82cfc791 100644 --- a/dev/tests/unit/testsuite/Magento/DesignEditor/Model/Url/NavigationModeTest.php +++ b/dev/tests/unit/testsuite/Magento/DesignEditor/Model/Url/NavigationModeTest.php @@ -51,6 +51,11 @@ class NavigationModeTest extends \PHPUnit_Framework_TestCase */ protected $_requestMock; + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $_routeParamsMock; + /** * @var array */ @@ -68,9 +73,19 @@ class NavigationModeTest extends \PHPUnit_Framework_TestCase array('editorMode', 'navigation'), array('themeId', 1)))); + $this->_routeParamsMock = $this->getMock( + 'Magento\Url\RouteParamsResolverFactory', array(), array(), '', false + ); + $this->_routeParamsMock->expects($this->any()) + ->method('create') + ->will($this->returnValue($this->getMock( + 'Magento\Core\Model\Url\RouteParamsResolver', array(), array(), '', false + ))); + $this->_model = $objectManagerHelper->getObject('Magento\DesignEditor\Model\Url\NavigationMode', array( 'helper' => $this->_designHelperMock, - 'data' => $this->_testData + 'data' => $this->_testData, + 'routeParamsResolver' => $this->_routeParamsMock )); } @@ -109,7 +124,7 @@ class NavigationModeTest extends \PHPUnit_Framework_TestCase ->method('isFrontUrlSecure') ->will($this->returnValue(false)); - $this->_model->setData('store', $store); + $this->_model->setData('scope', $store); $this->_model->setData('type', null); $this->_model->setData('route_front_name', self::FRONT_NAME); diff --git a/dev/tests/unit/testsuite/Magento/Directory/Helper/DataTest.php b/dev/tests/unit/testsuite/Magento/Directory/Helper/DataTest.php index f0e8c86a87a387723c23532036195e5288bf29d0..a3d7aa9ebbf76749b58a571849e3540424b35bbf 100644 --- a/dev/tests/unit/testsuite/Magento/Directory/Helper/DataTest.php +++ b/dev/tests/unit/testsuite/Magento/Directory/Helper/DataTest.php @@ -92,7 +92,7 @@ class DataTest extends \PHPUnit_Framework_TestCase 'coreHelper' => $this->_coreHelper, 'storeManager' => $storeManager, 'currencyFactory' => $currencyFactory, - 'config' => $this->getMock('Magento\Core\Model\Config', array(), array(), '', false), + 'config' => $this->getMock('Magento\App\ConfigInterface', array(), array(), '', false), ); $this->_object = $objectManager->getObject('Magento\Directory\Helper\Data', $arguments); } diff --git a/dev/tests/unit/testsuite/Magento/Directory/Model/Currency/DefaultLocatorTest.php b/dev/tests/unit/testsuite/Magento/Directory/Model/Currency/DefaultLocatorTest.php index e647fae51ccb933c6f956905203b91b1fe2891ee..c0ea3e4ddc3dd1ee33c865e30dead5fc8419046e 100644 --- a/dev/tests/unit/testsuite/Magento/Directory/Model/Currency/DefaultLocatorTest.php +++ b/dev/tests/unit/testsuite/Magento/Directory/Model/Currency/DefaultLocatorTest.php @@ -39,6 +39,11 @@ class DefaultLocatorTest extends \PHPUnit_Framework_TestCase */ protected $_appMock; + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $_storeManagerMock; + /** * @var \PHPUnit_Framework_MockObject_MockObject */ @@ -50,7 +55,8 @@ class DefaultLocatorTest extends \PHPUnit_Framework_TestCase $this->_requestMock = $this->getMockForAbstractClass('Magento\App\RequestInterface', array($backendData), '', false, false, true, array('getParam')); $this->_appMock = $this->getMock('Magento\Core\Model\App', array(), array(), '', false); - $this->_model = new \Magento\Directory\Model\Currency\DefaultLocator($this->_appMock); + $this->_storeManagerMock = $this->getMock('Magento\Core\Model\StoreManager', array(), array(), '', false); + $this->_model = new \Magento\Directory\Model\Currency\DefaultLocator($this->_appMock, $this->_storeManagerMock); } public function testGetDefaultCurrencyReturnDefaultStoreDefaultCurrencyIfNoStoreIsSpecified() @@ -66,7 +72,7 @@ class DefaultLocatorTest extends \PHPUnit_Framework_TestCase ->will($this->returnValue('someStore')); $storeMock = $this->getMock('Magento\Core\Model\Store', array(), array(), '', false); $storeMock->expects($this->once())->method('getBaseCurrencyCode')->will($this->returnValue('storeCurrency')); - $this->_appMock->expects($this->once())->method('getStore')->with('someStore') + $this->_storeManagerMock->expects($this->once())->method('getStore')->with('someStore') ->will($this->returnValue($storeMock)); $this->assertEquals('storeCurrency', $this->_model->getDefaultCurrency($this->_requestMock)); } @@ -80,7 +86,7 @@ class DefaultLocatorTest extends \PHPUnit_Framework_TestCase $websiteMock = $this->getMock('Magento\Core\Model\Website', array(), array(), '', false); $websiteMock->expects($this->once())->method('getBaseCurrencyCode') ->will($this->returnValue('websiteCurrency')); - $this->_appMock->expects($this->once())->method('getWebsite')->with('someWebsite') + $this->_storeManagerMock->expects($this->once())->method('getWebsite')->with('someWebsite') ->will($this->returnValue($websiteMock)); $this->assertEquals('websiteCurrency', $this->_model->getDefaultCurrency($this->_requestMock)); } @@ -100,7 +106,7 @@ class DefaultLocatorTest extends \PHPUnit_Framework_TestCase $groupMock->expects($this->once())->method('getWebsite') ->will($this->returnValue($websiteMock)); - $this->_appMock->expects($this->once())->method('getGroup')->with('someGroup') + $this->_storeManagerMock->expects($this->once())->method('getGroup')->with('someGroup') ->will($this->returnValue($groupMock)); $this->assertEquals('websiteCurrency', $this->_model->getDefaultCurrency($this->_requestMock)); } diff --git a/dev/tests/unit/testsuite/Magento/Downloadable/Model/Sales/Order/Pdf/Items/CreditmemoTest.php b/dev/tests/unit/testsuite/Magento/Downloadable/Model/Sales/Order/Pdf/Items/CreditmemoTest.php index ffa08a36453eef13c7f9668f8db07f37a7204e23..83cc325bb746b850f147404fbefe4863d83b9886 100644 --- a/dev/tests/unit/testsuite/Magento/Downloadable/Model/Sales/Order/Pdf/Items/CreditmemoTest.php +++ b/dev/tests/unit/testsuite/Magento/Downloadable/Model/Sales/Order/Pdf/Items/CreditmemoTest.php @@ -84,9 +84,13 @@ class CreditmemoTest extends \PHPUnit_Framework_TestCase 'Magento\Sales\Model\Order\Pdf\AbstractPdf', array('drawLineBlocks', 'getPdf'), array(), '', false, false ); + $filterManager = $this->getMock('Magento\Filter\FilterManager', array('stripTags'), array(), '', false); + $filterManager->expects($this->any())->method('stripTags')->will($this->returnArgument(0)); + $modelConstructorArgs = $objectManager ->getConstructArguments('Magento\Downloadable\Model\Sales\Order\Pdf\Items\Creditmemo', array( - 'string' => new \Magento\Stdlib\String() + 'string' => new \Magento\Stdlib\String(), + 'filterManager' => $filterManager )); $this->_model = $this->getMock( diff --git a/dev/tests/unit/testsuite/Magento/Eav/Model/Resource/Entity/AttributeTest.php b/dev/tests/unit/testsuite/Magento/Eav/Model/Resource/Entity/AttributeTest.php index 4bd9b12d325baa5899d3d49cbe21a041538a2ba0..13131375ea7a32dc57c3729d4a5424e3bbeca17a 100644 --- a/dev/tests/unit/testsuite/Magento/Eav/Model/Resource/Entity/AttributeTest.php +++ b/dev/tests/unit/testsuite/Magento/Eav/Model/Resource/Entity/AttributeTest.php @@ -205,8 +205,8 @@ class AttributeTest extends \PHPUnit_Framework_TestCase array('status', '"status"'), ))); - $application = $this->getMock('Magento\Core\Model\App', array('getStores'), array(), '', false); - $application->expects($this->any()) + $storeManager = $this->getMock('Magento\Core\Model\StoreManager', array('getStores'), array(), '', false); + $storeManager->expects($this->any()) ->method('getStores') ->with(true) ->will($this->returnValue(array( @@ -228,12 +228,8 @@ class AttributeTest extends \PHPUnit_Framework_TestCase $eavEntityType = $this->getMock('Magento\Eav\Model\Resource\Entity\Type', array(), array(), '', false, false); $arguments = array( 'resource' => $resource, - 'app' => $this->getMock('Magento\Core\Model\App', array(), array(), '', false, false), + 'storeManager' => $storeManager, 'eavEntityType' => $eavEntityType, - 'arguments' => array( - 'application' => $application, - 'helper' => $this->getMock('Magento\Eav\Helper\Data', array(), array(), '', false, false), - ) ); $resourceModel = $this->getMock( 'Magento\Eav\Model\Resource\Entity\Attribute', diff --git a/dev/tests/unit/testsuite/Magento/GoogleAdwords/Helper/DataTest.php b/dev/tests/unit/testsuite/Magento/GoogleAdwords/Helper/DataTest.php index 8fc783f767e21a8155533ce8fcd2124ecab5ac9e..37b350c2df0621f1dbe2c7a866efa59f3ebd2e97 100644 --- a/dev/tests/unit/testsuite/Magento/GoogleAdwords/Helper/DataTest.php +++ b/dev/tests/unit/testsuite/Magento/GoogleAdwords/Helper/DataTest.php @@ -52,7 +52,7 @@ class DataTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_configMock = $this->getMock('Magento\Core\Model\Config', array(), array(), '', false); + $this->_configMock = $this->getMock('Magento\App\ConfigInterface', array(), array(), '', false); $this->_storeConfigMock = $this->getMock( 'Magento\Core\Model\Store\ConfigInterface', array(), array(), '', false ); diff --git a/dev/tests/unit/testsuite/Magento/GroupedProduct/Block/Adminhtml/Order/Create/SidebarTest.php b/dev/tests/unit/testsuite/Magento/GroupedProduct/Block/Adminhtml/Order/Create/SidebarTest.php new file mode 100644 index 0000000000000000000000000000000000000000..c282ac2044b57a4548ef672d2b4fcf1f93a7a62e --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/GroupedProduct/Block/Adminhtml/Order/Create/SidebarTest.php @@ -0,0 +1,99 @@ +<?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\GroupedProduct\Block\Adminhtml\Order\Create; + +class SidebarTest extends \PHPUnit_Framework_TestCase +{ + + /** + * @var \Magento\GroupedProduct\Block\Adminhtml\Order\Create\Sidebar + */ + protected $sidebarMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $invocationChainMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $itemMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $productMock; + + protected function setUp() + { + $this->invocationChainMock = $this->getMock('Magento\Code\Plugin\InvocationChain', array(), array(), '', false); + $this->itemMock = $this->getMock('Magento\Catalog\Model\Product\Configuration\Item\ItemInterface'); + $this->productMock = $this->getMock('Magento\Catalog\Model\Product', array(), array(), '', false); + $this->sidebarMock = new \Magento\GroupedProduct\Block\Adminhtml\Order\Create\Sidebar(); + } + + public function testAroundGetItemQtyWhenProductGrouped() + { + $this->itemMock->expects($this->once())->method('getProduct')->will($this->returnValue($this->productMock)); + $this->productMock + ->expects($this->once()) + ->method('getTypeId') + ->will($this->returnValue(\Magento\GroupedProduct\Model\Product\Type\Grouped::TYPE_CODE)); + $this->invocationChainMock->expects($this->never())->method('proceed'); + $this->assertEquals('', + $this->sidebarMock->aroundGetItemQty(array($this->itemMock), $this->invocationChainMock)); + } + + public function testAroundGetItemQtyWhenProductNotGrouped() + { + $arguments = array($this->itemMock); + $this->itemMock->expects($this->once())->method('getProduct')->will($this->returnValue($this->productMock)); + $this->productMock + ->expects($this->once()) + ->method('getTypeId') + ->will($this->returnValue('one')); + $this->invocationChainMock->expects($this->once())->method('proceed')->with($arguments); + $this->sidebarMock->aroundGetItemQty($arguments, $this->invocationChainMock); + } + + public function testAroundIsConfigurationRequiredWhenProductGrouped() + { + $this->invocationChainMock->expects($this->never())->method('proceed'); + $this->assertEquals(true, + $this->sidebarMock->aroundIsConfigurationRequired( + array(\Magento\GroupedProduct\Model\Product\Type\Grouped::TYPE_CODE), + $this->invocationChainMock) + ); + } + + public function testAroundIsConfigurationRequiredWhenProductNotGrouped() + { + $arguments = array('someValue'); + $this->invocationChainMock->expects($this->once())->method('proceed')->with($arguments); + $this->sidebarMock->aroundIsConfigurationRequired($arguments, $this->invocationChainMock); + } +} + diff --git a/dev/tests/unit/testsuite/Magento/Checkout/Block/Cart/Item/Renderer/GroupedTest.php b/dev/tests/unit/testsuite/Magento/GroupedProduct/Block/Cart/Item/Renderer/GroupedTest.php similarity index 96% rename from dev/tests/unit/testsuite/Magento/Checkout/Block/Cart/Item/Renderer/GroupedTest.php rename to dev/tests/unit/testsuite/Magento/GroupedProduct/Block/Cart/Item/Renderer/GroupedTest.php index 201361a81ed843b0ef34783120875a0348135f35..f350ffe2a45a15e7fa8723a727a489ac4ba4630e 100644 --- a/dev/tests/unit/testsuite/Magento/Checkout/Block/Cart/Item/Renderer/GroupedTest.php +++ b/dev/tests/unit/testsuite/Magento/GroupedProduct/Block/Cart/Item/Renderer/GroupedTest.php @@ -25,9 +25,9 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Checkout\Block\Cart\Item\Renderer; +namespace Magento\GroupedProduct\Block\Cart\Item\Renderer; -use Magento\Checkout\Block\Cart\Item\Renderer\Grouped as Renderer; +use Magento\GroupedProduct\Block\Cart\Item\Renderer\Grouped as Renderer; use \Magento\Catalog\Model\Config\Source\Product\Thumbnail as ThumbnailSource; class GroupedTest extends \PHPUnit_Framework_TestCase @@ -44,7 +44,7 @@ class GroupedTest extends \PHPUnit_Framework_TestCase $objectManagerHelper = new \Magento\TestFramework\Helper\ObjectManager($this); $this->_storeConfig = $this->getMock('Magento\Core\Model\Store\Config', array(), array(), '', false, false); $this->_renderer = $objectManagerHelper->getObject( - 'Magento\Checkout\Block\Cart\Item\Renderer\Grouped', + 'Magento\GroupedProduct\Block\Cart\Item\Renderer\Grouped', array( 'storeConfig' => $this->_storeConfig, ) diff --git a/dev/tests/unit/testsuite/Magento/GroupedProduct/Model/Product/Cart/Configuration/Plugin/GroupedTest.php b/dev/tests/unit/testsuite/Magento/GroupedProduct/Model/Product/Cart/Configuration/Plugin/GroupedTest.php new file mode 100644 index 0000000000000000000000000000000000000000..e3d2bf2606d362344eb654716895a8b54fea4401 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/GroupedProduct/Model/Product/Cart/Configuration/Plugin/GroupedTest.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\GroupedProduct\Model\Product\Cart\Configuration\Plugin; + +class GroupedTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\GroupedProduct\Model\Product\Cart\Configuration\Plugin\Grouped + */ + protected $groupedPlugin; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $invocationChainMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $productMock; + + protected function setUp() + { + $this->invocationChainMock = $this->getMock('Magento\Code\Plugin\InvocationChain', array(), array(), '', false); + $this->productMock = $this->getMock('Magento\Catalog\Model\Product', array(), array(), '', false); + $this->groupedPlugin = new \Magento\GroupedProduct\Model\Product\Cart\Configuration\Plugin\Grouped(); + } + + public function testAroundIsProductConfiguredWhenProductGrouped() + { + $config = array('super_group' => 'product'); + $this->productMock + ->expects($this->once()) + ->method('getTypeId') + ->will($this->returnValue(\Magento\GroupedProduct\Model\Product\Type\Grouped::TYPE_CODE)); + $this->invocationChainMock->expects($this->never())->method('proceed'); + $this->assertEquals(true, + $this->groupedPlugin->aroundIsProductConfigured( + array($this->productMock, $config), $this->invocationChainMock)); + } + + public function testAroundIsProductConfiguredWhenProductIsNotGrouped() + { + $config = array('super_group' => 'product'); + $this->productMock + ->expects($this->once()) + ->method('getTypeId') + ->will($this->returnValue('product')); + $this->invocationChainMock->expects($this->once())->method('proceed')->with(array($this->productMock, $config)); + $this->groupedPlugin->aroundIsProductConfigured(array($this->productMock, $config), $this->invocationChainMock); + } +} + diff --git a/dev/tests/unit/testsuite/Magento/GroupedProduct/Model/Product/CatalogPriceTest.php b/dev/tests/unit/testsuite/Magento/GroupedProduct/Model/Product/CatalogPriceTest.php new file mode 100644 index 0000000000000000000000000000000000000000..5969163a2c9df4840d2201bf5355a135e7b3696a --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/GroupedProduct/Model/Product/CatalogPriceTest.php @@ -0,0 +1,170 @@ +<?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\GroupedProduct\Model\Product; + + +class CatalogPriceTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\GroupedProduct\Model\Product\CatalogPrice + */ + protected $catalogPrice; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $storeManagerMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $commonPriceMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $productMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $priceModelMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $productTypeMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $associatedProductMock; + + protected function setUp() + { + $this->storeManagerMock = $this->getMock('Magento\Core\Model\StoreManagerInterface'); + $this->commonPriceMock + = $this->getMock('Magento\Catalog\Model\Product\CatalogPrice', array(), array(), '', false); + $productMethods = array('getWebsiteId', 'getCustomerGroupId', '__wakeup', 'getTypeInstance', 'setTaxClassId'); + $this->productMock = $this->getMock('Magento\Catalog\Model\Product', $productMethods, array(), '', false); + $methods = array('setWebsiteId', 'isSalable', '__wakeup', 'setCustomerGroupId', 'getTaxClassId'); + $this->associatedProductMock = $this->getMock('Magento\Catalog\Model\Product', $methods, array(), '', false); + $this->priceModelMock + = $this->getMock('Magento\Catalog\Model\Product\Type\Price', array('getTotalPrices'), array(), '', false); + $this->productTypeMock + = $this->getMock('Magento\GroupedProduct\Model\Product\Type\Grouped', array(), array(), '', false); + + $this->catalogPrice = new \Magento\GroupedProduct\Model\Product\CatalogPrice( + $this->storeManagerMock, + $this->commonPriceMock + ); + } + + public function testGetCatalogPriceWithDefaultStoreAndWhenProductDoesNotHaveAssociatedProducts() + { + $this->productMock + ->expects($this->once()) + ->method('getTypeInstance') + ->will($this->returnValue($this->productTypeMock)); + $this->productTypeMock + ->expects($this->once()) + ->method('getAssociatedProducts') + ->with($this->productMock)->will($this->returnValue(array())); + $this->storeManagerMock->expects($this->never())->method('getStore'); + $this->storeManagerMock->expects($this->never())->method('setCurrentStore'); + $this->assertEquals(null, $this->catalogPrice->getCatalogPrice($this->productMock)); + } + + public function testGetCatalogPriceWithDefaultStoreAndSubProductIsNotSalable() + { + $this->productMock + ->expects($this->once()) + ->method('getTypeInstance') + ->will($this->returnValue($this->productTypeMock)); + $this->productTypeMock + ->expects($this->once()) + ->method('getAssociatedProducts') + ->with($this->productMock)->will($this->returnValue(array($this->associatedProductMock))); + $this->productMock->expects($this->once())->method('getWebsiteId')->will($this->returnValue('website_id')); + $this->productMock->expects($this->once())->method('getCustomerGroupId')->will($this->returnValue('group_id')); + $this->associatedProductMock + ->expects($this->once()) + ->method('setWebsiteId') + ->will($this->returnValue($this->associatedProductMock)); + $this->associatedProductMock + ->expects($this->once()) + ->method('setCustomerGroupId') + ->with('group_id') + ->will($this->returnValue($this->associatedProductMock)); + $this->associatedProductMock->expects($this->once())->method('isSalable')->will($this->returnValue(false)); + $this->productMock->expects($this->never())->method('setTaxClassId'); + $this->storeManagerMock->expects($this->never())->method('getStore'); + $this->storeManagerMock->expects($this->never())->method('setCurrentStore'); + $this->assertEquals(null, $this->catalogPrice->getCatalogPrice($this->productMock)); + } + + public function testGetCatalogPriceWithCustomStoreAndSubProductIsSalable() + { + $storeMock = $this->getMock('Magento\Core\Model\Store', array(), array(), '', false); + $this->productMock + ->expects($this->once()) + ->method('getTypeInstance') + ->will($this->returnValue($this->productTypeMock)); + $this->productTypeMock + ->expects($this->once()) + ->method('getAssociatedProducts') + ->with($this->productMock)->will($this->returnValue(array($this->associatedProductMock))); + $this->productMock->expects($this->once())->method('getWebsiteId')->will($this->returnValue('website_id')); + $this->productMock->expects($this->once())->method('getCustomerGroupId')->will($this->returnValue('group_id')); + $this->associatedProductMock + ->expects($this->once()) + ->method('setWebsiteId') + ->will($this->returnValue($this->associatedProductMock)); + $this->associatedProductMock + ->expects($this->once()) + ->method('setCustomerGroupId') + ->with('group_id') + ->will($this->returnValue($this->associatedProductMock)); + $this->associatedProductMock->expects($this->once())->method('isSalable')->will($this->returnValue(true)); + $this->commonPriceMock + ->expects($this->exactly(2)) + ->method('getCatalogPrice') + ->with($this->associatedProductMock) + ->will($this->returnValue(15)); + $this->associatedProductMock + ->expects($this->once()) + ->method('getTaxClassId') + ->will($this->returnValue('tax_class')); + $this->productMock->expects($this->once())->method('setTaxClassId')->with('tax_class'); + $this->storeManagerMock->expects($this->exactly(2))->method('setCurrentStore'); + $this->assertEquals(15, $this->catalogPrice->getCatalogPrice($this->productMock, $storeMock, true)); + } + + public function testGetCatalogRegularPrice() + { + $this->assertEquals(null, $this->catalogPrice->getCatalogRegularPrice($this->productMock)); + } +} + diff --git a/dev/tests/unit/testsuite/Magento/GroupedProduct/Model/Product/Type/PluginTest.php b/dev/tests/unit/testsuite/Magento/GroupedProduct/Model/Product/Type/PluginTest.php new file mode 100644 index 0000000000000000000000000000000000000000..212fd14d9de5f4114a77e97a0217031279025ac7 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/GroupedProduct/Model/Product/Type/PluginTest.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\GroupedProduct\Model\Product\Type; + +class PluginTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var PHPUnit_Framework_MockObject_MockObject + */ + protected $moduleManagerMock; + + /** + * @var \Magento\GroupedProduct\Model\Product\Type\Plugin + */ + protected $object; + + protected function setUp() + { + $this->moduleManagerMock = $this->getMock('\Magento\Module\Manager', array(), array(), '', false); + $this->object = new \Magento\GroupedProduct\Model\Product\Type\Plugin($this->moduleManagerMock); + } + + public function testAfterGetOptionArray() + { + $this->moduleManagerMock->expects($this->any())->method('isOutputEnabled')->will($this->returnValue(false)); + $this->assertEquals(array(), $this->object->afterGetOptionArray(array('grouped' => 'test'))); + } +} diff --git a/dev/tests/unit/testsuite/Magento/ImportExport/Model/Export/Entity/Eav/Customer/AddressTest.php b/dev/tests/unit/testsuite/Magento/ImportExport/Model/Export/Entity/Eav/Customer/AddressTest.php index 64c6f59c81e065e4a8e5dbdb814eb3fa78bc3d80..0489b8127dcba712650c3c82edf32c60420bb3f6 100644 --- a/dev/tests/unit/testsuite/Magento/ImportExport/Model/Export/Entity/Eav/Customer/AddressTest.php +++ b/dev/tests/unit/testsuite/Magento/ImportExport/Model/Export/Entity/Eav/Customer/AddressTest.php @@ -99,10 +99,16 @@ class AddressTest extends \PHPUnit_Framework_TestCase protected function setUp() { + + $storeManager = $this->getMock('Magento\Core\Model\StoreManager', array(), array(), '', false); + $storeManager->expects($this->once()) + ->method('getWebsites') + ->will($this->returnCallback(array($this, 'getWebsites'))); + $this->_objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); $this->_model = new \Magento\ImportExport\Model\Export\Entity\Eav\Customer\Address( $this->getMock('Magento\Core\Model\Store\Config', array(), array(), '', false), - $this->getMock('Magento\Core\Model\App', array(), array(), '', false), + $storeManager, $this->getMock('Magento\ImportExport\Model\Export\Factory', array(), array(), '', false), $this->getMock( 'Magento\ImportExport\Model\Resource\CollectionByPagesIteratorFactory', array(), array(), '', false @@ -129,11 +135,6 @@ class AddressTest extends \PHPUnit_Framework_TestCase */ protected function _getModelDependencies() { - $websiteManager = $this->getMock('stdClass', array('getWebsites')); - $websiteManager->expects($this->once()) - ->method('getWebsites') - ->will($this->returnCallback(array($this, 'getWebsites'))); - $translator = $this->getMock('stdClass'); $entityFactory = $this->getMock('Magento\Core\Model\EntityFactory', array(), array(), '', false); @@ -176,8 +177,6 @@ class AddressTest extends \PHPUnit_Framework_TestCase ->will($this->returnSelf()); $data = array( - 'website_manager' => $websiteManager, - 'store_manager' => 'not_used', 'translator' => $translator, 'attribute_collection' => $attributeCollection, 'page_size' => 1, diff --git a/dev/tests/unit/testsuite/Magento/ImportExport/Model/Export/Entity/Eav/CustomerTest.php b/dev/tests/unit/testsuite/Magento/ImportExport/Model/Export/Entity/Eav/CustomerTest.php index f6a31794d8f381e75d24ee58f53f56ddab04214f..70de1f948dcdc756e6d42d59a110977fb5edae8c 100644 --- a/dev/tests/unit/testsuite/Magento/ImportExport/Model/Export/Entity/Eav/CustomerTest.php +++ b/dev/tests/unit/testsuite/Magento/ImportExport/Model/Export/Entity/Eav/CustomerTest.php @@ -87,9 +87,19 @@ class CustomerTest extends \PHPUnit_Framework_TestCase protected function setUp() { + $storeManager = $this->getMock('Magento\Core\Model\StoreManager', array(), array(), '', false); + + $storeManager->expects($this->any()) + ->method('getWebsites') + ->will($this->returnCallback(array($this, 'getWebsites'))); + + $storeManager->expects($this->any()) + ->method('getStores') + ->will($this->returnCallback(array($this, 'getStores'))); + $this->_model = new \Magento\ImportExport\Model\Export\Entity\Eav\Customer( $this->getMock('Magento\Core\Model\Store\Config', array(), array(), '', false), - $this->getMock('Magento\Core\Model\App', array(), array(), '', false), + $storeManager, $this->getMock('Magento\ImportExport\Model\Export\Factory', array(), array(), '', false), $this->getMock( 'Magento\ImportExport\Model\Resource\CollectionByPagesIteratorFactory', array(), array(), '', false @@ -113,16 +123,6 @@ class CustomerTest extends \PHPUnit_Framework_TestCase */ protected function _getModelDependencies() { - $websiteManager = $this->getMock('stdClass', array('getWebsites')); - $websiteManager->expects($this->once()) - ->method('getWebsites') - ->will($this->returnCallback(array($this, 'getWebsites'))); - - $storeManager = $this->getMock('stdClass', array('getStores')); - $storeManager->expects($this->once()) - ->method('getStores') - ->will($this->returnCallback(array($this, 'getStores'))); - $translator = $this->getMock('stdClass'); $objectManagerHelper = new \Magento\TestFramework\Helper\ObjectManager($this); @@ -142,8 +142,6 @@ class CustomerTest extends \PHPUnit_Framework_TestCase } $data = array( - 'website_manager' => $websiteManager, - 'store_manager' => $storeManager, 'translator' => $translator, 'attribute_collection' => $attributeCollection, 'page_size' => 1, diff --git a/dev/tests/unit/testsuite/Magento/ImportExport/Model/Import/Entity/Eav/Customer/AddressTest.php b/dev/tests/unit/testsuite/Magento/ImportExport/Model/Import/Entity/Eav/Customer/AddressTest.php index 49490d08281f5b306e4ff169fe6179aa8df40e85..da49daa955aba08480474579af92ffc8a2c63111 100644 --- a/dev/tests/unit/testsuite/Magento/ImportExport/Model/Import/Entity/Eav/Customer/AddressTest.php +++ b/dev/tests/unit/testsuite/Magento/ImportExport/Model/Import/Entity/Eav/Customer/AddressTest.php @@ -217,8 +217,6 @@ class AddressTest extends \PHPUnit_Framework_TestCase 'page_size' => 1, 'max_data_size' => 1, 'bunch_size' => 1, - 'website_manager' => $websiteManager, - 'store_manager' => 'not_used', 'attribute_collection' => $attributeCollection, 'entity_type_id' => 1, 'customer_storage' => $customerStorage, @@ -483,6 +481,10 @@ class AddressTest extends \PHPUnit_Framework_TestCase protected function _getModelMock() { $coreStoreConfig = $this->getMock('Magento\Core\Model\Store\Config', array(), array(), '', false); + $storeManager = $this->getMock('\Magento\Core\Model\StoreManager', array('getWebsites'), array(), '', false); + $storeManager->expects($this->once()) + ->method('getWebsites') + ->will($this->returnCallback(array($this, 'getWebsites'))); $modelMock = new \Magento\ImportExport\Model\Import\Entity\Eav\Customer\Address( $this->_coreDataMock, @@ -491,7 +493,7 @@ class AddressTest extends \PHPUnit_Framework_TestCase $this->getMock('Magento\ImportExport\Model\ImportFactory', array(), array(), '', false), $this->getMock('Magento\ImportExport\Model\Resource\Helper', array(), array(), '', false), $this->getMock('Magento\App\Resource', array(), array(), '', false), - $this->getMock('Magento\Core\Model\App', array(), array(), '', false), + $storeManager, $this->getMock('Magento\ImportExport\Model\Export\Factory', array(), array(), '', false), $this->getMock('Magento\Eav\Model\Config', array(), array(), '', false), $this->getMock('Magento\ImportExport\Model\Resource\Customer\StorageFactory', array(), array(), '', false), diff --git a/dev/tests/unit/testsuite/Magento/ImportExport/Model/Import/Entity/EavAbstractTest.php b/dev/tests/unit/testsuite/Magento/ImportExport/Model/Import/Entity/EavAbstractTest.php index 9eb29a22cf264e85281a1a15023bfcd2aaecc608..8f6569bd3d1d4f398caf2d21db70e7dd16718e39 100644 --- a/dev/tests/unit/testsuite/Magento/ImportExport/Model/Import/Entity/EavAbstractTest.php +++ b/dev/tests/unit/testsuite/Magento/ImportExport/Model/Import/Entity/EavAbstractTest.php @@ -72,7 +72,7 @@ class EavAbstractTest extends \PHPUnit_Framework_TestCase /** * @var \Magento\Core\Model\App */ - protected $_app; + protected $_storeManager; /** * @var \Magento\ImportExport\Model\Export\Factory @@ -95,7 +95,7 @@ class EavAbstractTest extends \PHPUnit_Framework_TestCase $this->_resourceHelper = $this->getMock( 'Magento\ImportExport\Model\Resource\Helper', array(), array(), '', false ); - $this->_app = $this->getMock('Magento\Core\Model\App', array(), array(), '', false); + $this->_storeManager = $this->getMock('Magento\Core\Model\StoreManager', array(), array(), '', false); $this->_collectionFactory = $this->getMock( 'Magento\ImportExport\Model\Export\Factory', array(), array(), '', false); $this->_eavConfig = $this->getMock( @@ -109,7 +109,7 @@ class EavAbstractTest extends \PHPUnit_Framework_TestCase $this->_importFactory, $this->_resourceHelper, $this->_resource, - $this->_app, + $this->_storeManager, $this->_collectionFactory, $this->_eavConfig, $this->_getModelDependencies() diff --git a/dev/tests/unit/testsuite/Magento/Index/App/IndexerTest.php b/dev/tests/unit/testsuite/Magento/Index/App/IndexerTest.php index 7cef4fbaca664d2394ffb809947f26dcc6612d86..7dc0e46c048ca259fd440c8c82759c215da25805 100644 --- a/dev/tests/unit/testsuite/Magento/Index/App/IndexerTest.php +++ b/dev/tests/unit/testsuite/Magento/Index/App/IndexerTest.php @@ -78,7 +78,7 @@ class IndexerTest extends \PHPUnit_Framework_TestCase * @param bool $value * @dataProvider executeDataProvider */ - public function testExecute($value) + public function testLaunch($value) { $process = $this->getMock( 'Magento\Index\Model\Process', @@ -101,7 +101,7 @@ class IndexerTest extends \PHPUnit_Framework_TestCase $indexerInterface->expects($this->once())->method('isVisible')->will($this->returnValue(false)); $process->expects($this->never())->method('reindexEverything'); } - $this->assertEquals($this->_responseMock, $this->_entryPoint->execute()); + $this->assertEquals($this->_responseMock, $this->_entryPoint->launch()); } /** diff --git a/dev/tests/unit/testsuite/Magento/Index/App/ShellTest.php b/dev/tests/unit/testsuite/Magento/Index/App/ShellTest.php index b48c46c8b7efbd889272050e2b6ca31d99b7a2ec..fd4dfb12cfe977a350cf0249632811075ab7ec7d 100644 --- a/dev/tests/unit/testsuite/Magento/Index/App/ShellTest.php +++ b/dev/tests/unit/testsuite/Magento/Index/App/ShellTest.php @@ -80,7 +80,7 @@ class ShellTest extends \PHPUnit_Framework_TestCase ->will($this->returnValue($shell) ); - $this->_entryPoint->execute(); + $this->_entryPoint->launch(); } /** diff --git a/dev/tests/unit/testsuite/Magento/Indexer/App/IndexerTest.php b/dev/tests/unit/testsuite/Magento/Indexer/App/IndexerTest.php new file mode 100644 index 0000000000000000000000000000000000000000..ebf5fd098c188c4da444e8284b50d875734b9dc2 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Indexer/App/IndexerTest.php @@ -0,0 +1,76 @@ +<?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\Indexer\App; + +class IndexerTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Indexer\App\Indexer + */ + protected $entryPoint; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Indexer\Model\Processor + */ + protected $processorMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Filesystem + */ + protected $filesystemMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\App\Console\Response + */ + protected $responseMock; + + protected function setUp() + { + $this->responseMock = $this->getMock('Magento\App\Console\Response', array('setCode'), array(), '', false); + $this->filesystemMock = $this->getMock('Magento\Filesystem', array('getDirectoryWrite'), array(), '', false); + $directoryMock = $this->getMock('Magento\Filesystem\Directory\Write', array(), array(), '', false); + $directoryMock->expects($this->any()) + ->method('getRelativePath') + ->will($this->returnArgument(0)); + $this->filesystemMock->expects($this->once()) + ->method('getDirectoryWrite') + ->will($this->returnValue($directoryMock)); + $this->processorMock = $this->getMock('Magento\Indexer\Model\Processor', array(), array(), '', false); + $this->entryPoint = new \Magento\Indexer\App\Indexer( + 'reportDir', + $this->filesystemMock, + $this->processorMock, + $this->responseMock + ); + } + + public function testLaunch() + { + $this->responseMock->expects($this->once()) + ->method('setCode') + ->with(0); + $this->processorMock->expects($this->once())->method('reindexAll'); + $this->assertSame($this->responseMock, $this->entryPoint->launch()); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Indexer/App/ShellTest.php b/dev/tests/unit/testsuite/Magento/Indexer/App/ShellTest.php new file mode 100644 index 0000000000000000000000000000000000000000..c29a7f48901d7050cfb2b605031f06dd273061c7 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Indexer/App/ShellTest.php @@ -0,0 +1,94 @@ +<?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\Indexer\App; + +class ShellTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Index\App\Shell + */ + protected $entryPoint; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $shellFactoryMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $errorHandlerMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\App\Console\Response + */ + protected $responseMock; + + protected function setUp() + { + $this->shellFactoryMock = $this->getMock('Magento\Indexer\Model\ShellFactory', + array('create'), array(), '', false); + $this->responseMock = $this->getMock('Magento\App\Console\Response', array(), array(), '', false); + $this->entryPoint = new \Magento\Indexer\App\Shell( + 'indexer.php', + $this->shellFactoryMock, + $this->responseMock + ); + } + + /** + * @param boolean $shellHasErrors + * @dataProvider processRequestDataProvider + */ + public function testProcessRequest($shellHasErrors) + { + $shell = $this->getMock('Magento\Indexer\Model\Shell', array(), array(), '', false); + $shell->expects($this->once()) + ->method('hasErrors') + ->will($this->returnValue($shellHasErrors)); + $shell->expects($this->once()) + ->method('run'); + $this->responseMock->expects($this->once()) + ->method('setCode') + ->with($shellHasErrors ? -1 : 0) + ->will($this->returnSelf()); + $this->shellFactoryMock->expects($this->any()) + ->method('create') + ->will($this->returnValue($shell) + ); + + $this->entryPoint->launch(); + } + + /** + * @return array + */ + public function processRequestDataProvider() + { + return array( + array(true), + array(false) + ); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Indexer/Model/ActionFactoryTest.php b/dev/tests/unit/testsuite/Magento/Indexer/Model/ActionFactoryTest.php new file mode 100644 index 0000000000000000000000000000000000000000..b71c77da2dc6def6790b646cb7eb3ff188a91d2c --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Indexer/Model/ActionFactoryTest.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\Indexer\Model; + +class ActionFactoryTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Indexer\Model\ActionFactory|\PHPUnit_Framework_MockObject_MockObject + */ + protected $model; + + /** + * @var \Magento\ObjectManager|\PHPUnit_Framework_MockObject_MockObject + */ + protected $objectManagerMock; + + protected function setUp() + { + $this->objectManagerMock = $this->getMock('Magento\ObjectManager', array(), array(), '', false); + $this->model = new \Magento\Indexer\Model\ActionFactory($this->objectManagerMock); + } + + /** + * @expectedException \InvalidArgumentException + * @expectedExceptionMessage NotAction doesn't implement \Magento\Indexer\Model\ActionInterface + */ + public function testGetWithException() + { + $notActionInterfaceMock = $this->getMock('NotAction', array(), array(), '', false); + $this->objectManagerMock->expects($this->once()) + ->method('get') + ->with('NotAction') + ->will($this->returnValue($notActionInterfaceMock)); + $this->model->get('NotAction'); + } + + public function testGet() + { + $actionInterfaceMock = $this->getMockForAbstractClass( + 'Magento\Indexer\Model\ActionInterface', array(), '', false + ); + $this->objectManagerMock->expects($this->once()) + ->method('get') + ->with('Magento\Indexer\Model\ActionInterface') + ->will($this->returnValue($actionInterfaceMock)); + $this->model->get('Magento\Indexer\Model\ActionInterface'); + $this->assertInstanceOf('Magento\Indexer\Model\ActionInterface', $actionInterfaceMock); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Indexer/Model/Config/ConverterTest.php b/dev/tests/unit/testsuite/Magento/Indexer/Model/Config/ConverterTest.php new file mode 100644 index 0000000000000000000000000000000000000000..99a838559cb80b29dc3c2832cf78a151530ed2c3 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Indexer/Model/Config/ConverterTest.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\Indexer\Model\Config; + +class ConverterTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Indexer\Model\Config\Converter|\PHPUnit_Framework_MockObject_MockObject + */ + protected $_model; + + protected function setUp() + { + $this->_model = new \Magento\Indexer\Model\Config\Converter; + } + + public function testConvert() + { + $data = include __DIR__ . '/../../_files/indexer_config.php'; + $dom = new \DOMDocument(); + $dom->loadXML($data['inputXML']); + + $this->assertEquals($data['expected'], $this->_model->convert($dom)); + } + + /** + * @param string $xmlData + * @dataProvider wrongXmlDataProvider + * @expectedException \Exception + */ + public function testMapThrowsExceptionWhenXmlHasWrongFormat($xmlData) + { + $dom = new \DOMDocument(); + $dom->loadXML($xmlData); + $this->_model->convert($dom); + } + + /** + * @return array + */ + public function wrongXmlDataProvider() + { + return array( + array( + '<?xml version="1.0"?><config>', + ) + ); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Indexer/Model/Config/ReaderTest.php b/dev/tests/unit/testsuite/Magento/Indexer/Model/Config/ReaderTest.php new file mode 100644 index 0000000000000000000000000000000000000000..3911050f1fac8d27cc9b9eb46f0a1cb594ed8ffd --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Indexer/Model/Config/ReaderTest.php @@ -0,0 +1,126 @@ +<?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\Indexer\Model\Config; + +class ReaderTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Indexer\Model\Config\Reader + */ + protected $_model; + + /** + * @var \Magento\Indexer\Model\Config\Converter|\PHPUnit_Framework_MockObject_MockObject + */ + protected $_converter; + + /** + * @var \Magento\Core\Model\Config\FileResolver|\PHPUnit_Framework_MockObject_MockObject + */ + protected $_fileResolverMock; + + protected function setUp() + { + $this->_fileResolverMock = $this->getMock( + 'Magento\Core\Model\Config\FileResolver', array('get'), array(), '', false + ); + + $this->_converter = $this->getMock( + 'Magento\Indexer\Model\Config\Converter', array('convert') + ); + + $moduleReader = $this->getMock( + 'Magento\Module\Dir\Reader', array('getModuleDir'), array(), '', false + ); + $moduleReader->expects($this->once()) + ->method('getModuleDir') + ->with('etc', 'Magento_Indexer') + ->will($this->returnValue('stub')) + ; + $schemaLocator = new \Magento\Indexer\Model\Config\SchemaLocator($moduleReader); + + $validationState = $this->getMock('Magento\Config\ValidationStateInterface'); + $validationState->expects($this->once())->method('isValidated')->will($this->returnValue(false)); + + $this->_model = new \Magento\Indexer\Model\Config\Reader( + $this->_fileResolverMock, + $this->_converter, + $schemaLocator, + $validationState + ); + } + + /** + * @dataProvider readerDataProvider + */ + public function testReadValidConfig($files, $expectedFile) + { + $this->_fileResolverMock->expects($this->once()) + ->method('get') + ->with('indexer.xml', 'scope') + ->will($this->returnValue($files)); + + $constraint = function (\DOMDocument $actual) use ($expectedFile) { + try { + $expected = file_get_contents(__DIR__ . '/../../_files/' . $expectedFile); + \PHPUnit_Framework_Assert::assertXmlStringEqualsXmlString($expected, $actual->saveXML()); + return true; + } catch (\PHPUnit_Framework_AssertionFailedError $e) { + return false; + } + }; + $expectedResult = new \stdClass(); + $this->_converter + ->expects($this->once()) + ->method('convert') + ->with($this->callback($constraint)) + ->will($this->returnValue($expectedResult)) + ; + + $this->assertSame($expectedResult, $this->_model->read('scope')); + } + + /** + * @return array + */ + public function readerDataProvider() + { + return array( + array( + array( + 'indexer_one.xml' => file_get_contents(__DIR__ . '/../../_files/indexer_one.xml'), + 'indexer_two.xml' => file_get_contents(__DIR__ . '/../../_files/indexer_two.xml'), + ), + 'indexer_merged_one.xml', + ), + array( + array( + 'indexer_one.xml' => file_get_contents(__DIR__ . '/../../_files/indexer_one.xml'), + 'indexer_three.xml' => file_get_contents(__DIR__ . '/../../_files/indexer_three.xml'), + ), + 'indexer_merged_two.xml', + ), + ); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Indexer/Model/Indexer/CollectionTest.php b/dev/tests/unit/testsuite/Magento/Indexer/Model/Indexer/CollectionTest.php new file mode 100644 index 0000000000000000000000000000000000000000..7652c3259ea0092acd2238366109ba981d96b840 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Indexer/Model/Indexer/CollectionTest.php @@ -0,0 +1,92 @@ +<?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\Indexer\Model\Indexer; + +class CollectionTest extends \PHPUnit_Framework_TestCase +{ + public function testLoadData() + { + $indexerIdOne = 'first_indexer_id'; + $indexerIdSecond = 'second_indexer_id'; + + $entityFactory = $this->getMockBuilder('Magento\Data\Collection\EntityFactoryInterface') + ->disableOriginalConstructor() + ->setMethods(array('create')) + ->getMock(); + + $config = $this->getMockBuilder('Magento\Indexer\Model\ConfigInterface') + ->getMock(); + + $statesFactory = $this->getMockBuilder('Magento\Indexer\Model\Resource\Indexer\State\CollectionFactory') + ->disableOriginalConstructor() + ->setMethods(array('create')) + ->getMock(); + + $states = $this->getMockBuilder('Magento\Indexer\Model\Resource\Indexer\State\Collection') + ->disableOriginalConstructor() + ->getMock(); + + $state = $this->getMockBuilder('Magento\Indexer\Model\Indexer\State') + ->setMethods(array('getIndexerId', '__wakeup')) + ->disableOriginalConstructor() + ->getMock(); + + $state->expects($this->any()) + ->method('getIndexerId') + ->will($this->returnValue('second_indexer_id')); + + $indexer = $this->getMockBuilder('Magento\Indexer\Model\Indexer\Collection') + ->setMethods(array('load', 'setState')) + ->disableOriginalConstructor() + ->getMock(); + + $indexer->expects($this->once()) + ->method('setState') + ->with($state); + + $indexer->expects($this->any()) + ->method('load') + ->with($this->logicalOr($indexerIdOne, $indexerIdSecond)); + + $entityFactory->expects($this->any()) + ->method('create') + ->with('Magento\Indexer\Model\Indexer') + ->will($this->returnValue($indexer)); + + $statesFactory->expects($this->once()) + ->method('create') + ->will($this->returnValue($states)); + + $config->expects($this->once()) + ->method('getIndexerIds') + ->will($this->returnValue(array($indexerIdOne, $indexerIdSecond))); + + $states->expects($this->any()) + ->method('getItems') + ->will($this->returnValue(array($state))); + + $collection = new \Magento\Indexer\Model\Indexer\Collection($entityFactory, $config, $statesFactory); + $this->assertInstanceOf('Magento\Indexer\Model\Indexer\Collection', $collection->loadData()); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Indexer/Model/IndexerTest.php b/dev/tests/unit/testsuite/Magento/Indexer/Model/IndexerTest.php new file mode 100644 index 0000000000000000000000000000000000000000..1c7927e5eb7b2f695c8c20e460316844f5411e3b --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Indexer/Model/IndexerTest.php @@ -0,0 +1,366 @@ +<?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\Indexer\Model; + +class IndexerTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Indexer\Model\Indexer|\PHPUnit_Framework_MockObject_MockObject + */ + protected $model; + + /** + * @var \Magento\Indexer\Model\Config|\PHPUnit_Framework_MockObject_MockObject + */ + protected $configMock; + + /** + * @var \Magento\Indexer\Model\ActionFactory|\PHPUnit_Framework_MockObject_MockObject + */ + protected $actionFactoryMock; + + /** + * @var \Magento\Mview\View|\PHPUnit_Framework_MockObject_MockObject + */ + protected $viewMock; + + /** + * @var \Magento\Indexer\Model\Indexer\StateFactory|\PHPUnit_Framework_MockObject_MockObject + */ + protected $stateFactoryMock; + + /** + * @var \Magento\Indexer\Model\Indexer\CollectionFactory|\PHPUnit_Framework_MockObject_MockObject + */ + protected $indexFactoryMock; + + protected function setUp() + { + $this->configMock = $this->getMock('Magento\Indexer\Model\Config', array('get'), array(), '', false); + $this->actionFactoryMock = $this->getMock( + 'Magento\Indexer\Model\ActionFactory', array('get'), array(), '', false + ); + $this->viewMock = $this->getMock( + 'Magento\Mview\View', + array('load', 'getMode', 'getUpdated', 'getStatus', '__wakeup', 'getId'), + array(), + '', + false + ); + $this->stateFactoryMock = $this->getMock( + 'Magento\Indexer\Model\Indexer\StateFactory', array('create'), array(), '', false + ); + $this->indexFactoryMock = $this->getMock( + 'Magento\Indexer\Model\Indexer\CollectionFactory', array('create'), array(), '', false + ); + $this->model = new Indexer( + $this->configMock, + $this->actionFactoryMock, + $this->viewMock, + $this->stateFactoryMock, + $this->indexFactoryMock + ); + } + + /** + * @expectedException \InvalidArgumentException + * @expectedExceptionMessage indexer_id indexer does not exist. + */ + public function testLoadWithException() + { + $indexId = 'indexer_id'; + $this->configMock->expects($this->once()) + ->method('get') + ->with($indexId) + ->will($this->returnValue($this->getIndexerData())); + $this->model->load($indexId); + } + + public function testGetView() + { + $indexId = 'indexer_internal_name'; + $this->viewMock->expects($this->once()) + ->method('load') + ->with('view_test') + ->will($this->returnSelf()); + $this->loadIndexer($indexId); + + $this->assertEquals($this->viewMock, $this->model->getView()); + } + + public function testGetState() + { + $indexId = 'indexer_internal_name'; + $stateMock = $this->getMock( + '\Magento\Indexer\Model\Indexer\State', + array('load', 'getId', 'setIndexerId', '__wakeup'), + array(), + '', + false + ); + $stateMock->expects($this->once()) + ->method('load') + ->with($indexId, 'indexer_id') + ->will($this->returnSelf()); + $stateMock->expects($this->never()) + ->method('setIndexerId'); + $stateMock->expects($this->once()) + ->method('getId') + ->will($this->returnValue(1)); + $this->stateFactoryMock->expects($this->once()) + ->method('create') + ->will($this->returnValue($stateMock)); + + $this->loadIndexer($indexId); + + $this->assertInstanceOf('\Magento\Indexer\Model\Indexer\State', $this->model->getState()); + } + + /** + * @param string $mode + * @param string $status + * @param bool $statusCall + * @param bool $stateCall + * @param string $result + * @dataProvider indexerStatusProvider + */ + public function testGetStatus($mode, $status, $statusCall, $stateCall, $result) + { + $indexId = 'indexer_internal_name'; + $this->viewMock->expects($statusCall ? $this->exactly(2) : $this->once()) + ->method('getId') + ->will($this->returnValue(1)); + $this->viewMock->expects($this->once()) + ->method('getMode') + ->will($this->returnValue($mode)); + $this->viewMock->expects($statusCall ? $this->once() : $this->never()) + ->method('getStatus') + ->will($this->returnValue($status)); + + if ($stateCall) { + $stateMock = $this->getMock( + '\Magento\Indexer\Model\Indexer\State', + array('load', 'getId', 'setIndexerId', '__wakeup', 'getStatus'), + array(), + '', + false + ); + $stateMock->expects($this->once()) + ->method('load') + ->with($indexId, 'indexer_id') + ->will($this->returnSelf()); + $stateMock->expects($this->never()) + ->method('setIndexerId'); + $stateMock->expects($this->once()) + ->method('getId') + ->will($this->returnValue(1)); + $stateMock->expects($this->once()) + ->method('getStatus') + ->will($this->returnValue($status)); + $this->stateFactoryMock->expects($this->once()) + ->method('create') + ->will($this->returnValue($stateMock)); + } + + $this->loadIndexer($indexId); + + $this->assertEquals($result, $this->model->getStatus()); + } + + /** + * @return array + */ + public function indexerStatusProvider() + { + return array( + 'enabled_working' => array('enabled', 'working', true, false, 'working'), + 'enabled_idle' => array('enabled', 'idle', true, true, 'idle'), + 'disabled_working' => array('disabled', 'working', false, true, 'working'), + 'disabled_idle' => array('disabled', 'idle', false, true, 'idle'), + ); + } + + public function testGetUpdated() + { + $checkValue = 1; + $indexId = 'indexer_internal_name'; + $this->loadIndexer($indexId); + + $this->viewMock->expects($this->any()) + ->method('getId') + ->will($this->returnValue(1)); + $this->viewMock->expects($this->once()) + ->method('getMode') + ->will($this->returnValue('enabled')); + $this->viewMock->expects($this->any()) + ->method('getUpdated') + ->will($this->returnValue($checkValue)); + + $stateMock = $this->getMock( + '\Magento\Indexer\Model\Indexer\State', + array('load', 'getId', 'setIndexerId', '__wakeup', 'getUpdated'), + array(), + '', + false + ); + $stateMock->expects($this->once()) + ->method('getUpdated') + ->will($this->returnValue(0)); + $this->stateFactoryMock->expects($this->once()) + ->method('create') + ->will($this->returnValue($stateMock)); + + $this->assertEquals($checkValue, $this->model->getUpdated()); + } + + public function testReindexAll() + { + $indexId = 'indexer_internal_name'; + $this->loadIndexer($indexId); + + $stateMock = $this->getMock( + '\Magento\Indexer\Model\Indexer\State', + array('load', 'getId', 'setIndexerId', '__wakeup', 'getStatus', 'setStatus', 'save'), + array(), + '', + false + ); + $stateMock->expects($this->once()) + ->method('load') + ->with($indexId, 'indexer_id') + ->will($this->returnSelf()); + $stateMock->expects($this->never()) + ->method('setIndexerId'); + $stateMock->expects($this->once()) + ->method('getId') + ->will($this->returnValue(1)); + $stateMock->expects($this->exactly(2)) + ->method('setStatus') + ->will($this->returnSelf()); + $stateMock->expects($this->once()) + ->method('getStatus') + ->will($this->returnValue('idle')); + $stateMock->expects($this->exactly(2)) + ->method('save') + ->will($this->returnSelf()); + $this->stateFactoryMock->expects($this->once()) + ->method('create') + ->will($this->returnValue($stateMock)); + + $actionMock = $this->getMock( + 'Magento\Indexer\Model\ActionInterface', + array('executeFull', 'executeList', 'executeRow'), + array(), + '', + false + ); + $this->actionFactoryMock->expects($this->once()) + ->method('get') + ->with('Some\Class\Name') + ->will($this->returnValue($actionMock)); + + $this->model->reindexAll(); + } + + /** + * @expectedException \Exception + * @expectedExceptionMessage Test exception + */ + public function testReindexAllWithException() + { + $indexId = 'indexer_internal_name'; + $this->loadIndexer($indexId); + + $stateMock = $this->getMock( + '\Magento\Indexer\Model\Indexer\State', + array('load', 'getId', 'setIndexerId', '__wakeup', 'getStatus', 'setStatus', 'save'), + array(), + '', + false + ); + $stateMock->expects($this->once()) + ->method('load') + ->with($indexId, 'indexer_id') + ->will($this->returnSelf()); + $stateMock->expects($this->never()) + ->method('setIndexerId'); + $stateMock->expects($this->once()) + ->method('getId') + ->will($this->returnValue(1)); + $stateMock->expects($this->exactly(2)) + ->method('setStatus') + ->will($this->returnSelf()); + $stateMock->expects($this->once()) + ->method('getStatus') + ->will($this->returnValue('idle')); + $stateMock->expects($this->exactly(2)) + ->method('save') + ->will($this->returnSelf()); + $this->stateFactoryMock->expects($this->once()) + ->method('create') + ->will($this->returnValue($stateMock)); + + $actionMock = $this->getMock( + 'Magento\Indexer\Model\ActionInterface', + array('executeFull', 'executeList', 'executeRow'), + array(), + '', + false + ); + $actionMock->expects($this->once()) + ->method('executeFull') + ->will($this->returnCallback(function () { + throw new \Exception('Test exception'); + })); + $this->actionFactoryMock->expects($this->once()) + ->method('get') + ->with('Some\Class\Name') + ->will($this->returnValue($actionMock)); + + $this->model->reindexAll(); + } + + protected function getIndexerData() + { + return array( + 'indexer_id' => 'indexer_internal_name', + 'view_id' => 'view_test', + 'action_class' => 'Some\Class\Name', + 'title' => 'Indexer public name', + 'description' => 'Indexer public description', + ); + } + + /** + * @param $indexId + */ + protected function loadIndexer($indexId) + { + $this->configMock->expects($this->once()) + ->method('get') + ->with($indexId) + ->will($this->returnValue($this->getIndexerData())); + $this->model->load($indexId); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Indexer/Model/ProcessorTest.php b/dev/tests/unit/testsuite/Magento/Indexer/Model/ProcessorTest.php new file mode 100644 index 0000000000000000000000000000000000000000..5a2025245e45d66ecdf69e415e8ecba59b729d04 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Indexer/Model/ProcessorTest.php @@ -0,0 +1,140 @@ +<?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\Indexer\Model; + +class ProcessorTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Indexer\Model\Processor|\PHPUnit_Framework_MockObject_MockObject + */ + protected $model; + + /** + * @var \Magento\Indexer\Model\Config|\PHPUnit_Framework_MockObject_MockObject + */ + protected $configMock; + + /** + * @var \Magento\Indexer\Model\IndexerFactory|\PHPUnit_Framework_MockObject_MockObject + */ + protected $indexerFactoryMock; + + /** + * @var \Magento\Indexer\Model\Indexer\CollectionFactory|\PHPUnit_Framework_MockObject_MockObject + */ + protected $indexersFactoryMock; + + /** + * @var \Magento\Mview\ProcessorInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $viewProcessorMock; + + protected function setUp() + { + $this->configMock = $this->getMock('Magento\Indexer\Model\Config', array('getIndexerIds'), array(), '', false); + $this->indexerFactoryMock = $this->getMock( + 'Magento\Indexer\Model\IndexerFactory', array('create'), array(), '', false + ); + $this->indexersFactoryMock = $this->getMock( + 'Magento\Indexer\Model\Indexer\CollectionFactory', array('create'), array(), '', false + ); + $this->viewProcessorMock = $this->getMockForAbstractClass( + 'Magento\Mview\ProcessorInterface', array(), '', false + ); + $this->model = new \Magento\Indexer\Model\Processor( + $this->configMock, + $this->indexerFactoryMock, + $this->indexersFactoryMock, + $this->viewProcessorMock + ); + } + + public function testReindexAllInvalid() + { + $indexers = array( + 'indexer1', + 'indexer2', + ); + + $this->configMock->expects($this->once()) + ->method('getIndexerIds') + ->will($this->returnValue($indexers)); + + $state1Mock = $this->getMock('Magento\Indexer\Model\Indexer\State', + array('getStatus', '__wakeup'), array(), '', false); + $state1Mock->expects($this->once()) + ->method('getStatus') + ->will($this->returnValue(Indexer\State::STATUS_INVALID)); + $indexer1Mock = $this->getMock('Magento\Indexer\Model\Indexer', + array('load', 'getState', 'reindexAll'), array(), '', false); + $indexer1Mock->expects($this->once()) + ->method('getState') + ->will($this->returnValue($state1Mock)); + $indexer1Mock->expects($this->once()) + ->method('reindexAll'); + + $state2Mock = $this->getMock('Magento\Indexer\Model\Indexer\State', + array('getStatus', '__wakeup'), array(), '', false); + $state2Mock->expects($this->once()) + ->method('getStatus') + ->will($this->returnValue(Indexer\State::STATUS_VALID)); + $indexer2Mock = $this->getMock('Magento\Indexer\Model\Indexer', + array('load', 'getState', 'reindexAll'), array(), '', false); + $indexer2Mock->expects($this->never()) + ->method('reindexAll'); + $indexer2Mock->expects($this->once()) + ->method('getState') + ->will($this->returnValue($state2Mock)); + + $this->indexerFactoryMock->expects($this->at(0)) + ->method('create') + ->will($this->returnValue($indexer1Mock)); + $this->indexerFactoryMock->expects($this->at(1)) + ->method('create') + ->will($this->returnValue($indexer2Mock)); + + $this->model->reindexAllInvalid(); + } + + public function testReindexAll() + { + $indexerMock = $this->getMock('Magento\Indexer\Model\Indexer', array(), array(), '', false); + $indexerMock->expects($this->exactly(2)) + ->method('reindexAll'); + $indexers = array( + $indexerMock, + $indexerMock, + ); + + $indexersMock = $this->getMock('Magento\Indexer\Model\Indexer\Collection', array(), array(), '', false); + $this->indexersFactoryMock->expects($this->once()) + ->method('create') + ->will($this->returnValue($indexersMock)); + $indexersMock->expects($this->once()) + ->method('getItems') + ->will($this->returnValue($indexers)); + + $this->model->reindexAll(); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Indexer/XsdTest.php b/dev/tests/unit/testsuite/Magento/Indexer/XsdTest.php new file mode 100644 index 0000000000000000000000000000000000000000..373e349696563d62e8084088bde17a003db6ee5b --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Indexer/XsdTest.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\Indexer; + +class XsdTest extends \PHPUnit_Framework_TestCase +{ + /** + * Path to xsd schema file + * @var string + */ + protected $_xsdSchema; + + /** + * @var \Magento\TestFramework\Utility\XsdValidator + */ + protected $_xsdValidator; + + protected function setUp() + { + $this->_xsdSchema = BP . '/app/code/Magento/Indexer/etc/indexer.xsd'; + $this->_xsdValidator = new \Magento\TestFramework\Utility\XsdValidator(); + } + + /** + * @param string $xmlString + * @param array $expectedError + * @dataProvider schemaCorrectlyIdentifiesInvalidXmlDataProvider + */ + public function testSchemaCorrectlyIdentifiesInvalidXml($xmlString, $expectedError) + { + $actualError = $this->_xsdValidator->validate($this->_xsdSchema, $xmlString); + $this->assertEquals($expectedError, $actualError); + } + + public function testSchemaCorrectlyIdentifiesValidXml() + { + $xmlString = file_get_contents(__DIR__ . '/_files/valid_indexer.xml'); + $actualResult = $this->_xsdValidator->validate($this->_xsdSchema, $xmlString); + + $this->assertEmpty($actualResult); + } + + /** + * Data provider with invalid xml array according to events.xsd + */ + public function schemaCorrectlyIdentifiesInvalidXmlDataProvider() + { + return include(__DIR__ . '/_files/invalidIndexerXmlArray.php'); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Indexer/_files/indexer_config.php b/dev/tests/unit/testsuite/Magento/Indexer/_files/indexer_config.php new file mode 100644 index 0000000000000000000000000000000000000000..a2b431d93ab6460e81065152c8c26fe18174a020 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Indexer/_files/indexer_config.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) + */ +return array( + 'inputXML' => '<?xml version="1.0" encoding="UTF-8"?><config>' + . '<indexer id="indexer_internal_name" view_id="view01" class="Index\Class\Name">' + . '<title translate="true">' + . 'Indexer public name</title><description translate="true">Indexer public description</description>' + . '</indexer></config>', + 'expected' => array( + 'indexer_internal_name' => array( + 'indexer_id' => 'indexer_internal_name', + 'view_id' => 'view01', + 'action_class' => 'Index\Class\Name', + 'title' => 'Indexer public name', + 'description' => 'Indexer public description', + ), + ), +); diff --git a/app/code/Magento/PaypalUk/etc/frontend/di.xml b/dev/tests/unit/testsuite/Magento/Indexer/_files/indexer_merged_one.xml similarity index 53% rename from app/code/Magento/PaypalUk/etc/frontend/di.xml rename to dev/tests/unit/testsuite/Magento/Indexer/_files/indexer_merged_one.xml index 603125bde6606f86942e85ab514258947f6cccb2..cf21bbe45d2da403252b090fd7f9e787286d180d 100644 --- a/app/code/Magento/PaypalUk/etc/frontend/di.xml +++ b/dev/tests/unit/testsuite/Magento/Indexer/_files/indexer_merged_one.xml @@ -1,4 +1,4 @@ -<?xml version="1.0"?> +<?xml version="1.0" encoding="UTF-8"?> <!-- /** * Magento @@ -24,24 +24,16 @@ */ --> <config> - <virtualType name="Magento\PaypalUk\Model\Session\Storage" type="Magento\Session\Storage"> - <param name="namespace"> - <value>paypaluk</value> - </param> - </virtualType> - <virtualType name="Magento\PaypalUk\Model\Session" type="Magento\Session\Generic"> - <param name="storage"> - <instance type="Magento\PaypalUk\Model\Session\Storage" /> - </param> - <param name="sessionName"> - <value>frontend</value> - </param> - </virtualType> - <type name="Magento\Core\Model\Url\SecurityInfo"> - <param name="secureUrlList"> - <value> - <paypaluk_express>/paypaluk/express</paypaluk_express> - </value> - </param> - </type> -</config> + <indexer id="indexer_internal_name_one" view_id="view_one" class="Index\Class\Name\One"> + <title translate="true">Indexer public name one</title> + <description translate="true">Indexer public description one</description> + </indexer> + <indexer id="indexer_internal_name_two" view_id="view_two" class="Index\Class\Name\Two"> + <title translate="true">Indexer public name two</title> + <description translate="true">Indexer public description two</description> + </indexer> + <indexer id="indexer_internal_name_three" view_id="view_three" class="Index\Class\Name\Three"> + <title translate="true">Indexer public name three</title> + <description translate="true">Indexer public description three</description> + </indexer> +</config> \ No newline at end of file diff --git a/dev/tests/unit/testsuite/Magento/Indexer/_files/indexer_merged_two.xml b/dev/tests/unit/testsuite/Magento/Indexer/_files/indexer_merged_two.xml new file mode 100644 index 0000000000000000000000000000000000000000..5d24698a167ba448c08bdb2abaf73fdc4bda777c --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Indexer/_files/indexer_merged_two.xml @@ -0,0 +1,35 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- +/** + * 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) + */ +--> +<config> + <indexer id="indexer_internal_name_one" view_id="view_two" class="Index\Class\Name\Two"> + <title translate="true">Indexer public name two</title> + <description translate="true">Indexer public description two</description> + </indexer> + <indexer id="indexer_internal_name_three" view_id="view_three" class="Index\Class\Name\Three"> + <title translate="true">Indexer public name three</title> + <description translate="true">Indexer public description three</description> + </indexer> +</config> \ No newline at end of file diff --git a/dev/tests/unit/testsuite/Magento/Indexer/_files/indexer_one.xml b/dev/tests/unit/testsuite/Magento/Indexer/_files/indexer_one.xml new file mode 100644 index 0000000000000000000000000000000000000000..46c30a8b5d0a6fc98b3a470556fcaff89d9450ec --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Indexer/_files/indexer_one.xml @@ -0,0 +1,31 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- +/** + * 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) + */ +--> +<config> + <indexer id="indexer_internal_name_one" view_id="view_one" class="Index\Class\Name\One"> + <title translate="true">Indexer public name one</title> + <description translate="true">Indexer public description one</description> + </indexer> +</config> \ No newline at end of file diff --git a/dev/tests/unit/testsuite/Magento/Indexer/_files/indexer_three.xml b/dev/tests/unit/testsuite/Magento/Indexer/_files/indexer_three.xml new file mode 100644 index 0000000000000000000000000000000000000000..5d24698a167ba448c08bdb2abaf73fdc4bda777c --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Indexer/_files/indexer_three.xml @@ -0,0 +1,35 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- +/** + * 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) + */ +--> +<config> + <indexer id="indexer_internal_name_one" view_id="view_two" class="Index\Class\Name\Two"> + <title translate="true">Indexer public name two</title> + <description translate="true">Indexer public description two</description> + </indexer> + <indexer id="indexer_internal_name_three" view_id="view_three" class="Index\Class\Name\Three"> + <title translate="true">Indexer public name three</title> + <description translate="true">Indexer public description three</description> + </indexer> +</config> \ No newline at end of file diff --git a/dev/tests/unit/testsuite/Magento/Indexer/_files/indexer_two.xml b/dev/tests/unit/testsuite/Magento/Indexer/_files/indexer_two.xml new file mode 100644 index 0000000000000000000000000000000000000000..6b9e2d68f1e91a6a02fd167cac5af08283dd98f9 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Indexer/_files/indexer_two.xml @@ -0,0 +1,35 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- +/** + * 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) + */ +--> +<config> + <indexer id="indexer_internal_name_two" view_id="view_two" class="Index\Class\Name\Two"> + <title translate="true">Indexer public name two</title> + <description translate="true">Indexer public description two</description> + </indexer> + <indexer id="indexer_internal_name_three" view_id="view_three" class="Index\Class\Name\Three"> + <title translate="true">Indexer public name three</title> + <description translate="true">Indexer public description three</description> + </indexer> +</config> \ No newline at end of file diff --git a/dev/tests/unit/testsuite/Magento/Indexer/_files/invalidIndexerXmlArray.php b/dev/tests/unit/testsuite/Magento/Indexer/_files/invalidIndexerXmlArray.php new file mode 100644 index 0000000000000000000000000000000000000000..84151f7d9b7f0ace5fd120a2e8d9fab5931317ad --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Indexer/_files/invalidIndexerXmlArray.php @@ -0,0 +1,56 @@ +<?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) + */ +return array( + 'without_indexer_handle' => array( + '<?xml version="1.0"?><config></config>', + array("Element 'config': Missing child element(s). Expected is ( indexer ).")), + + 'indexer_with_notallowed_attribute' => array( + '<?xml version="1.0"?><config>' + . '<indexer id="somename" view_id="view_01" class="Class\Name" notallowed="some value">' + .'<title>Test</title><description>Test</description></indexer></config>', + array("Element 'indexer', attribute 'notallowed': The attribute 'notallowed' is not allowed.")), + + 'indexer_without_view_attribute' => array( + '<?xml version="1.0"?><config><indexer id="somename" class="Class\Name">' + .'<title>Test</title><description>Test</description></indexer></config>', + array("Element 'indexer': The attribute 'view_id' is required but missing.")), + + 'indexer_duplicate_view_attribute' => array( + '<?xml version="1.0"?><config><indexer id="somename" view_id="view_01" class="Class\Name">' + .'<title>Test</title><description>Test</description></indexer>' + .'<indexer id="somename_two" view_id="view_01" class="Class\Name">' + .'<title>Test</title><description>Test</description></indexer></config>', + array("Element 'indexer': Duplicate key-sequence ['view_01'] in unique identity-constraint 'uniqueViewId'.")), + + 'indexer_without_title' => array( + '<?xml version="1.0"?><config><indexer id="somename" view_id="view_01" class="Class\Name">' + .'<description>Test</description></indexer></config>', + array("Element 'description': This element is not expected. Expected is ( title ).")), + + 'indexer_without_description' => array( + '<?xml version="1.0"?><config><indexer id="somename" view_id="view_01" class="Class\Name">' + .'<title>Test</title></indexer></config>', + array("Element 'indexer': Missing child element(s). Expected is ( description ).")), +); diff --git a/dev/tests/unit/testsuite/Magento/Indexer/_files/valid_indexer.xml b/dev/tests/unit/testsuite/Magento/Indexer/_files/valid_indexer.xml new file mode 100644 index 0000000000000000000000000000000000000000..28b00625e0fc6cba4b18e9b940fd19f6a328e2cb --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Indexer/_files/valid_indexer.xml @@ -0,0 +1,35 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- +/** + * 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) + */ +--> +<config> + <indexer id="indexer_internal_name" view_id="view01" class="Index\Class\Name"> + <title translate="true">Indexer public name</title> + <description translate="true">Indexer public description</description> + </indexer> + <indexer id="new_indexer_internal_name" view_id="view02" class="Some\Class\Name"> + <title translate="true">Indexer public name</title> + <description translate="true">Indexer public description</description> + </indexer> +</config> \ No newline at end of file diff --git a/dev/tests/unit/testsuite/Magento/Install/App/ConsoleTest.php b/dev/tests/unit/testsuite/Magento/Install/App/ConsoleTest.php index 277336bae3ec7fb69ef6db33ce4fe888d9d9e2f5..cbf3c411b2c072f45308a549a9aa2f293efb9acb 100644 --- a/dev/tests/unit/testsuite/Magento/Install/App/ConsoleTest.php +++ b/dev/tests/unit/testsuite/Magento/Install/App/ConsoleTest.php @@ -145,7 +145,7 @@ class ConsoleTest extends \PHPUnit_Framework_TestCase * @param string $testValue * @dataProvider executeShowsRequestedDataProvider */ - public function testExecuteShowsRequestedData($param, $method, $testValue) + public function testLaunchShowsRequestedData($param, $method, $testValue) { $model = $this->_createModel(array($param => true)); $this->_installerMock @@ -153,7 +153,7 @@ class ConsoleTest extends \PHPUnit_Framework_TestCase ->method($method) ->will($this->returnValue($testValue)); $this->_outputMock->expects($this->once())->method('export')->with($testValue); - $this->assertEquals($this->_responseMock, $model->execute()); + $this->assertEquals($this->_responseMock, $model->launch()); } public function executeShowsRequestedDataProvider() @@ -170,7 +170,7 @@ class ConsoleTest extends \PHPUnit_Framework_TestCase { $model = $this->_createModel(array()); $this->_outputMock->expects($this->once())->method('success')->with($this->stringContains('successfully')); - $this->assertEquals($this->_responseMock, $model->execute()); + $this->assertEquals($this->_responseMock, $model->launch()); } public function testInstallReportsEncryptionKey() @@ -178,7 +178,7 @@ class ConsoleTest extends \PHPUnit_Framework_TestCase $model = $this->_createModel(array()); $this->_installerMock->expects($this->once())->method('install')->will($this->returnValue('enc_key')); $this->_outputMock->expects($this->once())->method('success')->with($this->stringContains('enc_key')); - $this->assertEquals($this->_responseMock, $model->execute()); + $this->assertEquals($this->_responseMock, $model->launch()); } public function testUninstallReportsSuccess() @@ -186,7 +186,7 @@ class ConsoleTest extends \PHPUnit_Framework_TestCase $model = $this->_createModel(array('uninstall' => true)); $this->_installerMock->expects($this->once())->method('uninstall')->will($this->returnValue(true)); $this->_outputMock->expects($this->once())->method('success')->with($this->stringContains('Uninstalled')); - $this->assertEquals($this->_responseMock, $model->execute()); + $this->assertEquals($this->_responseMock, $model->launch()); } public function testUninstallReportsIgnoreIfApplicationIsNotInstalled() @@ -194,7 +194,7 @@ class ConsoleTest extends \PHPUnit_Framework_TestCase $model = $this->_createModel(array('uninstall' => true)); $this->_installerMock->expects($this->once())->method('uninstall')->will($this->returnValue(false)); $this->_outputMock->expects($this->once())->method('success')->with($this->stringContains('non-installed')); - $this->assertEquals($this->_responseMock, $model->execute()); + $this->assertEquals($this->_responseMock, $model->launch()); } public function testExecuteReportsErrors() @@ -203,13 +203,13 @@ class ConsoleTest extends \PHPUnit_Framework_TestCase $this->_installerMock->expects($this->once())->method('hasErrors')->will($this->returnValue(true)); $this->_installerMock->expects($this->once())->method('getErrors')->will($this->returnValue(array('error1'))); $this->_outputMock->expects($this->once())->method('error')->with($this->stringContains('error1')); - $this->assertEquals($this->_responseMock, $model->execute()); + $this->assertEquals($this->_responseMock, $model->launch()); } public function testExecuteLoadsExtraConfig() { $model = $this->_createModel(array('config' => realpath(__DIR__ . '/_files/config.php'))); $this->_installerMock->expects($this->once())->method('uninstall')->will($this->returnValue(true)); - $this->assertEquals($this->_responseMock, $model->execute()); + $this->assertEquals($this->_responseMock, $model->launch()); } } diff --git a/dev/tests/unit/testsuite/Magento/Install/Model/Installer/Db/Mysql4Test.php b/dev/tests/unit/testsuite/Magento/Install/Model/Installer/Db/Mysql4Test.php index ce43f8664d24de0ab6f3d46213fabe67e5e9b476..637d7d881bd93a2332c095406c6928604412aec5 100644 --- a/dev/tests/unit/testsuite/Magento/Install/Model/Installer/Db/Mysql4Test.php +++ b/dev/tests/unit/testsuite/Magento/Install/Model/Installer/Db/Mysql4Test.php @@ -51,7 +51,7 @@ class Mysql4Test extends \PHPUnit_Framework_TestCase $adapterMock->expects($this->once())->method('getConnection')->will($this->returnValue($connectionMock)); $adapterFactory->expects($this->once())->method('create')->will($this->returnValue($adapterMock)); - $localConfig = $this->getMockBuilder('\Magento\App\Config') + $localConfig = $this->getMockBuilder('\Magento\App\Arguments') ->disableOriginalConstructor() ->getMock(); @@ -85,7 +85,7 @@ class Mysql4Test extends \PHPUnit_Framework_TestCase 'Magento\Core\Model\Resource\Type\Db\Pdo\MysqlFactory', array('create'), array(), '', false ); $localConfig = - $this->getMockBuilder('\Magento\App\Config')->disableOriginalConstructor()->getMock(); + $this->getMockBuilder('\Magento\App\Arguments')->disableOriginalConstructor()->getMock(); $installer = new \Magento\Install\Model\Installer\Db\Mysql4( $adapterFactory, $localConfig, $dbExtensions ); diff --git a/dev/tests/unit/testsuite/Magento/Install/Model/InstallerTest.php b/dev/tests/unit/testsuite/Magento/Install/Model/InstallerTest.php index 486fbe0b1efadeeb8a1806d7c1a8b42448144e0f..4b583942f8a7571aa40771ebe3373229ad205c27 100644 --- a/dev/tests/unit/testsuite/Magento/Install/Model/InstallerTest.php +++ b/dev/tests/unit/testsuite/Magento/Install/Model/InstallerTest.php @@ -46,7 +46,7 @@ class InstallerTest extends \PHPUnit_Framework_TestCase /** * Application config model * - * @var \Magento\Core\Model\ConfigInterface + * @var \Magento\App\ConfigInterface */ protected $_config; @@ -77,7 +77,7 @@ class InstallerTest extends \PHPUnit_Framework_TestCase { $this->_objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); $this->_cache = $this->getMock('\Magento\App\CacheInterface', array(), array(), '', false); - $this->_config = $this->getMock('\Magento\Core\Model\ConfigInterface', array(), array(), '', false); + $this->_config = $this->getMock('\Magento\App\ReinitableConfigInterface', array(), array(), '', false); $this->_cacheState = $this->getMock('\Magento\App\Cache\StateInterface', array(), array(), '', false); $this->_cacheTypeList = $this->getMock('\Magento\App\Cache\TypeListInterface', array(), array(), '', false); $this->_appState = $this->getMock('\Magento\App\State', 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 7c40ff0da9373ef0d1a15bf0549a82feddf8867b..5df13c474f98049a0e50d6266cf2013216a31fe6 100644 --- a/dev/tests/unit/testsuite/Magento/Integration/Controller/Adminhtml/IntegrationTest.php +++ b/dev/tests/unit/testsuite/Magento/Integration/Controller/Adminhtml/IntegrationTest.php @@ -51,7 +51,7 @@ class IntegrationTest extends \PHPUnit_Framework_TestCase /** @var \Magento\Core\Model\Layout\Filter\Acl|\PHPUnit_Framework_MockObject_MockObject */ protected $_layoutFilterMock; - /** @var \Magento\Core\Model\Config|\PHPUnit_Framework_MockObject_MockObject */ + /** @var \Magento\App\ConfigInterface|\PHPUnit_Framework_MockObject_MockObject */ protected $_configMock; /** @var \Magento\Event\ManagerInterface|\PHPUnit_Framework_MockObject_MockObject */ @@ -122,7 +122,7 @@ class IntegrationTest extends \PHPUnit_Framework_TestCase ->setMethods(array('getConfig')) ->disableOriginalConstructor() ->getMock(); - $this->_configMock = $this->getMockBuilder('Magento\Core\Model\Config')->disableOriginalConstructor() + $this->_configMock = $this->getMockBuilder('Magento\App\ConfigInterface')->disableOriginalConstructor() ->getMock(); $this->_appMock->expects($this->any())->method('getConfig')->will($this->returnValue($this->_configMock)); $this->_eventManagerMock = $this->getMockBuilder('Magento\Event\ManagerInterface') @@ -647,7 +647,7 @@ HANDLE; protected function _verifyLoadAndRenderLayout() { $map = array( - array('Magento\Core\Model\Config', $this->_configMock), + 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), diff --git a/dev/tests/unit/testsuite/Magento/Less/File/FileList/CollatorTest.php b/dev/tests/unit/testsuite/Magento/Less/File/FileList/CollatorTest.php new file mode 100644 index 0000000000000000000000000000000000000000..6f1492bfaefb27c3e8644d9fe454501a78043091 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Less/File/FileList/CollatorTest.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\Less\File\FileList; + +class CollatorTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var Collator + */ + protected $model; + + /** + * @var \Magento\View\Layout\File[] + */ + protected $originFiles; + + /** + * @var \Magento\View\Layout\File + */ + protected $baseFile; + + /** + * @var \Magento\View\Layout\File + */ + protected $themeFile; + + protected function setUp() + { + $this->baseFile = $this->createLayoutFile('fixture_1.less', 'Fixture_TestModule'); + $this->themeFile = $this->createLayoutFile('fixture.less', 'Fixture_TestModule', 'area/theme/path'); + $this->originFiles = array( + $this->baseFile->getFileIdentifier() => $this->baseFile, + $this->themeFile->getFileIdentifier() => $this->themeFile + ); + $this->model = new Collator(); + } + + /** + * Return newly created theme layout file with a mocked theme + * + * @param string $filename + * @param string $module + * @param string|null $themeFullPath + * @return \PHPUnit_Framework_MockObject_MockObject|\Magento\View\Layout\File + */ + protected function createLayoutFile($filename, $module, $themeFullPath = null) + { + $theme = null; + if ($themeFullPath !== null) { + $theme = $this->getMockForAbstractClass('Magento\View\Design\ThemeInterface'); + $theme->expects($this->any())->method('getFullPath')->will($this->returnValue($themeFullPath)); + } + return new \Magento\View\Layout\File($filename, $module, $theme); + } + + public function testCollate() + { + $file = $this->createLayoutFile('test/fixture.less', 'Fixture_TestModule'); + $expected = array( + $this->baseFile->getFileIdentifier() => $this->baseFile, + $file->getFileIdentifier() => $file + ); + $result = $this->model->collate(array($file), $this->originFiles); + $this->assertSame($expected, $result); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Less/_files/invalid.less b/dev/tests/unit/testsuite/Magento/Less/_files/invalid.less new file mode 100644 index 0000000000000000000000000000000000000000..2b0831f5506137ad90715e3646311d72d7918617 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Less/_files/invalid.less @@ -0,0 +1,38 @@ +/** + * 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) + */ + +/** magento_import wrong declaration*/ +//@magento_impor "magento_import.less"; //@magento_import "magento_import.less"; +//magento_import "magento_import.less"; +//@magento_import magento_import.less"; +//@magento_import "magento_import.less; +//@magento_import "magento_import.less" +// @magento_import "magento_import.less"; + +/** import wrong declaration*/ +@impor "dir/import.less"; @import "dir/import.less"; +import "dir/import.less"; +@import dir/import.less"; +@import "dir/import.less; +@import "dir/import.less" +@ import "dir/import.less"; diff --git a/dev/tests/unit/testsuite/Magento/Less/_files/valid.less b/dev/tests/unit/testsuite/Magento/Less/_files/valid.less new file mode 100644 index 0000000000000000000000000000000000000000..06890b797070fb288ecbdb687896804b949382c0 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Less/_files/valid.less @@ -0,0 +1,25 @@ +/** + * 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) + */ + +//@magento_import "magento_import.less"; +@import "dir/import.less"; diff --git a/dev/tests/unit/testsuite/Magento/Log/App/ShellTest.php b/dev/tests/unit/testsuite/Magento/Log/App/ShellTest.php index 1c1d2f323930568c506a55f5c88b0001e9b718ef..5cf2aae6452e82342ef98954342d61ced485ab60 100644 --- a/dev/tests/unit/testsuite/Magento/Log/App/ShellTest.php +++ b/dev/tests/unit/testsuite/Magento/Log/App/ShellTest.php @@ -61,6 +61,6 @@ class ShellTest extends \PHPUnit_Framework_TestCase ->with(array('entryPoint' => 'shell.php')) ->will($this->returnValue($shellMock)); $shellMock->expects($this->once())->method('run'); - $this->assertEquals($this->_responseMock, $this->_model->execute()); + $this->assertEquals($this->_responseMock, $this->_model->launch()); } } diff --git a/dev/tests/unit/testsuite/Magento/Module/ManagerTest.php b/dev/tests/unit/testsuite/Magento/Module/ManagerTest.php index 9638de7ead70f57ae346fefcc218d530733ed7c6..7805d61f40662b76a08f5676768fe5eddc04fb29 100644 --- a/dev/tests/unit/testsuite/Magento/Module/ManagerTest.php +++ b/dev/tests/unit/testsuite/Magento/Module/ManagerTest.php @@ -73,7 +73,7 @@ class ManagerTest extends \PHPUnit_Framework_TestCase { $this->_outputConfig ->expects($this->any()) - ->method('getFlag') + ->method('isSetFlag') ->will($this->returnValue(true)); $this->assertFalse($this->_model->isOutputEnabled('Nonexisting_Module')); } @@ -118,7 +118,7 @@ class ManagerTest extends \PHPUnit_Framework_TestCase ); $this->_outputConfig ->expects($this->at(0)) - ->method('getFlag') + ->method('isSetFlag') ->with(self::XML_PATH_OUTPUT_ENABLED) ->will($this->returnValue($configValue)) ; diff --git a/dev/tests/unit/testsuite/Magento/Mview/ActionFactoryTest.php b/dev/tests/unit/testsuite/Magento/Mview/ActionFactoryTest.php new file mode 100644 index 0000000000000000000000000000000000000000..7ff1b48fa87c4d4bd44fee9a00aab7cfd66459eb --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Mview/ActionFactoryTest.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\Mview; + +class ActionFactoryTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Mview\ActionFactory|\PHPUnit_Framework_MockObject_MockObject + */ + protected $model; + + /** + * @var \Magento\ObjectManager|\PHPUnit_Framework_MockObject_MockObject + */ + protected $objectManagerMock; + + protected function setUp() + { + $this->objectManagerMock = $this->getMock('Magento\ObjectManager', array(), array(), '', false); + $this->model = new \Magento\Mview\ActionFactory($this->objectManagerMock); + } + + /** + * @expectedException \InvalidArgumentException + * @expectedExceptionMessage NotAction doesn't implement \Magento\Mview\ActionInterface + */ + public function testGetWithException() + { + $notActionInterfaceMock = $this->getMock('NotAction', array(), array(), '', false); + $this->objectManagerMock->expects($this->once()) + ->method('get') + ->with('NotAction') + ->will($this->returnValue($notActionInterfaceMock)); + $this->model->get('NotAction'); + } + + public function testGet() + { + $actionInterfaceMock = $this->getMockForAbstractClass( + 'Magento\Mview\ActionInterface', array(), '', false + ); + $this->objectManagerMock->expects($this->once()) + ->method('get') + ->with('Magento\Mview\ActionInterface') + ->will($this->returnValue($actionInterfaceMock)); + $this->model->get('Magento\Mview\ActionInterface'); + $this->assertInstanceOf('Magento\Mview\ActionInterface', $actionInterfaceMock); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Config/Dom/Converter/ArrayConverterTest.php b/dev/tests/unit/testsuite/Magento/Mview/Config/ConverterTest.php similarity index 51% rename from dev/tests/unit/testsuite/Magento/Config/Dom/Converter/ArrayConverterTest.php rename to dev/tests/unit/testsuite/Magento/Mview/Config/ConverterTest.php index a200da37755e5199106940951cf3fe315afa00f0..01840079ee11580d43aee22dff5af0d0e4e00a2b 100644 --- a/dev/tests/unit/testsuite/Magento/Config/Dom/Converter/ArrayConverterTest.php +++ b/dev/tests/unit/testsuite/Magento/Mview/Config/ConverterTest.php @@ -17,57 +17,54 @@ * 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\Config\Dom\Converter; +namespace Magento\Mview\Config; -class ArrayConverterTest extends \PHPUnit_Framework_TestCase +class ConverterTest extends \PHPUnit_Framework_TestCase { /** - * @var \Magento\Config\Dom\Converter\ArrayConverter + * @var \Magento\Mview\Config\Converter|\PHPUnit_Framework_MockObject_MockObject */ protected $_model; - /** - * Path to fixtures - * - * @var string - */ - protected $_fixturePath; - protected function setUp() { - $this->_model = new \Magento\Config\Dom\Converter\ArrayConverter(); - $this->_fixturePath = realpath(__DIR__ . '/../../') - . '/_files/dom/converter/'; + $this->_model = new \Magento\Mview\Config\Converter; + } + + public function testConvert() + { + $data = include __DIR__ . '/../_files/mview_config.php'; + $dom = new \DOMDocument(); + $dom->loadXML($data['inputXML']); + + $this->assertEquals($data['expected'], $this->_model->convert($dom)); } /** - * @param string $xml - * @param string $array - * - * @dataProvider convertDataProvider + * @param string $xmlData + * @dataProvider wrongXmlDataProvider + * @expectedException \Exception */ - public function testConvert($xml, $array) + public function testMapThrowsExceptionWhenXmlHasWrongFormat($xmlData) { - $xmlPath = $this->_fixturePath . $xml; - $expected = require ($this->_fixturePath . $array); - $dom = new \DOMDocument(); - $dom->load($xmlPath); - - $actual = $this->_model->convert($dom->childNodes); - $this->assertEquals($expected, $actual); + $dom->loadXML($xmlData); + $this->_model->convert($dom); } - public function convertDataProvider() + /** + * @return array + */ + public function wrongXmlDataProvider() { return array( - 'no attributes' => array('no_attributes.xml', 'no_attributes.php'), - 'with attributes' => array('with_attributes.xml', 'with_attributes.php'), - 'cdata' => array('cdata.xml', 'cdata.php'), + array( + '<?xml version="1.0"?><config>', + ) ); } } diff --git a/dev/tests/unit/testsuite/Magento/Mview/Config/ReaderTest.php b/dev/tests/unit/testsuite/Magento/Mview/Config/ReaderTest.php new file mode 100644 index 0000000000000000000000000000000000000000..eb90a94ec4d9f26c8099f507aa4be768097a11b9 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Mview/Config/ReaderTest.php @@ -0,0 +1,126 @@ +<?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\Mview\Config; + +class ReaderTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Mview\Config\Reader + */ + protected $_model; + + /** + * @var \Magento\Mview\Config\Converter|\PHPUnit_Framework_MockObject_MockObject + */ + protected $_converter; + + /** + * @var \Magento\Core\Model\Config\FileResolver|\PHPUnit_Framework_MockObject_MockObject + */ + protected $_fileResolverMock; + + protected function setUp() + { + $this->_fileResolverMock = $this->getMock( + 'Magento\Core\Model\Config\FileResolver', array('get'), array(), '', false + ); + + $this->_converter = $this->getMock( + 'Magento\Mview\Config\Converter', array('convert') + ); + + $fsDirList = $this->getMock( + '\Magento\Filesystem\DirectoryList', array('getDir'), array(), '', false + ); + $fsDirList->expects($this->once()) + ->method('getDir') + ->with(\Magento\App\Filesystem::LIB_DIR) + ->will($this->returnValue('stub')) + ; + $schemaLocator = new \Magento\Mview\Config\SchemaLocator($fsDirList); + + $validationState = $this->getMock('Magento\Config\ValidationStateInterface'); + $validationState->expects($this->once())->method('isValidated')->will($this->returnValue(false)); + + $this->_model = new \Magento\Mview\Config\Reader( + $this->_fileResolverMock, + $this->_converter, + $schemaLocator, + $validationState + ); + } + + /** + * @dataProvider readerDataProvider + */ + public function testReadValidConfig($files, $expectedFile) + { + $this->_fileResolverMock->expects($this->once()) + ->method('get') + ->with('mview.xml', 'scope') + ->will($this->returnValue($files)); + + $constraint = function (\DOMDocument $actual) use ($expectedFile) { + try { + $expected = file_get_contents(__DIR__ . '/../_files/' . $expectedFile); + \PHPUnit_Framework_Assert::assertXmlStringEqualsXmlString($expected, $actual->saveXML()); + return true; + } catch (\PHPUnit_Framework_AssertionFailedError $e) { + return false; + } + }; + $expectedResult = new \stdClass(); + $this->_converter + ->expects($this->once()) + ->method('convert') + ->with($this->callback($constraint)) + ->will($this->returnValue($expectedResult)) + ; + + $this->assertSame($expectedResult, $this->_model->read('scope')); + } + + /** + * @return array + */ + public function readerDataProvider() + { + return array( + 'mview_merged_one' => array( + array( + 'mview_one.xml' => file_get_contents(__DIR__ . '/../_files/mview_one.xml'), + 'mview_two.xml' => file_get_contents(__DIR__ . '/../_files/mview_two.xml'), + ), + 'mview_merged_one.xml', + ), + 'mview_merged_two' => array( + array( + 'mview_one.xml' => file_get_contents(__DIR__ . '/../_files/mview_one.xml'), + 'mview_three.xml' => file_get_contents(__DIR__ . '/../_files/mview_three.xml'), + ), + 'mview_merged_two.xml', + ), + ); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Mview/ProcessorTest.php b/dev/tests/unit/testsuite/Magento/Mview/ProcessorTest.php new file mode 100644 index 0000000000000000000000000000000000000000..d92dffc8c669c30af0b7cedf49807db127ea650c --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Mview/ProcessorTest.php @@ -0,0 +1,128 @@ +<?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\Mview; + +class ProcessorTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Mview\Processor|\PHPUnit_Framework_MockObject_MockObject + */ + protected $model; + + /** + * @var \Magento\Mview\View\CollectionFactory|\PHPUnit_Framework_MockObject_MockObject + */ + protected $viewsFactoryMock; + + protected function setUp() + { + $this->viewsFactoryMock = $this->getMock( + 'Magento\Mview\View\CollectionFactory', array('create'), array(), '', false + ); + $this->model = new \Magento\Mview\Processor($this->viewsFactoryMock); + } + + /** + * Return array of mocked views + * + * @param string $method + * @return \Magento\Mview\View[]|\PHPUnit_Framework_MockObject_MockObject[] + */ + protected function getViews($method) + { + $viewMock = $this->getMock('Magento\Mview\View', array(), array(), '', false); + $viewMock->expects($this->exactly(2)) + ->method($method); + return array( + $viewMock, + $viewMock, + ); + } + + /** + * Return view collection mock + * + * @return \Magento\Mview\View\Collection|\PHPUnit_Framework_MockObject_MockObject + */ + protected function getViewsMock() + { + $viewsMock = $this->getMock('Magento\Mview\View\Collection', array(), array(), '', false); + $this->viewsFactoryMock->expects($this->once()) + ->method('create') + ->will($this->returnValue($viewsMock)); + return $viewsMock; + } + + public function testUpdate() + { + $viewsMock = $this->getViewsMock(); + $viewsMock->expects($this->once()) + ->method('getItems') + ->will($this->returnValue($this->getViews('update'))); + $viewsMock->expects($this->never()) + ->method('getItemsByColumnValue'); + + $this->model->update(); + } + + public function testUpdateWithGroup() + { + $group = 'group'; + $viewsMock = $this->getViewsMock(); + $viewsMock->expects($this->never()) + ->method('getItems'); + $viewsMock->expects($this->once()) + ->method('getItemsByColumnValue') + ->with($group) + ->will($this->returnValue($this->getViews('update'))); + + $this->model->update($group); + } + + public function testClearChangelog() + { + $viewsMock = $this->getViewsMock(); + $viewsMock->expects($this->once()) + ->method('getItems') + ->will($this->returnValue($this->getViews('clearChangelog'))); + $viewsMock->expects($this->never()) + ->method('getItemsByColumnValue'); + + $this->model->clearChangelog(); + } + + public function testClearChangelogWithGroup() + { + $group = 'group'; + $viewsMock = $this->getViewsMock(); + $viewsMock->expects($this->never()) + ->method('getItems'); + $viewsMock->expects($this->once()) + ->method('getItemsByColumnValue') + ->with($group) + ->will($this->returnValue($this->getViews('clearChangelog'))); + + $this->model->clearChangelog($group); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Mview/View/ChangelogTest.php b/dev/tests/unit/testsuite/Magento/Mview/View/ChangelogTest.php new file mode 100644 index 0000000000000000000000000000000000000000..2d5870c89c4989c2127eaeaaa7b961f2d0503fa9 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Mview/View/ChangelogTest.php @@ -0,0 +1,177 @@ +<?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\Mview\View; + +class ChangelogTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Mview\View\Changelog + */ + protected $model; + + /** + * Mysql PDO DB adapter mock + * + * @var \Magento\DB\Adapter\Pdo\Mysql + */ + protected $connectionMock; + + /** + * @var \Magento\App\Resource + */ + protected $resourceMock; + + protected function setUp() + { + $this->connectionMock = $this->getMock('Magento\DB\Adapter\Pdo\Mysql', array(), array(), '', false); + + $this->resourceMock = $this->getMock('Magento\App\Resource', array('getConnection'), array(), '', false, false); + $this->resourceMock->expects($this->once()) + ->method('getConnection') + ->will($this->returnValue($this->connectionMock)); + + $this->model = new \Magento\Mview\View\Changelog($this->resourceMock); + $this->model->setViewId('ViewIdTest'); + } + + public function testInstanceOf() + { + $this->assertInstanceOf('\Magento\Mview\View\ChangelogInterface', $this->model); + } + + /** + * @expectedException \Exception + * @expectedExceptionMessage Write DB connection is not available + */ + public function testCheckConnectionException() + { + $resourceMock = $this->getMock('Magento\App\Resource', array('getConnection'), array(), '', false, false); + $resourceMock->expects($this->once()) + ->method('getConnection') + ->will($this->returnValue(null)); + $model = new \Magento\Mview\View\Changelog($resourceMock); + $model->setViewId('ViewIdTest'); + $this->assertNull($model); + } + + public function testGetName() + { + $this->assertEquals('ViewIdTest' . '_' . \Magento\Mview\View\Changelog::NAME_SUFFIX, $this->model->getName()); + } + + public function testGetColumnName() + { + $this->assertEquals(\Magento\Mview\View\Changelog::COLUMN_NAME, $this->model->getColumnName()); + } + + public function testGetVersionWithException() + { + $changelogTableName = 'viewIdtest_cl'; + $connection = $this->getMock('Magento\DB\Adapter\Pdo\Mysql', array('isTableExists'), array(), '', false); + $connection->expects($this->once())->method('isTableExists') + ->with($this->equalTo($changelogTableName)) + ->will($this->returnValue(false)); + + $resource = $this->getMock('Magento\App\Resource', array('getConnection'), array(), '', false, false); + $resource->expects($this->once()) + ->method('getConnection') + ->will($this->returnValue($connection)); + $model = new \Magento\Mview\View\Changelog($resource); + $model->setViewId('viewIdtest'); + $this->setExpectedException('Exception', "Table {$changelogTableName} does not exist"); + $model->getVersion(); + } + + public function testDropWithException() + { + $changelogTableName = 'viewIdtest_cl'; + $connection = $this->getMock('Magento\DB\Adapter\Pdo\Mysql', array('isTableExists'), array(), '', false); + $connection->expects($this->once())->method('isTableExists') + ->with($this->equalTo($changelogTableName)) + ->will($this->returnValue(false)); + + $resource = $this->getMock('Magento\App\Resource', array('getConnection'), array(), '', false, false); + $resource->expects($this->once()) + ->method('getConnection') + ->will($this->returnValue($connection)); + $model = new \Magento\Mview\View\Changelog($resource); + $model->setViewId('viewIdtest'); + $this->setExpectedException('Exception', "Table {$changelogTableName} does not exist"); + $model->drop(); + } + + public function testCreateWithException() + { + $changelogTableName = 'viewIdtest_cl'; + $connection = $this->getMock('Magento\DB\Adapter\Pdo\Mysql', array('isTableExists'), array(), '', false); + $connection->expects($this->once())->method('isTableExists') + ->with($this->equalTo($changelogTableName)) + ->will($this->returnValue(true)); + + $resource = $this->getMock('Magento\App\Resource', array('getConnection'), array(), '', false, false); + $resource->expects($this->once()) + ->method('getConnection') + ->will($this->returnValue($connection)); + $model = new \Magento\Mview\View\Changelog($resource); + $model->setViewId('viewIdtest'); + $this->setExpectedException('Exception', "Table {$changelogTableName} already exist"); + $model->create(); + } + + public function testGetListWithException() + { + $changelogTableName = 'viewIdtest_cl'; + $connection = $this->getMock('Magento\DB\Adapter\Pdo\Mysql', array('isTableExists'), array(), '', false); + $connection->expects($this->once())->method('isTableExists') + ->with($this->equalTo($changelogTableName)) + ->will($this->returnValue(false)); + + $resource = $this->getMock('Magento\App\Resource', array('getConnection'), array(), '', false, false); + $resource->expects($this->once()) + ->method('getConnection') + ->will($this->returnValue($connection)); + $model = new \Magento\Mview\View\Changelog($resource); + $model->setViewId('viewIdtest'); + $this->setExpectedException('Exception', "Table {$changelogTableName} does not exist"); + $model->getList(mt_rand(1, 200), mt_rand(201, 400)); + } + + public function testClearWithException() + { + $changelogTableName = 'viewIdtest_cl'; + $connection = $this->getMock('Magento\DB\Adapter\Pdo\Mysql', array('isTableExists'), array(), '', false); + $connection->expects($this->once())->method('isTableExists') + ->with($this->equalTo($changelogTableName)) + ->will($this->returnValue(false)); + + $resource = $this->getMock('Magento\App\Resource', array('getConnection'), array(), '', false, false); + $resource->expects($this->once()) + ->method('getConnection') + ->will($this->returnValue($connection)); + $model = new \Magento\Mview\View\Changelog($resource); + $model->setViewId('viewIdtest'); + $this->setExpectedException('Exception', "Table {$changelogTableName} does not exist"); + $model->clear(mt_rand(1, 200)); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Mview/View/CollectionTest.php b/dev/tests/unit/testsuite/Magento/Mview/View/CollectionTest.php new file mode 100644 index 0000000000000000000000000000000000000000..517d618a4a25fe308a2165768155da2c17c3de99 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Mview/View/CollectionTest.php @@ -0,0 +1,92 @@ +<?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\Mview\View; + +class CollectionTest extends \PHPUnit_Framework_TestCase +{ + public function testLoadData() + { + $indexerIdOne = 'first_indexer_id'; + $indexerIdSecond = 'second_indexer_id'; + + $entityFactory = $this->getMockBuilder('Magento\Data\Collection\EntityFactoryInterface') + ->disableOriginalConstructor() + ->setMethods(array('create')) + ->getMock(); + + $config = $this->getMockBuilder('Magento\Mview\ConfigInterface') + ->getMock(); + + $statesFactory = $this->getMockBuilder('Magento\Mview\View\State\CollectionFactory') + ->disableOriginalConstructor() + ->setMethods(array('create')) + ->getMock(); + + $states = $this->getMockBuilder('Magento\Mview\View\State\Collection') + ->setMethods(array('getItems')) + ->disableOriginalConstructor() + ->getMock(); + + $state = $this->getMockBuilder('Magento\Mview\View\State') + ->setMethods(array('getViewId', '__wakeup')) + ->disableOriginalConstructor() + ->getMock(); + + $state->expects($this->any()) + ->method('getViewId') + ->will($this->returnValue('second_indexer_id')); + + $indexer = $this->getMockBuilder('Magento\Object') + ->setMethods(array('load', 'setState')) + ->disableOriginalConstructor() + ->getMock(); + + $indexer->expects($this->once()) + ->method('setState') + ->with($state); + $indexer->expects($this->any()) + ->method('load') + ->with($this->logicalOr($indexerIdOne, $indexerIdSecond)); + + $entityFactory->expects($this->any()) + ->method('create') + ->with('Magento\Mview\ViewInterface') + ->will($this->returnValue($indexer)); + + $statesFactory->expects($this->once()) + ->method('create') + ->will($this->returnValue($states)); + + $config->expects($this->once()) + ->method('getAll') + ->will($this->returnValue(array($indexerIdOne => 1, $indexerIdSecond => 2))); + + $states->expects($this->any()) + ->method('getItems') + ->will($this->returnValue(array($state))); + + $collection = new \Magento\Mview\View\Collection($entityFactory, $config, $statesFactory); + $this->assertInstanceOf('Magento\Mview\View\Collection', $collection->loadData()); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Mview/ViewTest.php b/dev/tests/unit/testsuite/Magento/Mview/ViewTest.php new file mode 100644 index 0000000000000000000000000000000000000000..811394055823d4d8429aafe607a93707fb024e9e --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Mview/ViewTest.php @@ -0,0 +1,286 @@ +<?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\Mview; + +class ViewTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Mview\View + */ + protected $model; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Mview\Config + */ + protected $configMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Mview\ActionFactory + */ + protected $actionFactoryMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Core\Model\Mview\View\State + */ + protected $stateMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Mview\View\Changelog + */ + protected $changelogMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Mview\View\SubscriptionFactory + */ + protected $subscriptionFactoryMock; + + protected function setUp() + { + $this->configMock = $this->getMock( + '\Magento\Mview\Config', array('get'), array(), '', false + ); + $this->actionFactoryMock = $this->getMock( + '\Magento\Mview\ActionFactory', array('get'), array(), '', false + ); + $this->stateMock = $this->getMock( + '\Magento\Core\Model\Mview\View\State', + array('getViewId', 'loadByView', 'getVersionId', 'setVersionId', + 'getStatus', 'setStatus', 'getMode', 'setMode', 'save', '__wakeup'), + array(), + '', + false + ); + $this->changelogMock = $this->getMock( + '\Magento\Mview\View\Changelog', + array('getViewId', 'setViewId', 'create', 'drop', 'getVersion', 'getList'), + array(), + '', + false + ); + $this->subscriptionFactoryMock = $this->getMock( + '\Magento\Mview\View\SubscriptionFactory', array('create'), array(), '', false + ); + $this->model = new View( + $this->configMock, + $this->actionFactoryMock, + $this->stateMock, + $this->changelogMock, + $this->subscriptionFactoryMock + ); + } + + public function testLoad() + { + $viewId = 'view_test'; + $this->configMock->expects($this->once()) + ->method('get') + ->with($viewId) + ->will($this->returnValue($this->getViewData())); + $this->assertInstanceOf('Magento\Mview\View', $this->model->load($viewId)); + } + + /** + * @expectedException \InvalidArgumentException + * @expectedExceptionMessage view_id view does not exist. + */ + public function testLoadWithException() + { + $viewId = 'view_id'; + $this->configMock->expects($this->once()) + ->method('get') + ->with($viewId) + ->will($this->returnValue($this->getViewData())); + $this->model->load($viewId); + } + + public function testSubscribe() + { + $this->stateMock->expects($this->once()) + ->method('getMode') + ->will($this->returnValue('disabled')); + $this->stateMock->expects($this->once()) + ->method('setMode') + ->with('enabled') + ->will($this->returnSelf()); + $this->changelogMock->expects($this->once()) + ->method('create'); + $subscriptionMock = $this->getMock('Magento\Mview\View\Subscription', array('create'), array(), '', false); + $subscriptionMock->expects($this->exactly(1)) + ->method('create'); + $this->subscriptionFactoryMock->expects($this->exactly(1)) + ->method('create') + ->will($this->returnValue($subscriptionMock)); + $this->loadView(); + $this->model->subscribe(); + } + + public function testUnsubscribe() + { + $this->stateMock->expects($this->once()) + ->method('getMode') + ->will($this->returnValue('enabled')); + $this->stateMock->expects($this->once()) + ->method('setMode') + ->with('disabled') + ->will($this->returnSelf()); + $this->changelogMock->expects($this->once()) + ->method('drop'); + $subscriptionMock = $this->getMock('Magento\Mview\View\Subscription', array('remove'), array(), '', false); + $subscriptionMock->expects($this->exactly(1)) + ->method('remove'); + $this->subscriptionFactoryMock->expects($this->exactly(1)) + ->method('create') + ->will($this->returnValue($subscriptionMock)); + $this->loadView(); + $this->model->unsubscribe(); + } + + public function testUpdate() + { + $currentVersionId = 3; + $lastVersionId = 1; + $listId = array(2, 3); + $this->stateMock->expects($this->any()) + ->method('getViewId') + ->will($this->returnValue(1)); + $this->stateMock->expects($this->once()) + ->method('getVersionId') + ->will($this->returnValue($lastVersionId)); + $this->stateMock->expects($this->once()) + ->method('setVersionId') + ->will($this->returnSelf()); + $this->stateMock->expects($this->once()) + ->method('getMode') + ->will($this->returnValue('enabled')); + $this->stateMock->expects($this->once()) + ->method('getStatus') + ->will($this->returnValue('idle')); + $this->stateMock->expects($this->exactly(2)) + ->method('setStatus') + ->will($this->returnSelf()); + $this->stateMock->expects($this->exactly(2)) + ->method('save') + ->will($this->returnSelf()); + + $this->changelogMock->expects($this->once()) + ->method('getVersion') + ->will($this->returnValue($currentVersionId)); + $this->changelogMock->expects($this->once()) + ->method('getList') + ->with($lastVersionId, $currentVersionId) + ->will($this->returnValue($listId)); + + $actionMock = $this->getMock('Magento\Mview\Action', array('execute'), array(), '', false); + $actionMock->expects($this->once()) + ->method('execute') + ->with($listId) + ->will($this->returnSelf()); + $this->actionFactoryMock->expects($this->once()) + ->method('get') + ->with('Some\Class\Name') + ->will($this->returnValue($actionMock)); + + $this->loadView(); + $this->model->update(); + } + + /** + * @expectedException \Exception + * @expectedExceptionMessage Test exception + */ + public function testUpdateWithException() + { + $currentVersionId = 3; + $lastVersionId = 1; + $listId = array(2, 3); + $this->stateMock->expects($this->any()) + ->method('getViewId') + ->will($this->returnValue(1)); + $this->stateMock->expects($this->once()) + ->method('getVersionId') + ->will($this->returnValue($lastVersionId)); + $this->stateMock->expects($this->never()) + ->method('setVersionId'); + $this->stateMock->expects($this->once()) + ->method('getMode') + ->will($this->returnValue('enabled')); + $this->stateMock->expects($this->once()) + ->method('getStatus') + ->will($this->returnValue('idle')); + $this->stateMock->expects($this->exactly(2)) + ->method('setStatus') + ->will($this->returnSelf()); + $this->stateMock->expects($this->exactly(2)) + ->method('save') + ->will($this->returnSelf()); + + $this->changelogMock->expects($this->once()) + ->method('getVersion') + ->will($this->returnValue($currentVersionId)); + $this->changelogMock->expects($this->once()) + ->method('getList') + ->with($lastVersionId, $currentVersionId) + ->will($this->returnValue($listId)); + + $actionMock = $this->getMock('Magento\Mview\Action', array('execute'), array(), '', false); + $actionMock->expects($this->once()) + ->method('execute') + ->with($listId) + ->will($this->returnCallback(function () { + throw new \Exception('Test exception'); + })); + $this->actionFactoryMock->expects($this->once()) + ->method('get') + ->with('Some\Class\Name') + ->will($this->returnValue($actionMock)); + + $this->loadView(); + $this->model->update(); + } + + protected function loadView() + { + $viewId = 'view_test'; + $this->configMock->expects($this->once()) + ->method('get') + ->with($viewId) + ->will($this->returnValue($this->getViewData())); + $this->model->load($viewId); + } + + protected function getViewData() + { + return array( + 'view_id' => 'view_test', + 'action_class' => 'Some\Class\Name', + 'group' => 'some_group', + 'subscriptions' => array( + 'some_entity' => array( + 'name' => 'some_entity', + 'column' => 'entity_id', + ), + ), + ); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Mview/XsdTest.php b/dev/tests/unit/testsuite/Magento/Mview/XsdTest.php new file mode 100644 index 0000000000000000000000000000000000000000..43978a263f1ca9d9a50684a300e9229c2a731c6f --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Mview/XsdTest.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\Mview; + +class XsdTest extends \PHPUnit_Framework_TestCase +{ + /** + * Path to xsd schema file + * @var string + */ + protected $_xsdSchema; + + /** + * @var \Magento\TestFramework\Utility\XsdValidator + */ + protected $_xsdValidator; + + protected function setUp() + { + $this->_xsdSchema = BP . '/lib/Magento/Mview/etc/mview.xsd'; + $this->_xsdValidator = new \Magento\TestFramework\Utility\XsdValidator(); + } + + /** + * @param string $xmlString + * @param array $expectedError + * @dataProvider schemaCorrectlyIdentifiesInvalidXmlDataProvider + */ + public function testSchemaCorrectlyIdentifiesInvalidXml($xmlString, $expectedError) + { + $actualError = $this->_xsdValidator->validate($this->_xsdSchema, $xmlString); + $this->assertEquals($expectedError, $actualError); + } + + public function testSchemaCorrectlyIdentifiesValidXml() + { + $xmlString = file_get_contents(__DIR__ . '/_files/valid_mview.xml'); + $actualResult = $this->_xsdValidator->validate($this->_xsdSchema, $xmlString); + + $this->assertEmpty($actualResult); + } + + /** + * Data provider with invalid xml array according to events.xsd + */ + public function schemaCorrectlyIdentifiesInvalidXmlDataProvider() + { + return include(__DIR__ . '/_files/invalidMviewXmlArray.php'); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Mview/_files/invalidMviewXmlArray.php b/dev/tests/unit/testsuite/Magento/Mview/_files/invalidMviewXmlArray.php new file mode 100644 index 0000000000000000000000000000000000000000..377789212addc74d66318112af1f01cd2896ba8a --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Mview/_files/invalidMviewXmlArray.php @@ -0,0 +1,78 @@ +<?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) + */ +return array( + 'without_mview_handle' => array( + '<?xml version="1.0"?><config></config>', + array("Element 'config': Missing child element(s). Expected is ( view )."), + ), + + 'mview_with_notallowed_attribute' => array( + '<?xml version="1.0" encoding="UTF-8"?><config>' + . '<view id="view_one" notallow="notallow" class="Ogogo\Class\One" group="some_view_group">' + . '<subscriptions><table name="some_entity" entity_column="entity_id" /></subscriptions></view></config>', + array("Element 'view', attribute 'notallow': The attribute 'notallow' is not allowed."), + ), + + 'mview_without_class_attribute' => array( + '<?xml version="1.0" encoding="UTF-8"?><config><view id="view_one" group="some_view_group"><subscriptions>' + . '<table name="some_entity" entity_column="entity_id" /></subscriptions></view></config>', + array("Element 'view': The attribute 'class' is required but missing."), + ), + + 'mview_without_group_attribute' => array( + '<?xml version="1.0" encoding="UTF-8"?><config><view id="view_one" class="Ogogo\Class\One"><subscriptions>' + . '<table name="some_entity" entity_column="entity_id" /></subscriptions></view></config>', + array("Element 'view': The attribute 'group' is required but missing."), + ), + + 'mview_with_empty_subscriptions' => array( + '<?xml version="1.0" encoding="UTF-8"?><config>' + . '<view id="view_one" class="Ogogo\Class\One" group="some_view_group"><subscriptions>' + . '</subscriptions></view></config>', + array("Element 'subscriptions': Missing child element(s). Expected is ( table )."), + ), + + 'subscriptions_without_table' => array( + '<?xml version="1.0" encoding="UTF-8"?><config>' + . '<view id="view_one" class="Ogogo\Class\One" group="some_view_group"><subscriptions>' + . '</subscriptions></view></config>', + array("Element 'subscriptions': Missing child element(s). Expected is ( table )."), + ), + + 'table_without_column_attribute' => array( + '<?xml version="1.0" encoding="UTF-8"?><config>' + . '<view id="view_one" class="Ogogo\Class\One" group="some_view_group"><subscriptions>' + . '<table name="some_entity" /></subscriptions></view></config>', + array("Element 'table': The attribute 'entity_column' is required but missing."), + ), + + 'subscriptions_duplicate_table' => array( + '<?xml version="1.0" encoding="UTF-8"?><config>' + . '<view id="view_one" class="Ogogo\Class\One" group="some_view_group"><subscriptions>' + . '<table name="some_entity" entity_column="entity_id" />' + . '<table name="some_entity" entity_column="entity_id" /></subscriptions></view></config>', + array("Element 'table': Duplicate key-sequence ['some_entity', 'entity_id'] in unique identity-constraint " + . "'uniqueSubscriptionsTable'."), + ), +); diff --git a/dev/tests/unit/testsuite/Magento/Mview/_files/mview_config.php b/dev/tests/unit/testsuite/Magento/Mview/_files/mview_config.php new file mode 100644 index 0000000000000000000000000000000000000000..652b3476d28108d41e5cc3a7138bd08c0356f477 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Mview/_files/mview_config.php @@ -0,0 +1,46 @@ +<?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) + */ +return array( + 'inputXML' => '<?xml version="1.0" encoding="UTF-8"?><config>' + . '<view id="view_one" class="Ogogo\Class\One" group="some_view_group">' + . '<subscriptions><table name="some_entity" entity_column="entity_id" />' + . '<table name="some_product_relation" entity_column="product_id" /></subscriptions></view></config>', + 'expected' => array( + 'view_one' => array( + 'view_id' => 'view_one', + 'action_class' => 'Ogogo\Class\One', + 'group' => 'some_view_group', + 'subscriptions' => array( + 'some_entity' => array( + 'name' => 'some_entity', + 'column' => 'entity_id', + ), + 'some_product_relation' => array( + 'name' => 'some_product_relation', + 'column' => 'product_id', + ), + ), + ), + ), +); diff --git a/dev/tests/unit/testsuite/Magento/Mview/_files/mview_merged_one.xml b/dev/tests/unit/testsuite/Magento/Mview/_files/mview_merged_one.xml new file mode 100644 index 0000000000000000000000000000000000000000..bde8447bbc0c5d3efeda560c7b375fd08902a1fb --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Mview/_files/mview_merged_one.xml @@ -0,0 +1,45 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- +/** + * 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) + */ +--> +<config> + <view id="view_one" class="Ogogo\Class\One"> + <subscriptions> + <table name="some_entity" entity_column="entity_id" /> + <table name="some_product_relation" entity_column="product_id" /> + </subscriptions> + </view> + <view id="view_two" class="Ogogo\Class\Two"> + <subscriptions> + <table name="some_entity" entity_column="entity_id" /> + <table name="some_product_relation_other" entity_column="product_id" /> + </subscriptions> + </view> + <view id="view_three" class="Ogogo\Class\Three"> + <subscriptions> + <table name="some_entity" entity_column="entity_id" /> + <table name="some_product_relation" entity_column="product_id" /> + </subscriptions> + </view> +</config> \ No newline at end of file diff --git a/app/code/Magento/Bundle/view/frontend/layout/multishipping_checkout_shipping.xml b/dev/tests/unit/testsuite/Magento/Mview/_files/mview_merged_two.xml similarity index 61% rename from app/code/Magento/Bundle/view/frontend/layout/multishipping_checkout_shipping.xml rename to dev/tests/unit/testsuite/Magento/Mview/_files/mview_merged_two.xml index 91de6ad093134cd321f61149d9ea65c4452c2eac..744d3c2ec505cdb7e8c0f5ccc8d995ad8b3808e9 100644 --- a/app/code/Magento/Bundle/view/frontend/layout/multishipping_checkout_shipping.xml +++ b/dev/tests/unit/testsuite/Magento/Mview/_files/mview_merged_two.xml @@ -1,4 +1,4 @@ -<?xml version="1.0"?> +<?xml version="1.0" encoding="UTF-8"?> <!-- /** * Magento @@ -23,11 +23,17 @@ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */ --> -<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> - <referenceBlock name="checkout_shipping"> - <block class="Magento\Bundle\Block\Checkout\Cart\Item\Renderer" as="bundle" template="Magento_Multishipping::checkout/item/default.phtml" cacheable="false"/> - </referenceBlock> - <referenceBlock name="checkout_billing_items"> - <block class="Magento\Bundle\Block\Checkout\Cart\Item\Renderer" as="bundle" template="Magento_Multishipping::checkout/item/default.phtml" cacheable="false"/> - </referenceBlock> -</layout> +<config> + <view id="view_one" class="Ogogo\Class\Two"> + <subscriptions> + <table name="some_entity" entity_column="entity_id" /> + <table name="some_product_relation" entity_column="entity_id" /> + </subscriptions> + </view> + <view id="view_three" class="Ogogo\Class\Three"> + <subscriptions> + <table name="some_entity" entity_column="entity_id" /> + <table name="some_product_relation" entity_column="product_id" /> + </subscriptions> + </view> +</config> \ No newline at end of file diff --git a/dev/tests/unit/testsuite/Magento/Mview/_files/mview_one.xml b/dev/tests/unit/testsuite/Magento/Mview/_files/mview_one.xml new file mode 100644 index 0000000000000000000000000000000000000000..fb2e5b221252cc2cde9af0dd69088f6b8d6e4d70 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Mview/_files/mview_one.xml @@ -0,0 +1,33 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- +/** + * 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) + */ +--> +<config> + <view id="view_one" class="Ogogo\Class\One"> + <subscriptions> + <table name="some_entity" entity_column="entity_id" /> + <table name="some_product_relation" entity_column="product_id" /> + </subscriptions> + </view> +</config> \ No newline at end of file diff --git a/dev/tests/unit/testsuite/Magento/Mview/_files/mview_three.xml b/dev/tests/unit/testsuite/Magento/Mview/_files/mview_three.xml new file mode 100644 index 0000000000000000000000000000000000000000..d495d661cdc9160f522067f32e3651a3a0aff540 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Mview/_files/mview_three.xml @@ -0,0 +1,38 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- +/** + * 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) + */ +--> +<config> + <view id="view_one" class="Ogogo\Class\Two"> + <subscriptions> + <table name="some_product_relation" entity_column="entity_id" /> + </subscriptions> + </view> + <view id="view_three" class="Ogogo\Class\Three"> + <subscriptions> + <table name="some_entity" entity_column="entity_id" /> + <table name="some_product_relation" entity_column="product_id" /> + </subscriptions> + </view> +</config> \ No newline at end of file diff --git a/dev/tests/unit/testsuite/Magento/Mview/_files/mview_two.xml b/dev/tests/unit/testsuite/Magento/Mview/_files/mview_two.xml new file mode 100644 index 0000000000000000000000000000000000000000..02b3c480d90520f16f84b660594413d9ba3af723 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Mview/_files/mview_two.xml @@ -0,0 +1,39 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- +/** + * 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) + */ +--> +<config> + <view id="view_two" class="Ogogo\Class\Two"> + <subscriptions> + <table name="some_entity" entity_column="entity_id" /> + <table name="some_product_relation_other" entity_column="product_id" /> + </subscriptions> + </view> + <view id="view_three" class="Ogogo\Class\Three"> + <subscriptions> + <table name="some_entity" entity_column="entity_id" /> + <table name="some_product_relation" entity_column="product_id" /> + </subscriptions> + </view> +</config> \ No newline at end of file diff --git a/app/code/Magento/PaypalUk/etc/module.xml b/dev/tests/unit/testsuite/Magento/Mview/_files/valid_mview.xml old mode 100755 new mode 100644 similarity index 61% rename from app/code/Magento/PaypalUk/etc/module.xml rename to dev/tests/unit/testsuite/Magento/Mview/_files/valid_mview.xml index 89ca2937a36d17cfacf2c4630b0294c009a6ea19..c4ba2a84b983516cbf5a77c15dc2dbb4063b3a77 --- a/app/code/Magento/PaypalUk/etc/module.xml +++ b/dev/tests/unit/testsuite/Magento/Mview/_files/valid_mview.xml @@ -1,4 +1,4 @@ -<?xml version="1.0"?> +<?xml version="1.0" encoding="UTF-8"?> <!-- /** * Magento @@ -24,19 +24,16 @@ */ --> <config> - <module name="Magento_PaypalUk" version="1.6.0.0" active="true"> - <sequence> - <module name="Magento_Checkout"/> - <module name="Magento_Sales"/> - <module name="Magento_Paypal"/> - </sequence> - <depends> - <module name="Magento_Checkout"/> - <module name="Magento_Directory"/> - <module name="Magento_Paypal"/> - <module name="Magento_Payment"/> - <module name="Magento_Core"/> - <module name="Magento_Customer"/> - </depends> - </module> -</config> + <view id="view_one" class="Ogogo\Class\One" group="index"> + <subscriptions> + <table name="some_entity" entity_column="entity_id" /> + <table name="some_product_relation" entity_column="product_id" /> + </subscriptions> + </view> + <view id="view_two" class="Ogogo\Class\Two" group="index"> + <subscriptions> + <table name="some_entity" entity_column="entity_id" /> + <table name="some_product_relation_other" entity_column="product_id" /> + </subscriptions> + </view> +</config> \ No newline at end of file diff --git a/dev/tests/unit/testsuite/Magento/ObjectManager/Config/Mapper/_files/mapped_simple_di_config.php b/dev/tests/unit/testsuite/Magento/ObjectManager/Config/Mapper/_files/mapped_simple_di_config.php index 940b985e3f689967e5a9d70d4d2befbcf697ae77..9c5c4c92dda6093ee47c6f12251bfc95be653727 100644 --- a/dev/tests/unit/testsuite/Magento/ObjectManager/Config/Mapper/_files/mapped_simple_di_config.php +++ b/dev/tests/unit/testsuite/Magento/ObjectManager/Config/Mapper/_files/mapped_simple_di_config.php @@ -24,7 +24,7 @@ return array( 'preferences' => array( 'Magento\Module\UpdaterInterface' => 'Magento\Module\Updaterter', - 'Magento\Core\Model\AppInterface' => 'Magento\Core\Model\App\Proxy', + 'Magento\AppInterface' => 'Magento\Core\Model\App\Proxy', ), 'Magento\App\State' => array( @@ -35,10 +35,10 @@ return array( ), ), - 'Magento\Core\Model\Config_Modules' => array( + 'Magento\Core\Model\Config\Modules' => array( 'parameters' => array( 'storage' => array( - 'instance' => 'Magento\Core\Model\Config\Storage_Modules', + 'instance' => 'Magento\Core\Model\Config\Storage\Modules', 'shared' => false ), ), @@ -46,11 +46,11 @@ return array( 'simple_modules_plugin' => array( 'sortOrder' => 10, 'disabled' => true, - 'instance' => 'Magento\Core\Model\Config_Modules_Plugin', + 'instance' => 'Magento\Core\Model\Config\Modules\Plugin', ), 'simple_modules_plugin_advanced' => array( 'sortOrder' => 0, - 'instance' => 'Magento\Core\Model\Config_Modules_PluginAdvanced', + 'instance' => 'Magento\Core\Model\Config\Modules\PluginAdvanced', ), 'overridden_plugin' => array( 'sortOrder' => 30, diff --git a/dev/tests/unit/testsuite/Magento/ObjectManager/Config/Mapper/_files/simple_di_config.xml b/dev/tests/unit/testsuite/Magento/ObjectManager/Config/Mapper/_files/simple_di_config.xml index eb0a63b512b255373150df6b13e693b72440c7e4..bc4af2b1efc07fa8e1dcd652679c9f72fb0c6a80 100644 --- a/dev/tests/unit/testsuite/Magento/ObjectManager/Config/Mapper/_files/simple_di_config.xml +++ b/dev/tests/unit/testsuite/Magento/ObjectManager/Config/Mapper/_files/simple_di_config.xml @@ -26,20 +26,20 @@ <config> <!-- Comment within root node --> <preference for="Magento\Module\UpdaterInterface" type="Magento\Module\Updaterter" /> - <preference for="Magento\Core\Model\AppInterface" type="Magento\Core\Model\App\Proxy" /> + <preference for="Magento\AppInterface" type="Magento\Core\Model\App\Proxy" /> <type name="Magento\App\State"> <param name="mode"> <value type="argument">Magento\App\State::PARAM_MODE</value> </param> </type> - <type name="Magento\Core\Model\Config_Modules"> + <type name="Magento\Core\Model\Config\Modules"> <!-- Comment within type node --> <param name="storage"> <!-- Comment within param node --> - <instance type="Magento\Core\Model\Config\Storage_Modules" shared="false" /> + <instance type="Magento\Core\Model\Config\Storage\Modules" shared="false" /> </param> - <plugin name="simple_modules_plugin" type="Magento\Core\Model\Config_Modules_Plugin" disabled="true" sortOrder="10" /> - <plugin name="simple_modules_plugin_advanced" type="Magento\Core\Model\Config_Modules_PluginAdvanced" /> + <plugin name="simple_modules_plugin" type="Magento\Core\Model\Config\Modules\Plugin" disabled="true" sortOrder="10" /> + <plugin name="simple_modules_plugin_advanced" type="Magento\Core\Model\Config\Modules\PluginAdvanced" /> <plugin name="overridden_plugin" sortOrder="30" disabled="true" /> </type> <type name="Magento\Http\Handler\Composite" shared="false"> @@ -47,34 +47,39 @@ <instance type="Magento\Http\HandlerFactory" /> </param> <param name="handlers"> - <value> + <array> <!-- Comment within value node --> - <custom_handler> - <sortOrder>25</sortOrder> - <class>Custom_Cache_Model_Http_Handler</class> - </custom_handler> - <other_handler> - <!-- Comment within child node of the value node that represents an assoc array --> - <sortOrder>10</sortOrder> - <class><![CDATA[Other_Cache_Model_Http_Handler]]></class> - </other_handler> - </value> + <item key="custom_handler"> + <array> + <item key="sortOrder"><value>25</value></item> + <item key="class"><value>Custom_Cache_Model_Http_Handler</value></item> + </array> + </item> + <item key="other_handler"> + <array> + <!-- Comment within child node of the value node that represents an assoc array --> + <item key="sortOrder"><value>10</value></item> + <item key="class"><value><![CDATA[Other_Cache_Model_Http_Handler]]></value></item> + </array> + </item> + </array> </param> </type> <type name="Magento\Data\Collection\Db\FetchStrategy\Cache"> <param name="cacheIdPrefix"><value><![CDATA[collection_]]></value></param> <param name="cacheLifetime"><value>86400</value></param> <param name="cacheTags"> - <value> - <const type='const'>Magento\Core\Model\Website::CACHE_TAG</const> - <boolFalse type='bool'>false</boolFalse> - <boolTrue type='bool'>true</boolTrue> - <boolOne type='bool'>1</boolOne> - <boolZero type='bool'>0</boolZero> - <intValue type='int'>100500</intValue> - <nullValue type='null' /> - <stringPattern type='string' pattern="[a-z\-]*">az-value</stringPattern> - </value> + <array> + <item key="const"><value type="const">Magento\Core\Model\Website::CACHE_TAG</value></item> + <item key="boolFalse"><value type="bool">false</value></item> + <item key="boolTrue"><value type="bool">true</value></item> + <item key="boolOne"><value type="bool">1</value></item> + <item key="boolZero"><value type="bool">0</value></item> + <item key="intValue"><value type="int">100500</value></item> + <item key="nullValue"><value type="null"/> + </item> + <item key="stringPattern"><value type="string" pattern="[a-z\-]*">az-value</value></item> + </array> </param> <param name="constParam"> <value type='const'>Magento\Core\Model\Website::CACHE_TAG</value> diff --git a/dev/tests/unit/testsuite/Magento/ObjectManager/Config/XsdTest.php b/dev/tests/unit/testsuite/Magento/ObjectManager/Config/XsdTest.php index 1d83bd2c54c18b27484a3cbeb118f9c2eefa2d9f..55ed9a00aef8afffa983b9246dd6d8ab99d08581 100644 --- a/dev/tests/unit/testsuite/Magento/ObjectManager/Config/XsdTest.php +++ b/dev/tests/unit/testsuite/Magento/ObjectManager/Config/XsdTest.php @@ -59,14 +59,6 @@ class XsdTest extends \PHPUnit_Framework_TestCase $this->assertEquals($expectedError, $actualError); } - public function testSchemaCorrectlyIdentifiesValidXml() - { - $xmlString = file_get_contents(__DIR__ . '/_files/valid_config.xml'); - $actualResult = $this->_xsdValidator->validate($this->_xsdSchema, $xmlString); - - $this->assertEmpty($actualResult); - } - /** * Data provider with invalid xml array according to events.xsd */ @@ -74,4 +66,12 @@ class XsdTest extends \PHPUnit_Framework_TestCase { return include(__DIR__ . '/_files/invalidConfigXmlArray.php'); } + + public function testSchemaCorrectlyIdentifiesValidXml() + { + $xmlString = file_get_contents(__DIR__ . '/_files/valid_config.xml'); + $actualResult = $this->_xsdValidator->validate($this->_xsdSchema, $xmlString); + + $this->assertEmpty($actualResult, join("\n", $actualResult)); + } } diff --git a/dev/tests/unit/testsuite/Magento/ObjectManager/Config/_files/invalidConfigXmlArray.php b/dev/tests/unit/testsuite/Magento/ObjectManager/Config/_files/invalidConfigXmlArray.php index d8b670952118c3de85b16d62055c91cc0c7efca3..ea7a1b3f24dad1222fbb9e9e3d1db18189ac4aa3 100644 --- a/dev/tests/unit/testsuite/Magento/ObjectManager/Config/_files/invalidConfigXmlArray.php +++ b/dev/tests/unit/testsuite/Magento/ObjectManager/Config/_files/invalidConfigXmlArray.php @@ -30,65 +30,273 @@ return array '<?xml version="1.0"?><config><preference for="Some_For_Name" /></config>', array("Element 'preference': The attribute 'type' is required but missing.")), 'preferences_with_same_for_attribute_value' => array( - '<?xml version="1.0"?><config><preference for="Some_For_Name" type="Some_Type_Name" />' - . '<preference for="Some_For_Name" type="Some_Type_Name" /></config>', + '<?xml version="1.0"?> + <config> + <preference for="Some_For_Name" type="Some_Type_Name" /> + <preference for="Some_For_Name" type="Some_Type_Name" /> + </config>', array("Element 'preference': Duplicate key-sequence ['Some_For_Name'] in unique " . "identity-constraint 'uniquePreference'.")), - 'preferences_with_notallowed_attribute' => array( - '<?xml version="1.0"?><config><preference for="Some_For_Name" type="Some_Type_Name" notallowed="text"/>' - . '</config>', - array("Element 'preference', attribute 'notallowed': The attribute 'notallowed' is not allowed.")), + 'preferences_with_forbidden_attribute' => array( + '<?xml version="1.0"?> + <config><preference for="Some_For_Name" type="Some_Type_Name" forbidden="text"/></config>', + array("Element 'preference', attribute 'forbidden': The attribute 'forbidden' is not allowed.")), 'type_without_required_name_attribute' => array( '<?xml version="1.0"?><config><type /></config>', array("Element 'type': The attribute 'name' is required but missing.")), 'type_with_same_name_attribute_value' => array( - '<?xml version="1.0"?><config><type name="Some_Type_name" /><type name="Some_Type_name" /></config>', + '<?xml version="1.0"?> + <config> + <type name="Some_Type_name" /> + <type name="Some_Type_name" /> + </config>', array("Element 'type': Duplicate key-sequence ['Some_Type_name'] in unique identity-constraint 'uniqueType'.")), - 'type_with_notallowed_attribute' => array( - '<?xml version="1.0"?><config><type name="Some_Name" notallowed="text"/></config>', - array("Element 'type', attribute 'notallowed': The attribute 'notallowed' is not allowed.")), + 'type_with_forbidden_attribute' => array( + '<?xml version="1.0"?><config><type name="Some_Name" forbidden="text"/></config>', + array("Element 'type', attribute 'forbidden': The attribute 'forbidden' is not allowed.")), 'type_shared_attribute_with_invalid_value' => array( '<?xml version="1.0"?><config><type name="Some_Name" shared="test"/></config>', array("Element 'type', attribute 'shared': 'test' is not a valid value of the atomic type 'xs:boolean'.")), - 'type_param_value_with_notallowed_attribute' => array( - '<?xml version="1.0"?><config><type name="Some_Type_name"><param name="test_param_name" >' - . '<value notallowed="test" /></param></type></config>', - array("Element 'value', attribute 'notallowed': The attribute 'notallowed' is not allowed.")), + 'type_param_value_with_forbidden_attribute' => array( + '<?xml version="1.0"?> + <config> + <type name="Some_Type_name"> + <param name="test_param_name"><value forbidden="test" /></param> + </type> + </config>', + array("Element 'value', attribute 'forbidden': The attribute 'forbidden' is not allowed.")), + 'type_param_empty' => array( + '<?xml version="1.0"?><config><type name="Some_Name"><param name="Param_name" /></type></config>', + array("Element 'param': Missing child element(s). Expected is one of ( instance, value, array ).")), 'type_param_without_required_name_attribute' => array( - '<?xml version="1.0"?><config><type name="Some_Name"><param /></type></config>', + '<?xml version="1.0"?> + <config> + <type name="Some_Name"><param><value /></param></type> + </config>', array("Element 'param': The attribute 'name' is required but missing.")), 'type_param_instance_without_required_type_attribute' => array( - '<?xml version="1.0"?><config><type name="Some_Name"><param name="Pram_Name"><instance /></param></type>' - . '</config>', + '<?xml version="1.0"?> + <config><type name="Some_Name"><param name="Param_name"><instance /></param></type></config>', array("Element 'instance': The attribute 'type' is required but missing.")), 'type_param_instance_with_invalid_shared_value' => array( - '<?xml version="1.0"?><config><type name="Some_Name"><param name="Pram_Name">' - . '<instance type="Some_type" shared="string" /></param></type></config>', + '<?xml version="1.0"?> + <config> + <type name="Some_Name"> + <param name="Param_name"> + <instance type="Some_type" shared="string" /> + </param> + </type> + </config>', array("Element 'instance', attribute 'shared': 'string' is not a valid value of the atomic " . "type 'xs:boolean'.")), - 'type_instance_with_notallowed_attribute' => array( - '<?xml version="1.0"?><config><type name="Some_Name"><param name="Pram_Name">' - . '<instance type="Some_type" notallowed="text" /></param></type></config>', - array("Element 'instance', attribute 'notallowed': The attribute 'notallowed' is not allowed.")), + 'type_instance_with_forbidden_attribute' => array( + '<?xml version="1.0"?> + <config> + <type name="Some_Name"> + <param name="Param_name"> + <instance type="Some_type" forbidden="text" /> + </param> + </type> + </config>', + array("Element 'instance', attribute 'forbidden': The attribute 'forbidden' is not allowed.")), 'type_plugin_without_required_name_attribute' => array( '<?xml version="1.0"?><config><type name="Some_Name"><plugin /></type></config>', array("Element 'plugin': The attribute 'name' is required but missing.")), - 'type_plugin_with_notallowed_attribute' => array( - '<?xml version="1.0"?><config><type name="Some_Name"><plugin name="some_name" notallowed="text" />' - . '</type></config>', - array("Element 'plugin', attribute 'notallowed': The attribute 'notallowed' is not allowed.")), + 'type_plugin_with_forbidden_attribute' => array( + '<?xml version="1.0"?> + <config><type name="Some_Name"><plugin name="some_name" forbidden="text" /></type></config>', + array("Element 'plugin', attribute 'forbidden': The attribute 'forbidden' is not allowed.")), 'type_plugin_disabled_attribute_invalid_value' => array( - '<?xml version="1.0"?><config><type name="Some_Name"><plugin name="some_name" disabled="string" />' - . '</type></config>', + '<?xml version="1.0"?> + <config><type name="Some_Name"><plugin name="some_name" disabled="string" /></type></config>', array("Element 'plugin', attribute 'disabled': 'string' is not a valid value of the atomic " . "type 'xs:boolean'.")), 'type_plugin_sortorder_attribute_invalid_value' => array( - '<?xml version="1.0"?><config><type name="Some_Name"><plugin name="some_name" sortOrder="string" />' - . '</type></config>', + '<?xml version="1.0"?> + <config><type name="Some_Name"><plugin name="some_name" sortOrder="string" /></type></config>', array("Element 'plugin', attribute 'sortOrder': 'string' is not a valid value of the atomic type 'xs:int'.")), 'type_same_name_attribute_value' => array( - '<?xml version="1.0"?><config><type name="Some_Name" /><type name="Some_Name" /></config>', + '<?xml version="1.0"?> + <config> + <type name="Some_Name" /> + <type name="Some_Name" /> + </config>', array("Element 'type': Duplicate key-sequence ['Some_Name'] in unique identity-constraint 'uniqueType'.")), + 'type_value_forbidden_element' => array( + '<?xml version="1.0"?> + <config> + <type name="Some_Name"> + <param name="test_param_name"> + <value> + <forbidden /> + </value> + </param> + </type> + </config>', + array("Element 'value': Element content is not allowed, because the content type is a simple type definition.") + ), + 'type_param_several_allowed_elements' => array( + '<?xml version="1.0"?> + <config> + <type name="Some_Name"> + <param name="test_param_name"> + <value>value</value> + <array> + <item key="key"><value>value</value></item> + </array> + </param> + </type> + </config>', + array("Element 'array': This element is not expected.") + ), + 'type_array_empty' => array( + '<?xml version="1.0"?> + <config> + <type name="Some_Name"> + <param name="test_param_name"> + <array /> + </param> + </type> + </config>', + array("Element 'array': Missing child element(s). Expected is ( item ).") + ), + 'type_array_forbidden_argument' => array( + '<?xml version="1.0"?> + <config> + <type name="Some_Name"> + <param name="test_param_name"> + <array forbidden="text"> + <item key="key"><value>value</value></item> + </array> + </param> + </type> + </config>', + array("Element 'array', attribute 'forbidden': The attribute 'forbidden' is not allowed.") + ), + 'type_array_forbidden_element' => array( + '<?xml version="1.0"?> + <config> + <type name="Some_Name"> + <param name="test_param_name"> + <array> + <forbidden /> + <item key="key"><value>value</value></item> + </array> + </param> + </type> + </config>', + array("Element 'forbidden': This element is not expected. Expected is ( item ).") + ), + 'type_array_item_missed_argument' => array( + '<?xml version="1.0"?> + <config> + <type name="Some_Name"> + <param name="test_param_name"> + <array> + <item><value>value</value></item> + </array> + </param> + </type> + </config>', + array("Element 'item': The attribute 'key' is required but missing.") + ), + 'type_array_item_name_argument (difference between item and param)' => array( + '<?xml version="1.0"?> + <config> + <type name="Some_Name"> + <param name="test_param_name"> + <array> + <item key="key" name="text"><value>value</value></item> + </array> + </param> + </type> + </config>', + array("Element 'item', attribute 'name': The attribute 'name' is not allowed.") + ), + 'type_array_item_empty_argument' => array( + '<?xml version="1.0"?> + <config> + <type name="Some_Name"> + <param name="test_param_name"> + <array> + <item key="key" /> + </array> + </param> + </type> + </config>', + array("Element 'item': Missing child element(s). Expected is one of ( instance, value, array ).") + ), + 'type_array_item_forbidden_element' => array( + '<?xml version="1.0"?> + <config> + <type name="Some_Name"> + <param name="test_param_name"> + <array> + <item key="key"><forbidden>value</forbidden></item> + </array> + </param> + </type> + </config>', + array("Element 'forbidden': This element is not expected. Expected is one of ( instance, value, array ).") + ), + 'type_array_item_same_keys' => array( + '<?xml version="1.0"?> + <config> + <type name="Some_Name"> + <param name="test_param_name"> + <array> + <item key="key"><value>value</value></item> + <item key="key"><value>value</value></item> + </array> + </param> + </type> + </config>', + array("Element 'item': Duplicate key-sequence ['key'] in unique identity-constraint 'uniqueArrayIndex'.") + ), + 'type_array_item_same_keys_in_nested_array' => array( + '<?xml version="1.0"?> + <config> + <type name="Some_Name"> + <param name="test_param_name"> + <array> + <item key="key_outer"> + <array> + <item key="key"><value>value</value></item> + <item key="key"><value>value</value></item> + </array> + </item> + </array> + </param> + </type> + </config>', + array("Element 'item': Duplicate key-sequence ['key'] in unique identity-constraint 'uniqueArrayIndex'.") + ), + 'type_array_item_value_forbidden_argument' => array( + '<?xml version="1.0"?> + <config> + <type name="Some_Name"> + <param name="test_param_name"> + <array> + <item key="key"><value forbidden="text">value</value></item> + </array> + </param> + </type> + </config>', + array("Element 'value', attribute 'forbidden': The attribute 'forbidden' is not allowed.") + ), + 'type_array_item_value_forbidden_element' => array( + '<?xml version="1.0"?> + <config> + <type name="Some_Name"> + <param name="test_param_name"> + <array> + <item key="key"><value><forbidden /></value></item> + </array> + </param> + </type> + </config>', + array("Element 'value': Element content is not allowed, because the content type is a simple type definition.") + ), 'virtualtype_without_required_name_attribute' => array( '<?xml version="1.0"?><config><virtualType /></config>', array("Element 'virtualType': The attribute 'name' is required but missing.")), @@ -96,16 +304,21 @@ return array '<?xml version="1.0"?><config><virtualType name="virtual_name" shared="string"/></config>', array("Element 'virtualType', attribute 'shared': 'string' is not a valid value of the atomic " . "type 'xs:boolean'.")), - 'virtualtype_with_notallowed_attribute' => array( - '<?xml version="1.0"?><config><virtualType name="virtual_name" notallowed="text"/></config>', - array("Element 'virtualType', attribute 'notallowed': The attribute 'notallowed' is not allowed.")), + 'virtualtype_with_forbidden_attribute' => array( + '<?xml version="1.0"?><config><virtualType name="virtual_name" forbidden="text"/></config>', + array("Element 'virtualType', attribute 'forbidden': The attribute 'forbidden' is not allowed.")), 'virtualtype_with_same_name_attribute_value' => array( '<?xml version="1.0"?><config><virtualType name="test_name" /><virtualType name="test_name" /></config>', array("Element 'virtualType': Duplicate key-sequence ['test_name'] in unique" . " identity-constraint 'uniqueVirtualType'.")), 'virtualtype_with_same_param_name_attribute' => array( - '<?xml version="1.0"?><config><virtualType name="virtual_name"><param name="same_param_name" />' - . '<param name="same_param_name" /></virtualType></config>', + '<?xml version="1.0"?> + <config> + <virtualType name="virtual_name"> + <param name="same_param_name"><value>value</value></param> + <param name="same_param_name"><value>value</value></param> + </virtualType> + </config>', array("Element 'param': Duplicate key-sequence ['same_param_name'] in unique " . "identity-constraint 'uniqueVirtualTypeParam'.")), ); diff --git a/dev/tests/unit/testsuite/Magento/ObjectManager/Config/_files/valid_config.xml b/dev/tests/unit/testsuite/Magento/ObjectManager/Config/_files/valid_config.xml index 5db3b39f59d83cccb4c00d1cda3597c5669f90d0..110dbfb89d2409c2ce19c8677949d81dbc31878a 100644 --- a/dev/tests/unit/testsuite/Magento/ObjectManager/Config/_files/valid_config.xml +++ b/dev/tests/unit/testsuite/Magento/ObjectManager/Config/_files/valid_config.xml @@ -26,13 +26,32 @@ <config> <preference for="Some_For_Name" type="Some_Type_Name" /> <virtualType name="" type="" shared="true"> - <param name="sessionNamespace"> - <value> - <backend> - <instance>value</instance> - <sortOrder>2</sortOrder> - </backend> - </value> + <param name="single_array"> + <array> + <item key="key1 unique for single array"><value>value</value></item> + <item key="Different symbols 1~!@#$%^&*()_+-=`[]\{}|;':,./<>?"><value>2</value></item> + </array> + </param> + <param name="nested_array"> + <array> + <item key="key1 unique for single array"> + <array> + <item key="key1 unique for single array"><value>value</value></item> + <item key="Different symbols 1~!@#$%^&*()_+-=`[]\{}|;':,./<>?"><value>2</value></item> + </array> + </item> + <item key="backend2"> + <array> + <item key="key1 unique for single array"><value>value</value></item> + <item key="Different symbols 1~!@#$%^&*()_+-=`[]\{}|;':,./<>?"> + <array> + <item key="key1 unique for single array"><value>value</value></item> + <item key="Different symbols 1~!@#$%^&*()_+-=`[]\{}|;':,./<>?"><value>2</value></item> + </array> + </item> + </array> + </item> + </array> </param> </virtualType> <type name="Some_Type_name"> @@ -40,13 +59,32 @@ <param name="text_value"> <instance type="Instance_test_name" /> </param> - <param name="test_param_name"> - <value> - <backend> - <instance>value</instance> - <sortOrder>2</sortOrder> - </backend> - </value> + <param name="single_array"> + <array> + <item key="key1 unique for single array"><value>value</value></item> + <item key="Different symbols 1~!@#$%^&*()_+-=`[]\{}|;':,./<>?"><instance type="Instance_test_name" /></item> + </array> + </param> + <param name="nested_array"> + <array> + <item key="key1 unique for single array"> + <array> + <item key="key1 unique for single array"><value>value</value></item> + <item key="Different symbols 1~!@#$%^&*()_+-=`[]\{}|;':,./<>?"><instance type="Instance_test_name" /></item> + </array> + </item> + <item key="backend2"> + <array> + <item key="key1 unique for single array"><value>value</value></item> + <item key="Different symbols 1~!@#$%^&*()_+-=`[]\{}|;':,./<>?"> + <array> + <item key="key1 unique for single array"><value>value</value></item> + <item key="Different symbols 1~!@#$%^&*()_+-=`[]\{}|;':,./<>?"><instance type="Instance_test_name" /></item> + </array> + </item> + </array> + </item> + </array> </param> <param name="baseController"> <value>some_value</value> diff --git a/dev/tests/unit/testsuite/Magento/PageCache/Controller/BlockTest.php b/dev/tests/unit/testsuite/Magento/PageCache/Controller/BlockTest.php new file mode 100644 index 0000000000000000000000000000000000000000..6f59c3ccdabde351d035e888d0a62eb9ae7fb39e --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/PageCache/Controller/BlockTest.php @@ -0,0 +1,180 @@ +<?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_PageCache + * @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) + */ + +/** + * Test class for \Magento\PageCache\Controller\Block + */ +namespace Magento\PageCache\Controller; + +/** + * Class BlockTest + * + * @package Magento\PageCache\Controller + */ +class BlockTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\App\Request\Http|\PHPUnit_Framework_MockObject_MockObject + */ + protected $requestMock; + + /** + * @var \Magento\App\Response\Http|\PHPUnit_Framework_MockObject_MockObject + */ + protected $responseMock; + + /** + * @var \Magento\App\View|\PHPUnit_Framework_MockObject_MockObject + */ + protected $viewMock; + + /** + * @var \Magento\PageCache\Controller\Block + */ + protected $controller; + + /** + * @var \Magento\Core\Model\Layout|\PHPUnit_Framework_MockObject_MockObject + */ + protected $layoutMock; + + /** + * Set up before test + */ + protected function setUp() + { + $this->layoutMock = $this->getMockBuilder('Magento\Core\Model\Layout') + ->disableOriginalConstructor() + ->getMock(); + + $contextMock = $this->getMockBuilder('Magento\App\Action\Context') + ->disableOriginalConstructor() + ->getMock(); + + $this->requestMock = $this->getMockBuilder('Magento\App\Request\Http') + ->disableOriginalConstructor() + ->getMock(); + $this->responseMock = $this->getMockBuilder('Magento\App\Response\Http') + ->disableOriginalConstructor() + ->getMock(); + $this->viewMock = $this->getMockBuilder('Magento\App\View') + ->disableOriginalConstructor() + ->getMock(); + + $contextMock->expects($this->any())->method('getRequest')->will($this->returnValue($this->requestMock)); + $contextMock->expects($this->any())->method('getResponse')->will($this->returnValue($this->responseMock)); + $contextMock->expects($this->any())->method('getView')->will($this->returnValue($this->viewMock)); + + $this->controller = new \Magento\PageCache\Controller\Block($contextMock); + } + + public function testRenderActionNotAjax() + { + $this->requestMock->expects($this->once())->method('isAjax')->will($this->returnValue(false)); + $this->requestMock->expects($this->once())->method('setActionName')->will($this->returnValue('noroute')); + $this->requestMock->expects($this->once())->method('setDispatched')->will($this->returnValue(false)); + $result = $this->controller->renderAction(); + $this->assertNull($result); + } + + /** + * Test no params: blocks, handles + */ + public function testRenderActionNoParams() + { + $this->requestMock->expects($this->once())->method('isAjax')->will($this->returnValue(true)); + $this->requestMock->expects($this->at(1)) + ->method('getParam') + ->with($this->equalTo('blocks'), $this->equalTo([])) + ->will($this->returnValue([])); + $this->requestMock->expects($this->at(2)) + ->method('getParam') + ->with($this->equalTo('handles'), $this->equalTo([])) + ->will($this->returnValue([])); + $result = $this->controller->renderAction(); + $this->assertNull($result); + } + + public function testRenderAction() + { + $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') + ); + $blockInstance1->expects($this->once())->method('toHtml')->will($this->returnValue($expectedData['block1'])); + + $blockInstance2 = $this->getMockForAbstractClass( + 'Magento\View\Element\AbstractBlock', array(), '', false, true, true, array('toHtml') + ); + $blockInstance2->expects($this->once())->method('toHtml')->will($this->returnValue($expectedData['block2'])); + + $this->requestMock->expects($this->once())->method('isAjax')->will($this->returnValue(true)); + $this->requestMock->expects($this->at(1)) + ->method('getParam') + ->with($this->equalTo('blocks'), $this->equalTo([])) + ->will($this->returnValue($blocks)); + $this->requestMock->expects($this->at(2)) + ->method('getParam') + ->with($this->equalTo('handles'), $this->equalTo([])) + ->will($this->returnValue($handles)); + $this->viewMock->expects($this->once()) + ->method('loadLayout') + ->with($this->equalTo($handles)); + $this->viewMock->expects($this->any()) + ->method('getLayout') + ->will($this->returnValue($this->layoutMock)); + $this->layoutMock->expects($this->at(0)) + ->method('getBlock') + ->with($this->equalTo($blocks[0])) + ->will($this->returnValue($blockInstance1)); + $this->layoutMock->expects($this->at(1)) + ->method('getBlock') + ->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)) + ->method('appendBody') + ->with($this->equalTo(json_encode($expectedData))); + + $this->controller->renderAction(); + } +} diff --git a/dev/tests/unit/testsuite/Magento/PageCache/Helper/DataTest.php b/dev/tests/unit/testsuite/Magento/PageCache/Helper/DataTest.php new file mode 100644 index 0000000000000000000000000000000000000000..ca95859ee108e9444a96304effb97d2ad3679f84 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/PageCache/Helper/DataTest.php @@ -0,0 +1,83 @@ +<?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_PageCache + * @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) + */ + +/** + * Test class for \Magento\PageCache\Helper\Data + */ +namespace Magento\PageCache\Helper; + +/** + * Class DataTest + * + * @package Magento\PageCache\Controller + */ +class DataTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\App\ConfigInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $configMock; + + /** + * @var \Magento\PageCache\Helper\Data + */ + protected $helper; + + /** + * Set up before test + */ + protected function setUp() + { + $context = $this->getMockBuilder('\Magento\App\Helper\Context') + ->disableOriginalConstructor() + ->getMock(); + + $this->configMock = $this->getMockBuilder('\Magento\App\Config') + ->disableOriginalConstructor() + ->getMock(); + + $this->helper = new \Magento\PageCache\Helper\Data($context, $this->configMock); + } + + public function testGetPublicMaxAgeCache() + { + $age = 0; + $this->configMock->expects($this->once()) + ->method('getValue') + ->with($this->equalTo(\Magento\PageCache\Helper\Data::PUBLIC_MAX_AGE_PATH)) + ->will($this->returnValue($age)); + $data = $this->helper->getPublicMaxAgeCache(); + $this->assertEquals($age, $data); + } + + public function testMaxAgeCache() + { + // one year + $age = 365 * 24 * 60 * 60; + $this->assertEquals($age, \Magento\PageCache\Helper\Data::PRIVATE_MAX_AGE_CACHE); + } +} 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 75075328a468fd57b10e3b6f82e5e4dbc845e747..2dea378966809c34a8fcf81dce4c1d94b858b72a 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 @@ -40,63 +40,121 @@ class HeaderPluginTest extends \PHPUnit_Framework_TestCase protected $layoutMock; /** - * @var \Magento\Core\Model\ConfigInterface|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\App\ConfigInterface|\PHPUnit_Framework_MockObject_MockObject */ protected $configMock; - + /** * @var \Magento\App\Response\Http|\PHPUnit_Framework_MockObject_MockObject */ protected $responseMock; + /** + * @var \Magento\PageCache\Model\Version|\PHPUnit_Framework_MockObject_MockObject + */ + protected $versionMock; + + /** + * @var \Magento\PageCache\Helper\Data|\PHPUnit_Framework_MockObject_MockObject + */ + protected $helperMock; + /** * SetUp */ protected function setUp() { $this->layoutMock = $this->getMock('Magento\Core\Model\Layout', array(), array(), '', false); - $this->configMock = $this->getMock('Magento\Core\Model\ConfigInterface', array(), array(), '', false); + $this->configMock = $this->getMock('Magento\App\ConfigInterface', array(), array(), '', false); $this->responseMock = $this->getMock('Magento\App\Response\Http', array(), array(), '', false); - $this->plugin = new HeaderPlugin($this->layoutMock, $this->configMock); + $this->helperMock = $this->getMock('Magento\PageCache\Helper\Data', array(), array(), '', false); + $this->versionMock = $this->getMockBuilder('Magento\PageCache\Model\Version') + ->disableOriginalConstructor() + ->getMock(); + $this->plugin = new HeaderPlugin($this->layoutMock, $this->configMock, $this->helperMock, $this->versionMock); } /** - * data providers for response headers + * Test if layout is not cacheable */ - public function headersCachableDataProvider() + public function testAfterDispatchNotCacheable() { - return array( - array(false, false, '10', 'no-store, no-cache, must-revalidate, max-age=0', 'no-cache'), - array(true, false, '20', 'public, max-age=20', 'cache'), - array(true, true, '30', 'private, max-age=30', 'cache'), - ); + $pragma = 'no-cache'; + $cacheControl = 'no-store, no-cache, must-revalidate, max-age=0'; + + $this->layoutMock->expects($this->once()) + ->method('isCacheable') + ->will($this->returnValue(false)); + + $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('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->plugin->afterDispatch($this->responseMock); } /** - * test response headers after dispatch, without cache - * - * @dataProvider headersCachableDataProvider + * Testing that `cache-control` already exists */ - public function testAfterDispatchCacheable($isCacheable, $isPrivate, $maxAge, $cacheControl, $pragma) + public function testAfterDispatchPrivateCache() { + $pragma = 'cache'; + $this->layoutMock->expects($this->once()) ->method('isCacheable') - ->will($this->returnValue($isCacheable)); - $this->layoutMock->expects($this->any()) - ->method('isPrivate') - ->will($this->returnValue($isPrivate)); - $this->configMock->expects($this->any()) - ->method('getValue') - ->with('system/headers/max-age') - ->will($this->returnValue($maxAge)); + ->will($this->returnValue(true)); $this->responseMock->expects($this->at(0)) ->method('setHeader') - ->with('pragma', $pragma); + ->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)); + + $this->versionMock->expects($this->once())->method('process'); + + $this->plugin->afterDispatch($this->responseMock); + } + + /** + * Test setting public headers + */ + public function testAfterDispatchPublicCache() + { + $maxAge = 0; + $pragma = 'cache'; + $cacheControl = 'public, max-age=' . $maxAge; + + $this->layoutMock->expects($this->once()) + ->method('isCacheable') + ->will($this->returnValue(true)); + + $this->helperMock->expects($this->once())->method('getPublicMaxAgeCache')->will($this->returnValue(0)); + $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(false)); + $this->responseMock->expects($this->at(2)) ->method('setHeader') - ->with('cache-control', $cacheControl); + ->with($this->equalTo('cache-control'), $this->equalTo($cacheControl), $this->equalTo(true)); + $this->responseMock->expects($this->at(3)) + ->method('setHeader') + ->with($this->equalTo('expires')); + + $this->versionMock->expects($this->once())->method('process'); $this->plugin->afterDispatch($this->responseMock); } diff --git a/dev/tests/unit/testsuite/Magento/PageCache/Model/VersionTest.php b/dev/tests/unit/testsuite/Magento/PageCache/Model/VersionTest.php new file mode 100644 index 0000000000000000000000000000000000000000..655979f1c7fed67809078d9260b3ce314e344a76 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/PageCache/Model/VersionTest.php @@ -0,0 +1,98 @@ +<?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_PageCache + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +namespace Magento\PageCache\Model; + +/** + * Class VersionTest + * @package Magento\PageCache\Model + */ +class VersionTest extends \PHPUnit_Framework_TestCase +{ + /** + * Cookie mock + * + * @var \Magento\Stdlib\Cookie|\PHPUnit_Framework_MockObject_MockObject + */ + private $cookieMock; + + /** + * Request mock + * + * @var \Magento\App\Request\Http|\PHPUnit_Framework_MockObject_MockObject + */ + private $requestMock; + + /** + * Version instance + * + * @var Version + */ + private $versionInstance; + + /** + * Create cookie and request mock, version instance + */ + public function setUp() + { + $this->cookieMock = $this->getMock('Magento\Stdlib\Cookie', array('set'), array(), '', false); + $this->requestMock = $this->getMock('Magento\App\Request\Http', array('isPost'), array(), '', false); + $this->versionInstance = new Version($this->cookieMock, $this->requestMock); + } + + /** + * Handle private content version cookie + * Set cookie if it is not set. + * Increment version on post requests. + * In all other cases do nothing. + */ + /** + * @dataProvider processProvider + * @param bool $isPost + */ + public function testProcess($isPost) + { + $this->requestMock->expects($this->once()) + ->method('isPost') + ->will($this->returnValue($isPost)); + if ($isPost) { + $this->cookieMock->expects($this->once())->method('set'); + } + $this->versionInstance->process(); + } + + /** + * Data provider for testProcess + * @return array + */ + public function processProvider() + { + return array( + array(true), + array(false) + ); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Persistent/Helper/DataTest.php b/dev/tests/unit/testsuite/Magento/Persistent/Helper/DataTest.php index ca2dd5de61c283ec48e93f81ce1116be43857801..fc37cc190e6f29d6781ea74c093eb857ad7fa451 100644 --- a/dev/tests/unit/testsuite/Magento/Persistent/Helper/DataTest.php +++ b/dev/tests/unit/testsuite/Magento/Persistent/Helper/DataTest.php @@ -27,7 +27,7 @@ namespace Magento\Persistent\Helper; class DataTest extends \PHPUnit_Framework_TestCase { /** - * @var \Magento\Core\Model\Config|PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Module\Dir\Reader|\PHPUnit_Framework_MockObject_MockObject */ protected $_modulesReader; diff --git a/dev/tests/unit/testsuite/Magento/Sales/Block/Adminhtml/Order/Create/Search/Grid/Renderer/QtyTest.php b/dev/tests/unit/testsuite/Magento/Sales/Block/Adminhtml/Order/Create/Search/Grid/Renderer/QtyTest.php new file mode 100644 index 0000000000000000000000000000000000000000..88bd2736cb4346e095e60daa89f8e85d95d03d2d --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Block/Adminhtml/Order/Create/Search/Grid/Renderer/QtyTest.php @@ -0,0 +1,82 @@ +<?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\Block\Adminhtml\Order\Create\Search\Grid\Renderer; + + +class QtyTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Sales\Block\Adminhtml\Order\Create\Search\Grid\Renderer\Qty + */ + protected $renderer; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $rowMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $typeConfigMock; + + protected function setUp() + { + $helper = new \Magento\TestFramework\Helper\ObjectManager($this); + + $this->rowMock = + $this->getMock('Magento\Object', array('getTypeId', 'getIndex'), + array(), '', false); + $this->typeConfigMock = $this->getMock('Magento\Catalog\Model\ProductTypes\ConfigInterface'); + $this->renderer = $helper->getObject( + 'Magento\Sales\Block\Adminhtml\Order\Create\Search\Grid\Renderer\Qty', + array( + 'typeConfig' => $this->typeConfigMock + ) + ); + } + + public function testRender() + { + $expected = '<input type="text" name="id_name" value="" disabled="disabled" ' . + 'class="input-text inline_css input-inactive" />'; + $this->typeConfigMock + ->expects($this->any()) + ->method('isProductSet') + ->with('id') + ->will($this->returnValue(true)); + $this->rowMock->expects($this->once())->method('getTypeId')->will($this->returnValue('id')); + $columnMock = + $this->getMock('Magento\Backend\Block\Widget\Grid\Column', + array('getInlineCss', 'getId'), array(), '', false); + $this->renderer->setColumn($columnMock); + + $columnMock->expects($this->once())->method('getId')->will($this->returnValue('id_name')); + $columnMock->expects($this->once())->method('getInlineCss')->will($this->returnValue('inline_css')); + + $this->assertEquals($expected, $this->renderer->render($this->rowMock)); + } +} + diff --git a/dev/tests/unit/testsuite/Magento/Sales/Block/Adminhtml/Order/Create/Sidebar/AbstractSidebarTest.php b/dev/tests/unit/testsuite/Magento/Sales/Block/Adminhtml/Order/Create/Sidebar/AbstractSidebarTest.php new file mode 100644 index 0000000000000000000000000000000000000000..c79744a6c8a0f6e2743b14f5fd1b437301ebfe83 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Block/Adminhtml/Order/Create/Sidebar/AbstractSidebarTest.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\Sales\Block\Adminhtml\Order\Create\Sidebar; + + +class AbstractSidebarTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Sales\Block\Adminhtml\Order\Create\Sidebar\AbstractSidebar + */ + protected $abstractSidebar; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $itemMock; + + protected function setUp() + { + $helper = new \Magento\TestFramework\Helper\ObjectManager($this); + $this->itemMock = $this->getMock('Magento\Object', array('getQty'), array(), '', false); + $this->abstractSidebar = + $helper->getObject('Magento\Sales\Block\Adminhtml\Order\Create\Sidebar\AbstractSidebar', array()); + } + + + /** + * @param int $itemQty + * @param int|bool $qty + * @param int $expectedValue + * @dataProvider getItemQtyDataProvider + */ + public function testGetItemQty($itemQty, $qty, $expectedValue) + { + $this->itemMock->expects($this->exactly($itemQty))->method('getQty')->will($this->returnValue($qty)); + $this->assertEquals($expectedValue, $this->abstractSidebar->getItemQty($this->itemMock)); + } + + public function getItemQtyDataProvider() + { + return array( + 'whenQtyIsset' => array(2, 10, 10), + 'whenQtyNotIsset' => array(1, false, 1) + ); + } + + public function testIsConfigurationRequired() + { + $productTypeMock = $this->getMock('Magento\Catalog\Model\Product\Type', array(), array(), '', false); + $this->assertEquals(false, $this->abstractSidebar->isConfigurationRequired($productTypeMock)); + } +} + diff --git a/dev/tests/unit/testsuite/Magento/Sales/Block/Items/AbstractTest.php b/dev/tests/unit/testsuite/Magento/Sales/Block/Items/AbstractTest.php index b9c99177427081de840d9d2f38196641e43fdffc..1736965db12a500b3d0c01809145aa78a0cb6e8f 100644 --- a/dev/tests/unit/testsuite/Magento/Sales/Block/Items/AbstractTest.php +++ b/dev/tests/unit/testsuite/Magento/Sales/Block/Items/AbstractTest.php @@ -35,17 +35,22 @@ class AbstractTest extends \PHPUnit_Framework_TestCase public function testGetItemRenderer() { - $renderer = $this->getMock('Magento\View\Element\AbstractBlock', array('setRenderedBlock'), array(), '', false); + $renderer = $this->getMock('Magento\View\Element\RendererList', array(), array(), '', false); + + $renderer->expects($this->once())->method('getRenderer') + ->with('some-type', AbstractItems::DEFAULT_TYPE)->will($this->returnValue('rendererObject')); + $layout = $this->getMock('Magento\Core\Model\Layout', array( 'getChildName', 'getBlock' ), array(), '', false); - $layout->expects($this->at(0)) + + $layout->expects($this->once()) ->method('getChildName') - ->with(null, 'some-type') - ->will($this->returnValue('some-block-name')); - $layout->expects($this->at(1)) + ->will($this->returnValue('renderer.list')); + + $layout->expects($this->once()) ->method('getBlock') - ->with('some-block-name') + ->with('renderer.list') ->will($this->returnValue($renderer)); /** @var $block \Magento\Sales\Block\Items\AbstractItems */ @@ -55,31 +60,21 @@ class AbstractTest extends \PHPUnit_Framework_TestCase )) )); - $renderer->expects($this->once()) - ->method('setRenderedBlock') - ->with($block); - - $this->assertSame($renderer, $block->getItemRenderer('some-type')); + $this->assertSame('rendererObject', $block->getItemRenderer('some-type')); } /** * @expectedException \RuntimeException - * @expectedExceptionMessage Renderer for type "some-type" does not exist. + * @expectedExceptionMessage Renderer list for block "" is not defined */ public function testGetItemRendererThrowsExceptionForNonexistentRenderer() { - $renderer = $this->getMock('StdClass'); $layout = $this->getMock('Magento\Core\Model\Layout', array( 'getChildName', 'getBlock' ), array(), '', false); - $layout->expects($this->at(0)) + $layout->expects($this->once()) ->method('getChildName') - ->with(null, 'some-type') - ->will($this->returnValue('some-block-name')); - $layout->expects($this->at(1)) - ->method('getBlock') - ->with('some-block-name') - ->will($this->returnValue($renderer)); + ->will($this->returnValue(null)); /** @var $block \Magento\Sales\Block\Items\AbstractItems */ $block = $this->_objectManager->getObject('Magento\Sales\Block\Items\AbstractItems', array( diff --git a/dev/tests/unit/testsuite/Magento/Sales/Model/Quote/Item/RelatedProductsTest.php b/dev/tests/unit/testsuite/Magento/Sales/Model/Quote/Item/RelatedProductsTest.php new file mode 100644 index 0000000000000000000000000000000000000000..7e37af1f31d9e526ad3317865cbe5dcb257d20f6 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Sales/Model/Quote/Item/RelatedProductsTest.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\Quote\Item; + +class RelatedProductsTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Sales\Model\Quote\Item\RelatedProducts + */ + protected $model; + + /** + * @var array + */ + protected $relatedProductTypes; + + protected function setUp() + { + $this->relatedProductTypes = array('type1', 'type2', 'type3'); + $this->model = new \Magento\Sales\Model\Quote\Item\RelatedProducts($this->relatedProductTypes); + } + + /** + * @param string $optionValue + * @param int|bool $productId + * @param array $expectedResult + * + * @covers \Magento\Sales\Model\Quote\Item\RelatedProducts::getRelatedProductIds + * @dataProvider getRelatedProductIdsDataProvider + */ + public function testGetRelatedProductIds($optionValue, $productId, $expectedResult) + { + $quoteItemMock = $this->getMock('\Magento\Sales\Model\Quote\Item', array(), array(), '', false); + $itemOptionMock = $this->getMock( + '\Magento\Sales\Model\Quote\Item\Option', array('getValue', 'getProductId', '__wakeup'), array(), '', false + ); + + $quoteItemMock->expects($this->once()) + ->method('getOptionByCode') + ->with('product_type') + ->will($this->returnValue($itemOptionMock)); + + $itemOptionMock->expects($this->once()) + ->method('getValue') + ->will($this->returnValue($optionValue)); + + $itemOptionMock->expects($this->any()) + ->method('getProductId') + ->will($this->returnValue($productId)); + + $this->assertEquals($expectedResult, $this->model->getRelatedProductIds(array($quoteItemMock))); + } + + /* + * Data provider for testGetRelatedProductIds + * + * @return array + */ + public function getRelatedProductIdsDataProvider() + { + return array( + array( + 'optionValue' => 'type1', + 'productId' => 123, + 'expectedResult' => array(123) + ), + array( + 'optionValue' => 'other_type', + 'productId' => 123, + 'expectedResult' => array() + ), + array( + 'optionValue' => 'type1', + 'productId' => null, + 'expectedResult' => array() + ), + array( + 'optionValue' => 'other_type', + 'productId' => false, + 'expectedResult' => array() + ) + ); + } + + /** + * @covers \Magento\Sales\Model\Quote\Item\RelatedProducts::getRelatedProductIds + */ + public function testGetRelatedProductIdsNoOptions() + { + $quoteItemMock = $this->getMock('\Magento\Sales\Model\Quote\Item', array(), array(), '', false); + + $quoteItemMock->expects($this->once()) + ->method('getOptionByCode') + ->with('product_type') + ->will($this->returnValue(new \stdClass())); + + $this->assertEquals(array(), $this->model->getRelatedProductIds(array($quoteItemMock))); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Test/Tools/Di/_files/app/code/Magento/SomeModule/etc/di.xml b/dev/tests/unit/testsuite/Magento/Test/Tools/Di/_files/app/code/Magento/SomeModule/etc/di.xml index 63d92c6802586531e4a972e1d6626a16582f2806..bdc328046b3deee03ea81b3d8bcfd81a7020b5f6 100644 --- a/dev/tests/unit/testsuite/Magento/Test/Tools/Di/_files/app/code/Magento/SomeModule/etc/di.xml +++ b/dev/tests/unit/testsuite/Magento/Test/Tools/Di/_files/app/code/Magento/SomeModule/etc/di.xml @@ -24,7 +24,7 @@ */ --> <config> - <preference for="Magento\Core\Model\AppInterface" type="Magento\Core\Model\App\Proxy" /> + <preference for="Magento\AppInterface" type="Magento\Core\Model\App\Proxy" /> <preference for="Magento\Core\Model\Config\InvalidatorInterface" type="Magento\Core\Model\Config\Invalidator\Proxy" /> <preference for="Magento\App\CacheInterface" type="Magento\App\Cache\Proxy" /> <virtualType name="custom_cache_instance" type="Magento\App\Cache"> diff --git a/dev/tests/unit/testsuite/Magento/Theme/Block/Adminhtml/System/Design/Theme/Tab/CssTest.php b/dev/tests/unit/testsuite/Magento/Theme/Block/Adminhtml/System/Design/Theme/Tab/CssTest.php index ce42e4a1e8418213d8dc97c4d506e90d4f6a38a6..77d29bf2345261a64f398b4f8d0ba894ae77dac0 100644 --- a/dev/tests/unit/testsuite/Magento/Theme/Block/Adminhtml/System/Design/Theme/Tab/CssTest.php +++ b/dev/tests/unit/testsuite/Magento/Theme/Block/Adminhtml/System/Design/Theme/Tab/CssTest.php @@ -102,12 +102,12 @@ class CssTest extends \PHPUnit_Framework_TestCase { $method = self::getMethod('_getAdditionalElementTypes'); - /** @var $configModel \Magento\Core\Model\Config */ - $configModel = $this->getMock('Magento\Core\Model\Config', null, array(), '', false); + /** @var $configModel \Magento\App\ConfigInterface */ + $configModel = $this->getMock('Magento\App\ConfigInterface', array(), array(), '', false); $this->_objectManager->expects($this->any()) ->method('get') - ->with('Magento\Core\Model\Config') + ->with('Magento\App\ConfigInterface') ->will($this->returnValue($configModel)); $result = $method->invokeArgs($this->_model, array()); diff --git a/dev/tests/unit/testsuite/Magento/Theme/Model/ConfigTest.php b/dev/tests/unit/testsuite/Magento/Theme/Model/ConfigTest.php index 62086b35d5233c4ca50c604880fbd67f000c8181..18b003150253b1cedfc987b32f87d894a09c356b 100644 --- a/dev/tests/unit/testsuite/Magento/Theme/Model/ConfigTest.php +++ b/dev/tests/unit/testsuite/Magento/Theme/Model/ConfigTest.php @@ -128,7 +128,7 @@ class ConfigTest extends \PHPUnit_Framework_TestCase $this->_configData->expects($this->at(1)) ->method('addFieldToFilter') - ->with('scope', \Magento\Core\Model\Config::SCOPE_STORES) + ->with('scope', \Magento\Core\Model\ScopeInterface::SCOPE_STORES) ->will($this->returnValue($this->_configData)); $this->_configData->expects($this->at(2)) @@ -171,7 +171,7 @@ class ConfigTest extends \PHPUnit_Framework_TestCase $this->_configData->expects($this->at(1)) ->method('addFieldToFilter') - ->with('scope', \Magento\Core\Model\Config::SCOPE_STORES) + ->with('scope', \Magento\Core\Model\ScopeInterface::SCOPE_STORES) ->will($this->returnValue($this->_configData)); $this->_configData->expects($this->at(2)) diff --git a/dev/tests/unit/testsuite/Magento/UrlTest.php b/dev/tests/unit/testsuite/Magento/UrlTest.php new file mode 100644 index 0000000000000000000000000000000000000000..78fefdb526cfeaa22a9b4fca4a97a682bab0b93f --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/UrlTest.php @@ -0,0 +1,89 @@ +<?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_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) + */ + +/** + * Test class for \Magento\UrlInterface + */ +namespace Magento; + +class UrlTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\UrlInterface + */ + protected $_model; + + /** + * @var \Magento\TestFramework\Helper\ObjectManager + */ + protected $_objectManager; + + protected function setUp() + { + $this->_objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); + $paramsResolverMock = $this->getMock( + 'Magento\Url\RouteParamsResolverFactory', array(), array(), '', false + ); + $paramsResolver = $this->_objectManager->getObject('\Magento\Core\Model\Url\RouteParamsResolver'); + $paramsResolverMock->expects($this->any()) + ->method('create') + ->will($this->returnValue($paramsResolver)); + $this->_model = $this->_objectManager->getObject( + '\Magento\Url', array('routeParamsResolver' => $paramsResolverMock) + ); + } + /** + * @param $port mixed + * @param $url string + * @dataProvider getCurrentUrlProvider + */ + public function testGetCurrentUrl($port, $url) + { + $methods = array('getServer', 'getScheme', 'getHttpHost', 'getModuleName', 'setModuleName', + 'getActionName', 'setActionName', 'getParam'); + $requestMock = $this->getMock('\Magento\App\RequestInterface', $methods); + $requestMock->expects($this->at(0))->method('getServer')->with('SERVER_PORT') + ->will($this->returnValue($port)); + $requestMock->expects($this->at(1))->method('getServer')->with('REQUEST_URI') + ->will($this->returnValue('/fancy_uri')); + $requestMock->expects($this->once())->method('getScheme')->will($this->returnValue('http')); + $requestMock->expects($this->once())->method('getHttpHost')->will($this->returnValue('example.com')); + + /** @var \Magento\UrlInterface $model */ + $model = $this->_objectManager->getObject('Magento\Url', array('request' => $requestMock)); + $this->assertEquals($url, $model->getCurrentUrl()); + } + + public function getCurrentUrlProvider() + { + return array( + 'without_port' => array('', 'http://example.com/fancy_uri'), + 'default_port' => array(80, 'http://example.com/fancy_uri'), + 'custom_port' => array(8080, 'http://example.com:8080/fancy_uri') + ); + } +} diff --git a/dev/tests/unit/testsuite/Magento/View/Asset/GroupedCollectionTest.php b/dev/tests/unit/testsuite/Magento/View/Asset/GroupedCollectionTest.php index d65da377ee924abab0a17d915570abd7237a9ece..e5c9765d4bd8ca684dfea7ef09fbe5a8a6b31345 100644 --- a/dev/tests/unit/testsuite/Magento/View/Asset/GroupedCollectionTest.php +++ b/dev/tests/unit/testsuite/Magento/View/Asset/GroupedCollectionTest.php @@ -112,6 +112,10 @@ class GroupedCollectionTest extends \PHPUnit_Framework_TestCase $this->_object->add('css_asset_one', $cssAsset, array('property' => 'test_value')); $this->_object->add('css_asset_two', $cssAsset, array('property' => 'test_value')); + // assets with identical properties but empty properties should be grouped together + $this->_object->add('css_asset_four', $cssAsset, array('property' => 'test_value2', 'junk1' => null)); + $this->_object->add('css_asset_five', $cssAsset, array('property' => 'test_value2', 'junk2' => '')); + // assets with different properties should go to different groups $this->_object->add('css_asset_three', $cssAsset, array('property' => 'different_value')); $this->_object->add('js_asset_one', $jsAsset, array('property' => 'test_value')); @@ -132,6 +136,10 @@ class GroupedCollectionTest extends \PHPUnit_Framework_TestCase 'properties' => array('property' => 'test_value', 'content_type' => 'css', 'can_merge' => false), 'assets' => array('css_asset_one' => $cssAsset, 'css_asset_two' => $cssAsset), ), + array( + 'properties' => array('property' => 'test_value2', 'content_type' => 'css', 'can_merge' => false), + 'assets' => array('css_asset_four' => $cssAsset, 'css_asset_five' => $cssAsset), + ), array( 'properties' => array('property' => 'different_value', 'content_type' => 'css', 'can_merge' => false), 'assets' => array('css_asset_three' => $cssAsset), diff --git a/dev/tests/unit/testsuite/Magento/View/Asset/MergeStrategy/ChecksumTest.php b/dev/tests/unit/testsuite/Magento/View/Asset/MergeStrategy/ChecksumTest.php index 5d7a3c875681d1e62c25785900683eb2fd0f1565..50e59637598819a08482a4c7ab843d026656bb46 100644 --- a/dev/tests/unit/testsuite/Magento/View/Asset/MergeStrategy/ChecksumTest.php +++ b/dev/tests/unit/testsuite/Magento/View/Asset/MergeStrategy/ChecksumTest.php @@ -46,11 +46,21 @@ class ChecksumTest extends \PHPUnit_Framework_TestCase */ protected $_strategy; + /** + * @var string + */ + protected $_mergedFileAbs = 'absolutePath/destination_file.js'; + /** * @var string */ protected $_mergedFile = 'destination_file.js'; + /** + * @var string + */ + protected $_mergedMetaFileAbs = 'absolutePath/destination_file.js.dat'; + /** * @var string */ @@ -59,7 +69,7 @@ class ChecksumTest extends \PHPUnit_Framework_TestCase /** * @var array */ - protected $_filesArray = array('file1.js', 'file2.js'); + protected $_filesArray = array('absolutePath/file1.js', 'absolutePath/file2.js'); protected function setUp() { @@ -78,7 +88,14 @@ class ChecksumTest extends \PHPUnit_Framework_TestCase )); $this->_directory->expects($this->any()) ->method('getRelativePath') - ->will($this->returnArgument(0)); + ->will( + $this->returnCallback( + function ($path) { + $parts = explode('/', $path); + return end($parts); + } + ) + ); $this->_strategy = $this->getMock('Magento\View\Asset\MergeStrategyInterface'); @@ -110,7 +127,7 @@ class ChecksumTest extends \PHPUnit_Framework_TestCase ->expects($this->never()) ->method('mergeFiles'); - $this->_object->mergeFiles($this->_filesArray, $this->_mergedFile, 'contentType'); + $this->_object->mergeFiles($this->_filesArray, $this->_mergedFileAbs, 'contentType'); } /** @@ -130,14 +147,14 @@ class ChecksumTest extends \PHPUnit_Framework_TestCase $this->_strategy ->expects($this->once()) ->method('mergeFiles') - ->with($this->_filesArray, $this->_mergedFile, 'contentType'); + ->with($this->_filesArray, $this->_mergedFileAbs, 'contentType'); $this->_directory ->expects($this->once()) ->method('writeFile') ->with($this->_mergedMetaFile, '123456'); - $this->_object->mergeFiles($this->_filesArray, $this->_mergedFile, 'contentType'); + $this->_object->mergeFiles($this->_filesArray, $this->_mergedFileAbs, 'contentType'); } /** diff --git a/dev/tests/unit/testsuite/Magento/View/Asset/MergeStrategy/FileExistsTest.php b/dev/tests/unit/testsuite/Magento/View/Asset/MergeStrategy/FileExistsTest.php index aa493c862fd2c28f863fb8e2cdaafb87ee4a0c02..f86c306fc69bb3886419993de22312d9975792a6 100644 --- a/dev/tests/unit/testsuite/Magento/View/Asset/MergeStrategy/FileExistsTest.php +++ b/dev/tests/unit/testsuite/Magento/View/Asset/MergeStrategy/FileExistsTest.php @@ -46,6 +46,11 @@ class FileExistsTest extends \PHPUnit_Framework_TestCase */ protected $_strategy; + /** + * @var string + */ + protected $_mergedFileAbs = 'absolutePath/destination_file.js'; + /** * @var string */ @@ -71,6 +76,17 @@ class FileExistsTest extends \PHPUnit_Framework_TestCase ->will($this->returnValue($this->_directory)); $this->_strategy = $this->getMock('Magento\View\Asset\MergeStrategyInterface'); + $this->_directory->expects($this->any()) + ->method('getRelativePath') + ->will( + $this->returnCallback( + function ($path) { + $parts = explode('/', $path); + return end($parts); + } + ) + ); + $this->_object = new \Magento\View\Asset\MergeStrategy\FileExists( $this->_strategy, $this->_filesystem @@ -85,9 +101,10 @@ class FileExistsTest extends \PHPUnit_Framework_TestCase $this->_directory->expects($this->once()) ->method('isExist') + ->with($this->equalTo($this->_mergedFile)) ->will($this->returnValue(true)); - $this->_object->mergeFiles($this->_filesArray, $this->_mergedFile, 'contentType'); + $this->_object->mergeFiles($this->_filesArray, $this->_mergedFileAbs, 'contentType'); } public function testMergeFilesFileDoesNotExist() @@ -95,12 +112,13 @@ class FileExistsTest extends \PHPUnit_Framework_TestCase $this->_strategy ->expects($this->once()) ->method('mergeFiles') - ->with($this->_filesArray, $this->_mergedFile, 'contentType'); + ->with($this->_filesArray, $this->_mergedFileAbs, 'contentType'); $this->_directory->expects($this->once()) ->method('isExist') + ->with($this->equalTo($this->_mergedFile)) ->will($this->returnValue(false)); - $this->_object->mergeFiles($this->_filesArray, $this->_mergedFile, 'contentType'); + $this->_object->mergeFiles($this->_filesArray, $this->_mergedFileAbs, 'contentType'); } } diff --git a/dev/tests/unit/testsuite/Magento/View/Layout/File/FileList/CollatorTest.php b/dev/tests/unit/testsuite/Magento/View/Layout/File/FileList/CollatorTest.php new file mode 100644 index 0000000000000000000000000000000000000000..ab876f0c646c89bfaaf1909ae5c93c80762af935 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/View/Layout/File/FileList/CollatorTest.php @@ -0,0 +1,125 @@ +<?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\View\Layout\File\FileList; + +class CollatorTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var Collator + */ + protected $_model; + + /** + * @var \Magento\View\Layout\File[] + */ + protected $_originFiles; + + /** + * @var \Magento\View\Layout\File + */ + protected $_baseFile; + + /** + * @var \Magento\View\Layout\File + */ + protected $_themeFile; + + protected function setUp() + { + $this->_baseFile = $this->_createLayoutFile('fixture.xml', 'Fixture_TestModule'); + $this->_themeFile = $this->_createLayoutFile('fixture.xml', 'Fixture_TestModule', 'area/theme/path'); + $this->_originFiles = array( + $this->_baseFile->getFileIdentifier() => $this->_baseFile, + $this->_themeFile->getFileIdentifier() => $this->_themeFile + ); + $this->_model = new Collator(); + } + + /** + * Return newly created theme layout file with a mocked theme + * + * @param string $filename + * @param string $module + * @param string|null $themeFullPath + * @return \PHPUnit_Framework_MockObject_MockObject|\Magento\View\Layout\File + */ + protected function _createLayoutFile($filename, $module, $themeFullPath = null) + { + $theme = null; + if ($themeFullPath !== null) { + $theme = $this->getMockForAbstractClass('Magento\View\Design\ThemeInterface'); + $theme->expects($this->any())->method('getFullPath')->will($this->returnValue($themeFullPath)); + } + return new \Magento\View\Layout\File($filename, $module, $theme); + } + + public function testCollateBaseFile() + { + $file = $this->_createLayoutFile('test/fixture.xml', 'Fixture_TestModule'); + $this->assertSame( + array($file->getFileIdentifier() => $file, $this->_themeFile->getFileIdentifier() => $this->_themeFile), + $this->_model->collate(array($file), $this->_originFiles) + ); + } + + public function testReplaceThemeFile() + { + $file = $this->_createLayoutFile('test/fixture.xml', 'Fixture_TestModule', 'area/theme/path'); + $this->assertSame( + array($this->_baseFile->getFileIdentifier() => $this->_baseFile, $file->getFileIdentifier() => $file), + $this->_model->collate(array($file), $this->_originFiles) + ); + } + + /** + * @expectedException \LogicException + * @expectedExceptionMessage Overriding layout file 'new.xml' does not match to any of the files + */ + public function testReplaceBaseFileException() + { + $file = $this->_createLayoutFile('new.xml', 'Fixture_TestModule'); + $this->_model->collate(array($file), $this->_originFiles); + } + + /** + * @expectedException \LogicException + * @expectedExceptionMessage Overriding layout file 'test/fixture.xml' does not match to any of the files + */ + public function testReplaceBaseFileEmptyThemePathException() + { + $file = $this->_createLayoutFile('test/fixture.xml', 'Fixture_TestModule', ''); + $this->_model->collate(array($file), $this->_originFiles); + } + + /** + * @expectedException \LogicException + * @expectedExceptionMessage Overriding layout file 'new.xml' does not match to any of the files + */ + public function testReplaceThemeFileException() + { + $file = $this->_createLayoutFile('new.xml', 'Fixture_TestModule', 'area/theme/path'); + $this->_model->collate(array($file), $this->_originFiles); + } +} diff --git a/dev/tests/unit/testsuite/Magento/View/Layout/File/FileList/FactoryTest.php b/dev/tests/unit/testsuite/Magento/View/Layout/File/FileList/FactoryTest.php index ca78fb13c2619ea66fe1daaa6d92886c95a753f5..c6042c0391e45a6e7dbfb5bce4151bbfaa23b47b 100644 --- a/dev/tests/unit/testsuite/Magento/View/Layout/File/FileList/FactoryTest.php +++ b/dev/tests/unit/testsuite/Magento/View/Layout/File/FileList/FactoryTest.php @@ -44,7 +44,9 @@ class FactoryTest extends \PHPUnit_Framework_TestCase public function testCreate() { - $list = new \Magento\View\Layout\File\FileList(); + $helperObjectManager = new \Magento\TestFramework\Helper\ObjectManager($this); + $list = $helperObjectManager->getObject('Magento\View\Layout\File\FileList'); + $this->_objectManager ->expects($this->once()) ->method('create') diff --git a/dev/tests/unit/testsuite/Magento/View/Layout/File/FileListTest.php b/dev/tests/unit/testsuite/Magento/View/Layout/File/FileListTest.php index 93bea0df70245d634d35dbc56363f05bd8cee46c..251a48545c167e123463aa1a150fdbbeeb10142e 100644 --- a/dev/tests/unit/testsuite/Magento/View/Layout/File/FileListTest.php +++ b/dev/tests/unit/testsuite/Magento/View/Layout/File/FileListTest.php @@ -41,11 +41,17 @@ class FileListTest extends \PHPUnit_Framework_TestCase */ private $_themeFile; + /** + * @var \Magento\View\Layout\File\FileList\Collator|\PHPUnit_Framework_MockObject_MockObject + */ + protected $collator; + protected function setUp() { $this->_baseFile = $this->_createLayoutFile('fixture.xml', 'Fixture_TestModule'); $this->_themeFile = $this->_createLayoutFile('fixture.xml', 'Fixture_TestModule', 'area/theme/path'); - $this->_model = new \Magento\View\Layout\File\FileList(); + $this->collator = $this->getMock('Magento\View\Layout\File\FileList\Collator', array('collate')); + $this->_model = new \Magento\View\Layout\File\FileList($this->collator); $this->_model->add(array($this->_baseFile, $this->_themeFile)); } @@ -106,47 +112,21 @@ class FileListTest extends \PHPUnit_Framework_TestCase $this->_model->add(array($file)); } - public function testReplaceBaseFile() - { - $file = $this->_createLayoutFile('test/fixture.xml', 'Fixture_TestModule'); - $this->_model->replace(array($file)); - $this->assertSame(array($file, $this->_themeFile), $this->_model->getAll()); - } - - public function testReplaceThemeFile() - { - $file = $this->_createLayoutFile('test/fixture.xml', 'Fixture_TestModule', 'area/theme/path'); - $this->_model->replace(array($file)); - $this->assertSame(array($this->_baseFile, $file), $this->_model->getAll()); - } - - /** - * @expectedException \LogicException - * @expectedExceptionMessage Overriding layout file 'new.xml' does not match to any of the files - */ - public function testReplaceBaseFileException() - { - $file = $this->_createLayoutFile('new.xml', 'Fixture_TestModule'); - $this->_model->replace(array($file)); - } - - /** - * @expectedException \LogicException - * @expectedExceptionMessage Overriding layout file 'test/fixture.xml' does not match to any of the files - */ - public function testReplaceBaseFileEmptyThemePathException() - { - $file = $this->_createLayoutFile('test/fixture.xml', 'Fixture_TestModule', ''); - $this->_model->replace(array($file)); - } - - /** - * @expectedException \LogicException - * @expectedExceptionMessage Overriding layout file 'new.xml' does not match to any of the files - */ - public function testReplaceThemeFileException() + public function testReplace() { - $file = $this->_createLayoutFile('new.xml', 'Fixture_TestModule', 'area/theme/path'); - $this->_model->replace(array($file)); + $files = array('1'); + $result = array('3'); + $this->collator + ->expects($this->once()) + ->method('collate') + ->with( + $this->equalTo($files), + $this->equalTo(array( + $this->_baseFile->getFileIdentifier() => $this->_baseFile, + $this->_themeFile->getFileIdentifier() => $this->_themeFile) + )) + ->will($this->returnValue($result)); + $this->assertNull($this->_model->replace($files)); + $this->assertSame($result, $this->_model->getAll()); } } diff --git a/dev/tests/unit/testsuite/Magento/View/Layout/File/Source/AggregateTest.php b/dev/tests/unit/testsuite/Magento/View/Layout/File/Source/AggregateTest.php index b5fbdf41cc4461248c8a379b546738bb28096ccc..a5689d435d9a0f736cc705733570cf1e089302ca 100644 --- a/dev/tests/unit/testsuite/Magento/View/Layout/File/Source/AggregateTest.php +++ b/dev/tests/unit/testsuite/Magento/View/Layout/File/Source/AggregateTest.php @@ -79,7 +79,9 @@ class AggregateTest extends \PHPUnit_Framework_TestCase { $parentTheme = $this->getMockForAbstractClass('Magento\View\Design\ThemeInterface'); $theme = $this->getMockForAbstractClass('Magento\View\Design\ThemeInterface'); - $theme->expects($this->once())->method('getParentTheme')->will($this->returnValue($parentTheme)); + $theme->expects($this->once())->method('getInheritedThemes')->will( + $this->returnValue(array($parentTheme, $parentTheme)) + ); $files = array( new \Magento\View\Layout\File('0.xml', 'Module_One'), diff --git a/dev/tests/unit/testsuite/Magento/View/Layout/FileTest.php b/dev/tests/unit/testsuite/Magento/View/Layout/FileTest.php index 568db9de5d191edef08df3f43cc752f7c5e237d6..a24fe8f3ebad2e1bd7cf9db1ab7dbef85faad424 100644 --- a/dev/tests/unit/testsuite/Magento/View/Layout/FileTest.php +++ b/dev/tests/unit/testsuite/Magento/View/Layout/FileTest.php @@ -61,4 +61,13 @@ class FileTest extends \PHPUnit_Framework_TestCase { $this->assertSame($this->_theme, $this->_model->getTheme()); } + + public function testGetFileIdentifier() + { + $this->_theme->expects($this->once())->method('getFullPath')->will($this->returnValue('theme_name')); + $this->assertSame( + 'theme:theme_name|module:Fixture_TestModule|file:FileTest.php', + $this->_model->getFileIdentifier() + ); + } } diff --git a/dev/tests/unit/testsuite/Magento/Webapi/Controller/RestTest.php b/dev/tests/unit/testsuite/Magento/Webapi/Controller/RestTest.php index 23d35541a7de54ed0609fa6249918bfdf39d308f..fb939aee8f657c8f9dee663bb2c04f221370b9f0 100644 --- a/dev/tests/unit/testsuite/Magento/Webapi/Controller/RestTest.php +++ b/dev/tests/unit/testsuite/Magento/Webapi/Controller/RestTest.php @@ -60,8 +60,8 @@ class RestTest extends \PHPUnit_Framework_TestCase /** @var \Magento\Authz\Service\AuthorizationV1Interface */ protected $_authzServiceMock; - const SERVICE_METHOD = \Magento\Webapi\Model\Rest\Config::KEY_METHOD; - const SERVICE_ID = \Magento\Webapi\Model\Rest\Config::KEY_CLASS; + const SERVICE_METHOD = 'testMethod'; + const SERVICE_ID = 'Magento\Webapi\Controller\TestService'; protected function setUp() { @@ -89,7 +89,7 @@ class RestTest extends \PHPUnit_Framework_TestCase ->disableOriginalConstructor() ->getMock(); - $this->_serviceMock = $this->getMockBuilder('stdClass') + $this->_serviceMock = $this->getMockBuilder(self::SERVICE_ID) ->setMethods(array(self::SERVICE_METHOD)) ->disableOriginalConstructor() ->getMock(); @@ -110,6 +110,12 @@ class RestTest extends \PHPUnit_Framework_TestCase ->disableOriginalConstructor() ->getMock(); + $errorProcessorMock = $this->getMock('Magento\Webapi\Controller\ErrorProcessor', [], [], '', false); + $errorProcessorMock->expects($this->any())->method('maskException')->will($this->returnArgument(0)); + + $objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); + $serializer = $objectManager->getObject('Magento\Webapi\Controller\ServiceArgsSerializer'); + /** Init SUT. */ $this->_restController = new \Magento\Webapi\Controller\Rest( $this->_requestMock, @@ -119,7 +125,9 @@ class RestTest extends \PHPUnit_Framework_TestCase $this->_appStateMock, $this->_oauthServiceMock, $this->_oauthHelperMock, - $this->_authzServiceMock + $this->_authzServiceMock, + $serializer, + $errorProcessorMock ); // Set default expectations used by all tests @@ -133,6 +141,7 @@ class RestTest extends \PHPUnit_Framework_TestCase $this->_objectManagerMock->expects($this->any())->method('get')->will($this->returnValue($this->_serviceMock)); $this->_responseMock->expects($this->any())->method('prepareResponse')->will($this->returnValue(array())); $this->_requestMock->expects($this->any())->method('getRequestData')->will($this->returnValue(array())); + $this->_serviceMock->expects($this->any())->method(self::SERVICE_METHOD)->will($this->returnValue(null)); parent::setUp(); } @@ -227,29 +236,6 @@ class RestTest extends \PHPUnit_Framework_TestCase $this->assertEquals(\Magento\Webapi\Exception::HTTP_BAD_REQUEST, $exceptionArray[0]->getHttpCode()); } - /** - * Test incorrect format type response from service methods - */ - public function testInvalidReturnTypeFromService() - { - $this->_appStateMock->expects($this->any())->method('isInstalled')->will($this->returnValue(true)); - $this->_serviceMock->expects($this->any())->method(self::SERVICE_METHOD)->will($this->returnValue("invalid")); - $this->_routeMock->expects($this->any())->method('isSecure')->will($this->returnValue(false)); - $this->_requestMock->expects($this->any())->method('isSecure')->will($this->returnValue(false)); - $this->_authzServiceMock->expects($this->once())->method('isAllowed')->will($this->returnValue(true)); - - // Override default prepareResponse. It should never be called in this case - $this->_responseMock->expects($this->never())->method('prepareResponse'); - - $expectedMsg = 'The method "' . self::SERVICE_METHOD . '" of service "' - . self::SERVICE_ID . '" must return an array.'; - - $this->_restController->dispatch($this->_requestMock); - $this->assertTrue($this->_responseMock->isException()); - $exceptionArray = $this->_responseMock->getException(); - $this->assertEquals($expectedMsg, $exceptionArray[0]->getMessage()); - } - public function testAuthorizationFailed() { $this->_appStateMock->expects($this->any())->method('isInstalled')->will($this->returnValue(true)); @@ -263,3 +249,11 @@ class RestTest extends \PHPUnit_Framework_TestCase $this->assertEquals($expectedMsg, $exceptionArray[0]->getMessage()); } } + +class TestService +{ + public function testMethod() + { + return null; + } +} diff --git a/dev/tests/unit/testsuite/Magento/Webapi/Controller/Soap/HandlerTest.php b/dev/tests/unit/testsuite/Magento/Webapi/Controller/Soap/Request/HandlerTest.php similarity index 70% rename from dev/tests/unit/testsuite/Magento/Webapi/Controller/Soap/HandlerTest.php rename to dev/tests/unit/testsuite/Magento/Webapi/Controller/Soap/Request/HandlerTest.php index 2f83a4fd6ee0d2e70ebf5eaa7758e4d1e5a69cfa..492134ce8a1f2fc65d5435ba006c5b344acb999d 100644 --- a/dev/tests/unit/testsuite/Magento/Webapi/Controller/Soap/HandlerTest.php +++ b/dev/tests/unit/testsuite/Magento/Webapi/Controller/Soap/Request/HandlerTest.php @@ -22,14 +22,14 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Webapi\Controller\Soap; +namespace Magento\Webapi\Controller\Soap\Request; /** - * Test for \Magento\Webapi\Controller\Soap\Handler. + * Test for \Magento\Webapi\Controller\Soap\Request\Handler. */ class HandlerTest extends \PHPUnit_Framework_TestCase { - /** @var \Magento\Webapi\Controller\Soap\Handler */ + /** @var \Magento\Webapi\Controller\Soap\Request\Handler */ protected $_handler; /** @var \Magento\ObjectManager */ @@ -44,6 +44,12 @@ class HandlerTest extends \PHPUnit_Framework_TestCase /** @var \PHPUnit_Framework_MockObject_MockObject */ protected $_authzServiceMock; + /** @var \Magento\Webapi\Helper\Data|\PHPUnit_Framework_MockObject_MockObject */ + protected $_helperMock; + + /** @var \Magento\Webapi\Helper\Data|\PHPUnit_Framework_MockObject_MockObject */ + protected $_serializerMock; + /** @var array */ protected $_arguments; @@ -51,45 +57,24 @@ class HandlerTest extends \PHPUnit_Framework_TestCase { /** Prepare mocks for SUT constructor. */ $this->_apiConfigMock = $this->getMockBuilder('Magento\Webapi\Model\Soap\Config') - ->setMethods( - array('getServiceMethodInfo') - )->disableOriginalConstructor() - ->getMock(); - - $this->_requestMock = $this->getMockBuilder('Magento\Webapi\Controller\Soap\Request') - ->setMethods(array('getRequestedServices')) - ->disableOriginalConstructor() - ->getMock(); - - $this->_objectManagerMock = $this->getMockBuilder('Magento\ObjectManager') - ->disableOriginalConstructor() - ->getMock(); - - $this->_authzServiceMock = $this->getMockBuilder('Magento\Authz\Service\AuthorizationV1Interface') - ->disableOriginalConstructor() - ->getMock(); - + ->setMethods(array('getServiceMethodInfo'))->disableOriginalConstructor()->getMock(); + $this->_requestMock = $this->getMock('Magento\Webapi\Controller\Soap\Request', [], [], '', false); + $this->_objectManagerMock = $this->getMock('Magento\ObjectManager', [], [], '', false); + $this->_authzServiceMock = $this->getMock('Magento\Authz\Service\AuthorizationV1Interface', [], [], '', false); + $this->_helperMock = $this->getMock('Magento\Webapi\Helper\Data', [], [], '', false); + $this->_serializerMock = $this->getMock('Magento\Webapi\Controller\ServiceArgsSerializer', [], [], '', false); /** Initialize SUT. */ - $this->_handler = new \Magento\Webapi\Controller\Soap\Handler( + $this->_handler = new \Magento\Webapi\Controller\Soap\Request\Handler( $this->_requestMock, $this->_objectManagerMock, $this->_apiConfigMock, - $this->_authzServiceMock + $this->_authzServiceMock, + $this->_helperMock, + $this->_serializerMock ); - parent::setUp(); } - protected function tearDown() - { - unset($this->_handler); - unset($this->_objectManagerMock); - unset($this->_apiConfigMock); - unset($this->_requestMock); - unset($this->_authzServiceMock); - parent::tearDown(); - } - public function testCall() { $requestedServices = array('requestedServices'); @@ -121,14 +106,15 @@ class HandlerTest extends \PHPUnit_Framework_TestCase ->setMethods(array($methodName)) ->getMock(); - $expectedResult = array('foo' => 'bar'); - $serviceMock->expects($this->once())->method($methodName)->will($this->returnValue($expectedResult)); + $serviceResponse = array('foo' => 'bar'); + $serviceMock->expects($this->once())->method($methodName)->will($this->returnValue($serviceResponse)); $this->_objectManagerMock->expects($this->once())->method('get')->with($className) ->will($this->returnValue($serviceMock)); + $this->_serializerMock->expects($this->once())->method('getInputData')->will($this->returnArgument(2)); /** Execute SUT. */ $this->assertEquals( - $expectedResult, + array('result' => $serviceResponse), $this->_handler->__call($operationName, array((object)array('field' => 1))) ); } diff --git a/dev/tests/unit/testsuite/Magento/Webapi/Controller/SoapTest.php b/dev/tests/unit/testsuite/Magento/Webapi/Controller/SoapTest.php index 84d648e4fb1e78634f779a0f8b2ef44de1329159..a158c286ae47cb6d06760b7e44eb7bb67df69ca3 100644 --- a/dev/tests/unit/testsuite/Magento/Webapi/Controller/SoapTest.php +++ b/dev/tests/unit/testsuite/Magento/Webapi/Controller/SoapTest.php @@ -198,18 +198,15 @@ EXPECTED_MESSAGE; $this->_appStateMock->expects($this->any()) ->method('isInstalled') ->will($this->returnValue(true)); - $soapResponse = 'Some some response'; - $this->_soapServerMock->expects($this->any()) - ->method('handle') - ->will($this->returnValue($soapResponse)); + $this->_soapServerMock->expects($this->once()) + ->method('handle'); $_SERVER['HTTP_AUTHORIZATION'] = 'OAuth access_token'; $this->_oauthServiceMock->expects($this->once()) ->method('validateAccessToken') ->will($this->returnValue(true)); - - $this->_soapController->dispatch($this->_requestMock); + $response = $this->_soapController->dispatch($this->_requestMock); + $this->assertEquals(200, $response->getHttpResponseCode()); unset($_SERVER['HTTP_AUTHORIZATION']); - $this->assertEquals($soapResponse, $this->_responseMock->getBody()); } /** diff --git a/dev/tests/unit/testsuite/Magento/Webapi/Helper/DataTest.php b/dev/tests/unit/testsuite/Magento/Webapi/Helper/DataTest.php new file mode 100644 index 0000000000000000000000000000000000000000..32199a346cd59daf49d68997d75b293203bcc551 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Webapi/Helper/DataTest.php @@ -0,0 +1,111 @@ +<?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\Webapi\Helper; + +/** + * Class implements tests for \Magento\Webapi\Helper\Data class. + */ +class DataTest extends \PHPUnit_Framework_TestCase +{ + /** @var \Magento\Webapi\Helper\Data */ + protected $_helper; + + /** + * Set up helper. + */ + protected function setUp() + { + $objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); + $this->_helper = $objectManager->getObject('Magento\Webapi\Helper\Data'); + parent::setUp(); + } + + /** + * Test identifying service name parts including subservices using class name. + * + * @dataProvider serviceNamePartsDataProvider + */ + public function testGetServiceNameParts($className, $preserveVersion, $expected) + { + $actual = $this->_helper->getServiceNameParts( + $className, + $preserveVersion + ); + $this->assertEquals($expected, $actual); + } + + /** + * Dataprovider for serviceNameParts + * + * @return array + */ + public function serviceNamePartsDataProvider() + { + return array( + array('Magento\Customer\Service\V1\Customer\AddressInterface', false, array('Customer', 'Address')), + array( + 'Vendor\Customer\Service\V1\Customer\AddressInterface', + true, + array('VendorCustomer', 'Address', 'V1') + ), + array('Magento\Catalog\Service\V2\ProductInterface', true, array('CatalogProduct', 'V2')) + ); + } + + /** + * @expectedException \InvalidArgumentException + * @dataProvider dataProviderForTestGetServiceNamePartsInvalidName + */ + public function testGetServiceNamePartsInvalidName($interfaceClassName) + { + $this->_helper->getServiceNameParts($interfaceClassName); + } + + public function dataProviderForTestGetServiceNamePartsInvalidName() + { + return array( + array('BarV1Interface'), // Missed vendor, module, 'Service' + array('Service\\V1Interface'), // Missed vendor and module + array('Magento\\Foo\\Service\\BarVxInterface'), // Version number should be a number + array('Magento\\Foo\\Service\\BarInterface'), // Version missed + array('Magento\\Foo\\Service\\BarV1'), // 'Interface' missed + array('Foo\\Service\\BarV1Interface'), // Module missed + array('Foo\\BarV1Interface'), // Module and 'Service' missed + ); + } + + public function testDtoGetterNameToFieldName() + { + $this->assertEquals('id', $this->_helper->dtoGetterNameToFieldName('getId')); + } + + public function testDtoFieldNameToSetterName() + { + $this->assertEquals('setId', $this->_helper->dtoFieldNameToSetterName('id')); + } +} + +require_once realpath(__DIR__ . '/../_files/test_interfaces.php'); + diff --git a/dev/tests/unit/testsuite/Magento/Webapi/Model/Config/ClassReflector/TypeProcessorTest.php b/dev/tests/unit/testsuite/Magento/Webapi/Model/Config/ClassReflector/TypeProcessorTest.php new file mode 100644 index 0000000000000000000000000000000000000000..a49ef795ff539e282df7a7366cb480403b725a12 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Webapi/Model/Config/ClassReflector/TypeProcessorTest.php @@ -0,0 +1,144 @@ +<?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\Webapi\Model\Config\ClassReflector; + +/** + * Type processor Test + */ +class TypeProcessorTest extends \PHPUnit_Framework_TestCase +{ + /** @var \Magento\Webapi\Model\Config\ClassReflector\TypeProcessor */ + protected $_typeProcessor; + + /** @var \Magento\Webapi\Helper\Data|\PHPUnit_Framework_MockObject_MockObject */ + protected $_helperMock; + + /** + * Set up helper. + */ + protected function setUp() + { + $this->_helperMock = $this->getMock('Magento\Webapi\Helper\Data', [], [], '', false); + $this->_typeProcessor = new \Magento\Webapi\Model\Config\ClassReflector\TypeProcessor($this->_helperMock); + } + + /** + * Test Retrieving of processed types data. + */ + public function testGetTypesData() + { + $this->_typeProcessor->setTypeData('typeA', ['dataA']); + $this->_typeProcessor->setTypeData('typeB', ['dataB']); + $this->assertEquals(['typeA' => ['dataA'], 'typeB' => ['dataB']], $this->_typeProcessor->getTypesData()); + } + + /** + * @expectedException \InvalidArgumentException + * @expectedExceptionMessage Data type "NonExistentType" is not declared. + */ + public function testGetTypeDataInvalidArgumentException() + { + $this->_typeProcessor->getTypeData('NonExistentType'); + } + + /** + * Test retrieval of data type details for the given type name. + */ + public function testGetTypeData() + { + $this->_typeProcessor->setTypeData('typeA', ['dataA']); + $this->assertEquals(['dataA'], $this->_typeProcessor->getTypeData('typeA')); + } + + /** + * Test data type details for the same type name set multiple times. + */ + public function testSetTypeDataArrayMerge() + { + $this->_typeProcessor->setTypeData('typeA', ['dataA1']); + $this->_typeProcessor->setTypeData('typeA', ['dataA2']); + $this->_typeProcessor->setTypeData('typeA', ['dataA3']); + $this->assertEquals(['dataA1', 'dataA2', 'dataA3'], $this->_typeProcessor->getTypeData('typeA')); + } + + public function testNormalizeType() + { + $this->assertEquals('blah', $this->_typeProcessor->normalizeType('blah')); + $this->assertEquals('string', $this->_typeProcessor->normalizeType('str')); + //$this->assertEquals('integer', $this->_typeProcessor->normalizeType('int')); + $this->assertEquals('boolean', $this->_typeProcessor->normalizeType('bool')); + } + + public function testIsTypeSimple() + { + $this->assertTrue($this->_typeProcessor->isTypeSimple('string')); + $this->assertTrue($this->_typeProcessor->isTypeSimple('string[]')); + $this->assertTrue($this->_typeProcessor->isTypeSimple('int')); + $this->assertTrue($this->_typeProcessor->isTypeSimple('float')); + $this->assertTrue($this->_typeProcessor->isTypeSimple('double')); + $this->assertTrue($this->_typeProcessor->isTypeSimple('boolean')); + $this->assertFalse($this->_typeProcessor->isTypeSimple('blah')); + } + + public function testIsArrayType() + { + $this->assertFalse($this->_typeProcessor->isArrayType('string')); + $this->assertTrue($this->_typeProcessor->isArrayType('string[]')); + } + + public function getArrayItemType() + { + $this->assertEquals('string', $this->_typeProcessor->getArrayItemType('str[]')); + $this->assertEquals('string', $this->_typeProcessor->getArrayItemType('string[]')); + $this->assertEquals('integer', $this->_typeProcessor->getArrayItemType('int[]')); + $this->assertEquals('boolean', $this->_typeProcessor->getArrayItemType('bool[]')); + } + + public function testTranslateTypeName() + { + $this->assertEquals( + 'TestModule1V1EntityItem', + $this->_typeProcessor->translateTypeName('\Magento\TestModule1\Service\V1\Entity\Item') + ); + $this->assertEquals( + 'TestModule3V1EntityParameter[]', + $this->_typeProcessor->translateTypeName('\Magento\TestModule3\Service\V1\Entity\Parameter[]') + ); + } + + /** + * @expectedException \InvalidArgumentException + * @expectedExceptionMessage Invalid parameter type "\Magento\TestModule3\V1\Parameter[]". + */ + public function testTranslateTypeNameInvalidArgumentException() + { + $this->_typeProcessor->translateTypeName('\Magento\TestModule3\V1\Parameter[]'); + } + + public function testTranslateArrayTypeName() + { + $this->assertEquals('ArrayOfComplexType', $this->_typeProcessor->translateArrayTypeName('complexType')); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Webapi/Model/Config/ClassReflectorTest.php b/dev/tests/unit/testsuite/Magento/Webapi/Model/Config/ClassReflectorTest.php new file mode 100644 index 0000000000000000000000000000000000000000..243180db8cd522861f3c2823de5b5737a90fe9c7 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Webapi/Model/Config/ClassReflectorTest.php @@ -0,0 +1,119 @@ +<?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\Webapi\Model\Config; + +/** + * Test for class reflector. + */ +class ClassReflectorTest extends \PHPUnit_Framework_TestCase +{ + /** @var \Magento\Webapi\Model\Config\ClassReflector\TypeProcessor|\PHPUnit_Framework_MockObject_MockObject */ + protected $_typeProcessor; + + /** @var \Magento\Webapi\Model\Config\ClassReflector */ + protected $_classReflector; + + /** + * Set up helper. + */ + protected function setUp() + { + $this->_typeProcessor = $this->getMock( + '\Magento\Webapi\Model\Config\ClassReflector\TypeProcessor', + ['process'], + [], + '', + false + ); + $this->_typeProcessor->expects($this->any())->method('process')->will( + $this->returnValueMap( + array( + array('string', 'str'), + array('int', 'int') + ) + ) + ); + $this->_classReflector = new \Magento\Webapi\Model\Config\ClassReflector($this->_typeProcessor); + } + + public function testReflectClassMethods() + { + $data = $this->_classReflector->reflectClassMethods( + '\\Magento\\Webapi\\Model\\Config\\TestServiceForClassReflector', + ['generateRandomString' => ['method' => 'generateRandomString']] + ); + $this->assertEquals(['generateRandomString' => $this->_getSampleReflectionData()], $data); + } + + public function testExtractMethodData() + { + $classReflection = new \Zend\Server\Reflection\ReflectionClass + (new \ReflectionClass('\\Magento\\Webapi\\Model\\Config\\TestServiceForClassReflector')); + /** @var $methodReflection ReflectionMethod */ + $methodReflection = $classReflection->getMethods()[0]; + $methodData = $this->_classReflector->extractMethodData($methodReflection); + $expectedResponse = $this->_getSampleReflectionData(); + $this->assertEquals($expectedResponse, $methodData); + } + + /** + * Expected reflection data for TestServiceForClassReflector generateRandomString method + * + * @return array + */ + protected function _getSampleReflectionData() + { + return [ + 'documentation' => 'Basic random string generator', + 'interface' => + [ + 'in' => + [ + 'parameters' => + [ + 'length' => + [ + 'type' => 'int', + 'required' => true, + 'documentation' => 'length of the random string', + ], + ], + ], + 'out' => + [ + 'parameters' => + [ + 'result' => + [ + 'type' => 'str', + 'documentation' => 'random string', + 'required' => true, + ], + ], + ], + ], + ]; + } +} diff --git a/dev/tests/unit/testsuite/Magento/Webapi/Model/Config/TestServiceForClassReflector.php b/dev/tests/unit/testsuite/Magento/Webapi/Model/Config/TestServiceForClassReflector.php new file mode 100644 index 0000000000000000000000000000000000000000..91b4e15cb8fc2e8a25b9c01b55eaf467497a547a --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Webapi/Model/Config/TestServiceForClassReflector.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\Webapi\Model\Config; + +class TestServiceForClassReflector +{ + /** + * Basic random string generator + * + * @param int $length length of the random string + * @return string random string + */ + public function generateRandomString($length) + { + return substr(str_shuffle("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), 0, $length); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Webapi/Model/Config/XsdTest.php b/dev/tests/unit/testsuite/Magento/Webapi/Model/Config/XsdTest.php index cc4d53e31ae59e203147c27a25674ce33d067805..d20e4d41093971ab768ee358ec2295b2efe5a753 100644 --- a/dev/tests/unit/testsuite/Magento/Webapi/Model/Config/XsdTest.php +++ b/dev/tests/unit/testsuite/Magento/Webapi/Model/Config/XsdTest.php @@ -63,7 +63,7 @@ class XsdTest extends \PHPUnit_Framework_TestCase 'valid' => array( // @codingStandardsIgnoreStart '<config> - <service class="Magento\TestModule1\Service\AllSoapAndRestV1Interface" baseUrl="/V1/testmodule1"> + <service class="Magento\TestModule1\Service\V1\AllSoapAndRestInterface" baseUrl="/V1/testmodule1"> <rest-route httpMethod="GET" method="item" resources="Magento_TestModule1::resource1">/:id</rest-route> <rest-route httpMethod="POST" method="create" isSecure="1" resources="Magento_TestModule1::resource1,Magento_TestModule1::resource2"></rest-route> </service> @@ -72,14 +72,14 @@ class XsdTest extends \PHPUnit_Framework_TestCase ), 'valid with several entities' => array( '<config> - <service class="Magento\TestModule1\Service\AllSoapAndRestV1Interface" baseUrl="/V1/testmodule1"> + <service class="Magento\TestModule1\Service\V1\AllSoapAndRestInterface" baseUrl="/V1/testmodule1"> <rest-route httpMethod="GET" method="item" resources="Magento_TestModule1::resource1">/:id</rest-route> <rest-route httpMethod="GET" method="items" resources="Magento_TestModule1::resource2"></rest-route> <rest-route httpMethod="POST" method="create" resources="Magento_TestModule1::resource3"></rest-route> <rest-route httpMethod="PUT" method="update" resources="Magento_TestModule1::resource1,Magento_TestModule1::resource2">/:id</rest-route> </service> - <service class="Magento\TestModule1\Service\AllSoapAndRestV2Interface" baseUrl="/V2/testmodule1"> + <service class="Magento\TestModule1\Service\V2\AllSoapAndRestInterface" baseUrl="/V2/testmodule1"> <rest-route httpMethod="GET" method="item" resources="Magento_TestModule1::resource1">/:id</rest-route> <rest-route httpMethod="GET" method="items" resources="Magento_TestModule1::resource2"></rest-route> <rest-route httpMethod="POST" method="create" resources="Magento_TestModule1::resource3"></rest-route> @@ -87,7 +87,7 @@ class XsdTest extends \PHPUnit_Framework_TestCase <rest-route httpMethod="DELETE" method="delete" resources="Magento_TestModule1::resource1">/:id</rest-route> </service> - <service class="Magento\TestModule1\Service\AllSoapAndRestV2Interface" baseUrl="/V2/testmodule1"> + <service class="Magento\TestModule1\Service\V2\AllSoapAndRestInterface" baseUrl="/V2/testmodule1"> <rest-route httpMethod="GET" method="item" resources="Magento_TestModule1::resource1">/:id</rest-route> <rest-route httpMethod="GET" method="items" resources="Magento_TestModule1::resource2"></rest-route> <rest-route httpMethod="POST" method="create" resources="Magento_TestModule1::resource3"></rest-route> @@ -111,7 +111,7 @@ class XsdTest extends \PHPUnit_Framework_TestCase ), 'invalid rest-routes' => array( '<config> - <service class="Magento\TestModule1\Service\AllSoapAndRestV2Interface"> + <service class="Magento\TestModule1\Service\V2\AllSoapAndRestInterface"> <rest-route> <invalid></invalid> </rest-route> @@ -127,7 +127,7 @@ class XsdTest extends \PHPUnit_Framework_TestCase /** Excessive nodes */ 'irrelevant node in root' => array( '<config> - <service class="Magento\TestModule1\Service\AllSoapAndRestV2Interface"> + <service class="Magento\TestModule1\Service\V2\AllSoapAndRestInterface"> <rest-route> </rest-route> </service> @@ -137,7 +137,7 @@ class XsdTest extends \PHPUnit_Framework_TestCase ), 'irrelevant node in service' => array( '<config> - <service class="Magento\TestModule1\Service\AllSoapAndRestV2Interface"> + <service class="Magento\TestModule1\Service\V2\AllSoapAndRestInterface"> <rest-route> </rest-route> <invalid/> @@ -147,7 +147,7 @@ class XsdTest extends \PHPUnit_Framework_TestCase ), 'irrelevant node in rest-routes' => array( '<config> - <service class="Magento\TestModule1\Service\AllSoapAndRestV2Interface"> + <service class="Magento\TestModule1\Service\V2\AllSoapAndRestInterface"> <rest-route> <invalid/> </rest-route> @@ -159,7 +159,7 @@ class XsdTest extends \PHPUnit_Framework_TestCase /** Excessive attributes */ 'invalid attribute in root' => array( '<config invalid="invalid"> - <service class="Magento\TestModule1\Service\AllSoapAndRestV2Interface" baseUrl="/V2/testmodule1"> + <service class="Magento\TestModule1\Service\V2\AllSoapAndRestInterface" baseUrl="/V2/testmodule1"> <rest-route httpMethod="GET" method="item" resources="Magento_TestModule1::resource1">/:id</rest-route> </service> </config>', @@ -167,7 +167,7 @@ class XsdTest extends \PHPUnit_Framework_TestCase ), 'invalid attribute in service' => array( '<config> - <service invalid="invalid" class="Magento\TestModule1\Service\AllSoapAndRestV2Interface" baseUrl="/V2/testmodule1"> + <service invalid="invalid" class="Magento\TestModule1\Service\V2\AllSoapAndRestInterface" baseUrl="/V2/testmodule1"> <rest-route httpMethod="GET" method="item" resources="Magento_TestModule1::resource1">/:id</rest-route> </service> </config>', @@ -175,7 +175,7 @@ class XsdTest extends \PHPUnit_Framework_TestCase ), 'invalid attribute in rest-routes' => array( '<config> - <service class="Magento\TestModule1\Service\AllSoapAndRestV2Interface" baseUrl="/V2/testmodule1"> + <service class="Magento\TestModule1\Service\V2\AllSoapAndRestInterface" baseUrl="/V2/testmodule1"> <rest-route invalid="invalid" httpMethod="GET" method="item" resources="Magento_TestModule1::resource1">/:id</rest-route> </service> </config>', @@ -185,7 +185,7 @@ class XsdTest extends \PHPUnit_Framework_TestCase /** Invalid values */ 'rest-route with invalid httpMethod' => array( '<config> - <service class="Magento\TestModule1\Service\AllSoapAndRestV1Interface" baseUrl="/V1/testmodule1"> + <service class="Magento\TestModule1\Service\V1\AllSoapAndRestInterface" baseUrl="/V1/testmodule1"> <rest-route httpMethod="INVALID" method="item" resources="Magento_TestModule1::resource1">/:id</rest-route> </service> </config>', @@ -196,7 +196,7 @@ class XsdTest extends \PHPUnit_Framework_TestCase ), 'rest-route with invalid isSecure key type' => array( '<config> - <service class="Magento\TestModule1\Service\AllSoapAndRestV1Interface" baseUrl="/V1/testmodule1"> + <service class="Magento\TestModule1\Service\V1\AllSoapAndRestInterface" baseUrl="/V1/testmodule1"> <rest-route isSecure="Invalid"></rest-route> </service> </config>', @@ -206,7 +206,7 @@ class XsdTest extends \PHPUnit_Framework_TestCase ), 'rest-route with invalid resources type' => array( '<config> - <service class="Magento\TestModule1\Service\AllSoapAndRestV1Interface" baseUrl="/V1/testmodule1"> + <service class="Magento\TestModule1\Service\V1\AllSoapAndRestInterface" baseUrl="/V1/testmodule1"> <rest-route resources="Invalid"></rest-route> </service> </config>', diff --git a/dev/tests/unit/testsuite/Magento/Webapi/Model/Config/_files/webapi.php b/dev/tests/unit/testsuite/Magento/Webapi/Model/Config/_files/webapi.php index ec68b8304e9fce5c235752774002f6433b35c442..84d4a2c8038631be7de07770507ed0ed7db5dec1 100644 --- a/dev/tests/unit/testsuite/Magento/Webapi/Model/Config/_files/webapi.php +++ b/dev/tests/unit/testsuite/Magento/Webapi/Model/Config/_files/webapi.php @@ -22,8 +22,8 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ return array( - '\Magento\TestModule1\Service\AllSoapAndRestV1Interface' => array( - 'class' => '\Magento\TestModule1\Service\AllSoapAndRestV1Interface', + '\Magento\TestModule1\Service\V1\AllSoapAndRestInterface' => array( + 'class' => '\Magento\TestModule1\Service\V1\AllSoapAndRestInterface', 'baseUrl' => '/V1/testmodule1', 'methods' => array( 'item' => array( @@ -35,8 +35,8 @@ return array( ) ) ), - '\Magento\TestModule1\Service\AllSoapAndRestV2Interface' => array( - 'class' => '\Magento\TestModule1\Service\AllSoapAndRestV2Interface', + '\Magento\TestModule1\Service\V2\AllSoapAndRestInterface' => array( + 'class' => '\Magento\TestModule1\Service\V2\AllSoapAndRestInterface', 'baseUrl' => '/V2/testmodule1', 'methods' => array( 'item' => array( @@ -62,8 +62,8 @@ return array( ), ) ), - '\Magento\TestModule1\Service\AllSoapAndRestV3Interface' => array( - 'class' => '\Magento\TestModule1\Service\AllSoapAndRestV3Interface', + '\Magento\TestModule1\Service\V3\AllSoapAndRestInterface' => array( + 'class' => '\Magento\TestModule1\Service\V3\AllSoapAndRestInterface', 'methods' => array() ), ); diff --git a/dev/tests/unit/testsuite/Magento/Webapi/Model/Config/_files/webapi.xml b/dev/tests/unit/testsuite/Magento/Webapi/Model/Config/_files/webapi.xml index 72ad8f55363b537a3cc133f13eb92a8af68658d0..649e1ffedc2c3219e75256c7e142cf3874c9448f 100644 --- a/dev/tests/unit/testsuite/Magento/Webapi/Model/Config/_files/webapi.xml +++ b/dev/tests/unit/testsuite/Magento/Webapi/Model/Config/_files/webapi.xml @@ -24,16 +24,16 @@ */ --> <config> - <service class="\Magento\TestModule1\Service\AllSoapAndRestV1Interface" baseUrl="/V1/testmodule1"> + <service class="\Magento\TestModule1\Service\V1\AllSoapAndRestInterface" baseUrl="/V1/testmodule1"> <rest-route httpMethod="GET" method="item" resources="Magento_Test1::resource1">/:id</rest-route> </service> - <service class="\Magento\TestModule1\Service\AllSoapAndRestV2Interface" baseUrl="/V2/testmodule1"> + <service class="\Magento\TestModule1\Service\V2\AllSoapAndRestInterface" baseUrl="/V2/testmodule1"> <rest-route httpMethod="GET" method="item" resources="Magento_Test1::resource1, Magento_Test1::resource2">/:id</rest-route> <rest-route httpMethod="POST" method="create" resources="Magento_Test1::resource1,Magento_Test1::resource2"></rest-route> <rest-route httpMethod="DELETE" method="delete" isSecure="true" resources="Magento_Test1::resource2">/:id</rest-route> </service> <!--TODO: All service methods must have resources that's why all of them must be declared explicitly--> - <service class="\Magento\TestModule1\Service\AllSoapAndRestV3Interface"/> + <service class="\Magento\TestModule1\Service\V3\AllSoapAndRestInterface"/> </config> diff --git a/dev/tests/unit/testsuite/Magento/Webapi/Model/Soap/ConfigTest.php b/dev/tests/unit/testsuite/Magento/Webapi/Model/Soap/ConfigTest.php index 82632a7763b7e85de4d121e27c4b506254f2c372..07362790f43dcb70fbb568b5b237d52a3ece82f6 100644 --- a/dev/tests/unit/testsuite/Magento/Webapi/Model/Soap/ConfigTest.php +++ b/dev/tests/unit/testsuite/Magento/Webapi/Model/Soap/ConfigTest.php @@ -38,6 +38,9 @@ class ConfigTest extends \PHPUnit_Framework_TestCase /** @var \Magento\Webapi\Model\Config|\PHPUnit_Framework_MockObject_MockObject */ protected $_configMock; + /** @var \Magento\Webapi\Helper\Data|\PHPUnit_Framework_MockObject_MockObject */ + protected $_helperMock; + /** * Set up helper. */ @@ -47,74 +50,18 @@ class ConfigTest extends \PHPUnit_Framework_TestCase ->disableOriginalConstructor() ->getMock(); $fileSystemMock = $this->getMockBuilder('Magento\App\Filesystem')->disableOriginalConstructor()->getMock(); - $this->_configMock = $this->getMockBuilder('Magento\Webapi\Model\Config') - ->disableOriginalConstructor()->getMock(); - $this->_soapConfig = new \Magento\Webapi\Model\Soap\Config( - $objectManagerMock, - $fileSystemMock, - $this->_configMock - ); - parent::setUp(); - } - - /** - * Test identifying service name parts including subservices using class name. - * - * @dataProvider serviceNamePartsDataProvider - */ - public function testGetServiceNameParts($className, $preserveVersion, $expected) - { - $actual = $this->_soapConfig->getServiceNameParts( - $className, - $preserveVersion - ); - $this->assertEquals($expected, $actual); - } - - /** - * Dataprovider for serviceNameParts - * - * @return array - */ - public function serviceNamePartsDataProvider() - { - return array( - array('Magento\Customer\Service\Customer\AddressV1Interface', false, array('Customer', 'Address')), - array( - 'Vendor\Customer\Service\Customer\AddressV1Interface', - true, - array('VendorCustomer', 'Address', 'V1') - ), - array('Magento\Catalog\Service\ProductV2Interface', true, array('CatalogProduct', 'V2')) - ); - } - - /** - * @expectedException \InvalidArgumentException - * @dataProvider dataProviderForTestGetServiceNamePartsInvalidName - */ - public function testGetServiceNamePartsInvalidName($interfaceClassName) - { - $this->_soapConfig->getServiceNameParts($interfaceClassName); - } - - public function dataProviderForTestGetServiceNamePartsInvalidName() - { - return array( - array('BarV1Interface'), // Missed vendor, module, 'Service' - array('Service\\V1Interface'), // Missed vendor and module - array('Magento\\Foo\\Service\\BarVxInterface'), // Version number should be a number - array('Magento\\Foo\\Service\\BarInterface'), // Version missed - array('Magento\\Foo\\Service\\BarV1'), // 'Interface' missed - array('Foo\\Service\\BarV1Interface'), // Module missed - array('Foo\\BarV1Interface'), // Module and 'Service' missed + $classReflection = $this->getMock( + 'Magento\Webapi\Model\Config\ClassReflector', + ['reflectClassMethods'], + [], + '', + false ); - } - - public function testGetRequestedSoapServices() - { + $classReflection->expects($this->any())->method('reflectClassMethods')->will($this->returnValue(array())); + $this->_helperMock = $this->getMock('Magento\Webapi\Helper\Data', [], [], '', false); + $this->_configMock = $this->getMock('Magento\Webapi\Model\Config', [], [], '', false); $servicesConfig = array( - 'Magento\Module\Service\FooV1Interface' => array( + 'ModuleFooV1' => array( 'class' => 'Magento\Module\Service\FooV1Interface', 'baseUrl' => '/V1/foo', 'methods' => array( @@ -127,7 +74,7 @@ class ConfigTest extends \PHPUnit_Framework_TestCase ) ) ), - 'Magento\Module\Service\BarV1Interface' => array( + 'ModuleBarV1' => array( 'class' => 'Magento\Module\Service\BarV1Interface', 'baseUrl' => '/V1/bar', 'methods' => array( @@ -141,7 +88,29 @@ class ConfigTest extends \PHPUnit_Framework_TestCase ) ) ); + $this->_configMock->expects($this->once())->method('getServices')->will($this->returnValue($servicesConfig)); + $this->_helperMock->expects($this->any()) + ->method('getServiceName') + ->will( + $this->returnValueMap( + array( + array('Magento\Module\Service\FooV1Interface', true, 'moduleFooV1'), + array('Magento\Module\Service\BarV1Interface', true, 'moduleBarV1') + ) + ) + ); + $this->_soapConfig = new \Magento\Webapi\Model\Soap\Config( + $objectManagerMock, + $fileSystemMock, + $this->_configMock, + $classReflection, + $this->_helperMock + ); + parent::setUp(); + } + public function testGetRequestedSoapServices() + { $expectedResult = array( array( 'methods' => array( @@ -155,33 +124,31 @@ class ConfigTest extends \PHPUnit_Framework_TestCase 'class' => 'Magento\Module\Service\FooV1Interface' ) ); - - $this->_configMock->expects($this->once())->method('getServices')->will($this->returnValue($servicesConfig)); $result = $this->_soapConfig->getRequestedSoapServices(array('moduleFooV1', 'moduleBarV2', 'moduleBazV1')); $this->assertEquals($expectedResult, $result); } -} -namespace Magento\Module\Service; - -interface FooV1Interface -{ - public function someMethod(); -} - -interface BarV1Interface -{ - public function someMethod(); -} + public function testGetServiceMethodInfo() + { + $expectedResult = array( + 'class' => 'Magento\Module\Service\BarV1Interface', + 'method' => 'someMethod', + 'isSecure' => false, + 'resources' => array('Magento_TestModule1::resource2') + ); + $methodInfo = $this->_soapConfig->getServiceMethodInfo( + 'moduleBarV1SomeMethod', + array('moduleBarV1', 'moduleBazV1') + ); + $this->assertEquals($expectedResult, $methodInfo); + } -interface FooBarV1Interface -{ - public function someMethod(); + public function testGetSoapOperation() + { + $expectedResult = 'moduleFooV1SomeMethod'; + $soapOperation = $this->_soapConfig->getSoapOperation('Magento\Module\Service\FooV1Interface', 'someMethod'); + $this->assertEquals($expectedResult, $soapOperation); + } } -namespace Magento\Module\Service\Foo; - -interface BarV1Interface -{ - public function someMethod(); -} +require_once realpath(__DIR__ . '/../../_files/test_interfaces.php'); diff --git a/dev/tests/unit/testsuite/Magento/Webapi/Model/Soap/FaultTest.php b/dev/tests/unit/testsuite/Magento/Webapi/Model/Soap/FaultTest.php index 786e92a6cc15982b1f1d1416156c80524e381aa7..05ec5655e4077762e411b7c60656f3fdc13ec570 100644 --- a/dev/tests/unit/testsuite/Magento/Webapi/Model/Soap/FaultTest.php +++ b/dev/tests/unit/testsuite/Magento/Webapi/Model/Soap/FaultTest.php @@ -1,7 +1,5 @@ <?php /** - * Test SOAP fault model. - * * Magento * * NOTICE OF LICENSE @@ -23,8 +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\Webapi\Model\Soap; +use Magento\Webapi\Model\Soap\Fault; + +/** + * Test SOAP fault model. + */ class FaultTest extends \PHPUnit_Framework_TestCase { const WSDL_URL = 'http://host.com/?wsdl&services=customerV1'; @@ -91,13 +95,19 @@ class FaultTest extends \PHPUnit_Framework_TestCase <env:Text xml:lang="en">Soap fault reason.</env:Text> </env:Reason> <env:Detail> - <m:DefaultFault> + <m:GenericFault> <m:Parameters> - <m:param1>value1</m:param1> - <m:param2>2</m:param2> + <m:GenericFaultParameter> + <m:key>param1</m:key> + <m:value>value1</m:value> + </m:GenericFaultParameter> + <m:GenericFaultParameter> + <m:key>param2</m:key> + <m:value>2</m:value> + </m:GenericFaultParameter> </m:Parameters> <m:Code>111</m:Code> - </m:DefaultFault> + </m:GenericFault> </env:Detail> </env:Fault> </env:Body> @@ -155,38 +165,43 @@ XML; $expectedXmls = include __DIR__ . '/../../_files/soap_fault/soap_fault_expected_xmls.php'; return array( //Each array contains data for SOAP Fault Message, Expected XML, and Assert Message. - array( + 'ArrayDataDetails' => array( 'Fault reason', 'Sender', - array('key1' => 'value1', 'key2' => 'value2'), + array( + Fault::NODE_DETAIL_PARAMETERS => array('key1' => 'value1', 'key2' => 'value2', 'value3'), + Fault::NODE_DETAIL_CODE => 333, + Fault::NODE_DETAIL_TRACE => 'Trace', + 'Invalid' => 'This node should be skipped' + ), $expectedXmls['expectedResultArrayDataDetails'], 'SOAP fault message with associated array data details is invalid.' ), - array( + 'IndexArrayDetails' => array( 'Fault reason', 'Sender', array('value1', 'value2'), $expectedXmls['expectedResultIndexArrayDetails'], 'SOAP fault message with index array data details is invalid.' ), - array( + 'EmptyArrayDetails' => array( 'Fault reason', 'Sender', array(), $expectedXmls['expectedResultEmptyArrayDetails'], 'SOAP fault message with empty array data details is invalid.' ), - array( + 'ObjectDetails' => array( 'Fault reason', 'Sender', (object)array('key' => 'value'), $expectedXmls['expectedResultObjectDetails'], 'SOAP fault message with object data details is invalid.' ), - array( + 'ComplexDataDetails' => array( 'Fault reason', 'Sender', - array('key' => array('sub_key' => 'value')), + array(Fault::NODE_DETAIL_PARAMETERS => array('key' => array('sub_key' => 'value'))), $expectedXmls['expectedResultComplexDataDetails'], 'SOAP fault message with complex data details is invalid.' ), @@ -223,13 +238,19 @@ XML; <env:Text xml:lang="en">{$message}</env:Text> </env:Reason> <env:Detail> - <m:DefaultFault> + <m:GenericFault> <m:Parameters> - <m:param1>value1</m:param1> - <m:param2>2</m:param2> + <m:GenericFaultParameter> + <m:key>param1</m:key> + <m:value>value1</m:value> + </m:GenericFaultParameter> + <m:GenericFaultParameter> + <m:key>param2</m:key> + <m:value>2</m:value> + </m:GenericFaultParameter> </m:Parameters> <m:Code>{$code}</m:Code> - </m:DefaultFault> + </m:GenericFault> </env:Detail> </env:Fault> </env:Body> diff --git a/dev/tests/unit/testsuite/Magento/Webapi/Model/Soap/ServerTest.php b/dev/tests/unit/testsuite/Magento/Webapi/Model/Soap/ServerTest.php index 90fec0fa37d4ef27319eb2124c1854e0ee3e5b7b..b3d20236b2fae8160a357dfafb4a5b99fd253845 100644 --- a/dev/tests/unit/testsuite/Magento/Webapi/Model/Soap/ServerTest.php +++ b/dev/tests/unit/testsuite/Magento/Webapi/Model/Soap/ServerTest.php @@ -48,6 +48,9 @@ class ServerTest extends \PHPUnit_Framework_TestCase /** @var \Magento\Webapi\Model\Soap\Server\Factory */ protected $_soapServerFactory; + /** @var \Magento\Webapi\Model\Config\ClassReflector\TypeProcessor|\PHPUnit_Framework_MockObject_MockObject */ + protected $_typeProcessor; + protected function setUp() { $this->_storeManagerMock = $this->getMockBuilder('Magento\Core\Model\StoreManager') @@ -75,6 +78,14 @@ class ServerTest extends \PHPUnit_Framework_TestCase $this->_soapServerFactory = $this->getMockBuilder('Magento\Webapi\Model\Soap\Server\Factory') ->disableOriginalConstructor()->getMock(); + $this->_typeProcessor = $this->getMock( + 'Magento\Webapi\Model\Config\ClassReflector\TypeProcessor', + [], + [], + '', + false + ); + /** Init SUT. */ $this->_soapServer = new \Magento\Webapi\Model\Soap\Server( $areaListMock, @@ -82,7 +93,8 @@ class ServerTest extends \PHPUnit_Framework_TestCase $this->_requestMock, $this->_domDocumentFactory, $this->_storeManagerMock, - $this->_soapServerFactory + $this->_soapServerFactory, + $this->_typeProcessor ); parent::setUp(); diff --git a/dev/tests/unit/testsuite/Magento/Webapi/Model/Soap/Wsdl/ComplexTypeStrategyTest.php b/dev/tests/unit/testsuite/Magento/Webapi/Model/Soap/Wsdl/ComplexTypeStrategyTest.php new file mode 100644 index 0000000000000000000000000000000000000000..2dccec6dec5a37109432d2f0ac99e74dbabdfb0d --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Webapi/Model/Soap/Wsdl/ComplexTypeStrategyTest.php @@ -0,0 +1,308 @@ +<?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\Webapi\Model\Soap\Wsdl; + +use Zend\Soap\Wsdl; + +/** + * Complex type strategy tests. + */ +class ComplexTypeStrategyTest extends \PHPUnit_Framework_TestCase +{ + /** @var \Magento\Webapi\Model\Config\ClassReflector\TypeProcessor|\PHPUnit_Framework_MockObject_MockObject */ + protected $_typeProcessor; + + /** @var \Magento\Webapi\Model\Soap\Wsdl|\PHPUnit_Framework_MockObject_MockObject */ + protected $_wsdl; + + /** @var ComplexTypeStrategy */ + protected $_strategy; + + /** + * Set up strategy for test. + */ + protected function setUp() + { + $this->_typeProcessor = $this->getMockBuilder('Magento\Webapi\Model\Config\ClassReflector\TypeProcessor') + ->setMethods(array('getTypeData')) + ->disableOriginalConstructor() + ->getMock(); + $this->_wsdl = $this->getMockBuilder('Magento\Webapi\Model\Soap\Wsdl') + ->setMethods(array('toDomDocument', 'getTypes', 'getSchema')) + ->disableOriginalConstructor() + ->getMock(); + $this->_strategy = new ComplexTypeStrategy($this->_typeProcessor); + $this->_strategy->setContext($this->_wsdl); + parent::setUp(); + } + + /** + * Clean up. + */ + protected function tearDown() + { + unset($this->_typeProcessor); + unset($this->_strategy); + unset($this->_wsdl); + + parent::tearDown(); + } + + /** + * Test that addComplexType returns type WSDL name + * if it has already been processed (registered at includedTypes in WSDL) + */ + public function testCheckTypeName() + { + $testType = 'testComplexTypeName'; + $testTypeWsdlName = 'tns:' . $testType; + $includedTypes = array( + $testType => $testTypeWsdlName, + ); + $this->_wsdl->expects($this->exactly(2)) + ->method('getTypes') + ->will($this->returnValue($includedTypes)); + + $this->assertEquals($testTypeWsdlName, $this->_strategy->addComplexType($testType)); + } + + /** + * Test adding complex type with simple parameters. + * + * @param string $type + * @param array $data + * @dataProvider addComplexTypeDataProvider + */ + public function testAddComplexTypeSimpleParameters($type, $data) + { + $this->_wsdl->expects($this->any()) + ->method('getTypes') + ->will($this->returnValue(array())); + + $this->_wsdl->expects($this->any()) + ->method('toDomDocument') + ->will($this->returnValue(new \DOMDocument())); + + $schemaMock = $this->_getDomElementMock(); + $schemaMock->expects($this->any()) + ->method('appendChild'); + $this->_wsdl->expects($this->any()) + ->method('getSchema') + ->will($this->returnValue($schemaMock)); + + $this->_typeProcessor->expects($this->at(0)) + ->method('getTypeData') + ->with($type) + ->will($this->returnValue($data)); + + $this->assertEquals(Wsdl::TYPES_NS . ':' . $type, $this->_strategy->addComplexType($type)); + } + + /** + * Data provider for testAddComplexTypeSimpleParameters(). + * + * @return array + */ + public static function addComplexTypeDataProvider() + { + return array( + 'simple parameters' => array( + 'VendorModuleADataStructure', + array( + 'documentation' => 'test', + 'parameters' => array( + 'string_param' => array( + 'type' => 'string', + 'required' => true, + 'documentation' => 'Required string param.' + ), + 'int_param' => array( + 'type' => 'int', + 'required' => true, + 'documentation' => 'Required int param.' + ), + 'bool_param' => array( + 'type' => 'boolean', + 'required' => false, + 'documentation' => 'Optional complex type param.{annotation:test}' + ), + ), + ), + ), + 'type with call info' => array( + 'VendorModuleADataStructure', + array( + 'documentation' => 'test', + 'parameters' => array( + 'string_param' => array( + 'type' => 'string', + 'required' => false, + 'documentation' => '{callInfo:VendorModuleACreate:requiredInput:conditionally}', + ), + ), + 'callInfo' => array( + 'requiredInput' => array( + 'yes' => array( + 'calls' => array('VendorModuleACreate') + ) + ), + 'returned' => array( + 'always' => array( + 'calls' => array('VendorModuleAGet') + ) + ) + ), + ), + ), + 'parameter with call info' => array( + 'VendorModuleADataStructure', + array( + 'documentation' => 'test', + 'parameters' => array( + 'string_param' => array( + 'type' => 'string', + 'required' => false, + 'documentation' => '{callInfo:VendorModuleACreate:requiredInput:conditionally}' + . '{callInfo:allCallsExcept(VendorModuleAGet):returned:always}', + ), + ), + ), + ), + 'parameter with see link' => array( + 'VendorModuleADataStructure', + array( + 'documentation' => 'test', + 'parameters' => array( + 'string_param' => array( + 'type' => 'string', + 'required' => false, + 'documentation' => '{seeLink:http://google.com/:title:for}', + ), + ), + ), + ), + 'parameter with doc instructions' => array( + 'VendorModuleADataStructure', + array( + 'documentation' => 'test', + 'parameters' => array( + 'string_param' => array( + 'type' => 'string', + 'required' => false, + 'documentation' => '{docInstructions:output:noDoc}', + ), + ), + ), + ), + ); + } + + /** + * Test adding complex type with complex parameters and arrays. + */ + public function testAddComplexTypeComplexParameters() + { + $type = 'VendorModuleADataStructure'; + $parameterType = 'ComplexType'; + $typeData = array( + 'documentation' => 'test', + 'parameters' => array( + 'complex_param' => array( + 'type' => $parameterType, + 'required' => true, + 'documentation' => 'complex type param.' + ), + ), + ); + $parameterData = array( + 'documentation' => 'test', + 'parameters' => array( + 'string_param' => array( + 'type' => 'ComplexTypeB[]', + 'required' => true, + 'documentation' => 'string param.' + ), + ), + ); + + $this->_wsdl->expects($this->at(0)) + ->method('getTypes') + ->will($this->returnValue(array())); + $this->_wsdl->expects($this->any()) + ->method('getTypes') + ->will($this->returnValue(array($type => Wsdl::TYPES_NS . ':' . $type))); + + $this->_wsdl->expects($this->any()) + ->method('toDomDocument') + ->will($this->returnValue(new \DOMDocument())); + $schemaMock = $this->_getDomElementMock(); + $schemaMock->expects($this->any()) + ->method('appendChild'); + $this->_wsdl->expects($this->any()) + ->method('getSchema') + ->will($this->returnValue($schemaMock)); + $this->_typeProcessor->expects($this->at(0)) + ->method('getTypeData') + ->with($type) + ->will($this->returnValue($typeData)); + $this->_typeProcessor->expects($this->at(1)) + ->method('getTypeData') + ->with($parameterType) + ->will($this->returnValue($parameterData)); + + $this->assertEquals(Wsdl::TYPES_NS . ':' . $type, $this->_strategy->addComplexType($type)); + } + + /** + * Test to verify if annotations are added correctly + */ + public function testAddAnnotationToComplexType() + { + $dom = new \DOMDocument(); + $this->_wsdl->expects($this->any()) + ->method('toDomDocument') + ->will($this->returnValue($dom)); + $annotationDoc = "test doc"; + $complexType = $dom->createElement(Wsdl::XSD_NS . ':complexType'); + $complexType->setAttribute('name', 'testRequest'); + $this->_strategy->addAnnotation($complexType, $annotationDoc); + $this->assertEquals( + $annotationDoc, + $complexType->getElementsByTagName("xsd:documentation")->item(0)->nodeValue + ); + } + + /** + * Create mock for DOMElement. + * + * @return \PHPUnit_Framework_MockObject_MockObject + */ + protected function _getDomElementMock() + { + return $this->getMockBuilder('DOMElement') + ->disableOriginalConstructor() + ->getMock(); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Webapi/Model/Soap/Wsdl/GeneratorTest.php b/dev/tests/unit/testsuite/Magento/Webapi/Model/Soap/Wsdl/GeneratorTest.php index a7a73b99f70d5317249ee6a1eeff46009386b2a7..ebab2bd3bfd80fb899202c204bfa87b599b892d5 100644 --- a/dev/tests/unit/testsuite/Magento/Webapi/Model/Soap/Wsdl/GeneratorTest.php +++ b/dev/tests/unit/testsuite/Magento/Webapi/Model/Soap/Wsdl/GeneratorTest.php @@ -30,17 +30,17 @@ class GeneratorTest extends \PHPUnit_Framework_TestCase /** @var \Magento\Webapi\Model\Soap\Wsdl\Generator */ protected $_wsdlGenerator; - /** @var \Magento\Webapi\Model\Soap\Config */ + /** @var \Magento\Webapi\Model\Soap\Config|\PHPUnit_Framework_MockObject_MockObject */ protected $_soapConfigMock; - /** @var \Magento\Webapi\Model\Soap\Wsdl\Factory */ + /** @var \Magento\Webapi\Model\Soap\Wsdl\Factory|\PHPUnit_Framework_MockObject_MockObject */ protected $_wsdlFactoryMock; - /** @var \Magento\Webapi\Model\Cache\Type */ + /** @var \Magento\Webapi\Model\Cache\Type|\PHPUnit_Framework_MockObject_MockObject */ protected $_cacheMock; - /** @var \Magento\DomDocument\Factory */ - protected $_domDocumentFactory; + /** @var \Magento\Webapi\Model\Config\ClassReflector\TypeProcessor|\PHPUnit_Framework_MockObject_MockObject */ + protected $_typeProcessor; protected function setUp() { @@ -79,132 +79,24 @@ class GeneratorTest extends \PHPUnit_Framework_TestCase $this->_cacheMock->expects($this->any())->method('load')->will($this->returnValue(false)); $this->_cacheMock->expects($this->any())->method('save')->will($this->returnValue(true)); - $this->_domDocumentFactory = $this->getMockBuilder('Magento\DomDocument\Factory') - ->disableOriginalConstructor()->getMock(); + $this->_typeProcessor = $this->getMock( + 'Magento\Webapi\Model\Config\ClassReflector\TypeProcessor', + [], + [], + '', + false + ); $this->_wsdlGenerator = new \Magento\Webapi\Model\Soap\Wsdl\Generator( $this->_soapConfigMock, $this->_wsdlFactoryMock, $this->_cacheMock, - $this->_domDocumentFactory + $this->_typeProcessor ); parent::setUp(); } - protected function tearDown() - { - unset($this->_wsdlGenerator); - unset($this->_soapConfigMock); - unset($this->_wsdlFactoryMock); - unset($this->_cacheMock); - parent::tearDown(); - } - - public function testGetComplexTypeNodes() - { - $serviceName = "serviceName"; - $nodesList = $this->_wsdlGenerator->getComplexTypeNodes($serviceName, - 'ItemsResponse', - $this->_getXsdDocumentWithReferencedTypes() - ); - $expectedCount = 2; - $this->assertCount($expectedCount, $nodesList, "Defined complex types count does not match."); - $actualTypes = array(); - foreach ($nodesList as $node) { - $actualTypes[] = $node->getAttribute('name'); - } - $expectedTypes = array($serviceName . 'ItemsResponse', $serviceName . 'ArrayItem'); - $this->assertEquals( - $expectedCount, - count(array_intersect($expectedTypes, $actualTypes)), - "Complex types does not match." - ); - } - - /** - * @return \DOMDocument - */ - protected function _getXsdDocumentWithReferencedTypes() - { - $xsd = - '<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="targetNamespace"> - <xsd:complexType name="ItemRequest"> - <xsd:sequence> - <xsd:element name="id" type="xsd:int" /> - </xsd:sequence> - </xsd:complexType> - <xsd:complexType name="ItemResponse"> - <xsd:sequence> - <xsd:element name="id" type="xsd:int" /> - <xsd:element name="name" type="xsd:string" /> - </xsd:sequence> - </xsd:complexType> - - <xsd:complexType name="ItemsResponse"> - <xsd:sequence> - <xsd:element minOccurs="0" maxOccurs="unbounded" name="complexObjectArray" type="ArrayItem" /> - <!-- "item" is required to ensure that the same complex type is included into WSDL only once--> - <xsd:element name="item" type="ArrayItem" /> - </xsd:sequence> - </xsd:complexType> - <xsd:complexType name="ArrayItem"> - <xsd:sequence> - <xsd:element name="id" type="xsd:int" /> - <xsd:element name="name" type="xsd:string" /> - </xsd:sequence> - </xsd:complexType> - </xsd:schema>'; - $xsdDom = new \DOMDocument(); - $xsdDom->loadXML($xsd); - return $xsdDom; - } - - /** - * @return \DOMDocument - */ - protected function _getXsdDocumentMissingTargetNamespace() - { - $xsd = - '<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"> - <xsd:complexType name="ItemRequest"> - <xsd:sequence> - <xsd:element name="id" type="xsd:int" /> - </xsd:sequence> - </xsd:complexType> - <xsd:complexType name="ItemResponse"> - <xsd:sequence> - <xsd:element name="id" type="xsd:int" /> - <xsd:element name="name" type="xsd:string" /> - </xsd:sequence> - </xsd:complexType> - </xsd:schema>'; - $xsdDom = new \DOMDocument(); - $xsdDom->loadXML($xsd); - return $xsdDom; - } - - /** - * @dataProvider providerIsComplexType - */ - public function testIsComplexType($type, $isComplex) - { - $this->assertEquals( - $isComplex, - $this->_wsdlGenerator->isComplexType($type), - "Complex type is defined incorrectly" - ); - } - - public static function providerIsComplexType() - { - return array( - array('xs:int', false), - array('xsd:string', false), - array('itemRequest', true), - ); - } - /** * Test getElementComplexTypeName */ @@ -280,25 +172,25 @@ class GeneratorTest extends \PHPUnit_Framework_TestCase $genWSDL = 'generatedWSDL'; $exceptionMsg = 'exception message'; $requestedService = array( - 'catalogProduct' => 'V1', + 'catalogProduct', ); $wsdlGeneratorMock = $this->getMockBuilder( 'Magento\Webapi\Model\Soap\Wsdl\Generator' ) - ->setMethods(array('_prepareServiceData')) + ->setMethods(array('_collectCallInfo')) ->setConstructorArgs( array( $this->_soapConfigMock, $this->_wsdlFactoryMock, $this->_cacheMock, - $this->_domDocumentFactory + $this->_typeProcessor ) ) ->getMock(); - $wsdlGeneratorMock->expects($this->once())->method('_prepareServiceData')->will( - $this->throwException(new \Exception($exceptionMsg)) + $wsdlGeneratorMock->expects($this->once())->method('_collectCallInfo')->will( + $this->throwException(new \Magento\Webapi\Exception($exceptionMsg)) ); $this->assertEquals($genWSDL, $wsdlGeneratorMock->generate($requestedService, 'http://magento.host')); diff --git a/dev/tests/unit/testsuite/Magento/Webapi/Service/Entity/AssociativeArrayDto.php b/dev/tests/unit/testsuite/Magento/Webapi/Service/Entity/AssociativeArrayDto.php new file mode 100644 index 0000000000000000000000000000000000000000..64ce79a41b092c7bfd4c192daa4fdf486fb22da3 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Webapi/Service/Entity/AssociativeArrayDto.php @@ -0,0 +1,37 @@ +<?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\Webapi\Service\Entity; + +use Magento\Service\Entity\AbstractDto; + +class AssociativeArrayDto extends AbstractDto +{ + /** + * @return string[] + */ + public function getAssociativeArray() + { + return $this->_get('associativeArray'); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Webapi/Service/Entity/DtoArrayDto.php b/dev/tests/unit/testsuite/Magento/Webapi/Service/Entity/DtoArrayDto.php new file mode 100644 index 0000000000000000000000000000000000000000..91245024ab6e9111582f164341bd0348c2414a18 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Webapi/Service/Entity/DtoArrayDto.php @@ -0,0 +1,37 @@ +<?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\Webapi\Service\Entity; + +use Magento\Service\Entity\AbstractDto; + +class DtoArrayDto extends AbstractDto +{ + /** + * @return \Magento\Webapi\Service\Entity\SimpleDto[]|null + */ + public function getItems() + { + return $this->_get('items'); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Webapi/Service/Entity/DtoFromArrayTest.php b/dev/tests/unit/testsuite/Magento/Webapi/Service/Entity/DtoFromArrayTest.php new file mode 100644 index 0000000000000000000000000000000000000000..1f953121ed926cb191d654a9040275a646aab489 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Webapi/Service/Entity/DtoFromArrayTest.php @@ -0,0 +1,199 @@ +<?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\Webapi\Service\Entity; + +use Magento\Service\Entity\AbstractDto; +use Magento\Service\Entity\AbstractDtoTest; +use Magento\Webapi\Controller\ServiceArgsSerializer; + +class DtoFromArrayTest extends \PHPUnit_Framework_TestCase +{ + /** @var ServiceArgsSerializer */ + protected $serializer; + + public function setUp() + { + $objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); + $typeProcessor = $objectManager->getObject('Magento\Webapi\Model\Config\ClassReflector\TypeProcessor'); + $this->serializer = new ServiceArgsSerializer($typeProcessor); + } + + public function testSimpleProperties() + { + $data = ['entityId' => 15, 'name' => 'Test']; + $result = $this->serializer + ->getInputData('\\Magento\\Webapi\\Service\\Entity\\TestService', 'simple', $data); + $this->assertNotNull($result); + $this->assertEquals(15, $result[0]); + $this->assertEquals('Test', $result[1]); + } + + public function testNestedDtoProperties() + { + $data = ['nested' => ['details' => ['entityId' => 15, 'name' => 'Test']]]; + $result = $this->serializer + ->getInputData('\\Magento\\Webapi\\Service\\Entity\\TestService', 'nestedDto', $data); + $this->assertNotNull($result); + $this->assertTrue( $result[0] instanceof NestedDto); + /** @var array $result */ + $this->assertEquals(1, count($result)); + $this->assertNotEmpty($result[0]); + /** @var NestedDto $arg */ + $arg = $result[0]; + $this->assertTrue($arg instanceof NestedDto); + /** @var SimpleDto $details */ + $details = $arg->getDetails(); + $this->assertNotNull($details); + $this->assertTrue($details instanceof SimpleDto); + $this->assertEquals(15, $details->getEntityId()); + $this->assertEquals('Test', $details->getName()); + } + + public function testSimpleArrayProperties() + { + $data = ['ids'=>[1,2,3,4]]; + $result = $this->serializer->getInputData( + '\\Magento\\Webapi\\Service\\Entity\\TestService', + 'simpleArray', + $data + ); + $this->assertNotNull($result); + /** @var array $result */ + $this->assertEquals(1, count($result)); + /** @var array $ids */ + $ids = $result[0]; + $this->assertNotNull($ids); + $this->assertEquals(4, count($ids)); + $this->assertEquals($data['ids'], $ids); + } + + public function testAssociativeArrayProperties() + { + $data = ['associativeArray' => ['key' => 'value', 'key_two' => 'value_two']]; + $result = $this->serializer->getInputData( + '\\Magento\\Webapi\\Service\\Entity\\TestService', + 'associativeArray', + $data + ); + $this->assertNotNull($result); + /** @var array $result */ + $this->assertEquals(1, count($result)); + /** @var array $associativeArray */ + $associativeArray = $result[0]; + $this->assertNotNull($associativeArray); + $this->assertEquals('value', $associativeArray['key']); + $this->assertEquals('value_two', $associativeArray['key_two']); + } + + public function testArrayOfDtoProperties() + { + $data = ['dtos' => [ ['entityId' => 14, 'name' => 'First'], [ 'entityId' => 15, 'name' => 'Second' ] ]]; + $result = $this->serializer->getInputData('\\Magento\\Webapi\\Service\\Entity\\TestService', 'dtoArray', $data); + $this->assertNotNull($result); + /** @var array $result */ + $this->assertEquals(1, count($result)); + /** @var array $dtos */ + $dtos = $result[0]; + $this->assertEquals(2, count($dtos)); + /** @var SimpleDto $first */ + $first = $dtos[0]; + /** @var SimpleDto $second */ + $second = $dtos[1]; + $this->assertTrue($first instanceof SimpleDto); + $this->assertEquals(14, $first->getEntityId()); + $this->assertEquals('First', $first->getName()); + $this->assertTrue($second instanceof SimpleDto); + $this->assertEquals(15, $second->getEntityId()); + $this->assertEquals('Second', $second->getName()); + } + + public function testNestedSimpleArrayProperties() + { + $data = ['arrayDto' => ['ids' => [1, 2, 3, 4]]]; + $result = $this->serializer + ->getInputData('\\Magento\\Webapi\\Service\\Entity\\TestService', 'nestedSimpleArray', $data); + $this->assertNotNull($result); + /** @var array $result */ + $this->assertEquals(1, count($result)); + /** @var SimpleArrayDto $dto */ + $dto = $result[0]; + $this->assertTrue($dto instanceof SimpleArrayDto); + /** @var array $ids */ + $ids = $dto->getIds(); + $this->assertNotNull($ids); + $this->assertEquals(4, count($ids)); + $this->assertEquals($data['arrayDto']['ids'], $ids); + } + + public function testNestedAssociativeArrayProperties() + { + $data = ['associativeArrayDto' => ['associativeArray' => ['key' => 'value', 'key2' => 'value2']]]; + $result = $this->serializer->getInputData( + '\\Magento\\Webapi\\Service\\Entity\\TestService', + 'nestedAssociativeArray', + $data + ); + $this->assertNotNull($result); + /** @var array $result */ + $this->assertEquals(1, count($result)); + /** @var AssociativeArrayDto $dto */ + $dto = $result[0]; + $this->assertTrue($dto instanceof AssociativeArrayDto); + /** @var array $associativeArray */ + $associativeArray = $dto->getAssociativeArray(); + $this->assertNotNull($associativeArray); + $this->assertEquals('value', $associativeArray['key']); + $this->assertEquals('value2', $associativeArray['key2']); + } + + public function testNestedArrayOfDtoProperties() + { + $data = ['dtos' => ['items' => [['entityId' => 1, 'name' => 'First'], ['entityId' => 2, 'name' => 'Second']]]]; + $result = $this->serializer->getInputData( + '\\Magento\\Webapi\\Service\\Entity\\TestService', + 'nestedDtoArray', + $data + ); + $this->assertNotNull($result); + /** @var array $result */ + $this->assertEquals(1, count($result)); + /** @var DtoArrayDto $dtos */ + $dtos = $result[0]; + $this->assertTrue($dtos instanceof DtoArrayDto); + /** @var array $items */ + $items = $dtos->getItems(); + $this->assertEquals(2, count($items)); + /** @var SimpleDto $first */ + $first = $items[0]; + /** @var SimpleDto $second */ + $second = $items[1]; + $this->assertTrue($first instanceof SimpleDto); + $this->assertEquals(1, $first->getEntityId()); + $this->assertEquals('First', $first->getName()); + $this->assertTrue($second instanceof SimpleDto); + $this->assertEquals(2, $second->getEntityId()); + $this->assertEquals('Second', $second->getName()); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Webapi/Service/Entity/NestedDto.php b/dev/tests/unit/testsuite/Magento/Webapi/Service/Entity/NestedDto.php new file mode 100644 index 0000000000000000000000000000000000000000..8766f45b557dd30dc6f47746cafa69af8b6dc7f2 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Webapi/Service/Entity/NestedDto.php @@ -0,0 +1,37 @@ +<?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\Webapi\Service\Entity; + +use Magento\Service\Entity\AbstractDto; + +class NestedDto extends AbstractDto +{ + /** + * @return \Magento\Webapi\Service\Entity\SimpleDto + */ + public function getDetails() + { + return $this->_get('details'); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Webapi/Service/Entity/SimpleArrayDto.php b/dev/tests/unit/testsuite/Magento/Webapi/Service/Entity/SimpleArrayDto.php new file mode 100644 index 0000000000000000000000000000000000000000..24fa2be7bcab07bccb8ee18a2445f5288d3eb2d2 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Webapi/Service/Entity/SimpleArrayDto.php @@ -0,0 +1,38 @@ +<?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\Webapi\Service\Entity; + +use Magento\Service\Entity\AbstractDto; + +class SimpleArrayDto extends AbstractDto +{ + /** + * @return int[] + */ + public function getIds() + { + return $this->_get('ids'); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Webapi/Service/Entity/SimpleDto.php b/dev/tests/unit/testsuite/Magento/Webapi/Service/Entity/SimpleDto.php new file mode 100644 index 0000000000000000000000000000000000000000..2b11cfb18822e61eaf9e6c97fc0352ade63e54b2 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Webapi/Service/Entity/SimpleDto.php @@ -0,0 +1,46 @@ +<?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\Webapi\Service\Entity; + +use Magento\Service\Entity\AbstractDto; + +class SimpleDto extends AbstractDto +{ + /** + * @return int|null + */ + public function getEntityId() + { + return $this->_get('entityId'); + } + + /** + * @return string|null + */ + public function getName() + { + return $this->_get('name'); + } +} diff --git a/dev/tests/unit/testsuite/Magento/Webapi/Service/Entity/TestService.php b/dev/tests/unit/testsuite/Magento/Webapi/Service/Entity/TestService.php new file mode 100644 index 0000000000000000000000000000000000000000..c05deda979aab23c1e87ec7a02bb91abe34fa8ef --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Webapi/Service/Entity/TestService.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\Webapi\Service\Entity; + +class TestService +{ + /** + * @param int $entityId + * @param string $name + * @return string[] + */ + public function simple($entityId, $name) + { + return [$entityId, $name]; + } + + /** + * @param \Magento\Webapi\Service\Entity\NestedDto $nested + * @return \Magento\Webapi\Service\Entity\NestedDto + */ + public function nestedDto(NestedDto $nested) + { + return $nested; + } + + /** + * @param int[] $ids + * @return int[] + */ + public function simpleArray(array $ids) + { + return $ids; + } + + /** + * @param string[] $associativeArray + * @return string[] + */ + public function associativeArray(array $associativeArray) + { + return $associativeArray; + } + + /** + * @param \Magento\Webapi\Service\Entity\SimpleDto[] $dtos + * @return \Magento\Webapi\Service\Entity\SimpleDto[] + */ + public function dtoArray(array $dtos) + { + return $dtos; + } + + /** + * @param \Magento\Webapi\Service\Entity\SimpleArrayDto $arrayDto + * @return \Magento\Webapi\Service\Entity\SimpleArrayDto + */ + public function nestedSimpleArray(SimpleArrayDto $arrayDto) + { + return $arrayDto; + } + + /** + * @param \Magento\Webapi\Service\Entity\AssociativeArrayDto $associativeArrayDto + * @return \Magento\Webapi\Service\Entity\AssociativeArrayDto + */ + public function nestedAssociativeArray(AssociativeArrayDto $associativeArrayDto) + { + return $associativeArrayDto; + } + + /** + * @param \Magento\Webapi\Service\Entity\DtoArrayDto $dtos + * @return \Magento\Webapi\Service\Entity\DtoArrayDto + */ + public function nestedDtoArray(DtoArrayDto $dtos) + { + return $dtos; + } +} diff --git a/dev/tests/unit/testsuite/Magento/Webapi/_files/soap_fault/soap_fault_expected_xmls.php b/dev/tests/unit/testsuite/Magento/Webapi/_files/soap_fault/soap_fault_expected_xmls.php index b5f5f1832c5b7692a3febe99a6fa56e1e93e14c6..851968de2d9711e29daad618624170b9d8afa6fc 100644 --- a/dev/tests/unit/testsuite/Magento/Webapi/_files/soap_fault/soap_fault_expected_xmls.php +++ b/dev/tests/unit/testsuite/Magento/Webapi/_files/soap_fault/soap_fault_expected_xmls.php @@ -36,10 +36,20 @@ return array( <env:Text xml:lang="en">Fault reason</env:Text> </env:Reason> <env:Detail> - <m:DefaultFault> - <m:key1>value1</m:key1> - <m:key2>value2</m:key2> - </m:DefaultFault> + <m:GenericFault> + <m:Parameters> + <m:GenericFaultParameter> + <m:key>key1</m:key> + <m:value>value1</m:value> + </m:GenericFaultParameter> + <m:GenericFaultParameter> + <m:key>key2</m:key> + <m:value>value2</m:value> + </m:GenericFaultParameter> + </m:Parameters> + <m:Code>333</m:Code> + <m:Trace>Trace</m:Trace> + </m:GenericFault> </env:Detail> </env:Fault> </env:Body> @@ -88,7 +98,7 @@ return array( </env:Envelope>', 'expectedResultComplexDataDetails' => '<?xml version = "1.0" encoding = "utf-8" ?> - <env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope" xmlns:m="{wsdl_url}"> + <env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope"> <env:Body> <env:Fault> <env:Code> @@ -97,13 +107,6 @@ return array( <env:Reason> <env:Text xml:lang="en">Fault reason</env:Text> </env:Reason> - <env:Detail> - <m:DefaultFault> - <m:key> - <m:sub_key>value</m:sub_key> - </m:key> - </m:DefaultFault> - </env:Detail> </env:Fault> </env:Body> </env:Envelope>' diff --git a/dev/tests/unit/testsuite/Magento/Webapi/_files/test_interfaces.php b/dev/tests/unit/testsuite/Magento/Webapi/_files/test_interfaces.php new file mode 100644 index 0000000000000000000000000000000000000000..9aee13f65fb869d95044128f57f5b4612bc1bce7 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Webapi/_files/test_interfaces.php @@ -0,0 +1,50 @@ +<?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\Module\Service; + +/** + * The list of test interfaces. + */ +interface FooV1Interface +{ + public function someMethod(); +} + +interface BarV1Interface +{ + public function someMethod(); +} + +interface FooBarV1Interface +{ + public function someMethod(); +} + +namespace Magento\Module\Service\Foo; + +interface BarV1Interface +{ + public function someMethod(); +} diff --git a/dev/tools/Magento/Tools/Migration/factory_table_names/replace_ce.php b/dev/tools/Magento/Tools/Migration/factory_table_names/replace_ce.php index ad151d45e334fb75f813d34fee4e349751d447cc..71c4e44e7395b5aca1ee987f2dcc6278a0cf759e 100644 --- a/dev/tools/Magento/Tools/Migration/factory_table_names/replace_ce.php +++ b/dev/tools/Magento/Tools/Migration/factory_table_names/replace_ce.php @@ -279,12 +279,10 @@ return array( 'paybox/api_debug' => 'paybox_api_debug', 'paybox/question_number' => 'paybox_question_number', 'paygate/authorizenet_debug' => 'authorizenet_debug', - 'paypal/api_debug' => 'paypal_api_debug', 'paypal/cert' => 'paypal_cert', 'paypal/payment_transaction' => 'paypal_payment_transaction', 'paypal/settlement_report' => 'paypal_settlement_report', 'paypal/settlement_report_row' => 'paypal_settlement_report_row', - 'paypaluk/api_debug' => 'paypaluk_api_debug', 'persistent/session' => 'persistent_session', 'poll/poll' => 'poll', 'poll/poll_answer' => 'poll_answer', diff --git a/dev/tools/Magento/Tools/Migration/themes_view.php b/dev/tools/Magento/Tools/Migration/themes_view.php index 1f6c2e9972211f047c8c44c6a1abae4f23c7aaba..3ea1882ab265f4febcaf2f2b79b86db2e5006d36 100644 --- a/dev/tools/Magento/Tools/Migration/themes_view.php +++ b/dev/tools/Magento/Tools/Migration/themes_view.php @@ -28,9 +28,9 @@ $rootDir = realpath(__DIR__ . '/../../../../..'); try { $entryPoint = new \Magento\App\EntryPoint\EntryPoint($rootDir, array()); - $objectManager = new \Magento\App\ObjectManager($config); - /** @var $configModel \Magento\Core\Model\Config */ - $configModel = $objectManager->get('Magento\Core\Model\Config'); + $objectManager = new \Magento\App\ObjectManager(); + /** @var $configModel \Magento\App\ReinitableConfigInterface */ + $configModel = $objectManager->get('Magento\App\ReinitableConfigInterface'); $configModel->reinit(); $config = array(); diff --git a/dev/tools/Magento/Tools/View/Generator/ThemeLight.php b/dev/tools/Magento/Tools/View/Generator/ThemeLight.php index ef8198079b3c8e932a4cbab9b6d48ea48ffa7bac..08a45d0cf9f52fd80ce9a61a1fccd6a5e2cffb61 100644 --- a/dev/tools/Magento/Tools/View/Generator/ThemeLight.php +++ b/dev/tools/Magento/Tools/View/Generator/ThemeLight.php @@ -24,12 +24,14 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +namespace Magento\Tools\View\Generator; + +use Magento\View\Design\ThemeInterface; + /** * Lightweight theme that implements minimal required interface */ -namespace Magento\Tools\View\Generator; - -class ThemeLight extends \Magento\Object implements \Magento\View\Design\ThemeInterface +class ThemeLight extends \Magento\Object implements ThemeInterface { /** * {@inheritdoc} @@ -52,7 +54,7 @@ class ThemeLight extends \Magento\Object implements \Magento\View\Design\ThemeIn */ public function getFullPath() { - return $this->getArea() . \Magento\View\Design\ThemeInterface::PATH_SEPARATOR . $this->getThemePath(); + return $this->getArea() . ThemeInterface::PATH_SEPARATOR . $this->getThemePath(); } /** @@ -78,4 +80,12 @@ class ThemeLight extends \Magento\Object implements \Magento\View\Design\ThemeIn { return false; } + + /** + * {@inheritdoc} + */ + public function getInheritedThemes() + { + return array(); + } } diff --git a/downloader/app/Magento/Downloader/Controller.php b/downloader/app/Magento/Downloader/Controller.php index 305520d2cfe744b532a30facb99afabcc919891f..f40a5e929e6e4fcb42a61698faea65b298c80168 100755 --- a/downloader/app/Magento/Downloader/Controller.php +++ b/downloader/app/Magento/Downloader/Controller.php @@ -518,7 +518,7 @@ final class Controller } \Magento\App\ObjectManager::getInstance()->get('Magento\Core\Model\App'); if (self::isInstalled()) { - \Mage::getSingleton('Magento\Backend\Model\Url')->turnOffSecretKey(); + \Mage::getSingleton('Magento\Backend\Model\UrlInterface')->turnOffSecretKey(); } } } diff --git a/lib/Less/Autoloader.php b/lib/Less/Autoloader.php new file mode 100644 index 0000000000000000000000000000000000000000..09a884b700c7e9910ca1c0ba46bcb60d3769a1b2 --- /dev/null +++ b/lib/Less/Autoloader.php @@ -0,0 +1,79 @@ +<?php + +/** + * Autoloader + * + * @package Less + * @subpackage autoload + */ +class Less_Autoloader { + + /** + * Registered flag + * + * @var boolean + */ + protected static $registered = false; + + /** + * Library directory + * + * @var string + */ + protected static $libDir; + + /** + * Register the autoloader in the spl autoloader + * + * @return void + * @throws Exception If there was an error in registration + */ + public static function register(){ + if( self::$registered ){ + return; + } + + self::$libDir = dirname(__FILE__); + + if(false === spl_autoload_register(array('Less_Autoloader', 'loadClass'))){ + throw new Exception('Unable to register Less_Autoloader::loadClass as an autoloading method.'); + } + + self::$registered = true; + } + + /** + * Unregisters the autoloader + * + * @return void + */ + public static function unregister(){ + spl_autoload_unregister(array('Less_Autoloader', 'loadClass')); + self::$registered = false; + } + + /** + * Loads the class + * + * @param string $className The class to load + */ + public static function loadClass($className){ + + + // handle only package classes + if(strpos($className, 'Less_') !== 0){ + return; + } + + $className = substr($className,5); + $fileName = self::$libDir . '/' . str_replace('_', DIRECTORY_SEPARATOR, $className) . '.php'; + + if(file_exists($fileName)){ + require $fileName; + return true; + }else{ + throw new Exception('file not loadable '.$fileName); + } + } + +} \ No newline at end of file diff --git a/lib/Less/Cache.php b/lib/Less/Cache.php new file mode 100644 index 0000000000000000000000000000000000000000..56c7e71ddb6018bf047ee47b23f1558f9c399350 --- /dev/null +++ b/lib/Less/Cache.php @@ -0,0 +1,150 @@ +<?php + + +class Less_Cache{ + + public static $cache_dir = false; // directory less.php can use for storing data + public static $import_dirs = array(); + private static $use_cache = true; + + const cache_version = '1513'; + protected static $clean_cache = true; + + + public static function Get( $less_files, $parser_options = array() ){ + + //check $cache_dir + if( empty(self::$cache_dir) ){ + throw new Exception('cache_dir not set'); + return false; + } + + self::$cache_dir = str_replace('\\','/',self::$cache_dir); + self::$cache_dir = rtrim(self::$cache_dir,'/').'/'; + + if( !is_dir(self::$cache_dir) ){ + throw new Exception('cache_dir does not exist'); + return false; + } + + // generate name for compiled css file + $less_files = (array)$less_files; + $hash = md5(json_encode($less_files)); + $list_file = self::$cache_dir.'lessphp_'.$hash.'.list'; + + + if( self::$use_cache === true ){ + + // check cached content + $compiled_file = false; + $less_cache = false; + if( file_exists($list_file) ){ + + + $list = explode("\n",file_get_contents($list_file)); + $compiled_name = self::CompiledName($list); + $compiled_file = self::$cache_dir.$compiled_name; + if( file_exists($compiled_file) ){ + touch($list_file); + touch($compiled_file); + return $compiled_name; + } + } + + } + + $compiled = self::Cache( $less_files, $parser_options ); + if( !$compiled ){ + return false; + } + + + //save the file list + $cache = implode("\n",$less_files); + file_put_contents( $list_file, $cache ); + + + //save the css + $compiled_name = self::CompiledName( $less_files ); + file_put_contents( self::$cache_dir.$compiled_name, $compiled ); + + + //clean up + self::CleanCache(); + self::$use_cache = true; + + return $compiled_name; + + } + + public static function Regen( $less_files, $parser_options = array() ){ + self::$use_cache = false; + return self::Get( $less_files, $parser_options ); + } + + public static function Cache( &$less_files, $parser_options = array() ){ + + $parser = new Less_Parser($parser_options); + $parser->SetCacheDir( self::$cache_dir ); + $parser->SetImportDirs( self::$import_dirs ); + + + // combine files + foreach($less_files as $file_path => $uri_or_less ){ + + //treat as less markup if there are newline characters + if( strpos($uri_or_less,"\n") !== false ){ + $parser->Parse( $uri_or_less ); + continue; + } + + $parser->ParseFile( $file_path, $uri_or_less ); + } + + $compiled = $parser->getCss(); + + + $less_files = $parser->allParsedFiles(); + + return $compiled; + } + + + private static function CompiledName( $files ){ + + //save the file list + $temp = array(self::cache_version); + foreach($files as $file){ + $temp[] = filemtime($file)."\t".filesize($file)."\t".$file; + } + + return 'lessphp_'.sha1(json_encode($temp)).'.css'; + } + + + public static function CleanCache(){ + static $clean = false; + + if( $clean ){ + return; + } + + $files = scandir(self::$cache_dir); + if( $files ){ + $check_time = time() - 604800; + foreach($files as $file){ + if( strpos($file,'lessphp_') !== 0 ){ + continue; + } + $full_path = self::$cache_dir.'/'.$file; + if( filemtime($full_path) > $check_time ){ + continue; + } + unlink($full_path); + } + } + + $clean = true; + } + +} \ No newline at end of file diff --git a/lib/Less/Colors.php b/lib/Less/Colors.php new file mode 100644 index 0000000000000000000000000000000000000000..4bb2f137d85127aa77144e06cd2e47765b2f9811 --- /dev/null +++ b/lib/Less/Colors.php @@ -0,0 +1,176 @@ +<?php + +//less.js : lib/less/colors.js + +class Less_Colors { + + public static $colors; + + private static function all() { + if (self::$colors) + return self::$colors; + + self::$colors = array( + 'aliceblue'=>'#f0f8ff', + 'antiquewhite'=>'#faebd7', + 'aqua'=>'#00ffff', + 'aquamarine'=>'#7fffd4', + 'azure'=>'#f0ffff', + 'beige'=>'#f5f5dc', + 'bisque'=>'#ffe4c4', + 'black'=>'#000000', + 'blanchedalmond'=>'#ffebcd', + 'blue'=>'#0000ff', + 'blueviolet'=>'#8a2be2', + 'brown'=>'#a52a2a', + 'burlywood'=>'#deb887', + 'cadetblue'=>'#5f9ea0', + 'chartreuse'=>'#7fff00', + 'chocolate'=>'#d2691e', + 'coral'=>'#ff7f50', + 'cornflowerblue'=>'#6495ed', + 'cornsilk'=>'#fff8dc', + 'crimson'=>'#dc143c', + 'cyan'=>'#00ffff', + 'darkblue'=>'#00008b', + 'darkcyan'=>'#008b8b', + 'darkgoldenrod'=>'#b8860b', + 'darkgray'=>'#a9a9a9', + 'darkgrey'=>'#a9a9a9', + 'darkgreen'=>'#006400', + 'darkkhaki'=>'#bdb76b', + 'darkmagenta'=>'#8b008b', + 'darkolivegreen'=>'#556b2f', + 'darkorange'=>'#ff8c00', + 'darkorchid'=>'#9932cc', + 'darkred'=>'#8b0000', + 'darksalmon'=>'#e9967a', + 'darkseagreen'=>'#8fbc8f', + 'darkslateblue'=>'#483d8b', + 'darkslategray'=>'#2f4f4f', + 'darkslategrey'=>'#2f4f4f', + 'darkturquoise'=>'#00ced1', + 'darkviolet'=>'#9400d3', + 'deeppink'=>'#ff1493', + 'deepskyblue'=>'#00bfff', + 'dimgray'=>'#696969', + 'dimgrey'=>'#696969', + 'dodgerblue'=>'#1e90ff', + 'firebrick'=>'#b22222', + 'floralwhite'=>'#fffaf0', + 'forestgreen'=>'#228b22', + 'fuchsia'=>'#ff00ff', + 'gainsboro'=>'#dcdcdc', + 'ghostwhite'=>'#f8f8ff', + 'gold'=>'#ffd700', + 'goldenrod'=>'#daa520', + 'gray'=>'#808080', + 'grey'=>'#808080', + 'green'=>'#008000', + 'greenyellow'=>'#adff2f', + 'honeydew'=>'#f0fff0', + 'hotpink'=>'#ff69b4', + 'indianred'=>'#cd5c5c', + 'indigo'=>'#4b0082', + 'ivory'=>'#fffff0', + 'khaki'=>'#f0e68c', + 'lavender'=>'#e6e6fa', + 'lavenderblush'=>'#fff0f5', + 'lawngreen'=>'#7cfc00', + 'lemonchiffon'=>'#fffacd', + 'lightblue'=>'#add8e6', + 'lightcoral'=>'#f08080', + 'lightcyan'=>'#e0ffff', + 'lightgoldenrodyellow'=>'#fafad2', + 'lightgray'=>'#d3d3d3', + 'lightgrey'=>'#d3d3d3', + 'lightgreen'=>'#90ee90', + 'lightpink'=>'#ffb6c1', + 'lightsalmon'=>'#ffa07a', + 'lightseagreen'=>'#20b2aa', + 'lightskyblue'=>'#87cefa', + 'lightslategray'=>'#778899', + 'lightslategrey'=>'#778899', + 'lightsteelblue'=>'#b0c4de', + 'lightyellow'=>'#ffffe0', + 'lime'=>'#00ff00', + 'limegreen'=>'#32cd32', + 'linen'=>'#faf0e6', + 'magenta'=>'#ff00ff', + 'maroon'=>'#800000', + 'mediumaquamarine'=>'#66cdaa', + 'mediumblue'=>'#0000cd', + 'mediumorchid'=>'#ba55d3', + 'mediumpurple'=>'#9370d8', + 'mediumseagreen'=>'#3cb371', + 'mediumslateblue'=>'#7b68ee', + 'mediumspringgreen'=>'#00fa9a', + 'mediumturquoise'=>'#48d1cc', + 'mediumvioletred'=>'#c71585', + 'midnightblue'=>'#191970', + 'mintcream'=>'#f5fffa', + 'mistyrose'=>'#ffe4e1', + 'moccasin'=>'#ffe4b5', + 'navajowhite'=>'#ffdead', + 'navy'=>'#000080', + 'oldlace'=>'#fdf5e6', + 'olive'=>'#808000', + 'olivedrab'=>'#6b8e23', + 'orange'=>'#ffa500', + 'orangered'=>'#ff4500', + 'orchid'=>'#da70d6', + 'palegoldenrod'=>'#eee8aa', + 'palegreen'=>'#98fb98', + 'paleturquoise'=>'#afeeee', + 'palevioletred'=>'#d87093', + 'papayawhip'=>'#ffefd5', + 'peachpuff'=>'#ffdab9', + 'peru'=>'#cd853f', + 'pink'=>'#ffc0cb', + 'plum'=>'#dda0dd', + 'powderblue'=>'#b0e0e6', + 'purple'=>'#800080', + 'red'=>'#ff0000', + 'rosybrown'=>'#bc8f8f', + 'royalblue'=>'#4169e1', + 'saddlebrown'=>'#8b4513', + 'salmon'=>'#fa8072', + 'sandybrown'=>'#f4a460', + 'seagreen'=>'#2e8b57', + 'seashell'=>'#fff5ee', + 'sienna'=>'#a0522d', + 'silver'=>'#c0c0c0', + 'skyblue'=>'#87ceeb', + 'slateblue'=>'#6a5acd', + 'slategray'=>'#708090', + 'slategrey'=>'#708090', + 'snow'=>'#fffafa', + 'springgreen'=>'#00ff7f', + 'steelblue'=>'#4682b4', + 'tan'=>'#d2b48c', + 'teal'=>'#008080', + 'thistle'=>'#d8bfd8', + 'tomato'=>'#ff6347', + 'turquoise'=>'#40e0d0', + 'violet'=>'#ee82ee', + 'wheat'=>'#f5deb3', + 'white'=>'#ffffff', + 'whitesmoke'=>'#f5f5f5', + 'yellow'=>'#ffff00', + 'yellowgreen'=>'#9acd32' + ); + return self::$colors; + } + + public static function hasOwnProperty($color) { + $colors = self::all(); + return isset($colors[$color]); + } + + + public static function color($color) { + $colors = self::all(); + return $colors[$color]; + } + +} diff --git a/lib/Less/Environment.php b/lib/Less/Environment.php new file mode 100644 index 0000000000000000000000000000000000000000..57ece2148fdace8bfb025ec7856814312a5c6818 --- /dev/null +++ b/lib/Less/Environment.php @@ -0,0 +1,208 @@ +<?php + +//less.js : lib/less/functions.js + + +class Less_Environment{ + + public $paths = array(); // option - unmodified - paths to search for imports on + static $files = array(); // list of files that have been imported, used for import-once + public $relativeUrls; // option - whether to adjust URL's to be relative + public $rootpath; // option - rootpath to append to URL's + public $strictImports = null; // option - + public $insecure; // option - whether to allow imports from insecure ssl hosts + public static $compress = false; // option - whether to compress + public $processImports; // option - whether to process imports. if false then imports will not be imported + public $javascriptEnabled; // option - whether JavaScript is enabled. if undefined, defaults to true + public $useFileCache; // browser only - whether to use the per file session cache + public $currentFileInfo; // information about the current file - for error reporting and importing and making urls relative etc. + + /** + * @var array + */ + public $frames = array(); + + + /** + * @var bool + */ + public $debug = false; + + + /** + * @var array + */ + public $mediaBlocks = array(); + + /** + * @var array + */ + public $mediaPath = array(); + + public $selectors = array(); + + public $charset; + + public $parensStack = array(); + + public $strictMath = false; + + public $strictUnits = false; + + public $tabLevel = 0; + + public $lastRule = false; + + public $importMultiple = false; + + //public $type = 'Environment'; + + + public static $comma_space; + public static $colon_space; + public static $firstSelector; + + public function __construct( $options = null ){ + $this->frames = array(); + + + if( isset($options['compress']) ){ + self::$compress = (bool)$options['compress']; + } + if( isset($options['strictUnits']) ){ + $this->strictUnits = (bool)$options['strictUnits']; + } + + + if( self::$compress ){ + self::$comma_space = ','; + self::$colon_space = ':'; + }else{ + self::$comma_space = ', '; + self::$colon_space = ': '; + } + + + } + + + //may want to just use the __clone()? + public function copyEvalEnv($frames = array() ){ + + $evalCopyProperties = array( + //'silent', // whether to swallow errors and warnings + //'verbose', // whether to log more activity + //'yuicompress', // whether to compress with the outside tool yui compressor + //'ieCompat', // whether to enforce IE compatibility (IE8 data-uri) + 'strictMath', // whether math has to be within parenthesis + 'strictUnits', // whether units need to evaluate correctly + //'cleancss', // whether to compress with clean-css + //'sourceMap', // whether to output a source map + //'importMultiple'// whether we are currently importing multiple copies + ); + + $new_env = new Less_Environment(); + foreach($evalCopyProperties as $property){ + $new_env->$property = $this->$property; + } + $new_env->frames = $frames; + return $new_env; + } + + public function inParenthesis(){ + $this->parensStack[] = true; + } + + public function outOfParenthesis() { + array_pop($this->parensStack); + } + + public function isMathOn() { + return $this->strictMath ? !!$this->parensStack : true; + } + + public static function isPathRelative($path){ + /** + * - return !preg_match('/^(?:[a-z-]+:|\/)/',$path); + * + return !preg_match('/^(?:[A-Za-z-_]+:|\/)/',$path); + * + * For identification paths such as Magento_Theme::validation_advice_bg.gif as an absolute paths. + */ + return !preg_match('/^(?:[A-Za-z-_]+:|\/)/',$path); + } + + + /** + * Canonicalize a path by resolving references to '/./', '/../' + * Does not remove leading "../" + * @param string path or url + * @return string Canonicalized path + * + */ + static function normalizePath($path){ + + $segments = explode('/',$path); + $segments = array_reverse($segments); + + $path = array(); + $path_len = 0; + + while( $segments ){ + $segment = array_pop($segments); + switch( $segment ) { + + case '.': + break; + + case '..': + if( !$path_len || ( $path[$path_len-1] === '..') ){ + $path[] = $segment; + $path_len++; + }else{ + array_pop($path); + $path_len--; + } + break; + + default: + $path[] = $segment; + $path_len++; + break; + } + } + + return implode('/',$path); + } + + + /** + * @return bool + */ + public function getDebug(){ + return $this->debug; + } + + /** + * @param $debug + * @return void + */ + public function setDebug($debug){ + $this->debug = $debug; + } + + public function unshiftFrame($frame){ + array_unshift($this->frames, $frame); + } + + public function shiftFrame(){ + return array_shift($this->frames); + } + + public function addFrame($frame){ + $this->frames[] = $frame; + } + + public function addFrames(array $frames){ + $this->frames = array_merge($this->frames, $frames); + } +} diff --git a/lib/Less/Environment.php.origin b/lib/Less/Environment.php.origin new file mode 100644 index 0000000000000000000000000000000000000000..d8843597ec7fd5ef94f3a8991ff8cfefd537fb17 --- /dev/null +++ b/lib/Less/Environment.php.origin @@ -0,0 +1,202 @@ +<?php + +//less.js : lib/less/functions.js + + +class Less_Environment{ + + public $paths = array(); // option - unmodified - paths to search for imports on + static $files = array(); // list of files that have been imported, used for import-once + public $relativeUrls; // option - whether to adjust URL's to be relative + public $rootpath; // option - rootpath to append to URL's + public $strictImports = null; // option - + public $insecure; // option - whether to allow imports from insecure ssl hosts + public static $compress = false; // option - whether to compress + public $processImports; // option - whether to process imports. if false then imports will not be imported + public $javascriptEnabled; // option - whether JavaScript is enabled. if undefined, defaults to true + public $useFileCache; // browser only - whether to use the per file session cache + public $currentFileInfo; // information about the current file - for error reporting and importing and making urls relative etc. + + /** + * @var array + */ + public $frames = array(); + + + /** + * @var bool + */ + public $debug = false; + + + /** + * @var array + */ + public $mediaBlocks = array(); + + /** + * @var array + */ + public $mediaPath = array(); + + public $selectors = array(); + + public $charset; + + public $parensStack = array(); + + public $strictMath = false; + + public $strictUnits = false; + + public $tabLevel = 0; + + public $lastRule = false; + + public $importMultiple = false; + + //public $type = 'Environment'; + + + public static $comma_space; + public static $colon_space; + public static $firstSelector; + + public function __construct( $options = null ){ + $this->frames = array(); + + + if( isset($options['compress']) ){ + self::$compress = (bool)$options['compress']; + } + if( isset($options['strictUnits']) ){ + $this->strictUnits = (bool)$options['strictUnits']; + } + + + if( self::$compress ){ + self::$comma_space = ','; + self::$colon_space = ':'; + }else{ + self::$comma_space = ', '; + self::$colon_space = ': '; + } + + + } + + + //may want to just use the __clone()? + public function copyEvalEnv($frames = array() ){ + + $evalCopyProperties = array( + //'silent', // whether to swallow errors and warnings + //'verbose', // whether to log more activity + //'yuicompress', // whether to compress with the outside tool yui compressor + //'ieCompat', // whether to enforce IE compatibility (IE8 data-uri) + 'strictMath', // whether math has to be within parenthesis + 'strictUnits', // whether units need to evaluate correctly + //'cleancss', // whether to compress with clean-css + //'sourceMap', // whether to output a source map + //'importMultiple'// whether we are currently importing multiple copies + ); + + $new_env = new Less_Environment(); + foreach($evalCopyProperties as $property){ + $new_env->$property = $this->$property; + } + $new_env->frames = $frames; + return $new_env; + } + + public function inParenthesis(){ + $this->parensStack[] = true; + } + + public function outOfParenthesis() { + array_pop($this->parensStack); + } + + public function isMathOn() { + return $this->strictMath ? !!$this->parensStack : true; + } + + public static function isPathRelative($path){ + return !preg_match('/^(?:[a-z-]+:|\/)/',$path); + } + + + /** + * Canonicalize a path by resolving references to '/./', '/../' + * Does not remove leading "../" + * @param string path or url + * @return string Canonicalized path + * + */ + static function normalizePath($path){ + + $segments = explode('/',$path); + $segments = array_reverse($segments); + + $path = array(); + $path_len = 0; + + while( $segments ){ + $segment = array_pop($segments); + switch( $segment ) { + + case '.': + break; + + case '..': + if( !$path_len || ( $path[$path_len-1] === '..') ){ + $path[] = $segment; + $path_len++; + }else{ + array_pop($path); + $path_len--; + } + break; + + default: + $path[] = $segment; + $path_len++; + break; + } + } + + return implode('/',$path); + } + + + /** + * @return bool + */ + public function getDebug(){ + return $this->debug; + } + + /** + * @param $debug + * @return void + */ + public function setDebug($debug){ + $this->debug = $debug; + } + + public function unshiftFrame($frame){ + array_unshift($this->frames, $frame); + } + + public function shiftFrame(){ + return array_shift($this->frames); + } + + public function addFrame($frame){ + $this->frames[] = $frame; + } + + public function addFrames(array $frames){ + $this->frames = array_merge($this->frames, $frames); + } +} diff --git a/lib/Less/Exception/Compiler.php b/lib/Less/Exception/Compiler.php new file mode 100644 index 0000000000000000000000000000000000000000..84c1fda2b5e3b2f3e28e75080218681478c13ad6 --- /dev/null +++ b/lib/Less/Exception/Compiler.php @@ -0,0 +1,20 @@ +<?php + + +class Less_Exception_Compiler extends Exception { + + private $filename; + + public function __construct($message = null, $code = 0, Exception $previous = null, $filename = null ){ + parent::__construct($message, $code); + $this->filename = $filename; + } + + public function getFilename() { + return $this->filename; + } + + public function __toString() { + return $this->message . " (" . $this->filename . ")"; + } +} diff --git a/lib/Less/Exception/Parser.php b/lib/Less/Exception/Parser.php new file mode 100644 index 0000000000000000000000000000000000000000..013d6d330dddf981c11bacadc38d853deeffb149 --- /dev/null +++ b/lib/Less/Exception/Parser.php @@ -0,0 +1,6 @@ +<?php + + +class Less_Exception_Parser extends Exception{ + +} \ No newline at end of file diff --git a/lib/Less/Functions.php b/lib/Less/Functions.php new file mode 100644 index 0000000000000000000000000000000000000000..d25068cdba446a162be3501879138ca8f1730554 --- /dev/null +++ b/lib/Less/Functions.php @@ -0,0 +1,811 @@ +<?php + + +class Less_Functions{ + + function __construct($env, $currentFileInfo = null ){ + $this->env = $env; + $this->currentFileInfo = $currentFileInfo; + } + + + //tree.operate() + static public function operate ($env, $op, $a, $b){ + switch ($op) { + case '+': return $a + $b; + case '-': return $a - $b; + case '*': return $a * $b; + case '/': return $a / $b; + } + } + + static public function clamp($val){ + return min(1, max(0, $val)); + } + + static public function number($n){ + + if ($n instanceof Less_Tree_Dimension) { + return floatval( $n->unit->is('%') ? $n->value / 100 : $n->value); + } else if (is_numeric($n)) { + return $n; + } else { + throw new Less_Exception_Compiler("color functions take numbers as parameters"); + } + } + + static public function scaled($n, $size = 256 ){ + if( $n instanceof Less_Tree_Dimension && $n->unit->is('%') ){ + return (float)$n->value * $size / 100; + } else { + return Less_Functions::number($n); + } + } + + public function rgb ($r, $g, $b){ + return $this->rgba($r, $g, $b, 1.0); + } + + public function rgba($r, $g, $b, $a){ + $rgb = array($r, $g, $b); + $rgb = array_map(array('Less_Functions','scaled'),$rgb); + + $a = self::number($a); + return new Less_Tree_Color($rgb, $a); + } + + public function hsl($h, $s, $l){ + return $this->hsla($h, $s, $l, 1.0); + } + + public function hsla($h, $s, $l, $a){ + + $h = fmod(self::number($h), 360) / 360; // Classic % operator will change float to int + $s = self::clamp(self::number($s)); + $l = self::clamp(self::number($l)); + $a = self::clamp(self::number($a)); + + $m2 = $l <= 0.5 ? $l * ($s + 1) : $l + $s - $l * $s; + + $m1 = $l * 2 - $m2; + + return $this->rgba( self::hsla_hue($h + 1/3, $m1, $m2) * 255, + self::hsla_hue($h, $m1, $m2) * 255, + self::hsla_hue($h - 1/3, $m1, $m2) * 255, + $a); + } + + function hsla_hue($h, $m1, $m2){ + $h = $h < 0 ? $h + 1 : ($h > 1 ? $h - 1 : $h); + if ($h * 6 < 1) return $m1 + ($m2 - $m1) * $h * 6; + else if ($h * 2 < 1) return $m2; + else if ($h * 3 < 2) return $m1 + ($m2 - $m1) * (2/3 - $h) * 6; + else return $m1; + } + + public function hsv($h, $s, $v) { + return $this->hsva($h, $s, $v, 1.0); + } + + public function hsva($h, $s, $v, $a) { + $h = ((Less_Functions::number($h) % 360) / 360 ) * 360; + $s = Less_Functions::number($s); + $v = Less_Functions::number($v); + $a = Less_Functions::number($a); + + $i = floor(($h / 60) % 6); + $f = ($h / 60) - $i; + + $vs = array( $v, + $v * (1 - $s), + $v * (1 - $f * $s), + $v * (1 - (1 - $f) * $s)); + + $perm = array(array(0, 3, 1), + array(2, 0, 1), + array(1, 0, 3), + array(1, 2, 0), + array(3, 1, 0), + array(0, 1, 2)); + + return $this->rgba($vs[$perm[$i][0]] * 255, + $vs[$perm[$i][1]] * 255, + $vs[$perm[$i][2]] * 255, + $a); + } + + public function hue($color){ + $c = $color->toHSL(); + return new Less_Tree_Dimension(Less_Parser::round($c['h'])); + } + + public function saturation($color){ + $c = $color->toHSL(); + return new Less_Tree_Dimension(Less_Parser::round($c['s'] * 100), '%'); + } + + public function lightness($color){ + $c = $color->toHSL(); + return new Less_Tree_Dimension(Less_Parser::round($c['l'] * 100), '%'); + } + + public function hsvhue( $color ){ + $hsv = $color->toHSV(); + return new Less_Tree_Dimension( Less_Parser::round($hsv['h']) ); + } + + + public function hsvsaturation( $color ){ + $hsv = $color->toHSV(); + return new Less_Tree_Dimension( Less_Parser::round($hsv['s'] * 100), '%' ); + } + + public function hsvvalue( $color ){ + $hsv = $color->toHSV(); + return new Less_Tree_Dimension( Less_Parser::round($hsv['v'] * 100), '%' ); + } + + public function red($color) { + return new Less_Tree_Dimension( $color->rgb[0] ); + } + + public function green($color) { + return new Less_Tree_Dimension( $color->rgb[1] ); + } + + public function blue($color) { + return new Less_Tree_Dimension( $color->rgb[2] ); + } + + public function alpha($color){ + $c = $color->toHSL(); + return new Less_Tree_Dimension($c['a']); + } + + public function luma ($color) { + return new Less_Tree_Dimension(Less_Parser::round( $color->luma() * $color->alpha * 100), '%'); + } + + public function saturate($color, $amount = null){ + // filter: saturate(3.2); + // should be kept as is, so check for color + if( !property_exists($color,'rgb') ){ + return null; + } + $hsl = $color->toHSL(); + + $hsl['s'] += $amount->value / 100; + $hsl['s'] = self::clamp($hsl['s']); + + return $this->hsla($hsl['h'], $hsl['s'], $hsl['l'], $hsl['a']); + } + + public function desaturate($color, $amount){ + $hsl = $color->toHSL(); + + $hsl['s'] -= $amount->value / 100; + $hsl['s'] = self::clamp($hsl['s']); + + return $this->hsla($hsl['h'], $hsl['s'], $hsl['l'], $hsl['a']); + } + + + + public function lighten($color, $amount){ + $hsl = $color->toHSL(); + + $hsl['l'] += $amount->value / 100; + $hsl['l'] = self::clamp($hsl['l']); + + return $this->hsla($hsl['h'], $hsl['s'], $hsl['l'], $hsl['a']); + } + + public function darken($color, $amount){ + + if( $color instanceof Less_Tree_Color ){ + $hsl = $color->toHSL(); + $hsl['l'] -= $amount->value / 100; + $hsl['l'] = self::clamp($hsl['l']); + + return $this->hsla($hsl['h'], $hsl['s'], $hsl['l'], $hsl['a']); + } + + Less_Functions::Expected('color',$color); + } + + public function fadein($color, $amount){ + $hsl = $color->toHSL(); + $hsl['a'] += $amount->value / 100; + $hsl['a'] = self::clamp($hsl['a']); + return $this->hsla($hsl['h'], $hsl['s'], $hsl['l'], $hsl['a']); + } + + public function fadeout($color, $amount){ + $hsl = $color->toHSL(); + $hsl['a'] -= $amount->value / 100; + $hsl['a'] = self::clamp($hsl['a']); + return $this->hsla($hsl['h'], $hsl['s'], $hsl['l'], $hsl['a']); + } + + public function fade($color, $amount){ + $hsl = $color->toHSL(); + + $hsl['a'] = $amount->value / 100; + $hsl['a'] = self::clamp($hsl['a']); + return $this->hsla($hsl['h'], $hsl['s'], $hsl['l'], $hsl['a']); + } + + + + public function spin($color, $amount){ + $hsl = $color->toHSL(); + $hue = fmod($hsl['h'] + $amount->value, 360); + + $hsl['h'] = $hue < 0 ? 360 + $hue : $hue; + + return $this->hsla($hsl['h'], $hsl['s'], $hsl['l'], $hsl['a']); + } + + // + // Copyright (c) 2006-2009 Hampton Catlin, Nathan Weizenbaum, and Chris Eppstein + // http://sass-lang.com + // + public function mix($color1, $color2, $weight = null){ + if (!$weight) { + $weight = new Less_Tree_Dimension('50', '%'); + } + + $p = $weight->value / 100.0; + $w = $p * 2 - 1; + $hsl1 = $color1->toHSL(); + $hsl2 = $color2->toHSL(); + $a = $hsl1['a'] - $hsl2['a']; + + $w1 = (((($w * $a) == -1) ? $w : ($w + $a) / (1 + $w * $a)) + 1) / 2; + $w2 = 1 - $w1; + + $rgb = array($color1->rgb[0] * $w1 + $color2->rgb[0] * $w2, + $color1->rgb[1] * $w1 + $color2->rgb[1] * $w2, + $color1->rgb[2] * $w1 + $color2->rgb[2] * $w2); + + $alpha = $color1->alpha * $p + $color2->alpha * (1 - $p); + + return new Less_Tree_Color($rgb, $alpha); + } + + public function greyscale($color){ + return $this->desaturate($color, new Less_Tree_Dimension(100)); + } + + + public function contrast( $color, $dark = false, $light = false, $threshold = false) { + // filter: contrast(3.2); + // should be kept as is, so check for color + if( !property_exists($color,'rgb') ){ + return null; + } + if( $light === false ){ + $light = $this->rgba(255, 255, 255, 1.0); + } + if( $dark === false ){ + $dark = $this->rgba(0, 0, 0, 1.0); + } + //Figure out which is actually light and dark! + if( $dark->luma() > $light->luma() ){ + $t = $light; + $light = $dark; + $dark = $t; + } + if( $threshold === false ){ + $threshold = 0.43; + } else { + $threshold = Less_Functions::number($threshold); + } + + if( ($color->luma() * $color->alpha) < $threshold ){ + return $light; + } else { + return $dark; + } + } + + public function e ($str){ + return new Less_Tree_Anonymous($str instanceof Less_Tree_JavaScript ? $str->evaluated : $str); + } + + public function escape ($str){ + + $revert = array('%21'=>'!', '%2A'=>'*', '%27'=>"'",'%3F'=>'?','%26'=>'&','%2C'=>',','%2F'=>'/','%40'=>'@','%2B'=>'+','%24'=>'$'); + + return new Less_Tree_Anonymous(strtr(rawurlencode($str->value), $revert)); + } + + + public function _percent(){ + $quoted = func_get_arg(0); + + $args = func_get_args(); + array_shift($args); + $str = $quoted->value; + + foreach($args as $arg){ + if( preg_match('/%[sda]/i',$str, $token) ){ + $token = $token[0]; + $value = stristr($token, 's') ? $arg->value : $arg->toCSS(); + $value = preg_match('/[A-Z]$/', $token) ? urlencode($value) : $value; + $str = preg_replace('/%[sda]/i',$value, $str, 1); + } + } + $str = str_replace('%%', '%', $str); + + return new Less_Tree_Quoted('"' . $str . '"', $str); + } + + public function unit($val, $unit = null ){ + if( !($val instanceof Less_Tree_Dimension) ){ + throw new Less_Exception_Compiler('The first argument to unit must be a number' . ($val instanceof Less_Tree_Operation ? '. Have you forgotten parenthesis?' : '.') ); + } + return new Less_Tree_Dimension($val->value, $unit ? $unit->toCSS() : ""); + } + + public function convert($val, $unit){ + return $val->convertTo($unit->value); + } + + public function round($n, $f = false) { + + $fraction = 0; + if( $f !== false ){ + $fraction = $f->value; + } + + return $this->_math('Less_Parser::round',null, $n, $fraction); + } + + public function pi(){ + return new Less_Tree_Dimension(M_PI); + } + + public function mod($a, $b) { + return new Less_Tree_Dimension( $a->value % $b->value, $a->unit); + } + + + + public function pow($x, $y) { + if( is_numeric($x) && is_numeric($y) ){ + $x = new Less_Tree_Dimension($x); + $y = new Less_Tree_Dimension($y); + }elseif( !($x instanceof Less_Tree_Dimension) || !($y instanceof Less_Tree_Dimension) ){ + throw new Less_Exception_Compiler('Arguments must be numbers'); + } + + return new Less_Tree_Dimension( pow($x->value, $y->value), $x->unit ); + } + + // var mathFunctions = [{name:"ce ... + public function ceil( $n ){ return $this->_math('ceil', null, $n); } + public function floor( $n ){ return $this->_math('floor', null, $n); } + public function sqrt( $n ){ return $this->_math('sqrt', null, $n); } + public function abs( $n ){ return $this->_math('abs', null, $n); } + + public function tan( $n ){ return $this->_math('tan', '', $n); } + public function sin( $n ){ return $this->_math('sin', '', $n); } + public function cos( $n ){ return $this->_math('cos', '', $n); } + + public function atan( $n ){ return $this->_math('atan', 'rad', $n); } + public function asin( $n ){ return $this->_math('asin', 'rad', $n); } + public function acos( $n ){ return $this->_math('acos', 'rad', $n); } + + private function _math() { + $args = func_get_args(); + $fn = array_shift($args); + $unit = array_shift($args); + + if ($args[0] instanceof Less_Tree_Dimension) { + + if( $unit === null ){ + $unit = $args[0]->unit; + }else{ + $args[0] = $args[0]->unify(); + } + $args[0] = (float)$args[0]->value; + return new Less_Tree_Dimension( call_user_func_array($fn, $args), $unit); + } else if (is_numeric($args[0])) { + return call_user_func_array($fn,$args); + } else { + throw new Less_Exception_Compiler("math functions take numbers as parameters"); + } + } + + function _minmax( $isMin, $args ){ + + switch( count($args) ){ + case 0: throw new Less_Exception_Compiler( 'one or more arguments required'); + case 1: return $args[0]; + } + + $order = array(); // elems only contains original argument values. + $values = array(); // key is the unit.toString() for unified tree.Dimension values, + // value is the index into the order array. + + for( $i = 0; $i < count($args); $i++ ){ + $current = $args[$i]; + if( !($current instanceof Less_Tree_Dimension) ){ + $order[] = $current; + continue; + } + $currentUnified = $current->unify(); + $unit = $currentUnified->unit->toString(); + + if( !isset($values[$unit]) ){ + $values[$unit] = count($order); + $order[] = $current; + continue; + } + + $j = $values[$unit]; + $referenceUnified = $order[$j]->unify(); + if( ($isMin && $currentUnified->value < $referenceUnified->value) || (!$isMin && $currentUnified->value > $referenceUnified->value) ){ + $order[$j] = $current; + } + } + if( count($order) == 1 ){ + return $order[0]; + } + + foreach($order as $k => $a){ + $order[$k] = $a->toCSS( $this->env ); + } + + $args = implode( Less_Environment::$comma_space, $order); + + return new Less_Tree_Anonymous( ($isMin ? 'min' : 'max') . '(' . $args . ')'); + } + + public function min(){ + return $this->_minmax(true, func_get_args() ); + } + + public function max(){ + return $this->_minmax(false, func_get_args() ); + } + + public function argb($color) { + return new Less_Tree_Anonymous($color->toARGB()); + } + + public function percentage($n) { + return new Less_Tree_Dimension($n->value * 100, '%'); + } + + public function color($n) { + + if( $n instanceof Less_Tree_Quoted ){ + $colorCandidate = $n->value; + $returnColor = Less_Tree_Color::fromKeyword($colorCandidate); + if( $returnColor ){ + return $returnColor; + } + if( preg_match('/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})/',$colorCandidate) ){ + return new Less_Tree_Color(substr($colorCandidate, 1)); + } + throw new Less_Exception_Compiler("argument must be a color keyword or 3/6 digit hex e.g. #FFF"); + } else { + throw new Less_Exception_Compiler("argument must be a string"); + } + } + + + public function iscolor($n) { + return $this->_isa($n, 'Less_Tree_Color'); + } + + public function isnumber($n) { + return $this->_isa($n, 'Less_Tree_Dimension'); + } + + public function isstring($n) { + return $this->_isa($n, 'Less_Tree_Quoted'); + } + + public function iskeyword($n) { + return $this->_isa($n, 'Less_Tree_Keyword'); + } + + public function isurl($n) { + return $this->_isa($n, 'Less_Tree_Url'); + } + + public function ispixel($n) { + return $this->isunit($n, 'px'); + } + + public function ispercentage($n) { + return $this->isunit($n, '%'); + } + + public function isem($n) { + return $this->isunit($n, 'em'); + } + + public function isunit( $n, $unit ){ + return ($n instanceof Less_Tree_Dimension) && $n->unit->is( ( property_exists($unit,'value') ? $unit->value : $unit) ) ? new Less_Tree_Keyword('true') : new Less_Tree_Keyword('false'); + } + + private function _isa($n, $type) { + return is_a($n, $type) ? new Less_Tree_Keyword('true') : new Less_Tree_Keyword('false'); + } + + /* Blending modes */ + + public function multiply($color1, $color2) { + $r = $color1->rgb[0] * $color2->rgb[0] / 255; + $g = $color1->rgb[1] * $color2->rgb[1] / 255; + $b = $color1->rgb[2] * $color2->rgb[2] / 255; + return $this->rgb($r, $g, $b); + } + + public function screen($color1, $color2) { + $r = 255 - (255 - $color1->rgb[0]) * (255 - $color2->rgb[0]) / 255; + $g = 255 - (255 - $color1->rgb[1]) * (255 - $color2->rgb[1]) / 255; + $b = 255 - (255 - $color1->rgb[2]) * (255 - $color2->rgb[2]) / 255; + return $this->rgb($r, $g, $b); + } + + public function overlay($color1, $color2) { + $r = $color1->rgb[0] < 128 ? 2 * $color1->rgb[0] * $color2->rgb[0] / 255 : 255 - 2 * (255 - $color1->rgb[0]) * (255 - $color2->rgb[0]) / 255; + $g = $color1->rgb[1] < 128 ? 2 * $color1->rgb[1] * $color2->rgb[1] / 255 : 255 - 2 * (255 - $color1->rgb[1]) * (255 - $color2->rgb[1]) / 255; + $b = $color1->rgb[2] < 128 ? 2 * $color1->rgb[2] * $color2->rgb[2] / 255 : 255 - 2 * (255 - $color1->rgb[2]) * (255 - $color2->rgb[2]) / 255; + return $this->rgb($r, $g, $b); + } + + public function softlight($color1, $color2) { + $t = $color2->rgb[0] * $color1->rgb[0] / 255; + $r = $t + $color1->rgb[0] * (255 - (255 - $color1->rgb[0]) * (255 - $color2->rgb[0]) / 255 - $t) / 255; + $t = $color2->rgb[1] * $color1->rgb[1] / 255; + $g = $t + $color1->rgb[1] * (255 - (255 - $color1->rgb[1]) * (255 - $color2->rgb[1]) / 255 - $t) / 255; + $t = $color2->rgb[2] * $color1->rgb[2] / 255; + $b = $t + $color1->rgb[2] * (255 - (255 - $color1->rgb[2]) * (255 - $color2->rgb[2]) / 255 - $t) / 255; + return $this->rgb($r, $g, $b); + } + + public function hardlight($color1, $color2) { + $r = $color2->rgb[0] < 128 ? 2 * $color2->rgb[0] * $color1->rgb[0] / 255 : 255 - 2 * (255 - $color2->rgb[0]) * (255 - $color1->rgb[0]) / 255; + $g = $color2->rgb[1] < 128 ? 2 * $color2->rgb[1] * $color1->rgb[1] / 255 : 255 - 2 * (255 - $color2->rgb[1]) * (255 - $color1->rgb[1]) / 255; + $b = $color2->rgb[2] < 128 ? 2 * $color2->rgb[2] * $color1->rgb[2] / 255 : 255 - 2 * (255 - $color2->rgb[2]) * (255 - $color1->rgb[2]) / 255; + return $this->rgb($r, $g, $b); + } + + public function difference($color1, $color2) { + $r = abs($color1->rgb[0] - $color2->rgb[0]); + $g = abs($color1->rgb[1] - $color2->rgb[1]); + $b = abs($color1->rgb[2] - $color2->rgb[2]); + return $this->rgb($r, $g, $b); + } + + public function exclusion($color1, $color2) { + $r = $color1->rgb[0] + $color2->rgb[0] * (255 - $color1->rgb[0] - $color1->rgb[0]) / 255; + $g = $color1->rgb[1] + $color2->rgb[1] * (255 - $color1->rgb[1] - $color1->rgb[1]) / 255; + $b = $color1->rgb[2] + $color2->rgb[2] * (255 - $color1->rgb[2] - $color1->rgb[2]) / 255; + return $this->rgb($r, $g, $b); + } + + public function average($color1, $color2) { + $r = ($color1->rgb[0] + $color2->rgb[0]) / 2; + $g = ($color1->rgb[1] + $color2->rgb[1]) / 2; + $b = ($color1->rgb[2] + $color2->rgb[2]) / 2; + return $this->rgb($r, $g, $b); + } + + public function negation($color1, $color2) { + $r = 255 - abs(255 - $color2->rgb[0] - $color1->rgb[0]); + $g = 255 - abs(255 - $color2->rgb[1] - $color1->rgb[1]); + $b = 255 - abs(255 - $color2->rgb[2] - $color1->rgb[2]); + return $this->rgb($r, $g, $b); + } + + public function tint($color, $amount) { + return $this->mix( $this->rgb(255,255,255), $color, $amount); + } + + public function shade($color, $amount) { + return $this->mix($this->rgb(0, 0, 0), $color, $amount); + } + + public function extract($values, $index ){ + $index = (int)$index->value - 1; // (1-based index) + // handle non-array values as an array of length 1 + // return 'undefined' if index is invalid + if( property_exists($values,'value') && is_array($values->value) ){ + if( isset($values->value[$index]) ){ + return $values->value[$index]; + } + return null; + + }elseif( (int)$index === 0 ){ + return $values; + } + + return null; + } + + function length($values){ + $n = (property_exists($values,'value') && is_array($values->value)) ? count($values->value) : 1; + return new Less_Tree_Dimension($n); + } + + function datauri($mimetypeNode, $filePathNode = null ) { + + $filePath = ( $filePathNode ? $filePathNode->value : null ); + $mimetype = $mimetypeNode->value; + $useBase64 = false; + + $args = 2; + if( !$filePath ){ + $filePath = $mimetype; + $args = 1; + } + + $filePath = str_replace('\\','/',$filePath); + if( Less_Environment::isPathRelative($filePath) ){ + + if( $this->env->relativeUrls ){ + $temp = $this->env->currentFileInfo['currentDirectory']; + } else { + $temp = $this->env->currentFileInfo['entryPath']; + } + + if( !empty($temp) ){ + $filePath = Less_Environment::normalizePath(rtrim($temp,'/').'/'.$filePath); + } + + } + + + // detect the mimetype if not given + if( $args < 2 ){ + + /* incomplete + $mime = require('mime'); + mimetype = mime.lookup(path); + + // use base 64 unless it's an ASCII or UTF-8 format + var charset = mime.charsets.lookup(mimetype); + useBase64 = ['US-ASCII', 'UTF-8'].indexOf(charset) < 0; + if (useBase64) mimetype += ';base64'; + */ + + $mimetype = Less_Mime::lookup($filePath); + + $charset = Less_Mime::charsets_lookup($mimetype); + $useBase64 = !in_array($charset,array('US-ASCII', 'UTF-8')); + if( $useBase64 ){ $mimetype .= ';base64'; } + + }else{ + $useBase64 = preg_match('/;base64$/',$mimetype); + } + + + if( file_exists($filePath) ){ + $buf = @file_get_contents($filePath); + }else{ + $buf = false; + } + + + // IE8 cannot handle a data-uri larger than 32KB. If this is exceeded + // and the --ieCompat flag is enabled, return a normal url() instead. + $DATA_URI_MAX_KB = 32; + $fileSizeInKB = round( strlen($buf) / 1024 ); + if( $fileSizeInKB >= $DATA_URI_MAX_KB ){ + $url = new Less_Tree_Url( ($filePathNode ? $filePathNode : $mimetypeNode), $this->currentFileInfo); + return $url->compile($this); + } + + if( $buf ){ + $buf = $useBase64 ? base64_encode($buf) : rawurlencode($buf); + $filePath = "'data:" . $mimetype . ',' . $buf . "'"; + } + + return new Less_Tree_Url( new Less_Tree_Anonymous($filePath) ); + } + + //svg-gradient + function svggradient( $direction ){ + + $throw_message = 'svg-gradient expects direction, start_color [start_position], [color position,]..., end_color [end_position]'; + $arguments = func_get_args(); + + if( count($arguments) < 3 ){ + throw new Less_Exception_Compiler( $throw_message ); + } + + $stops = array_slice($arguments,1); + $gradientType = 'linear'; + $rectangleDimension = 'x="0" y="0" width="1" height="1"'; + $useBase64 = true; + $renderEnv = new Less_Environment(); + $directionValue = $direction->toCSS($renderEnv); + + + switch( $directionValue ){ + case "to bottom": + $gradientDirectionSvg = 'x1="0%" y1="0%" x2="0%" y2="100%"'; + break; + case "to right": + $gradientDirectionSvg = 'x1="0%" y1="0%" x2="100%" y2="0%"'; + break; + case "to bottom right": + $gradientDirectionSvg = 'x1="0%" y1="0%" x2="100%" y2="100%"'; + break; + case "to top right": + $gradientDirectionSvg = 'x1="0%" y1="100%" x2="100%" y2="0%"'; + break; + case "ellipse": + case "ellipse at center": + $gradientType = "radial"; + $gradientDirectionSvg = 'cx="50%" cy="50%" r="75%"'; + $rectangleDimension = 'x="-50" y="-50" width="101" height="101"'; + break; + default: + throw new Less_Exception_Compiler( "svg-gradient direction must be 'to bottom', 'to right', 'to bottom right', 'to top right' or 'ellipse at center'" ); + } + + $returner = '<?xml version="1.0" ?>' . + '<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="100%" height="100%" viewBox="0 0 1 1" preserveAspectRatio="none">' . + '<' . $gradientType . 'Gradient id="gradient" gradientUnits="userSpaceOnUse" ' . $gradientDirectionSvg . '>'; + + for( $i = 0; $i < count($stops); $i++ ){ + if( is_object($stops[$i]) && property_exists($stops[$i],'value') ){ + $color = $stops[$i]->value[0]; + $position = $stops[$i]->value[1]; + }else{ + $color = $stops[$i]; + $position = null; + } + + if( !($color instanceof Less_Tree_Color) || (!(($i === 0 || $i+1 === count($stops)) && $position === null) && !($position instanceof Less_Tree_Dimension)) ){ + throw new Less_Exception_Compiler( $throw_message ); + } + if( $position ){ + $positionValue = $position->toCSS($renderEnv); + }elseif( $i === 0 ){ + $positionValue = '0%'; + }else{ + $positionValue = '100%'; + } + $alpha = $color->alpha; + $returner .= '<stop offset="' . $positionValue . '" stop-color="' . $color->toRGB() . '"' . ($alpha < 1 ? ' stop-opacity="' . $alpha . '"' : '') . '/>'; + } + + $returner .= '</' . $gradientType . 'Gradient><rect ' . $rectangleDimension . ' fill="url(#gradient)" /></svg>'; + + + if( $useBase64 ){ + // only works in node, needs interface to what is supported in environment + try{ + $returner = base64_encode($returner); + }catch(Exception $e){ + $useBase64 = false; + } + } + + $returner = "'data:image/svg+xml" . ($useBase64 ? ";base64" : "") . "," . $returner . "'"; + return new Less_Tree_URL( new Less_Tree_Anonymous( $returner ) ); + } + + + private static function Expected( $type, $arg ){ + + $debug = debug_backtrace(); + array_shift($debug); + $last = array_shift($debug); + $last = array_intersect_key($last,array('function'=>'','class'=>'','line'=>'')); + + $message = 'Object of type '.get_class($arg).' passed to darken function. Expecting `Color`. '.$arg->toCSS().'. '.print_r($last,true); + throw new Less_Exception_Compiler($message); + + } + +} diff --git a/lib/Less/LICENSE b/lib/Less/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..82216a5da4551160b4892a32a296720ba21aa7f4 --- /dev/null +++ b/lib/Less/LICENSE @@ -0,0 +1,178 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + diff --git a/lib/Less/Less.php.combine b/lib/Less/Less.php.combine new file mode 100644 index 0000000000000000000000000000000000000000..af1c4cfac489af12445ca5d781d0e0a4cae23205 --- /dev/null +++ b/lib/Less/Less.php.combine @@ -0,0 +1,12 @@ + +./Parser.php +./Colors.php +./Environment.php +./Functions.php +./Mime.php +./Tree.php +./Visitor.php +./VisitorReplacing.php +./Tree +./Visitor +./Exception diff --git a/lib/Less/Less_Cache.php b/lib/Less/Less_Cache.php new file mode 100644 index 0000000000000000000000000000000000000000..94c90e0fa6cf5d96dba039d0d6d2fb3d2c3bee26 --- /dev/null +++ b/lib/Less/Less_Cache.php @@ -0,0 +1,3 @@ +<?php + +require_once dirname(__FILE__).'/Cache.php'; \ No newline at end of file diff --git a/lib/Less/Mime.php b/lib/Less/Mime.php new file mode 100644 index 0000000000000000000000000000000000000000..22cc68ae76a1b53bd0cff9b6fcd90b884ed5d900 --- /dev/null +++ b/lib/Less/Mime.php @@ -0,0 +1,32 @@ +<?php + +//less.js : lib/less/functions.js + +class Less_Mime{ + + // this map is intentionally incomplete + // if you want more, install 'mime' dep + static $_types = array( + '.htm' => 'text/html', + '.html'=> 'text/html', + '.gif' => 'image/gif', + '.jpg' => 'image/jpeg', + '.jpeg'=> 'image/jpeg', + '.png' => 'image/png' + ); + + static function lookup( $filepath ){ + $parts = explode('.',$filepath); + $ext = '.'.strtolower(array_pop($parts)); + + if( !isset(self::$_types[$ext]) ){ + return null; + } + return self::$_types[$ext]; + } + + static function charsets_lookup( $type = false ){ + // assumes all text types are UTF-8 + return $type && preg_match('/^text\//',$type) ? 'UTF-8' : ''; + } +} \ No newline at end of file diff --git a/lib/Less/Parser.php b/lib/Less/Parser.php new file mode 100644 index 0000000000000000000000000000000000000000..fdd4ed30090da054f729e6c93c5f19308c39300d --- /dev/null +++ b/lib/Less/Parser.php @@ -0,0 +1,2014 @@ +<?php + +require_once( dirname(__FILE__).'/Cache.php'); + +class Less_Parser extends Less_Cache{ + + + private $input; // LeSS input string + private $input_len; // input string length + private $pos; // current index in `input` + private $memo; // temporarily holds `i`, when backtracking + + + /** + * @var string + */ + private $path; + + /** + * @var string + */ + private $filename; + + + /** + * + */ + const version = '1.5.1'; + const less_version = '1.5.1'; + + /** + * @var Less_Environment + */ + private $env; + private $rules = array(); + + private static $imports = array(); + + public static $has_extends = false; + + public $cache_method = 'php'; //false, 'serialize', 'php', 'var_export'; + + public static $next_id = 0; + + + /** + * @param Environment|null $env + */ + public function __construct( $env = null ){ + + + // Top parser on an import tree must be sure there is one "env" + // which will then be passed around by reference. + if( $env instanceof Less_Environment ){ + $this->env = $env; + }else{ + $this->env = new Less_Environment( $env ); + self::$imports = array(); + self::$import_dirs = array(); + if( is_array($env) ){ + $this->SetOptions($env); + } + } + + $this->pos = 0; + } + + // options: import_dirs, compress, cache_dir, cache_method, strictUnits + public function SetOptions( $options ){ + foreach($options as $option => $value){ + $this->SetOption($option,$value); + } + } + + public function SetOption($option,$value){ + + switch($option){ + + case 'import_dirs': + $this->SetImportDirs($value); + break; + + case 'cache_dir': + $this->SetCacheDir($value); + break; + + case 'cache_method': + if( in_array($value, array('php','serialize','var_export')) ){ + $this->cache_method = $value; + } + break; + } + } + + + + + /** + * Get the current css buffer + * + * @return string + */ + public function getCss(){ + + $precision = ini_get('precision'); + @ini_set('precision',16); + $locale = setlocale(LC_NUMERIC, 0); + setlocale(LC_NUMERIC, "C"); + + + $root = new Less_Tree_Ruleset(array(), $this->rules ); + $root->root = true; + $root->firstRoot = true; + + + //$importVisitor = new Less_importVisitor(); + //$importVisitor->run($root); + + //obj($root); + + self::$has_extends = false; + + $evaldRoot = $root->compile($this->env); + + + $joinSelector = new Less_Visitor_joinSelector(); + $joinSelector->run($evaldRoot); + + + if( self::$has_extends ){ + $extendsVisitor = new Less_Visitor_processExtends(); + $extendsVisitor->run($evaldRoot); + } + + $toCSSVisitor = new Less_Visitor_toCSS( $this->env ); + $toCSSVisitor->run($evaldRoot); + + $css = $evaldRoot->toCSS($this->env); + + if( Less_Environment::$compress ){ + $css = preg_replace('/(^(\s)+)|((\s)+$)/', '', $css); + } + + //reset php settings + @ini_set('precision',$precision); + setlocale(LC_NUMERIC, $locale); + + return $css; + } + + + /** + * Parse a Less string into css + * + * @param string $str The string to convert + * @param bool $returnRoot Indicates whether the return value should be a css string a root node + * @return Less_Tree_Ruleset|Less_Parser + */ + public function parse($str){ + $this->input = $str; + $this->_parse(); + } + + + /** + * Parse a Less string from a given file + * + * @throws Less_Exception_Parser + * @param $filename The file to parse + * @param $uri_root The url of the file + * @param bool $returnRoot Indicates whether the return value should be a css string a root node + * @return Less_Tree_Ruleset|Less_Parser + */ + public function parseFile( $filename, $uri_root = '', $returnRoot = false){ + + if( !file_exists($filename) ){ + throw new Less_Exception_Parser(sprintf('File `%s` not found.', $filename)); + } + + $previousFileInfo = $this->env->currentFileInfo; + $this->SetFileInfo($filename, $uri_root); + + $previousImportDirs = self::$import_dirs; + self::AddParsedFile($filename); + + $return = null; + if( $returnRoot ){ + $rules = $this->GetRules( $filename ); + $return = new Less_Tree_Ruleset(array(), $rules ); + }else{ + $this->_parse( $filename ); + } + + if( $previousFileInfo ){ + $this->env->currentFileInfo = $previousFileInfo; + } + self::$import_dirs = $previousImportDirs; + + return $return; + } + + + public function SetFileInfo( $filename, $uri_root = ''){ + + $this->path = pathinfo($filename, PATHINFO_DIRNAME); + $this->filename = Less_Environment::normalizePath($filename); + + $dirname = preg_replace('/[^\/\\\\]*$/','',$this->filename); + + $currentFileInfo = array(); + $currentFileInfo['currentDirectory'] = $dirname; + $currentFileInfo['filename'] = $filename; + $currentFileInfo['rootpath'] = $dirname; + $currentFileInfo['entryPath'] = $dirname; + + if( empty($uri_root) ){ + $currentFileInfo['uri_root'] = $uri_root; + }else{ + $currentFileInfo['uri_root'] = rtrim($uri_root,'/').'/'; + } + + + //inherit reference + if( isset($this->env->currentFileInfo['reference']) && $this->env->currentFileInfo['reference'] ){ + $currentFileInfo['reference'] = true; + } + + $this->env->currentFileInfo = $currentFileInfo; + + self::$import_dirs = array_merge( array( $dirname => $currentFileInfo['uri_root'] ), self::$import_dirs ); + } + + public function SetCacheDir( $dir ){ + + if( !file_exists($dir) ){ + if( mkdir($dir) ){ + return true; + } + throw new Less_Exception_Parser('Less.php cache directory couldn\'t be created: '.$dir); + + }elseif( !is_dir($dir) ){ + throw new Less_Exception_Parser('Less.php cache directory doesn\'t exist: '.$dir); + + }elseif( !is_writable($dir) ){ + throw new Less_Exception_Parser('Less.php cache directory isn\'t writable: '.$dir); + + }else{ + $dir = str_replace('\\','/',$dir); + self::$cache_dir = rtrim($dir,'/').'/'; + return true; + } + } + + public function SetImportDirs( $dirs ){ + + foreach($dirs as $path => $uri_root){ + + $path = str_replace('\\','/',$path); + if( !empty($path) ){ + $path = rtrim($path,'/').'/'; + } + + if ( !is_callable($uri_root) ){ + $uri_root = str_replace('\\','/',$uri_root); + if( !empty($uri_root) ){ + $uri_root = rtrim($uri_root,'/').'/'; + } + } + + self::$import_dirs[$path] = $uri_root; + } + } + + private function _parse( $file_path = false ){ + $this->rules = array_merge($this->rules, $this->GetRules( $file_path )); + } + + + /** + * Return the results of parsePrimary for $file_path + * Use cache and save cached results if possible + * + */ + private function GetRules( $file_path ){ + + $cache_file = false; + if( $file_path ){ + if( $this->cache_method ){ + $cache_file = $this->CacheFile( $file_path ); + + if( $cache_file && file_exists($cache_file) ){ + switch($this->cache_method){ + + // Using serialize + // Faster but uses more memory + case 'serialize': + $cache = unserialize(file_get_contents($cache_file)); + if( $cache ){ + touch($cache_file); + return $cache; + } + break; + + + // Using generated php code + case 'var_export': + case 'php': + return include($cache_file); + } + } + } + + $this->input = file_get_contents( $file_path ); + } + + $this->pos = 0; + + // Remove potential UTF Byte Order Mark + $this->input = preg_replace('/\\G\xEF\xBB\xBF/', '', $this->input); + $this->input_len = strlen($this->input); + + $rules = $this->parsePrimary(); + + + // free up a little memory + unset($this->input, $this->pos); + + + //save the cache + if( $cache_file && $this->cache_method ){ + + switch($this->cache_method){ + case 'serialize': + file_put_contents( $cache_file, serialize($rules) ); + break; + case 'php': + file_put_contents( $cache_file, '<?php return '.self::ArgString($rules).'; ?>' ); + break; + case 'var_export': + /** + * Requires __set_state() + */ + file_put_contents( $cache_file, '<?php return '.var_export($rules,true).'; ?>' ); + break; + } + + if( self::$clean_cache ){ + self::CleanCache(); + } + + } + + return $rules; + } + + + public function CacheFile( $file_path ){ + + if( $file_path && self::$cache_dir ){ + + $env = get_object_vars($this->env); + unset($env['frames']); + + $parts = array(); + $parts[] = $file_path; + $parts[] = filesize( $file_path ); + $parts[] = filemtime( $file_path ); + $parts[] = $env; + $parts[] = self::cache_version; + $parts[] = $this->cache_method; + return self::$cache_dir.'lessphp_'.base_convert( sha1(json_encode($parts) ), 16, 36).'.lesscache'; + } + } + + + static function AddParsedFile($file){ + self::$imports[] = $file; + } + + static function AllParsedFiles(){ + return self::$imports; + } + + static function FileParsed($file){ + return in_array($file,self::$imports); + } + + + function save() { + $this->memo = $this->pos; + } + + private function restore() { + $this->pos = $this->memo; + } + + + private function isWhitespace($offset = 0) { + return preg_match('/\s/',$this->input[ $this->pos + $offset]); + } + + /** + * Parse from a token, regexp or string, and move forward if match + * + * @param string $tok + * @return null|bool|object + */ + private function match($toks){ + + // The match is confirmed, add the match length to `this::pos`, + // and consume any extra white-space characters (' ' || '\n') + // which come after that. The reason for this is that LeSS's + // grammar is mostly white-space insensitive. + // + + foreach($toks as $tok){ + + $char = $tok[0]; + + if( $char === '/' ){ + $match = $this->MatchReg($tok); + + if( $match ){ + return count($match) === 1 ? $match[0] : $match; + } + + }elseif( $char === '#' ){ + $match = $this->MatchChar($tok[1]); + + }else{ + // Non-terminal, match using a function call + $match = $this->$tok(); + + } + + if( $match ){ + return $match; + } + } + } + + private function MatchFuncs($toks){ + + foreach($toks as $tok){ + $match = $this->$tok(); + if( $match ){ + return $match; + } + } + + } + + // Match a single character in the input, + private function MatchChar($tok){ + if( ($this->pos < $this->input_len) && ($this->input[$this->pos] === $tok) ){ + $this->skipWhitespace(1); + return $tok; + } + } + + // Match a regexp from the current start point + private function MatchReg($tok){ + + if( preg_match($tok, $this->input, $match, 0, $this->pos) ){ + $this->skipWhitespace(strlen($match[0])); + return $match; + } + } + + + /** + * Same as match(), but don't change the state of the parser, + * just return the match. + * + * @param $tok + * @param int $offset + * @return bool + */ + public function PeekReg($tok){ + return preg_match($tok, $this->input, $match, 0, $this->pos); + } + + public function PeekChar($tok){ + return ($this->input[$this->pos] === $tok ); + //return ($this->pos < $this->input_len) && ($this->input[$this->pos] === $tok ); + } + + + public function skipWhitespace($length){ + + $this->pos += $length; + + for(; $this->pos < $this->input_len; $this->pos++ ){ + $c = $this->input[$this->pos]; + + if( ($c !== "\n") && ($c !== "\r") && ($c !== "\t") && ($c !== ' ') ){ + break; + } + } + } + + + public function expect($tok, $msg = NULL) { + $result = $this->match( array($tok) ); + if (!$result) { + throw new Less_Exception_Parser( $msg ? "Expected '" . $tok . "' got '" . $this->input[$this->pos] . "'" : $msg ); + } else { + return $result; + } + } + + public function expectChar($tok, $msg = null ){ + $result = $this->MatchChar($tok); + if( !$result ){ + throw new Less_Exception_Parser( $msg ? "Expected '" . $tok . "' got '" . $this->input[$this->pos] . "'" : $msg ); + }else{ + return $result; + } + } + + // + // Here in, the parsing rules/functions + // + // The basic structure of the syntax tree generated is as follows: + // + // Ruleset -> Rule -> Value -> Expression -> Entity + // + // Here's some LESS code: + // + // .class { + // color: #fff; + // border: 1px solid #000; + // width: @w + 4px; + // > .child {...} + // } + // + // And here's what the parse tree might look like: + // + // Ruleset (Selector '.class', [ + // Rule ("color", Value ([Expression [Color #fff]])) + // Rule ("border", Value ([Expression [Dimension 1px][Keyword "solid"][Color #000]])) + // Rule ("width", Value ([Expression [Operation "+" [Variable "@w"][Dimension 4px]]])) + // Ruleset (Selector [Element '>', '.child'], [...]) + // ]) + // + // In general, most rules will try to parse a token with the `$()` function, and if the return + // value is truly, will return a new node, of the relevant type. Sometimes, we need to check + // first, before parsing, that's when we use `peek()`. + // + + // + // The `primary` rule is the *entry* and *exit* point of the parser. + // The rules here can appear at any level of the parse tree. + // + // The recursive nature of the grammar is an interplay between the `block` + // rule, which represents `{ ... }`, the `ruleset` rule, and this `primary` rule, + // as represented by this simplified grammar: + // + // primary → (ruleset | rule)+ + // ruleset → selector+ block + // block → '{' primary '}' + // + // Only at one point is the primary rule not called from the + // block rule: at the root level. + // + private function parsePrimary(){ + $root = array(); + + while( true ){ + + if( $this->pos >= $this->input_len ){ + break; + } + + $node = $this->parseExtend(true); + if( $node ){ + $root = array_merge($root,$node); + continue; + } + + $node = $this->MatchFuncs( array( 'parseMixinDefinition', 'parseRule', 'parseRuleset', 'parseMixinCall', 'parseComment', 'parseDirective')); + + if( $node ){ + $root[] = $node; + }elseif( !$this->MatchReg('/\\G[\s\n;]+/') ){ + break; + } + + } + + return $root; + } + + + + // We create a Comment node for CSS comments `/* */`, + // but keep the LeSS comments `//` silent, by just skipping + // over them. + private function parseComment(){ + + if( $this->input[$this->pos] !== '/' ){ + return; + } + + if( $this->input[$this->pos+1] === '/' ){ + $match = $this->MatchReg('/\\G\/\/.*/'); + return $this->Less_Tree_Comment($match[0], true, $this->pos, $this->env->currentFileInfo); + } + + //$comment = $this->MatchReg('/\\G\/\*(?:[^*]|\*+[^\/*])*\*+\/\n?/'); + $comment = $this->MatchReg('/\\G\/\*(?s).*?\*+\/\n?/');//not the same as less.js to prevent fatal errors + if( $comment ){ + return $this->Less_Tree_Comment($comment[0], false, $this->pos, $this->env->currentFileInfo); + } + } + + private function parseComments(){ + $comments = array(); + + while( true ){ + $comment = $this->parseComment(); + if( !$comment ){ + break; + } + + $comments[] = $comment; + } + + return $comments; + } + + + + // + // A string, which supports escaping " and ' + // + // "milky way" 'he\'s the one!' + // + private function parseEntitiesQuoted() { + $j = 0; + $e = false; + $index = $this->pos; + + if ($this->PeekChar('~')) { + $j++; + $e = true; // Escaped strings + } + + $char = $this->input[$this->pos+$j]; + if( $char != '"' && $char !== "'" ){ + return; + } + + if ($e) { + $this->MatchChar('~'); + } + $str = $this->MatchReg('/\\G"((?:[^"\\\\\r\n]|\\\\.)*)"|\'((?:[^\'\\\\\r\n]|\\\\.)*)\'/'); + if( $str ){ + $result = $str[0][0] == '"' ? $str[1] : $str[2]; + return $this->Less_Tree_Quoted($str[0], $result, $e, $index, $this->env->currentFileInfo ); + } + return; + } + + // + // A catch-all word, such as: + // + // black border-collapse + // + private function parseEntitiesKeyword(){ + + $k = $this->MatchReg('/\\G[_A-Za-z-][_A-Za-z0-9-]*/'); + if( $k ){ + $k = $k[0]; + $color = $this->fromKeyword($k); + if( $color ){ + return $color; + } + return $this->Less_Tree_Keyword($k); + } + } + + // duplicate of Less_Tree_Color::FromKeyword + private function FromKeyword( $keyword ){ + if( Less_Colors::hasOwnProperty($keyword) ){ + // detect named color + return $this->Less_Tree_Color(substr(Less_Colors::color($keyword), 1)); + } + + if( $keyword === 'transparent' ){ + $transparent = $this->Less_Tree_Color( array(0, 0, 0), 0); + $transparent->isTransparentKeyword = true; + return $transparent; + } + } + + // + // A function call + // + // rgb(255, 0, 255) + // + // We also try to catch IE's `alpha()`, but let the `alpha` parser + // deal with the details. + // + // The arguments are parsed with the `entities.arguments` parser. + // + private function parseEntitiesCall(){ + $index = $this->pos; + + if( !preg_match('/\\G([\w-]+|%|progid:[\w\.]+)\(/', $this->input, $name,0,$this->pos) ){ + return; + } + $name = $name[1]; + $nameLC = strtolower($name); + + if ($nameLC === 'url') { + return null; + } + + $this->pos += strlen($name); + + if( $nameLC === 'alpha' ){ + $alpha_ret = $this->parseAlpha(); + if( $alpha_ret ){ + return $alpha_ret; + } + } + + $this->MatchChar('('); // Parse the '(' and consume whitespace. + + $args = $this->parseEntitiesArguments(); + + if( !$this->MatchChar(')') ){ + return; + } + + if ($name) { + return $this->Less_Tree_Call($name, $args, $index, $this->env->currentFileInfo ); + } + } + + /** + * Parse a list of arguments + * + * @return array + */ + private function parseEntitiesArguments(){ + + $args = array(); + while( true ){ + $arg = $this->MatchFuncs( array('parseEntitiesAssignment','parseExpression') ); + if( !$arg ){ + break; + } + + $args[] = $arg; + if( !$this->MatchChar(',') ){ + break; + } + } + return $args; + } + + private function parseEntitiesLiteral(){ + return $this->MatchFuncs( array('parseEntitiesDimension','parseEntitiesColor','parseEntitiesQuoted','parseUnicodeDescriptor') ); + } + + // Assignments are argument entities for calls. + // They are present in ie filter properties as shown below. + // + // filter: progid:DXImageTransform.Microsoft.Alpha( *opacity=50* ) + // + private function parseEntitiesAssignment() { + + $key = $this->MatchReg('/\\G\w+(?=\s?=)/'); + if( !$key ){ + return; + } + + if( !$this->MatchChar('=') ){ + return; + } + + $value = $this->parseEntity(); + if( $value ){ + return $this->Less_Tree_Assignment($key[0], $value); + } + } + + // + // Parse url() tokens + // + // We use a specific rule for urls, because they don't really behave like + // standard function calls. The difference is that the argument doesn't have + // to be enclosed within a string, so it can't be parsed as an Expression. + // + private function parseEntitiesUrl(){ + + + if( $this->input[$this->pos] !== 'u' || !$this->matchReg('/\\Gurl\(/') ){ + return; + } + + $value = $this->match( array('parseEntitiesQuoted','parseEntitiesVariable','/\\G(?:(?:\\\\[\(\)\'"])|[^\(\)\'"])+/') ); + if( !$value ){ + $value = ''; + } + + + $this->expectChar(')'); + + + return $this->Less_Tree_Url((isset($value->value) || $value instanceof Less_Tree_Variable) + ? $value : $this->Less_Tree_Anonymous($value), $this->env->currentFileInfo ); + } + + + // + // A Variable entity, such as `@fink`, in + // + // width: @fink + 2px + // + // We use a different parser for variable definitions, + // see `parsers.variable`. + // + private function parseEntitiesVariable(){ + $index = $this->pos; + if ($this->PeekChar('@') && ($name = $this->MatchReg('/\\G@@?[\w-]+/'))) { + return $this->Less_Tree_Variable( $name[0], $index, $this->env->currentFileInfo); + } + } + + + // A variable entity useing the protective {} e.g. @{var} + private function parseEntitiesVariableCurly() { + $index = $this->pos; + + if( $this->input_len > ($this->pos+1) && $this->input[$this->pos] === '@' && ($curly = $this->MatchReg('/\\G@\{([\w-]+)\}/')) ){ + return $this->Less_Tree_Variable('@'.$curly[1], $index, $this->env->currentFileInfo); + } + } + + // + // A Hexadecimal color + // + // #4F3C2F + // + // `rgb` and `hsl` colors are parsed through the `entities.call` parser. + // + private function parseEntitiesColor(){ + if ($this->PeekChar('#') && ($rgb = $this->MatchReg('/\\G#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})/'))) { + return $this->Less_Tree_Color($rgb[1]); + } + } + + // + // A Dimension, that is, a number and a unit + // + // 0.5em 95% + // + private function parseEntitiesDimension(){ + + $c = @ord($this->input[$this->pos]); + + //Is the first char of the dimension 0-9, '.', '+' or '-' + if (($c > 57 || $c < 43) || $c === 47 || $c == 44){ + return; + } + + $value = $this->MatchReg('/\\G([+-]?\d*\.?\d+)(%|[a-z]+)?/'); + if( $value ){ + return $this->Less_Tree_Dimension( $value[1], isset($value[2]) ? $value[2] : null); + } + } + + + // + // A unicode descriptor, as is used in unicode-range + // + // U+0?? or U+00A1-00A9 + // + function parseUnicodeDescriptor() { + $ud = $this->MatchReg('/\\G(U\+[0-9a-fA-F?]+)(\-[0-9a-fA-F?]+)?/'); + if( $ud ){ + return $this->Less_Tree_UnicodeDescriptor( $ud[0]); + } + } + + + // + // JavaScript code to be evaluated + // + // `window.location.href` + // + private function parseEntitiesJavascript(){ + $e = false; + $j = $this->pos; + if( $this->input[$j] === '~' ){ + $j++; + $e = true; + } + if( $this->input[$j] !== '`' ){ + return; + } + if( $e ){ + $this->MatchChar('~'); + } + $str = $this->MatchReg('/\\G`([^`]*)`/'); + if( $str ){ + return $this->Less_Tree_Javascript( $str[1], $this->pos, $e); + } + } + + + // + // The variable part of a variable definition. Used in the `rule` parser + // + // @fink: + // + private function parseVariable(){ + if ($this->PeekChar('@') && ($name = $this->MatchReg('/\\G(@[\w-]+)\s*:/'))) { + return $name[1]; + } + } + + // + // extend syntax - used to extend selectors + // + function parseExtend($isRule = false){ + + $index = $this->pos; + $extendList = array(); + + + if( !$this->MatchReg( $isRule ? '/\\G&:extend\(/' : '/\\G:extend\(/' ) ){ return; } + + do{ + $option = null; + $elements = array(); + while( true ){ + $option = $this->MatchReg('/\\G(all)(?=\s*(\)|,))/'); + if( $option ){ break; } + $e = $this->parseElement(); + if( !$e ){ break; } + $elements[] = $e; + } + + if( $option ){ + $option = $option[1]; + } + + $extendList[] = $this->Less_Tree_Extend( $this->Less_Tree_Selector($elements), $option, $index ); + + }while( $this->MatchChar(",") ); + + $this->expect('/\\G\)/'); + + if( $isRule ){ + $this->expect('/\\G;/'); + } + + return $extendList; + } + + + // + // A Mixin call, with an optional argument list + // + // #mixins > .square(#fff); + // .rounded(4px, black); + // .button; + // + // The `while` loop is there because mixins can be + // namespaced, but we only support the child and descendant + // selector for now. + // + private function parseMixinCall(){ + $elements = array(); + $index = $this->pos; + $important = false; + $args = null; + $c = null; + + $char = $this->input[$this->pos]; + if( $char !== '.' && $char !== '#' ){ + return; + } + + $this->save(); // stop us absorbing part of an invalid selector + + while( true ){ + $e = $this->MatchReg('/\\G[#.](?:[\w-]|\\\\(?:[A-Fa-f0-9]{1,6} ?|[^A-Fa-f0-9]))+/'); + if( !$e ){ + break; + } + $elements[] = $this->Less_Tree_Element($c, $e[0], $this->pos, $this->env->currentFileInfo); + $c = $this->MatchChar('>'); + } + + if( $this->MatchChar('(') ){ + $returned = $this->parseMixinArgs(true); + $args = $returned['args']; + $this->expectChar(')'); + } + + if( !$args ){ + $args = array(); + } + + if( $this->parseImportant() ){ + $important = true; + } + + if( $elements && ($this->MatchChar(';') || $this->PeekChar('}')) ){ + return Less_Parser::Less_Tree_Mixin_Call( $elements, $args, $index, $this->env->currentFileInfo, $important); + } + + $this->restore(); + } + + + private function parseMixinArgs( $isCall ){ + $expressions = array(); + $argsSemiColon = array(); + $isSemiColonSeperated = null; + $argsComma = array(); + $expressionContainsNamed = null; + $name = null; + $nameLoop = null; + $returner = array('args'=>null, 'variadic'=> false); + + while( true ){ + if( $isCall ){ + $arg = $this->parseExpression(); + } else { + $this->parseComments(); + if( $this->input[ $this->pos ] === '.' && $this->MatchReg('/\\G\.{3}/') ){ + $returner['variadic'] = true; + if( $this->MatchChar(";") && !$isSemiColonSeperated ){ + $isSemiColonSeperated = true; + } + + if( $isSemiColonSeperated ){ + $argsSemiColon[] = array('variadic'=>true); + }else{ + $argsComma[] = array('variadic'=>true); + } + break; + } + $arg = $this->MatchFuncs( array('parseEntitiesVariable','parseEntitiesLiteral','parseEntitiesKeyword') ); + } + + + if( !$arg ){ + break; + } + + + $nameLoop = null; + if( $arg instanceof Less_Tree_Expression ){ + $arg->throwAwayComments(); + } + $value = $arg; + $val = null; + + if( $isCall ){ + // Variable + if( count($arg->value) == 1 ){ + $val = $arg->value[0]; + } + } else { + $val = $arg; + } + + + if( $val && $val instanceof Less_Tree_Variable ){ + + if( $this->MatchChar(':') ){ + if( $expressions ){ + if( $isSemiColonSeperated ){ + throw new Less_Exception_Parser('Cannot mix ; and , as delimiter types'); + } + $expressionContainsNamed = true; + } + $value = $this->expect('parseExpression'); + $nameLoop = ($name = $val->name); + }elseif( !$isCall && $this->MatchReg('/\\G\.{3}/') ){ + $returner['variadic'] = true; + if( $this->MatchChar(";") && !$isSemiColonSeperated ){ + $isSemiColonSeperated = true; + } + if( $isSemiColonSeperated ){ + $argsSemiColon[] = array('name'=> $arg->name, 'variadic' => true); + }else{ + $argsComma[] = array('name'=> $arg->name, 'variadic' => true); + } + break; + }elseif( !$isCall ){ + $name = $nameLoop = $val->name; + $value = null; + } + } + + if( $value ){ + $expressions[] = $value; + } + + $argsComma[] = array('name'=>$nameLoop, 'value'=>$value ); + + if( $this->MatchChar(',') ){ + continue; + } + + if( $this->MatchChar(';') || $isSemiColonSeperated ){ + + if( $expressionContainsNamed ){ + throw new Less_Exception_Parser('Cannot mix ; and , as delimiter types'); + } + + $isSemiColonSeperated = true; + + if( count($expressions) > 1 ){ + $value = $this->Less_Tree_Value( $expressions); + } + $argsSemiColon[] = array('name'=>$name, 'value'=>$value ); + + $name = null; + $expressions = array(); + $expressionContainsNamed = false; + } + } + + $returner['args'] = ($isSemiColonSeperated ? $argsSemiColon : $argsComma); + return $returner; + } + + + // + // A Mixin definition, with a list of parameters + // + // .rounded (@radius: 2px, @color) { + // ... + // } + // + // Until we have a finer grained state-machine, we have to + // do a look-ahead, to make sure we don't have a mixin call. + // See the `rule` function for more information. + // + // We start by matching `.rounded (`, and then proceed on to + // the argument list, which has optional default values. + // We store the parameters in `params`, with a `value` key, + // if there is a value, such as in the case of `@radius`. + // + // Once we've got our params list, and a closing `)`, we parse + // the `{...}` block. + // + private function parseMixinDefinition(){ + $params = array(); + $variadic = false; + $cond = null; + + $char = $this->input[$this->pos]; + if( ($char !== '.' && $char !== '#') || ($char === '{' && $this->Peek('/\\G[^{]*\}/')) ){ + return; + } + + $this->save(); + + $match = $this->MatchReg('/\\G([#.](?:[\w-]|\\\(?:[A-Fa-f0-9]{1,6} ?|[^A-Fa-f0-9]))+)\s*\(/'); + if( $match ){ + $name = $match[1]; + + $argInfo = $this->parseMixinArgs( false ); + $params = $argInfo['args']; + $variadic = $argInfo['variadic']; + + + // .mixincall("@{a}"); + // looks a bit like a mixin definition.. so we have to be nice and restore + if( !$this->MatchChar(')') ){ + //furthest = i; + $this->restore(); + } + + $this->parseComments(); + + if ($this->MatchReg('/\\Gwhen/')) { // Guard + $cond = $this->expect('parseConditions', 'Expected conditions'); + } + + $ruleset = $this->parseBlock(); + + if( is_array($ruleset) ){ + return Less_Parser::Less_Tree_Mixin_Definition( $name, $params, $ruleset, $cond, $variadic); + } else { + $this->restore(); + } + } + } + + // + // Entities are the smallest recognized token, + // and can be found inside a rule's value. + // + private function parseEntity(){ + + return $this->MatchFuncs( array('parseEntitiesLiteral','parseEntitiesVariable','parseEntitiesUrl','parseEntitiesCall','parseEntitiesKeyword','parseEntitiesJavascript','parseComment') ); + } + + // + // A Rule terminator. Note that we use `peek()` to check for '}', + // because the `block` rule will be expecting it, but we still need to make sure + // it's there, if ';' was ommitted. + // + private function parseEnd(){ + return $this->MatchChar(';') || $this->PeekChar('}'); + } + + // + // IE's alpha function + // + // alpha(opacity=88) + // + private function parseAlpha(){ + + if ( ! $this->MatchReg('/\\G\(opacity=/i')) { + return; + } + + $value = $this->MatchReg('/\\G[0-9]+/'); + if( $value ){ + $value = $value[0]; + }else{ + $value = $this->parseEntitiesVariable(); + if( !$value ){ + return; + } + } + + $this->expectChar(')'); + return $this->Less_Tree_Alpha( $value); + } + + + // + // A Selector Element + // + // div + // + h1 + // #socks + // input[type="text"] + // + // Elements are the building blocks for Selectors, + // they are made out of a `Combinator` (see combinator rule), + // and an element name, such as a tag a class, or `*`. + // + private function parseElement(){ + $c = $this->parseCombinator(); + + $e = $this->match( array('/\\G(?:\d+\.\d+|\d+)%/', '/\\G(?:[.#]?|:*)(?:[\w-]|[^\x00-\x9f]|\\\\(?:[A-Fa-f0-9]{1,6} ?|[^A-Fa-f0-9]))+/', + '#*', '#&', 'parseAttribute', '/\\G\([^()@]+\)/', '/\\G[\.#](?=@)/', 'parseEntitiesVariableCurly') ); + + if( is_null($e) ){ + if( $this->MatchChar('(') ){ + if( ($v = $this->parseSelector()) && $this->MatchChar(')') ){ + $e = $this->Less_Tree_Paren( $v); + } + } + } + + if( !is_null($e) ){ + return $this->Less_Tree_Element( $c, $e, $this->pos, $this->env->currentFileInfo); + } + } + + // + // Combinators combine elements together, in a Selector. + // + // Because our parser isn't white-space sensitive, special care + // has to be taken, when parsing the descendant combinator, ` `, + // as it's an empty space. We have to check the previous character + // in the input, to see if it's a ` ` character. + // + private function parseCombinator(){ + $c = $this->input[$this->pos]; + if ($c === '>' || $c === '+' || $c === '~' || $c === '|') { + + $this->skipWhitespace(1); + + return $this->Less_Tree_Combinator( $c); + }elseif( $this->pos > 0 && $this->isWhitespace(-1) ){ + return $this->Less_Tree_Combinator(' '); + } else { + return $this->Less_Tree_Combinator(); + } + } + + // + // A CSS selector (see selector below) + // with less extensions e.g. the ability to extend and guard + // + private function parseLessSelector(){ + return $this->parseSelector(true); + } + + // + // A CSS Selector + // + // .class > div + h1 + // li a:hover + // + // Selectors are made out of one or more Elements, see above. + // + private function parseSelector( $isLess = false ){ + $elements = array(); + $extendList = array(); + $condition = null; + $when = false; + $extend = false; + + while( ($isLess && ($extend = $this->parseExtend())) || ($isLess && ($when = $this->MatchReg('/\\Gwhen/') )) || ($e = $this->parseElement()) ){ + if( $when ){ + $condition = $this->expect('parseConditions', 'expected condition'); + }elseif( $condition ){ + //error("CSS guard can only be used at the end of selector"); + }elseif( $extend ){ + $extendList = array_merge($extendList,$extend); + }else{ + //if( count($extendList) ){ + //error("Extend can only be used at the end of selector"); + //} + $c = $this->input[ $this->pos ]; + $elements[] = $e; + $e = null; + } + + if( $c === '{' || $c === '}' || $c === ';' || $c === ',' || $c === ')') { break; } + } + + if( $elements ){ + return $this->Less_Tree_Selector( $elements, $extendList, $condition, $this->pos, $this->env->currentFileInfo); + } + if( $extendList ) { throw new Less_Exception_Parser('Extend must be used to extend a selector, it cannot be used on its own'); } + } + + private function parseTag(){ + return ( $tag = $this->MatchReg('/\\G[A-Za-z][A-Za-z-]*[0-9]?/') ) ? $tag : $this->MatchChar('*'); + } + + private function parseAttribute(){ + + $val = null; + $op = null; + + if( !$this->MatchChar('[') ){ + return; + } + + $key = $this->parseEntitiesVariableCurly(); + if( !$key ){ + $key = $this->expect('/\\G(?:[_A-Za-z0-9-\*]*\|)?(?:[_A-Za-z0-9-]|\\\\.)+/'); + } + + $op = $this->MatchReg('/\\G[|~*$^]?=/'); + if( $op ){ + $val = $this->match( array('parseEntitiesQuoted','/\\G[0-9]+%/','/\\G[\w-]+/','parseEntitiesVariableCurly') ); + } + + $this->expectChar(']'); + + return $this->Less_Tree_Attribute( $key, $op[0], $val); + } + + // + // The `block` rule is used by `ruleset` and `mixin.definition`. + // It's a wrapper around the `primary` rule, with added `{}`. + // + private function parseBlock(){ + if ($this->MatchChar('{') && (is_array($content = $this->parsePrimary())) && $this->MatchChar('}')) { + return $content; + } + } + + // + // div, .class, body > p {...} + // + private function parseRuleset(){ + $selectors = array(); + $start = $this->pos; + + while( true ){ + $s = $this->parseLessSelector(); + if( !$s ){ + break; + } + $selectors[] = $s; + $this->parseComments(); + if( !$this->MatchChar(',') ){ + break; + } + if( $s->condition ){ + //error("Guards are only currently allowed on a single selector."); + } + $this->parseComments(); + } + + + if( $selectors && (is_array($rules = $this->parseBlock())) ){ + return $this->Less_Tree_Ruleset( $selectors, $rules, $this->env->strictImports); + } else { + // Backtrack + $this->pos = $start; + } + } + + + private function parseRule( $tryAnonymous = null ){ + $merge = false; + $start = $this->pos; + $this->save(); + + $c = $this->input[$this->pos]; + if( $c === '.' || $c === '#' || $c === '&' ){ + return; + } + + if( $name = $this->MatchFuncs( array('parseVariable','parseRuleProperty')) ){ + + + // prefer to try to parse first if its a variable or we are compressing + // but always fallback on the other one + if( !$tryAnonymous && $name[0] === '@' ){ + $value = $this->MatchFuncs( array('parseValue','parseAnonymousValue')); + }else{ + $value = $this->MatchFuncs( array('parseAnonymousValue','parseValue')); + } + + $important = $this->parseImportant(); + + if( substr($name,-1) === '+' ){ + $merge = true; + $name = substr($name, 0, -1 ); + } + + if( $value && $this->parseEnd() ){ + return $this->Less_Tree_Rule( $name, $value, $important[0], $merge, $start, $this->env->currentFileInfo); + }else{ + $this->restore(); + if( $value && !$tryAnonymous ){ + return $this->parseRule(true); + } + } + } + } + + function parseAnonymousValue(){ + + if( preg_match('/\\G([^@+\/\'"*`(;{}-]*);/',$this->input, $match, 0, $this->pos) ){ + $this->pos += strlen($match[1]); + return $this->Less_Tree_Anonymous( $match[1]); + } + } + + // + // An @import directive + // + // @import "lib"; + // + // Depending on our environment, importing is done differently: + // In the browser, it's an XHR request, in Node, it would be a + // file-system operation. The function used for importing is + // stored in `import`, which we pass to the Import constructor. + // + private function parseImport(){ + $index = $this->pos; + + $this->save(); + + $dir = $this->MatchReg('/\\G@import?\s+/'); + + $options = array(); + if( $dir ){ + $options = $this->parseImportOptions(); + if( !$options ){ + $options = array(); + } + } + + if( $dir && ($path = $this->MatchFuncs( array('parseEntitiesQuoted','parseEntitiesUrl'))) ){ + $features = $this->parseMediaFeatures(); + if( $this->MatchChar(';') ){ + if( $features ){ + $features = $this->Less_Tree_Value( $features); + } + + return $this->Less_Tree_Import( $path, $features, $options, $this->pos, $this->env->currentFileInfo ); + } + } + + $this->restore(); + } + + private function parseImportOptions(){ + + $options = array(); + + // list of options, surrounded by parens + if( !$this->MatchChar('(') ){ return null; } + do{ + $optionName = $this->parseImportOption(); + if( $optionName ){ + $value = true; + switch( $optionName ){ + case "css": + $optionName = "less"; + $value = false; + break; + case "once": + $optionName = "multiple"; + $value = false; + break; + } + $options[$optionName] = $value; + if( !$this->MatchChar(',') ){ break; } + } + }while( $optionName ); + $this->expectChar(')'); + return $options; + } + + private function parseImportOption(){ + $opt = $this->MatchReg('/\\G(less|css|multiple|once|inline|reference)/'); + if( $opt ){ + return $opt[1]; + } + } + + private function parseMediaFeature() { + $nodes = array(); + + do{ + $e = $this->MatchFuncs(array('parseEntitiesKeyword','parseEntitiesVariable')); + if( $e ){ + $nodes[] = $e; + } elseif ($this->MatchChar('(')) { + $p = $this->parseProperty(); + $e = $this->parseValue(); + if ($this->MatchChar(')')) { + if ($p && $e) { + $nodes[] = $this->Less_Tree_Paren($this->Less_Tree_Rule( $p, $e, null, null, $this->pos, $this->env->currentFileInfo, true)); + } elseif ($e) { + $nodes[] = $this->Less_Tree_Paren( $e); + } else { + return null; + } + } else + return null; + } + } while ($e); + + if ($nodes) { + return $this->Less_Tree_Expression( $nodes); + } + } + + private function parseMediaFeatures() { + $features = array(); + + do{ + $e = $this->parseMediaFeature(); + if( $e ){ + $features[] = $e; + if (!$this->MatchChar(',')) break; + }else{ + $e = $this->parseEntitiesVariable(); + if( $e ){ + $features[] = $e; + if (!$this->MatchChar(',')) break; + } + } + } while ($e); + + return $features ? $features : null; + } + + private function parseMedia() { + if ($this->MatchReg('/\\G@media/')) { + $features = $this->parseMediaFeatures(); + + if ($rules = $this->parseBlock()) { + return $this->Less_Tree_Media( $rules, $features, $this->pos, $this->env->currentFileInfo); + } + } + } + + // + // A CSS Directive + // + // @charset "utf-8"; + // + private function parseDirective(){ + $hasBlock = false; + $hasIdentifier = false; + $hasExpression = false; + + if (! $this->PeekChar('@')) { + return; + } + + $value = $this->MatchFuncs(array('parseImport','parseMedia')); + if( $value ){ + return $value; + } + + $this->save(); + + $name = $this->MatchReg('/\\G@[a-z-]+/'); + + if( !$name ) return; + $name = $name[0]; + + $nonVendorSpecificName = $name; + $pos = strpos($name,'-', 2); + if( $name[1] == '-' && $pos > 0 ){ + $nonVendorSpecificName = "@" . substr($name, $pos + 1); + } + + switch($nonVendorSpecificName) { + case "@font-face": + $hasBlock = true; + break; + case "@viewport": + case "@top-left": + case "@top-left-corner": + case "@top-center": + case "@top-right": + case "@top-right-corner": + case "@bottom-left": + case "@bottom-left-corner": + case "@bottom-center": + case "@bottom-right": + case "@bottom-right-corner": + case "@left-top": + case "@left-middle": + case "@left-bottom": + case "@right-top": + case "@right-middle": + case "@right-bottom": + $hasBlock = true; + break; + case "@host": + case "@page": + case "@document": + case "@supports": + case "@keyframes": + $hasBlock = true; + $hasIdentifier = true; + break; + case "@namespace": + $hasExpression = true; + break; + } + + if( $hasIdentifier ){ + $identifier = $this->MatchReg('/\\G[^{]+/'); + if( $identifier ){ + $name .= " " .trim($identifier[0]); + } + } + + + if( $hasBlock ){ + + if ($rules = $this->parseBlock()) { + return $this->Less_Tree_Directive($name, $rules, $this->pos, $this->env->currentFileInfo); + } + }else{ + $value = $hasExpression ? $this->parseExpression() : $this->parseEntity(); + if( $value && $this->MatchChar(';') ){ + return $this->Less_Tree_Directive($name, $value, $this->pos, $this->env->currentFileInfo); + } + } + + $this->restore(); + } + + + // + // A Value is a comma-delimited list of Expressions + // + // font-family: Baskerville, Georgia, serif; + // + // In a Rule, a Value represents everything after the `:`, + // and before the `;`. + // + private function parseValue(){ + $expressions = array(); + + do{ + $e = $this->parseExpression(); + if( $e ){ + $expressions[] = $e; + if (! $this->MatchChar(',')) { + break; + } + } + }while($e); + + if( $expressions ){ + return $this->Less_Tree_Value($expressions); + } + } + + private function parseImportant (){ + if ($this->PeekChar('!')) { + return $this->MatchReg('/\\G! *important/'); + } + } + + private function parseSub (){ + + if( $this->MatchChar('(') ){ + if( $a = $this->parseAddition() ){ + $e = $this->Less_Tree_Expression( array($a) ); + $this->expectChar(')'); + $e->parens = true; + return $e; + } + } + } + + function parseMultiplication(){ + $operation = false; + $m = $this->parseOperand(); + if( $m ){ + $isSpaced = $this->isWhitespace( -1 ); + while( true ){ + + if( $this->PeekReg('/\\G\/[*\/]/') ){ + break; + } + + $op = $this->MatchChar('/'); + if( !$op ){ + $op = $this->MatchChar('*'); + if( !$op ){ + break; + } + } + + $a = $this->parseOperand(); + + if(!$a) { break; } + + $m->parensInOp = true; + $a->parensInOp = true; + $operation = $this->Less_Tree_Operation( $op, array( $operation ? $operation : $m, $a ), $isSpaced ); + $isSpaced = $this->isWhitespace( -1 ); + } + return ($operation ? $operation : $m); + } + } + + private function parseAddition (){ + $operation = false; + $m = $this->parseMultiplication(); + if( $m ){ + $isSpaced = $this->isWhitespace( -1 ); + + while( true ){ + $op = $this->MatchReg('/\\G[-+]\s+/'); + if( $op ){ + $op = $op[0]; + }elseif( !$isSpaced ){ + $op = $this->match(array('#+','#-')); + } + if( !$op ){ + break; + } + + $a = $this->parseMultiplication(); + if( !$a ){ + break; + } + + $m->parensInOp = true; + $a->parensInOp = true; + $operation = $this->Less_Tree_Operation($op, array($operation ? $operation : $m, $a), $isSpaced); + $isSpaced = $this->isWhitespace( -1 ); + } + return $operation ? $operation : $m; + } + } + + private function parseConditions() { + $index = $this->pos; + $condition = null; + $a = $this->parseCondition(); + if( $a ){ + while( $this->PeekReg('/\\G,\s*(not\s*)?\(/') && $this->MatchChar(',') ){ + $b = $this->parseCondition(); + if( !$b ){ + break; + } + + $condition = $this->Less_Tree_Condition('or', $condition ? $condition : $a, $b, $index); + } + return $condition ? $condition : $a; + } + } + + private function parseCondition() { + $index = $this->pos; + $negate = false; + + + if ($this->MatchReg('/\\Gnot/')) $negate = true; + $this->expectChar('('); + $a = $this->MatchFuncs(array('parseAddition','parseEntitiesKeyword','parseEntitiesQuoted')); + + if( $a ){ + $op = $this->MatchReg('/\\G(?:>=|<=|=<|[<=>])/'); + if( $op ){ + $b = $this->MatchFuncs(array('parseAddition','parseEntitiesKeyword','parseEntitiesQuoted')); + if( $b ){ + $c = $this->Less_Tree_Condition($op[0], $a, $b, $index, $negate); + } else { + throw new Less_Exception_Parser('Unexpected expression'); + } + } else { + $c = $this->Less_Tree_Condition('=', $a, $this->Less_Tree_Keyword('true'), $index, $negate); + } + $this->expectChar(')'); + return $this->MatchReg('/\\Gand/') ? $this->Less_Tree_Condition('and', $c, $this->parseCondition()) : $c; + } + } + + // + // An operand is anything that can be part of an operation, + // such as a Color, or a Variable + // + private function parseOperand (){ + + $negate = false; + $offset = $this->pos+1; + if( $offset >= $this->input_len ){ + return; + } + $char = $this->input[$offset]; + if( $char === '@' || $char === '(' ){ + $negate = $this->MatchChar('-'); + } + + $o = $this->MatchFuncs(array('parseSub','parseEntitiesDimension','parseEntitiesColor','parseEntitiesVariable','parseEntitiesCall')); + + if( $negate ){ + $o->parensInOp = true; + $o = $this->Less_Tree_Negative($o); + } + + return $o; + } + + // + // Expressions either represent mathematical operations, + // or white-space delimited Entities. + // + // 1px solid black + // @var * 2 + // + private function parseExpression (){ + $entities = array(); + + do{ + $e = $this->MatchFuncs(array('parseAddition','parseEntity')); + if( $e ){ + $entities[] = $e; + // operations do not allow keyword "/" dimension (e.g. small/20px) so we support that here + if( !$this->PeekReg('/\\G\/[\/*]/') ){ + $delim = $this->MatchChar('/'); + if( $delim ){ + $entities[] = $this->Less_Tree_Anonymous($delim); + } + } + } + }while($e); + + if( $entities ){ + return $this->Less_Tree_Expression($entities); + } + } + + private function parseProperty (){ + $name = $this->MatchReg('/\\G(\*?-?[_a-zA-Z0-9-]+)\s*:/'); + if( $name ){ + return $name[1]; + } + } + + private function parseRuleProperty(){ + $name = $this->MatchReg('/\\G(\*?-?[_a-zA-Z0-9-]+)\s*(\+?)\s*:/'); + if( $name ){ + return $name[1] . (isset($name[2]) ? $name[2] : ''); + } + } + + /** + * Some versions of php have trouble with method_exists($a,$b) if $a is not an object + * + */ + public static function is_method($a,$b){ + return is_object($a) && method_exists($a,$b); + } + + /** + * + * Round 1.499999 to 1 instead of 2 + * + */ + public static function round($i, $precision = 0){ + + $precision = pow(10,$precision); + $i = $i*$precision; + + $ceil = ceil($i); + $floor = floor($i); + if( ($ceil - $i) <= ($i - $floor) ){ + return $ceil/$precision; + }else{ + return $floor/$precision; + } + } + + public function __call($class,$args){ + + //$pre_args = $args; + //$args += array(null,null,null,null,null,null,null); + //$obj = new $class( $args[0], $args[1], $args[2], $args[3], $args[4], $args[5], $args[6] ); + + $count = count($args); + switch($count){ + case 0: + $obj = new $class(); + break; + + case 1: + $obj = new $class( $args[0]); + break; + + case 2: + $obj = new $class( $args[0], $args[1]); + break; + + case 3: + $obj = new $class( $args[0], $args[1], $args[2]); + break; + + case 4: + $obj = new $class( $args[0], $args[1], $args[2], $args[3]); + break; + + case 5: + $obj = new $class( $args[0], $args[1], $args[2], $args[3], $args[4] ); + break; + + case 6: + $obj = new $class( $args[0], $args[1], $args[2], $args[3], $args[4], $args[5] ); + break; + + case 7: + $obj = new $class( $args[0], $args[1], $args[2], $args[3], $args[4], $args[5], $args[6] ); + break; + } + + + //caching + if( self::$cache_dir ){ + $obj->cache_string = ' new '.$class.'('; + $comma = ''; + foreach($args as $arg){ + $obj->cache_string .= $comma.self::ArgString($arg); + $comma = ', '; + } + $obj->cache_string .= ')'; + } + + return $obj; + } + + public static function ArgString($arg){ + + $type = gettype($arg); + switch( $type ){ + + case 'object': + $string = $arg->cache_string; + unset($arg->cache_string); + return $string; + + case 'array': + $string = ' Array('; + foreach($arg as $k => $a){ + $string .= var_export($k,true).' => '.self::ArgString($a).','; + } + return $string . ')'; + + default: + return var_export($arg,true); + } + + } +} + + diff --git a/lib/Less/Tree.php b/lib/Less/Tree.php new file mode 100644 index 0000000000000000000000000000000000000000..fbd94a3d889e47be8ba6c2be01476325790d9b76 --- /dev/null +++ b/lib/Less/Tree.php @@ -0,0 +1,63 @@ +<?php + +class Less_Tree{ + + public function toCSS($env = null){ + $strs = array(); + $this->genCSS($env, $strs ); + return implode('',$strs); + } + + public static function OutputAdd( &$strs, $chunk, $fileInfo = null, $index = null ){ + $strs[] = $chunk; + } + + + public static function outputRuleset($env, &$strs, $rules ){ + + $ruleCnt = count($rules); + $env->tabLevel++; + + + // Compressed + if( Less_Environment::$compress ){ + self::OutputAdd( $strs, '{' ); + for( $i = 0; $i < $ruleCnt; $i++ ){ + $rules[$i]->genCSS( $env, $strs ); + } + self::OutputAdd( $strs, '}' ); + $env->tabLevel--; + return; + } + + + // Non-compressed + $tabSetStr = "\n".str_repeat( ' ' , $env->tabLevel-1 ); + $tabRuleStr = $tabSetStr.' '; + + self::OutputAdd( $strs, " {" ); + for($i = 0; $i < $ruleCnt; $i++ ){ + self::OutputAdd( $strs, $tabRuleStr ); + $rules[$i]->genCSS( $env, $strs ); + } + $env->tabLevel--; + self::OutputAdd( $strs, $tabSetStr.'}' ); + + } + + public function accept($visitor){} + + /** + * Requires php 5.3+ + */ + public static function __set_state($args){ + + $class = get_called_class(); + $obj = new $class(null,null,null,null); + foreach($args as $key => $val){ + $obj->$key = $val; + } + return $obj; + } + +} \ No newline at end of file diff --git a/lib/Less/Tree/Alpha.php b/lib/Less/Tree/Alpha.php new file mode 100644 index 0000000000000000000000000000000000000000..524a39dce40f1c9dd23f54c29b06f4739ae6827d --- /dev/null +++ b/lib/Less/Tree/Alpha.php @@ -0,0 +1,41 @@ +<?php + + +class Less_Tree_Alpha extends Less_Tree{ + public $value; + public $type = 'Alpha'; + + public function __construct($val){ + $this->value = $val; + } + + //function accept( $visitor ){ + // $this->value = $visitor->visit( $this->value ); + //} + + public function compile($env){ + + if( !is_string($this->value) ){ return new Less_Tree_Alpha( $this->value->compile($env) ); } + + return $this; + } + + public function genCSS( $env, &$strs ){ + + self::OutputAdd( $strs, "alpha(opacity=" ); + + if( is_string($this->value) ){ + self::OutputAdd( $strs, $this->value ); + }else{ + $this->value->genCSS($env, $strs); + } + + self::OutputAdd( $strs, ')' ); + } + + public function toCSS($env = null){ + return "alpha(opacity=" . (is_string($this->value) ? $this->value : $this->value->toCSS()) . ")"; + } + + +} \ No newline at end of file diff --git a/lib/Less/Tree/Anonymous.php b/lib/Less/Tree/Anonymous.php new file mode 100644 index 0000000000000000000000000000000000000000..d089c231e4fe2625870e641442920baa885005cc --- /dev/null +++ b/lib/Less/Tree/Anonymous.php @@ -0,0 +1,43 @@ +<?php + + +class Less_Tree_Anonymous extends Less_Tree{ + public $value; + public $quote; + public $type = 'Anonymous'; + + public function __construct($value, $index = null, $currentFileInfo = null, $mapLines = null ){ + $this->value = is_object($value) ? $value->value : $value; + $this->index = $index; + $this->mapLines = $mapLines; + $this->currentFileInfo = $currentFileInfo; + } + + public function compile($env){ + return $this; + } + + function compare($x){ + if( !is_object($x) ){ + return -1; + } + + $left = $this->toCSS(); + $right = $x->toCSS(); + + if( $left === $right ){ + return 0; + } + + return $left < $right ? -1 : 1; + } + + public function genCSS( $env, &$strs ){ + self::OutputAdd( $strs, $this->value, $this->currentFileInfo, $this->index, $this->mapLines ); + } + + public function toCSS($env = null){ + return $this->value; + } + +} diff --git a/lib/Less/Tree/Assignment.php b/lib/Less/Tree/Assignment.php new file mode 100644 index 0000000000000000000000000000000000000000..14af3e63071d24826a929d9afb7a4331c5cc7db7 --- /dev/null +++ b/lib/Less/Tree/Assignment.php @@ -0,0 +1,39 @@ +<?php + + +class Less_Tree_Assignment extends Less_Tree{ + + public $key; + public $value; + public $type = 'Assignment'; + + function __construct($key, $val) { + $this->key = $key; + $this->value = $val; + } + + function accept( $visitor ){ + $this->value = $visitor->visitObj( $this->value ); + } + + + public function compile($env) { + if( Less_Parser::is_method($this->value,'compile') ){ + return new Less_Tree_Assignment( $this->key, $this->value->compile($env)); + } + return $this; + } + + public function genCSS( $env, &$strs ){ + self::OutputAdd( $strs, $this->key . '=' ); + if( is_string($this->value) ){ + self::OutputAdd( $strs, $this->value ); + }else{ + $this->value->genCSS( $env, $strs ); + } + } + + public function toCss($env = null){ + return $this->key . '=' . (is_string($this->value) ? $this->value : $this->value->toCSS()); + } +} diff --git a/lib/Less/Tree/Attribute.php b/lib/Less/Tree/Attribute.php new file mode 100644 index 0000000000000000000000000000000000000000..8eb7fd175aad5de51c1c31aeb329429ef713f393 --- /dev/null +++ b/lib/Less/Tree/Attribute.php @@ -0,0 +1,39 @@ +<?php + + +class Less_Tree_Attribute extends Less_Tree{ + + public $key; + public $op; + public $value; + public $type = 'Attribute'; + + function __construct($key, $op, $value){ + $this->key = $key; + $this->op = $op; + $this->value = $value; + } + + function compile($env){ + + return new Less_Tree_Attribute( + is_object($this->key) ? $this->key->compile($env) : $this->key , + $this->op, + is_object($this->value) ? $this->value->compile($env) : $this->value); + } + + function genCSS( $env, &$strs ){ + self::OutputAdd( $strs, $this->toCSS($env) ); + } + + function toCSS($env = null){ + $value = $this->key; + + if( $this->op ){ + $value .= $this->op; + $value .= (is_object($this->value) ? $this->value->toCSS($env) : $this->value); + } + + return '[' . $value . ']'; + } +} \ No newline at end of file diff --git a/lib/Less/Tree/Call.php b/lib/Less/Tree/Call.php new file mode 100644 index 0000000000000000000000000000000000000000..c61cca112c5ee02fab7e2b6ff79c1d3f8ce7e2a2 --- /dev/null +++ b/lib/Less/Tree/Call.php @@ -0,0 +1,97 @@ +<?php + + +// +// A function call node. +// + +class Less_Tree_Call extends Less_Tree{ + public $value; + + var $name; + var $args; + var $index; + var $currentFileInfo; + public $type = 'Call'; + + public function __construct($name, $args, $index, $currentFileInfo = null ){ + $this->name = $name; + $this->args = $args; + $this->index = $index; + $this->currentFileInfo = $currentFileInfo; + } + + function accept( $visitor ){ + $this->args = $visitor->visitArray( $this->args ); + } + + // + // When evaluating a function call, + // we either find the function in `tree.functions` [1], + // in which case we call it, passing the evaluated arguments, + // or we simply print it out as it appeared originally [2]. + // + // The *functions.js* file contains the built-in functions. + // + // The reason why we evaluate the arguments, is in the case where + // we try to pass a variable to a function, like: `saturate(@color)`. + // The function should receive the value, not the variable. + // + public function compile($env){ + $args = array(); + foreach($this->args as $a){ + $args[] = $a->compile($env); + } + + $name = $this->name; + switch($name){ + case '%': + $name = '_percent'; + break; + + case 'data-uri': + $name = 'datauri'; + break; + + case 'svg-gradient': + $name = 'svggradient'; + break; + } + + + if( is_callable( array('Less_Functions',$name) ) ){ // 1. + try { + $func = new Less_Functions($env, $this->currentFileInfo); + $result = call_user_func_array( array($func,$name),$args); + if( $result != null ){ + return $result; + } + + } catch (Exception $e) { + throw new Less_Exception_Compiler('error evaluating function `' . $this->name . '` '.$e->getMessage().' index: '. $this->index); + } + + } + + return new Less_Tree_Call( $this->name, $args, $this->index, $this->currentFileInfo ); + } + + public function genCSS( $env, &$strs ){ + + self::OutputAdd( $strs, $this->name . '(', $this->currentFileInfo, $this->index ); + $args_len = count($this->args); + for($i = 0; $i < $args_len; $i++ ){ + $this->args[$i]->genCSS($env, $strs ); + if( $i + 1 < $args_len ){ + self::OutputAdd( $strs, ', ' ); + } + } + + self::OutputAdd( $strs, ')' ); + } + + public function toCSS($env = null){ + return $this->compile($env)->toCSS(); + } + +} diff --git a/lib/Less/Tree/Color.php b/lib/Less/Tree/Color.php new file mode 100644 index 0000000000000000000000000000000000000000..9990e954c8ef509fc79e3f75b04902e7c5b228ed --- /dev/null +++ b/lib/Less/Tree/Color.php @@ -0,0 +1,202 @@ +<?php + + +class Less_Tree_Color extends Less_Tree{ + var $rgb; + var $alpha; + public $type = 'Color'; + + public function __construct($rgb, $a = 1){ + $this->rgb = array(); + if( is_array($rgb) ){ + $this->rgb = $rgb; + }else if( strlen($rgb) == 6 ){ + foreach(str_split($rgb, 2) as $c){ + $this->rgb[] = hexdec($c); + } + }else{ + foreach(str_split($rgb, 1) as $c){ + $this->rgb[] = hexdec($c.$c); + } + } + $this->alpha = is_numeric($a) ? $a : 1; + } + + public function compile($env = null){ + return $this; + } + + public function luma(){ + return (0.2126 * $this->rgb[0] / 255) + (0.7152 * $this->rgb[1] / 255) + (0.0722 * $this->rgb[2] / 255); + } + + public function genCSS( $env, &$strs ){ + self::OutputAdd( $strs, $this->toCSS($env) ); + } + + public function toCSS($env = null, $doNotCompress = false ){ + $compress = Less_Environment::$compress && !$doNotCompress; + + + // + // If we have some transparency, the only way to represent it + // is via `rgba`. Otherwise, we use the hex representation, + // which has better compatibility with older browsers. + // Values are capped between `0` and `255`, rounded and zero-padded. + // + if( $this->alpha < 1.0 ){ + if( $this->alpha === 0 && isset($this->isTransparentKeyword) && $this->isTransparentKeyword ){ + return 'transparent'; + } + + + $values = array_map('round', $this->rgb); + $values[] = $this->alpha; + + $glue = ($compress ? ',' : ', '); + return "rgba(" . implode($glue, $values) . ")"; + }else{ + + $color = $this->toRGB(); + + if( $compress ){ + + // Convert color to short format + if( $color[1] === $color[2] && $color[3] === $color[4] && $color[5] === $color[6]) { + $color = '#'.$color[1] . $color[3] . $color[5]; + } + } + + return $color; + } + } + + // + // Operations have to be done per-channel, if not, + // channels will spill onto each other. Once we have + // our result, in the form of an integer triplet, + // we create a new Color node to hold the result. + // + public function operate($env, $op, $other) { + $result = array(); + + if (! ($other instanceof Less_Tree_Color)) { + $other = $other->toColor(); + } + + for ($c = 0; $c < 3; $c++) { + $result[$c] = Less_Functions::operate($env, $op, $this->rgb[$c], $other->rgb[$c]); + } + return new Less_Tree_Color($result, $this->alpha + $other->alpha); + } + + public function toRGB(){ + $color = ''; + foreach($this->rgb as $i){ + $i = Less_Parser::round($i); + $i = ($i > 255 ? 255 : ($i < 0 ? 0 : $i)); + $i = dechex($i); + $color .= str_pad($i, 2, '0', STR_PAD_LEFT); + } + return '#'.$color; + } + + public function toHSL(){ + $r = $this->rgb[0] / 255; + $g = $this->rgb[1] / 255; + $b = $this->rgb[2] / 255; + $a = $this->alpha; + + $max = max($r, $g, $b); + $min = min($r, $g, $b); + $l = ($max + $min) / 2; + $d = $max - $min; + + if( $max === $min ){ + $h = $s = 0; + } else { + $s = $l > 0.5 ? $d / (2 - $max - $min) : $d / ($max + $min); + + switch ($max) { + case $r: $h = ($g - $b) / $d + ($g < $b ? 6 : 0); break; + case $g: $h = ($b - $r) / $d + 2; break; + case $b: $h = ($r - $g) / $d + 4; break; + } + $h /= 6; + } + return array('h' => $h * 360, 's' => $s, 'l' => $l, 'a' => $a ); + } + + //Adapted from http://mjijackson.com/2008/02/rgb-to-hsl-and-rgb-to-hsv-color-model-conversion-algorithms-in-javascript + function toHSV() { + $r = $this->rgb[0] / 255; + $g = $this->rgb[1] / 255; + $b = $this->rgb[2] / 255; + $a = $this->alpha; + + $max = max($r, $g, $b); + $min = min($r, $g, $b); + + $v = $max; + + $d = $max - $min; + if ($max === 0) { + $s = 0; + } else { + $s = $d / $max; + } + + if ($max === $min) { + $h = 0; + } else { + switch($max){ + case $r: $h = ($g - $b) / $d + ($g < $b ? 6 : 0); break; + case $g: $h = ($b - $r) / $d + 2; break; + case $b: $h = ($r - $g) / $d + 4; break; + } + $h /= 6; + } + return array('h'=> $h * 360, 's'=> $s, 'v'=> $v, 'a' => $a ); + } + + public function toARGB(){ + $argb = array_merge( (array) Less_Parser::round($this->alpha * 255), $this->rgb); + + $temp = ''; + foreach($argb as $i){ + $i = Less_Parser::round($i); + $i = dechex($i > 255 ? 255 : ($i < 0 ? 0 : $i)); + $temp .= str_pad($i, 2, '0', STR_PAD_LEFT); + } + return '#' . $temp; + } + + public function compare($x){ + + if( !property_exists( $x, 'rgb' ) ){ + return -1; + } + + + return ($x->rgb[0] === $this->rgb[0] && + $x->rgb[1] === $this->rgb[1] && + $x->rgb[2] === $this->rgb[2] && + $x->alpha === $this->alpha) ? 0 : -1; + } + + + public static function fromKeyword( $keyword ){ + + if( Less_Colors::hasOwnProperty($keyword) ){ + // detect named color + return new Less_Tree_Color(substr(Less_Colors::color($keyword), 1)); + } + + if( $keyword === 'transparent' ){ + $transparent = new Less_Tree_Color( array(0, 0, 0), 0); + $transparent->isTransparentKeyword = true; + return $transparent; + } + } + +} diff --git a/lib/Less/Tree/Combinator.php b/lib/Less/Tree/Combinator.php new file mode 100644 index 0000000000000000000000000000000000000000..4adb8962bc62d0a72f4d4e3e44757dc7e4ef95f2 --- /dev/null +++ b/lib/Less/Tree/Combinator.php @@ -0,0 +1,45 @@ +<?php + + +class Less_Tree_Combinator extends Less_Tree{ + + public $value; + public $type = 'Combinator'; + + public function __construct($value = null) { + if( $value == ' ' ){ + $this->value = ' '; + }else { + $this->value = trim($value); + } + } + + static $_outputMap = array( + '' => '', + ' ' => ' ', + ':' => ' :', + '+' => ' + ', + '~' => ' ~ ', + '>' => ' > ', + '|' => '|' + ); + + static $_outputMapCompressed = array( + '' => '', + ' ' => ' ', + ':' => ' :', + '+' => '+', + '~' => '~', + '>' => '>', + '|' => '|' + ); + + function genCSS($env, &$strs ){ + if( Less_Environment::$compress ){ + self::OutputAdd( $strs, self::$_outputMapCompressed[$this->value] ); + }else{ + self::OutputAdd( $strs, self::$_outputMap[$this->value] ); + } + } + +} diff --git a/lib/Less/Tree/Comment.php b/lib/Less/Tree/Comment.php new file mode 100644 index 0000000000000000000000000000000000000000..94045001208a15f860a1264107e606c33ce34b63 --- /dev/null +++ b/lib/Less/Tree/Comment.php @@ -0,0 +1,38 @@ +<?php + +class Less_Tree_Comment extends Less_Tree{ + + public $type = 'Comment'; + + public function __construct($value, $silent, $index = null, $currentFileInfo = null ){ + $this->value = $value; + $this->silent = !! $silent; + $this->currentFileInfo = $currentFileInfo; + } + + public function genCSS( $env, &$strs ){ + //if( $this->debugInfo ){ + //self::OutputAdd( $strs, tree.debugInfo($env, $this), $this->currentFileInfo, $this->index); + //} + self::OutputAdd( $strs, trim($this->value) );//TODO shouldn't need to trim, we shouldn't grab the \n + } + + public function toCSS($env = null){ + return Less_Environment::$compress ? '' : $this->value; + } + + public function isSilent( $env ){ + $isReference = ($this->currentFileInfo && isset($this->currentFileInfo['reference']) && (!isset($this->isReferenced) || !$this->isReferenced) ); + $isCompressed = Less_Environment::$compress && !preg_match('/^\/\*!/', $this->value); + return $this->silent || $isReference || $isCompressed; + } + + public function compile(){ + return $this; + } + + public function markReferenced(){ + $this->isReferenced = true; + } + +} diff --git a/lib/Less/Tree/Condition.php b/lib/Less/Tree/Condition.php new file mode 100644 index 0000000000000000000000000000000000000000..7c7a0c785f766c0ae3be46ed3a0b4fbcc33e3120 --- /dev/null +++ b/lib/Less/Tree/Condition.php @@ -0,0 +1,68 @@ +<?php + +class Less_Tree_Condition extends Less_Tree{ + + public $op; + public $lvalue; + public $rvalue; + public $index; + public $negate; + public $type = 'Condition'; + + public function __construct($op, $l, $r, $i = 0, $negate = false) { + $this->op = trim($op); + $this->lvalue = $l; + $this->rvalue = $r; + $this->index = $i; + $this->negate = $negate; + } + + public function accept($visitor){ + $this->lvalue = $visitor->visitObj( $this->lvalue ); + $this->rvalue = $visitor->visitObj( $this->rvalue ); + } + + public function compile($env) { + $a = $this->lvalue->compile($env); + $b = $this->rvalue->compile($env); + + $i = $this->index; + + switch( $this->op ){ + case 'and': + $result = $a && $b; + break; + + case 'or': + $result = $a || $b; + break; + + default: + if( Less_Parser::is_method($a, 'compare') ){ + $result = $a->compare($b); + }elseif( Less_Parser::is_method($b, 'compare') ){ + $result = $b->compare($a); + }else{ + throw new Less_Exception_Compiler('Unable to perform comparison', $this->index); + } + + switch ($result) { + case -1: + $result = $this->op === '<' || $this->op === '=<' || $this->op === '<='; + break; + + case 0: + $result = $this->op === '=' || $this->op === '>=' || $this->op === '=<' || $this->op === '<='; + break; + + case 1: + $result = $this->op === '>' || $this->op === '>='; + break; + } + break; + } + + return $this->negate ? !$result : $result; + } + +} diff --git a/lib/Less/Tree/Dimension.php b/lib/Less/Tree/Dimension.php new file mode 100644 index 0000000000000000000000000000000000000000..a8729a1ac1c9d8c0293f136ce9de61d1381c2226 --- /dev/null +++ b/lib/Less/Tree/Dimension.php @@ -0,0 +1,184 @@ +<?php + + +class Less_Tree_Dimension extends Less_Tree{ + + public $type = 'Dimension'; + + public function __construct($value, $unit = false){ + $this->value = floatval($value); + + if( $unit && ($unit instanceof Less_Tree_Unit) ){ + $this->unit = $unit; + }elseif( $unit ){ + $this->unit = new Less_Tree_Unit( array($unit) ); + }else{ + $this->unit = new Less_Tree_Unit( ); + } + } + + function accept( $visitor ){ + $this->unit = $visitor->visitObj( $this->unit ); + } + + public function compile($env = null) { + return $this; + } + + public function toColor() { + return new Less_Tree_Color(array($this->value, $this->value, $this->value)); + } + + public function genCSS( $env, &$strs ){ + + if( ($env && $env->strictUnits) && !$this->unit->isSingular() ){ + throw new Less_Exception_Compiler("Multiple units in dimension. Correct the units or use the unit function. Bad unit: ".$this->unit->toString()); + } + + $value = $this->value; + $strValue = (string)$value; + + if( $value !== 0 && $value < 0.000001 && $value > -0.000001 ){ + // would be output 1e-6 etc. + $strValue = number_format($strValue,10); + $strValue = preg_replace('/\.?0+$/','', $strValue); + } + + if( Less_Environment::$compress ){ + // Zero values doesn't need a unit + if( $value === 0 && $this->unit->isLength() ){ + self::OutputAdd( $strs, $strValue ); + return $strValue; + } + + // Float values doesn't need a leading zero + if( $value > 0 && $value < 1 && $strValue[0] === '0' ){ + $strValue = substr($strValue,1); + } + } + + self::OutputAdd( $strs, $strValue ); + $this->unit->genCSS($env, $strs); + } + + public function __toString(){ + return $this->toCSS(); + } + + // In an operation between two Dimensions, + // we default to the first Dimension's unit, + // so `1px + 2em` will yield `3px`. + public function operate($env, $op, $other){ + + $value = Less_Functions::operate($env, $op, $this->value, $other->value); + $unit = clone $this->unit; + + if( $op === '+' || $op === '-' ){ + + if( !$unit->numerator && !$unit->denominator ){ + $unit->numerator = $other->unit->numerator; + $unit->denominator = $other->unit->denominator; + }elseif( !$other->unit->numerator && !$other->unit->denominator ){ + // do nothing + }else{ + $other = $other->convertTo( $this->unit->usedUnits()); + + if( $env->strictUnits && $other->unit->toString() !== $unit->toCSS() ){ + throw new Less_Exception_Compiler("Incompatible units. Change the units or use the unit function. Bad units: '".$unit->toString() . "' and ".$other->unit->toString()+"'."); + } + + $value = Less_Functions::operate($env, $op, $this->value, $other->value); + } + }elseif( $op === '*' ){ + $unit->numerator = array_merge($unit->numerator, $other->unit->numerator); + $unit->denominator = array_merge($unit->denominator, $other->unit->denominator); + sort($unit->numerator); + sort($unit->denominator); + $unit->cancel(); + }elseif( $op === '/' ){ + $unit->numerator = array_merge($unit->numerator, $other->unit->denominator); + $unit->denominator = array_merge($unit->denominator, $other->unit->numerator); + sort($unit->numerator); + sort($unit->denominator); + $unit->cancel(); + } + return new Less_Tree_Dimension( $value, $unit); + } + + public function compare($other) { + if ($other instanceof Less_Tree_Dimension) { + + $a = $this->unify(); + $b = $other->unify(); + $aValue = $a->value; + $bValue = $b->value; + + if ($bValue > $aValue) { + return -1; + } elseif ($bValue < $aValue) { + return 1; + } else { + if( !$b->unit->isEmpty() && $a->unit->compare($b->unit) !== 0) { + return -1; + } + return 0; + } + } else { + return -1; + } + } + + function unify() { + return $this->convertTo(array('length'=> 'm', 'duration'=> 's', 'angle' => 'rad' )); + } + + function convertTo($conversions) { + $value = $this->value; + $unit = clone $this->unit; + + if( is_string($conversions) ){ + $derivedConversions = array(); + foreach( Less_Tree_UnitConversions::$groups as $i ){ + if( isset(Less_Tree_UnitConversions::${$i}[$conversions]) ){ + $derivedConversions = array( $i => $conversions); + } + } + $conversions = $derivedConversions; + } + + + foreach($conversions as $groupName => $targetUnit){ + $group = Less_Tree_UnitConversions::${$groupName}; + + //numerator + $len = count($unit->numerator); + for($i=0; $i < $len; $i++ ){ + $atomicUnit = $unit->numerator[$i]; + if( !isset($group[$atomicUnit]) ){ + continue; + } + + $value = $value * ($group[$atomicUnit] / $group[$targetUnit]); + + $unit->numerator[$i] = $targetUnit; + } + + //denominator + $len = count($unit->denominator); + for($i=0; $i < $len; $i++ ){ + $atomicUnit = $unit->denominator[$i]; + if( !isset($group[$atomicUnit]) ){ + continue; + } + + $value = $value / ($group[$atomicUnit] / $group[$targetUnit]); + + $unit->denominator[$i] = $targetUnit; + } + } + + $unit->cancel(); + + return new Less_Tree_Dimension( $value, $unit); + } +} diff --git a/lib/Less/Tree/Directive.php b/lib/Less/Tree/Directive.php new file mode 100644 index 0000000000000000000000000000000000000000..528a63b2a96d41714d4e36a812bcdb7eda42e86a --- /dev/null +++ b/lib/Less/Tree/Directive.php @@ -0,0 +1,81 @@ +<?php + +class Less_Tree_Directive extends Less_Tree{ + + public $name; + public $value; + public $rules; + public $index; + public $type = 'Directive'; + + public function __construct($name, $value = null, $index = null, $currentFileInfo = null ){ + $this->name = $name; + if (is_array($value)) { + $rule = new Less_Tree_Ruleset(array(), $value); + $rule->allowImports = true; + $this->rules = array($rule); + } else { + $this->value = $value; + } + $this->currentFileInfo = $currentFileInfo; + } + + + function accept( $visitor ){ + if( $this->rules ){ + $this->rules = $visitor->visitArray( $this->rules ); + } + if( $this->value ){ + $this->value = $visitor->visitObj( $this->value ); + } + } + + function genCSS( $env, &$strs ){ + + self::OutputAdd( $strs, $this->name, $this->currentFileInfo, $this->index ); + + if( $this->rules ){ + Less_Tree::outputRuleset( $env, $strs, $this->rules); + }else{ + self::OutputAdd( $strs, ' ' ); + $this->value->genCSS( $env, $strs ); + self::OutputAdd( $strs, ';' ); + } + } + + public function compile($env){ + $evaldDirective = $this; + if( $this->rules ){ + $env->unshiftFrame($this); + $evaldDirective = new Less_Tree_Directive( $this->name, null, $this->index, $this->currentFileInfo ); + $evaldDirective->rules = array( $this->rules[0]->compile($env) ); + $evaldDirective->rules[0]->root = true; + $env->shiftFrame(); + } + return $evaldDirective; + } + + // TODO: Not sure if this is right... + public function variable($name){ + return $this->rules[0]->variable($name); + } + + public function find($selector){ + return $this->rules[0]->find($selector, $this); + } + + //rulesets: function () { return tree.Ruleset.prototype.rulesets.apply(this.rules[0]); }, + + public function markReferenced(){ + $this->isReferenced = true; + if( $this->rules ){ + $rules = $this->rules[0]->rules; + for( $i = 0; $i < count($rules); $i++ ){ + if( Less_Parser::is_method( $rules[$i], 'markReferenced') ){ + $rules[$i]->markReferenced(); + } + } + } + } + +} diff --git a/lib/Less/Tree/Element.php b/lib/Less/Tree/Element.php new file mode 100644 index 0000000000000000000000000000000000000000..aafae04e488a8fc05a0ace587ad78a90012cbdb3 --- /dev/null +++ b/lib/Less/Tree/Element.php @@ -0,0 +1,58 @@ +<?php + +//less.js : lib/less/tree/element.js + +class Less_Tree_Element extends Less_Tree{ + + public $combinator; + public $value = ''; + public $index; + public $type = 'Element'; + + public function __construct($combinator, $value, $index = null, $currentFileInfo = null ){ + if( ! ($combinator instanceof Less_Tree_Combinator)) { + $combinator = new Less_Tree_Combinator($combinator); + } + + if( !is_null($value) ){ + $this->value = $value; + } + + $this->combinator = $combinator; + $this->index = $index; + $this->currentFileInfo = $currentFileInfo; + } + + function accept( $visitor ){ + $this->combinator = $visitor->visitObj( $this->combinator ); + if( is_object($this->value) ){ //object or string + $this->value = $visitor->visitObj( $this->value ); + } + } + + public function compile($env) { + return new Less_Tree_Element($this->combinator, + is_string($this->value) ? $this->value : $this->value->compile($env), + $this->index, + $this->currentFileInfo + ); + } + + public function genCSS( $env, &$strs ){ + self::OutputAdd( $strs, $this->toCSS($env), $this->currentFileInfo, $this->index ); + } + + public function toCSS( $env = null ){ + + $value = $this->value; + if( !is_string($value) ){ + $value = $value->toCSS($env); + } + + if( $value === '' && $this->combinator->value[0] === '&' ){ + return ''; + } + return $this->combinator->toCSS($env) . $value; + } + +} diff --git a/lib/Less/Tree/Expression.php b/lib/Less/Tree/Expression.php new file mode 100644 index 0000000000000000000000000000000000000000..0b83b538465f17941c1684074eaf4c87798023ef --- /dev/null +++ b/lib/Less/Tree/Expression.php @@ -0,0 +1,86 @@ +<?php + +class Less_Tree_Expression extends Less_Tree{ + + public $value = array(); + public $parens = false; + public $parensInOp = false; + public $type = 'Expression'; + + public function __construct($value=null) { + $this->value = $value; + } + + function accept( $visitor ){ + $this->value = $visitor->visitArray( $this->value ); + } + + public function compile($env) { + + $inParenthesis = $this->parens && !$this->parensInOp; + $doubleParen = false; + if( $inParenthesis ) { + $env->inParenthesis(); + } + + if( $this->value ){ + + $count = count($this->value); + + if( $count > 1 ){ + + $ret = array(); + foreach($this->value as $e){ + $ret[] = $e->compile($env); + } + $returnValue = new Less_Tree_Expression($ret); + + }elseif( $count === 1 ){ + + if( !isset($this->value[0]) ){ + $this->value = array_slice($this->value,0); + } + + if( ($this->value[0] instanceof Less_Tree_Expression) && $this->value[0]->parens && !$this->value[0]->parensInOp ){ + $doubleParen = true; + } + + $returnValue = $this->value[0]->compile($env); + } + + } else { + $returnValue = $this; + } + if( $inParenthesis ){ + $env->outOfParenthesis(); + } + if( $this->parens && $this->parensInOp && !$env->isMathOn() && !$doubleParen ){ + $returnValue = new Less_Tree_Paren($returnValue); + } + return $returnValue; + } + + function genCSS( $env, &$strs ){ + $val_len = count($this->value); + for( $i = 0; $i < $val_len; $i++ ){ + $this->value[$i]->genCSS( $env, $strs ); + if( $i + 1 < $val_len ){ + self::OutputAdd( $strs, ' ' ); + } + } + } + + function throwAwayComments() { + + if( is_array($this->value) ){ + $new_value = array(); + foreach($this->value as $v){ + if( $v instanceof Less_Tree_Comment ){ + continue; + } + $new_value[] = $v; + } + $this->value = $new_value; + } + } +} diff --git a/lib/Less/Tree/Extend.php b/lib/Less/Tree/Extend.php new file mode 100644 index 0000000000000000000000000000000000000000..203d1156556c50c9f95079f3b86fd4257aa185d8 --- /dev/null +++ b/lib/Less/Tree/Extend.php @@ -0,0 +1,66 @@ +<?php + + +class Less_Tree_Extend extends Less_Tree{ + + public $selector; + public $option; + public $index; + public $selfSelectors = array(); + public $allowBefore; + public $allowAfter; + public $firstExtendOnThisSelectorPath; + public $type = 'Extend'; + + + public $object_id; + public $parent_ids = array(); + + function __construct($selector, $option, $index){ + static $i = 0; + $this->selector = $selector; + $this->option = $option; + $this->index = $index; + + switch($option){ + case "all": + $this->allowBefore = true; + $this->allowAfter = true; + break; + default: + $this->allowBefore = false; + $this->allowAfter = false; + break; + } + + $this->object_id = $i++; + $this->parent_ids = array($this->object_id); + } + + function accept( $visitor ){ + $this->selector = $visitor->visitObj( $this->selector ); + } + + function compile( $env ){ + Less_Parser::$has_extends = true; + return new Less_Tree_Extend( $this->selector->compile($env), $this->option, $this->index); + } + + function findSelfSelectors( $selectors ){ + $selfElements = array(); + + + for( $i = 0, $selectors_len = count($selectors); $i < $selectors_len; $i++ ){ + $selectorElements = $selectors[$i]->elements; + // duplicate the logic in genCSS function inside the selector node. + // future TODO - move both logics into the selector joiner visitor + if( $i && $selectorElements && $selectorElements[0]->combinator->value === "") { + $selectorElements[0]->combinator->value = ' '; + } + $selfElements = array_merge( $selfElements, $selectors[$i]->elements ); + } + + $this->selfSelectors = array(new Less_Tree_Selector($selfElements)); + } + +} \ No newline at end of file diff --git a/lib/Less/Tree/Import.php b/lib/Less/Tree/Import.php new file mode 100644 index 0000000000000000000000000000000000000000..528238082bf5da89ec80b1300e702fc0b432619f --- /dev/null +++ b/lib/Less/Tree/Import.php @@ -0,0 +1,221 @@ +<?php + + + +// +// CSS @import node +// +// The general strategy here is that we don't want to wait +// for the parsing to be completed, before we start importing +// the file. That's because in the context of a browser, +// most of the time will be spent waiting for the server to respond. +// +// On creation, we push the import path to our import queue, though +// `import,push`, we also pass it a callback, which it'll call once +// the file has been fetched, and parsed. +// +class Less_Tree_Import extends Less_Tree{ + + public $options; + public $index; + public $path; + public $features; + public $currentFileInfo; + public $css; + public $skip; + public $root; + public $type = 'Import'; + + function __construct($path, $features, $options, $index, $currentFileInfo = null ){ + $this->options = $options; + $this->index = $index; + $this->path = $path; + $this->features = $features; + $this->currentFileInfo = $currentFileInfo; + + if( is_array($options) ){ + $this->options += array('inline'=>false); + + if( isset($this->options['less']) || $this->options['inline'] ){ + $this->css = !isset($this->options['less']) || !$this->options['less'] || $this->options['inline']; + } else { + $pathValue = $this->getPath(); + if( $pathValue && preg_match('/css([\?;].*)?$/',$pathValue) ){ + $this->css = true; + } + } + } + } + +// +// The actual import node doesn't return anything, when converted to CSS. +// The reason is that it's used at the evaluation stage, so that the rules +// it imports can be treated like any other rules. +// +// In `eval`, we make sure all Import nodes get evaluated, recursively, so +// we end up with a flat structure, which can easily be imported in the parent +// ruleset. +// + + function accept($visitor){ + + if( $this->features ){ + $this->features = $visitor->visitObj($this->features); + } + $this->path = $visitor->visitObj($this->path); + + if( !$this->options['inline'] && $this->root ){ + $this->root = $visitor->visit($this->root); + } + } + + function genCSS( $env, &$strs ){ + if( $this->css ){ + + self::OutputAdd( $strs, '@import ', $this->currentFileInfo, $this->index ); + + $this->path->genCSS( $env, $strs ); + if( $this->features ){ + self::OutputAdd( $strs, ' ' ); + $this->features->genCSS( $env, $strs ); + } + self::OutputAdd( $strs, ';' ); + } + } + + function toCSS($env = null){ + $features = $this->features ? ' ' . $this->features->toCSS($env) : ''; + + if ($this->css) { + return "@import " . $this->path->toCSS() . $features . ";\n"; + } else { + return ""; + } + } + + function getPath(){ + if ($this->path instanceof Less_Tree_Quoted) { + $path = $this->path->value; + return ( isset($this->css) || preg_match('/(\.[a-z]*$)|([\?;].*)$/',$path)) ? $path : $path . '.less'; + } else if ($this->path instanceof Less_Tree_URL) { + return $this->path->value->value; + } + return null; + } + + function compileForImport( $env ){ + return new Less_Tree_Import( $this->path->compile($env), $this->features, $this->options, $this->index, $this->currentFileInfo); + } + + function compilePath($env) { + $path = $this->path->compile($env); + $rootpath = ''; + if( $this->currentFileInfo && $this->currentFileInfo['rootpath'] ){ + $rootpath = $this->currentFileInfo['rootpath']; + } + + + if( !($path instanceof Less_Tree_URL) ){ + if( $rootpath ){ + $pathValue = $path->value; + // Add the base path if the import is relative + if( $pathValue && Less_Environment::isPathRelative($pathValue) ){ + $path->value = $this->currentFileInfo['uri_root'].$pathValue; + } + } + $path->value = Less_Environment::normalizePath($path->value); + } + + return $path; + } + + function compile($env) { + + $evald = $this->compileForImport($env); + $uri = $full_path = false; + + //get path & uri + $evald_path = $evald->getPath(); + if( $evald_path ){ + foreach(Less_Parser::$import_dirs as $rootpath => $rooturi){ + if( is_callable($rooturi) ){ + list($path, $uri) = call_user_func($rooturi, $evald_path); + if( null !== $path ){ + $full_path = $path; + break; + } + }else{ + $path = $rootpath.$evald_path; + if( file_exists($path) ){ + $full_path = Less_Environment::normalizePath($path); + $uri = Less_Environment::normalizePath(dirname($rooturi.$evald_path)); + break; + } + } + } + } + + if( !$full_path ){ + $uri = $evald_path; + $full_path = $evald_path; + } + + //import once + $realpath = realpath($full_path); + + + if( $realpath && Less_Parser::FileParsed($realpath) ){ + if( isset($this->currentFileInfo['reference']) ){ + $evald->skip = true; + }elseif( !isset($evald->options['multiple']) && !$env->importMultiple ){ + $evald->skip = true; + } + } + + $features = ( $evald->features ? $evald->features->compile($env) : null ); + + if( $evald->skip ){ + return array(); + } + + + if( $this->options['inline'] ){ + //todo needs to reference css file not import + //$contents = new Less_Tree_Anonymous($this->root, 0, array('filename'=>$this->importedFilename), true ); + + Less_Parser::AddParsedFile($full_path); + $contents = new Less_Tree_Anonymous( file_get_contents($full_path), 0, array(), true ); + + if( $this->features ){ + return new Less_Tree_Media( array($contents), $this->features->value ); + } + + return array( $contents ); + + }elseif( $evald->css ){ + $temp = $this->compilePath( $env); + return new Less_Tree_Import( $this->compilePath( $env), $features, $this->options, $this->index); + } + + + // options + $import_env = clone $env; + if( (isset($this->options['reference']) && $this->options['reference']) || isset($this->currentFileInfo['reference']) ){ + $import_env->currentFileInfo['reference'] = true; + } + + if( (isset($this->options['multiple']) && $this->options['multiple']) ){ + $import_env->importMultiple = true; + } + + $parser = new Less_Parser($import_env); + $evald->root = $parser->parseFile($full_path, $uri, true); + + + $ruleset = new Less_Tree_Ruleset(array(), $evald->root->rules ); + $ruleset->evalImports($import_env); + + return $this->features ? new Less_Tree_Media($ruleset->rules, $this->features->value) : $ruleset->rules; + } +} + diff --git a/lib/Less/Tree/Javascript.php b/lib/Less/Tree/Javascript.php new file mode 100644 index 0000000000000000000000000000000000000000..a32f15477fa4414fbf53718303dcb2e40b903449 --- /dev/null +++ b/lib/Less/Tree/Javascript.php @@ -0,0 +1,24 @@ +<?php + +class Less_Tree_Javascript extends Less_Tree{ + + public $type = 'Javascript'; + + public function __construct($string, $index, $escaped){ + $this->escaped = $escaped; + $this->expression = $string; + $this->index = $index; + } + + public function compile($env){ + return $this; + } + + function genCSS( $env, &$strs ){ + self::OutputAdd( $strs, '/* Sorry, can not do JavaScript evaluation in PHP... :( */' ); + } + + public function toCSS($env = null){ + return Less_Environment::$compress ? '' : '/* Sorry, can not do JavaScript evaluation in PHP... :( */'; + } +} diff --git a/lib/Less/Tree/Keyword.php b/lib/Less/Tree/Keyword.php new file mode 100644 index 0000000000000000000000000000000000000000..1749e7ea4a818c585b41c3746233682e6820a8bf --- /dev/null +++ b/lib/Less/Tree/Keyword.php @@ -0,0 +1,27 @@ +<?php + + +class Less_Tree_Keyword extends Less_Tree{ + + public $type = 'Keyword'; + + public function __construct($value=null){ + $this->value = $value; + } + + public function compile($env){ + return $this; + } + + public function genCSS( $env, &$strs ){ + self::OutputAdd( $strs, $this->value ); + } + + public function compare($other) { + if ($other instanceof Less_Tree_Keyword) { + return $other->value === $this->value ? 0 : 1; + } else { + return -1; + } + } +} diff --git a/lib/Less/Tree/Media.php b/lib/Less/Tree/Media.php new file mode 100644 index 0000000000000000000000000000000000000000..259b0dfee245b9ace7496aa06cff5c22f75df7a1 --- /dev/null +++ b/lib/Less/Tree/Media.php @@ -0,0 +1,166 @@ +<?php + +class Less_Tree_Media extends Less_Tree{ + + public $features; + public $ruleset; + public $type = 'Media'; + + public function __construct($value = array(), $features = array(), $index = null, $currentFileInfo = null ){ + + $this->index = $index; + $this->currentFileInfo = $currentFileInfo; + + $selectors = $this->emptySelectors(); + + $this->features = new Less_Tree_Value($features); + + $this->rules = array(new Less_Tree_Ruleset($selectors, $value)); + $this->rules[0]->allowImports = true; + } + + function accept( $visitor ){ + $this->features = $visitor->visitObj($this->features); + $this->rules = $visitor->visitArray($this->rules); + } + + function genCSS( $env, &$strs ){ + + self::OutputAdd( $strs, '@media ', $this->currentFileInfo, $this->index ); + $this->features->genCSS( $env, $strs ); + Less_Tree::outputRuleset( $env, $strs, $this->rules); + + } + + public function compile($env) { + + $media = new Less_Tree_Media(array(), array(), $this->index, $this->currentFileInfo ); + + $strictMathBypass = false; + if( $env->strictMath === false) { + $strictMathBypass = true; + $env->strictMath = true; + } + try { + $media->features = $this->features->compile($env); + }catch(Exception $e){} + + if( $strictMathBypass ){ + $env->strictMath = false; + } + + $env->mediaPath[] = $media; + $env->mediaBlocks[] = $media; + + array_unshift($env->frames, $this->rules[0]); + $media->rules = array($this->rules[0]->compile($env)); + array_shift($env->frames); + + array_pop($env->mediaPath); + + return !$env->mediaPath ? $media->compileTop($env) : $media->compileNested($env); + } + + public function variable($name) { + return $this->rules[0]->variable($name); + } + + public function find($selector) { + return $this->rules[0]->find($selector, $this); + } + + public function emptySelectors(){ + $el = new Less_Tree_Element('','&', $this->index, $this->currentFileInfo ); + return array( new Less_Tree_Selector(array($el), array(), null, $this->index, $this->currentFileInfo) ); + } + + public function markReferenced(){ + $this->isReferenced = true; + foreach($this->rules[0]->rules as $rule){ + if( Less_Parser::is_method($rule,'markReferenced') ){ + $rule->markReferenced(); + } + } + } + + // evaltop + public function compileTop($env) { + $result = $this; + + if (count($env->mediaBlocks) > 1) { + $selectors = $this->emptySelectors(); + $result = new Less_Tree_Ruleset($selectors, $env->mediaBlocks); + $result->multiMedia = true; + } + + $env->mediaBlocks = array(); + $env->mediaPath = array(); + + return $result; + } + + public function compileNested($env) { + $path = array_merge($env->mediaPath, array($this)); + + // Extract the media-query conditions separated with `,` (OR). + foreach ($path as $key => $p) { + $value = $p->features instanceof Less_Tree_Value ? $p->features->value : $p->features; + $path[$key] = is_array($value) ? $value : array($value); + } + + // Trace all permutations to generate the resulting media-query. + // + // (a, b and c) with nested (d, e) -> + // a and d + // a and e + // b and c and d + // b and c and e + + $permuted = $this->permute($path); + $expressions = array(); + foreach($permuted as $path){ + + for( $i=0, $len=count($path); $i < $len; $i++){ + $path[$i] = Less_Parser::is_method($path[$i], 'toCSS') ? $path[$i] : new Less_Tree_Anonymous($path[$i]); + } + + for( $i = count($path) - 1; $i > 0; $i-- ){ + array_splice($path, $i, 0, array(new Less_Tree_Anonymous('and'))); + } + + $expressions[] = new Less_Tree_Expression($path); + } + $this->features = new Less_Tree_Value($expressions); + + + + // Fake a tree-node that doesn't output anything. + return new Less_Tree_Ruleset(array(), array()); + } + + public function permute($arr) { + if (!$arr) + return array(); + + if (count($arr) == 1) + return $arr[0]; + + $result = array(); + $rest = $this->permute(array_slice($arr, 1)); + foreach ($rest as $r) { + foreach ($arr[0] as $a) { + $result[] = array_merge( + is_array($a) ? $a : array($a), + is_array($r) ? $r : array($r) + ); + } + } + + return $result; + } + + function bubbleSelectors($selectors) { + $this->rules = array(new Less_Tree_Ruleset( $selectors, array($this->rules[0]))); + } + +} diff --git a/lib/Less/Tree/Mixin/Call.php b/lib/Less/Tree/Mixin/Call.php new file mode 100644 index 0000000000000000000000000000000000000000..c8475b3c71d4a83bcd85acdfd4c9c1c7c7e2302b --- /dev/null +++ b/lib/Less/Tree/Mixin/Call.php @@ -0,0 +1,145 @@ +<?php + + +class Less_Tree_Mixin_Call extends Less_Tree{ + + public $selector; + public $arguments; + public $index; + public $currentFileInfo; + + public $important; + public $type = 'MixinCall'; + + /** + * less.js: tree.mixin.Call + * + */ + public function __construct($elements, $args, $index, $currentFileInfo, $important = false){ + $this->selector = new Less_Tree_Selector($elements); + $this->arguments = $args; + $this->index = $index; + $this->currentFileInfo = $currentFileInfo; + $this->important = $important; + } + + //function accept($visitor){ + // $this->selector = $visitor->visit($this->selector); + // $this->arguments = $visitor->visit($this->arguments); + //} + + + /** + * less.js: tree.mixin.Call.prototype() + * + */ + public function compile($env){ + + $rules = array(); + $match = false; + $isOneFound = false; + + $args = array(); + foreach($this->arguments as $a){ + $args[] = array('name'=> $a['name'], 'value' => $a['value']->compile($env) ); + } + + foreach($env->frames as $frame){ + $mixins = $frame->find($this->selector, null, $env); + + if( !$mixins ){ + continue; + } + + $isOneFound = true; + $mixins_len = count($mixins); + for( $m = 0; $m < $mixins_len; $m++ ){ + $mixin = $mixins[$m]; + + $isRecursive = false; + foreach($env->frames as $recur_frame){ + if( !($mixin instanceof Less_Tree_Mixin_Definition) ){ + if( (isset($recur_frame->originalRuleset) && $mixin->ruleset_id === $recur_frame->originalRuleset) + || ($mixin === $recur_frame) ){ + $isRecursive = true; + break; + } + } + } + if( $isRecursive ){ + continue; + } + + if ($mixin->matchArgs($args, $env)) { + + //if( !($mixin instanceof Less_Tree_Ruleset || $mixin instanceof Less_Tree_Mixin_Definition) || $mixin->matchCondition($args, $env) ){ + if( !Less_Parser::is_method($mixin,'matchCondition') || $mixin->matchCondition($args, $env) ){ + try{ + + if( !($mixin instanceof Less_Tree_Mixin_Definition) ){ + $mixin = new Less_Tree_Mixin_Definition('', array(), $mixin->rules, null, false); + $mixin->originalRuleset = $mixins[$m]->originalRuleset; + } + //if (this.important) { + // isImportant = env.isImportant; + // env.isImportant = true; + //} + + $rules = array_merge($rules, $mixin->compile($env, $args, $this->important)->rules); + //if (this.important) { + // env.isImportant = isImportant; + //} + } catch (Exception $e) { + //throw new Less_Exception_Compiler($e->getMessage(), $e->index, null, $this->currentFileInfo['filename']); + throw new Less_Exception_Compiler($e->getMessage(), null, null, $this->currentFileInfo['filename']); + } + } + $match = true; + } + + } + + if( $match ){ + if( !$this->currentFileInfo || !isset($this->currentFileInfo['reference']) || !$this->currentFileInfo['reference'] ){ + foreach($rules as $rule){ + if( Less_Parser::is_method($rule,'markReferenced') ){ + $rule->markReferenced(); + } + } + } + return $rules; + } + } + + + if( $isOneFound ){ + + $message = array(); + if( $args ){ + foreach($args as $a){ + $argValue = ''; + if( $a['name'] ){ + $argValue += $a['name']+':'; + } + if( is_object($a['value']) ){ + $argValue += $a['value']->toCSS(); + }else{ + $argValue += '???'; + } + $message[] = $argValue; + } + } + $message = implode(', ',$message); + + + throw new Less_Exception_Compiler('No matching definition was found for `'. + trim($this->selector->toCSS($env)) . '(' .$message.')', + $this->index, null, $this->currentFileInfo['filename']); + + }else{ + throw new Less_Exception_Compiler(trim($this->selector->toCSS($env)) . " is undefined", $this->index); + } + } +} + + diff --git a/lib/Less/Tree/Mixin/Definition.php b/lib/Less/Tree/Mixin/Definition.php new file mode 100644 index 0000000000000000000000000000000000000000..8476815c92df28c2f55231f1f728b966c233bda0 --- /dev/null +++ b/lib/Less/Tree/Mixin/Definition.php @@ -0,0 +1,231 @@ +<?php + +class Less_Tree_Mixin_Definition extends Less_Tree_Ruleset{ + public $name; + public $selectors; + public $params; + public $arity; + public $rules; + public $lookups; + public $required; + public $frames; + public $condition; + public $variadic; + public $type = 'MixinDefinition'; + + + // less.js : /lib/less/tree/mixin.js : tree.mixin.Definition + public function __construct($name, $params, $rules, $condition, $variadic = false){ + $this->name = $name; + $this->selectors = array(new Less_Tree_Selector(array( new Less_Tree_Element(null, $name)))); + + $this->params = $params; + $this->condition = $condition; + $this->variadic = $variadic; + $this->arity = count($params); + $this->rules = $rules; + $this->lookups = array(); + + $this->required = 0; + if( is_array($params) ){ + foreach( $params as $p ){ + if (! isset($p['name']) || ($p['name'] && !isset($p['value']))) { + $this->required++; + } + } + } + + $this->frames = array(); + $this->SetRulesetIndex(); + } + + + + //function accept( $visitor ){ + // $this->params = $visitor->visit($this->params); + // $this->rules = $visitor->visit($this->rules); + // $this->condition = $visitor->visit($this->condition); + //} + + + public function toCSS($env = null){ + return ''; + } + + // less.js : /lib/less/tree/mixin.js : tree.mixin.Definition.evalParams + public function compileParams($env, $mixinEnv, $args = array() , &$evaldArguments = array() ){ + $frame = new Less_Tree_Ruleset(null, array()); + $varargs; + $params = $this->params; + $val; + $name; + $isNamedFound; + + + $mixinEnv = clone $mixinEnv; + $mixinEnv->frames = array_merge( array($frame), $mixinEnv->frames); + //$mixinEnv = $mixinEnv->copyEvalEnv( array_merge( array($frame), $mixinEnv->frames) ); + + $args_len = count($args); + for($i = 0; $i < $args_len; $i++ ){ + $arg = $args[$i]; + + if( $arg && $arg['name'] ){ + $name = $arg['name']; + $isNamedFound = false; + + foreach($params as $j => $param){ + if( !isset($evaldArguments[$j]) && $name === $params[$j]['name']) { + $evaldArguments[$j] = $arg['value']->compile($env); + array_unshift($frame->rules, new Less_Tree_Rule( $name, $arg['value']->compile($env) ) ); + $isNamedFound = true; + break; + } + } + if ($isNamedFound) { + array_splice($args, $i, 1); + $i--; + $args_len--; + continue; + } else { + throw new Less_Exception_Compiler("Named argument for " . $this->name .' '.$args[$i]['name'] . ' not found'); + } + } + } + + $argIndex = 0; + foreach($params as $i => $param){ + + if ( isset($evaldArguments[$i]) ){ continue; } + + $arg = null; + if( array_key_exists($argIndex,$args) && $args[$argIndex] ){ + $arg = $args[$argIndex]; + } + + if (isset($param['name']) && $param['name']) { + $name = $param['name']; + + if( isset($param['variadic']) && $args ){ + $varargs = array(); + for ($j = $argIndex; $j < $args_len; $j++) { + $varargs[] = $args[$j]['value']->compile($env); + } + $expression = new Less_Tree_Expression($varargs); + array_unshift($frame->rules, new Less_Tree_Rule($param['name'], $expression->compile($env))); + }else{ + $val = ($arg && $arg['value']) ? $arg['value'] : false; + + if ($val) { + $val = $val->compile($env); + } else if ( isset($param['value']) ) { + $val = $param['value']->compile($mixinEnv); + $frame->resetCache(); + } else { + throw new Less_Exception_Compiler("Wrong number of arguments for " . $this->name . " (" . count($args) . ' for ' . $this->arity . ")"); + } + + array_unshift($frame->rules, new Less_Tree_Rule($param['name'], $val)); + $evaldArguments[$i] = $val; + } + } + + if ( isset($param['variadic']) && $args) { + for ($j = $argIndex; $j < $args_len; $j++) { + $evaldArguments[$j] = $args[$j]['value']->compile($env); + } + } + $argIndex++; + } + + asort($evaldArguments); + + return $frame; + } + + // less.js : /lib/less/tree/mixin.js : tree.mixin.Definition.eval + public function compile($env, $args = NULL, $important = NULL) { + $_arguments = array(); + + $mixinFrames = array_merge($this->frames, $env->frames); + + $mixinEnv = new Less_Environment(); + $mixinEnv->addFrames($mixinFrames); + + $frame = $this->compileParams($env, $mixinEnv, $args, $_arguments); + + + + $ex = new Less_Tree_Expression($_arguments); + array_unshift($frame->rules, new Less_Tree_Rule('@arguments', $ex->compile($env))); + + + $rules = array_slice($this->rules,0); + + $ruleset = new Less_Tree_Ruleset(null, $rules); + $ruleset->originalRuleset = $this->ruleset_id; + + + $ruleSetEnv = $env->copyEvalEnv( array_merge( array($this, $frame), $mixinFrames ) ); + $ruleset = $ruleset->compile( $ruleSetEnv ); + + if( $important ){ + $ruleset = $ruleset->makeImportant(); + } + return $ruleset; + } + + + public function matchCondition($args, $env) { + + if( !$this->condition ){ + return true; + } + + $frame = $this->compileParams($env, $env->copyEvalEnv(array_merge($this->frames,$env->frames)), $args ); + + $compile_env = $env->copyEvalEnv( + array_merge( + array($frame) // the parameter variables + , $this->frames // the parent namespace/mixin frames + , $env->frames // the current environment frames + ) + ); + + if( !$this->condition->compile($compile_env) ){ + return false; + } + + return true; + } + + public function matchArgs($args, $env = NULL){ + $argsLength = count($args); + + if( !$this->variadic ){ + if( $argsLength < $this->required ){ + return false; + } + if( $argsLength > count($this->params) ){ + return false; + } + }else{ + if( $argsLength < ($this->required - 1)){ + return false; + } + } + + $len = min($argsLength, $this->arity); + + for( $i = 0; $i < $len; $i++ ){ + if( !isset($this->params[$i]['name']) && !isset($this->params[$i]['variadic']) ){ + if( $args[$i]['value']->compile($env)->toCSS() != $this->params[$i]['value']->compile($env)->toCSS() ){ + return false; + } + } + } + + return true; + } + +} diff --git a/lib/Less/Tree/Negative.php b/lib/Less/Tree/Negative.php new file mode 100644 index 0000000000000000000000000000000000000000..42d4c626aef6c349bd8c659af22d49e0db4fcff8 --- /dev/null +++ b/lib/Less/Tree/Negative.php @@ -0,0 +1,29 @@ +<?php + + +class Less_Tree_Negative extends Less_Tree{ + + public $value; + public $type = 'Negative'; + + function __construct($node){ + $this->value = $node; + } + + //function accept($visitor) { + // $this->value = $visitor->visit($this->value); + //} + + function genCSS( $env, &$strs ){ + self::OutputAdd( $strs, '-' ); + $this->value->genCSS( $env, $strs ); + } + + function compile($env) { + if( $env->isMathOn() ){ + $ret = new Less_Tree_Operation('*', array( new Less_Tree_Dimension(-1), $this->value ) ); + return $ret->compile($env); + } + return new Less_Tree_Negative( $this->value->compile($env) ); + } +} \ No newline at end of file diff --git a/lib/Less/Tree/Operation.php b/lib/Less/Tree/Operation.php new file mode 100644 index 0000000000000000000000000000000000000000..5d67e7967ec6df4c403768c568a712e7a709258c --- /dev/null +++ b/lib/Less/Tree/Operation.php @@ -0,0 +1,58 @@ +<?php + + +class Less_Tree_Operation extends Less_Tree{ + + public $type = 'Operation'; + + public function __construct($op, $operands, $isSpaced = false){ + $this->op = trim($op); + $this->operands = $operands; + $this->isSpaced = $isSpaced; + } + + function accept($visitor) { + $this->operands = $visitor->visitArray($this->operands); + } + + public function compile($env){ + $a = $this->operands[0]->compile($env); + $b = $this->operands[1]->compile($env); + + + if( $env->isMathOn() ){ + + if( $a instanceof Less_Tree_Dimension ){ + + if( $b instanceof Less_Tree_Color ){ + if ($this->op === '*' || $this->op === '+') { + $temp = $b; + $b = $a; + $a = $temp; + } else { + throw new Less_Exception_Compiler("Operation on an invalid type"); + } + } + }elseif( !($a instanceof Less_Tree_Color) ){ + throw new Less_Exception_Compiler("Operation on an invalid type"); + } + + return $a->operate($env,$this->op, $b); + } else { + return new Less_Tree_Operation($this->op, array($a, $b), $this->isSpaced ); + } + } + + function genCSS( $env, &$strs ){ + $this->operands[0]->genCSS( $env, $strs ); + if( $this->isSpaced ){ + self::OutputAdd( $strs, " " ); + } + self::OutputAdd( $strs, $this->op ); + if( $this->isSpaced ){ + self::OutputAdd( $strs, ' ' ); + } + $this->operands[1]->genCSS( $env, $strs ); + } + +} diff --git a/lib/Less/Tree/Paren.php b/lib/Less/Tree/Paren.php new file mode 100644 index 0000000000000000000000000000000000000000..aab1337b6049b476c49310bec1012cb4e195b7cc --- /dev/null +++ b/lib/Less/Tree/Paren.php @@ -0,0 +1,26 @@ +<?php + +class Less_Tree_Paren extends Less_Tree{ + + public $value; + public $type = 'Paren'; + + public function __construct($value) { + $this->value = $value; + } + + function accept($visitor){ + $this->value = $visitor->visitObj($this->value); + } + + function genCSS( $env, &$strs ){ + self::OutputAdd( $strs, '(' ); + $this->value->genCSS( $env, $strs ); + self::OutputAdd( $strs, ')' ); + } + + public function compile($env) { + return new Less_Tree_Paren($this->value->compile($env)); + } + +} diff --git a/lib/Less/Tree/Quoted.php b/lib/Less/Tree/Quoted.php new file mode 100644 index 0000000000000000000000000000000000000000..26a67d9c8908b909c9f63823ad98e14711879b14 --- /dev/null +++ b/lib/Less/Tree/Quoted.php @@ -0,0 +1,67 @@ +<?php + + +class Less_Tree_Quoted extends Less_Tree{ + public $value; + public $content; + public $index; + public $currentFileInfo; + public $type = 'Quoted'; + + public function __construct($str, $content = '', $escaped = false, $index = false, $currentFileInfo = null ){ + $this->escaped = $escaped; + $this->value = $content; + $this->quote = $str[0]; + $this->index = $index; + $this->currentFileInfo = $currentFileInfo; + } + + public function genCSS( $env, &$strs ){ + if( !$this->escaped ){ + self::OutputAdd( $strs, $this->quote, $this->currentFileInfo, $this->index ); + } + self::OutputAdd( $strs, $this->value ); + if( !$this->escaped ){ + self::OutputAdd( $strs, $this->quote ); + } + } + + public function compile($env){ + + $value = $this->value; + if( preg_match_all('/`([^`]+)`/', $this->value, $matches) ){ + foreach($matches as $i => $match){ + $js = new Less_Tree_JavaScript($matches[1], $this->index, true); + $js = $js->compile($env)->value; + $value = str_replace($matches[0][$i], $js, $value); + } + } + + if( preg_match_all('/@\{([\w-]+)\}/',$value,$matches) ){ + foreach($matches[1] as $i => $match){ + $v = new Less_Tree_Variable('@' . $match, $this->index, $this->currentFileInfo ); + $v = $v->compile($env,true); + $v = ($v instanceof Less_Tree_Quoted) ? $v->value : $v->toCSS($env); + $value = str_replace($matches[0][$i], $v, $value); + } + } + + return new Less_Tree_Quoted($this->quote . $value . $this->quote, $value, $this->escaped, $this->index); + } + + function compare($x) { + + if( !Less_Parser::is_method($x, 'toCSS') ){ + return -1; + } + + $left = $this->toCSS(); + $right = $x->toCSS(); + + if ($left === $right) { + return 0; + } + + return $left < $right ? -1 : 1; + } +} diff --git a/lib/Less/Tree/Rule.php b/lib/Less/Tree/Rule.php new file mode 100644 index 0000000000000000000000000000000000000000..4d3748fe6734dcb865a8fab54f2c617f6a29f2d5 --- /dev/null +++ b/lib/Less/Tree/Rule.php @@ -0,0 +1,73 @@ +<?php + + +class Less_Tree_Rule extends Less_Tree{ + + public $name; + public $value; + public $important; + public $merge; + public $index; + public $inline; + public $variable; + public $currentFileInfo; + public $type = 'Rule'; + + public function __construct($name, $value = null, $important = null, $merge = null, $index = null, $currentFileInfo = null, $inline = false){ + $this->name = $name; + $this->value = ($value instanceof Less_Tree_Value) ? $value : new Less_Tree_Value(array($value)); + $this->important = $important ? ' ' . trim($important) : ''; + $this->merge = $merge; + $this->index = $index; + $this->currentFileInfo = $currentFileInfo; + $this->inline = $inline; + $this->variable = ($name[0] === '@'); + } + + function accept($visitor) { + $this->value = $visitor->visitObj( $this->value ); + } + + function genCSS( $env, &$strs ){ + + self::OutputAdd( $strs, $this->name . Less_Environment::$colon_space, $this->currentFileInfo, $this->index); + try{ + $this->value->genCSS($env, $strs); + + }catch( Exception $e ){ + $e->index = $this->index; + $e->filename = $this->currentFileInfo['filename']; + throw $e; + } + self::OutputAdd( $strs, $this->important . (($this->inline || ($env->lastRule && Less_Environment::$compress)) ? "" : ";"), $this->currentFileInfo, $this->index); + } + + public function compile ($env){ + + $return = null; + $strictMathBypass = false; + if( $this->name === "font" && !$env->strictMath ){ + $strictMathBypass = true; + $env->strictMath = true; + } + + $return = new Less_Tree_Rule($this->name, + $this->value->compile($env), + $this->important, + $this->merge, + $this->index, + $this->currentFileInfo, + $this->inline); + + if( $strictMathBypass ){ + $env->strictMath = false; + } + + return $return; + } + + function makeImportant(){ + return new Less_Tree_Rule($this->name, $this->value, '!important', $this->merge, $this->index, $this->currentFileInfo, $this->inline); + } + +} diff --git a/lib/Less/Tree/Ruleset.php b/lib/Less/Tree/Ruleset.php new file mode 100644 index 0000000000000000000000000000000000000000..4bc875bd04681529245c2ff2d781325383a48c3b --- /dev/null +++ b/lib/Less/Tree/Ruleset.php @@ -0,0 +1,535 @@ +<?php + + +class Less_Tree_Ruleset extends Less_Tree{ + + protected $lookups; + public $_variables; + public $_rulesets; + + public $strictImports; + + public $selectors; + public $rules; + public $root; + public $allowImports; + public $paths; + public $firstRoot; + public $type = 'Ruleset'; + + + var $ruleset_id; + var $originalRuleset; + + + public function SetRulesetIndex(){ + $this->ruleset_id = Less_Parser::$next_id++; + $this->originalRuleset = $this->ruleset_id; + } + + public function __construct($selectors, $rules, $strictImports = null){ + $this->selectors = $selectors; + $this->rules = $rules; + $this->lookups = array(); + $this->strictImports = $strictImports; + $this->SetRulesetIndex(); + } + + function accept( $visitor ){ + if( $this->paths ){ + $paths_len = count($this->paths); + for($i = 0,$paths_len; $i < $paths_len; $i++ ){ + $this->paths[$i] = $visitor->visitArray($this->paths[$i]); + } + }elseif( $this->selectors ){ + $this->selectors = $visitor->visitArray($this->selectors); + } + + if( $this->rules ){ + $this->rules = $visitor->visitArray($this->rules); + } + } + + public function compile($env){ + + $selectors = array(); + if( $this->selectors ){ + foreach($this->selectors as $s){ + $selectors[] = $s->compile($env); + } + } + $ruleset = new Less_Tree_Ruleset($selectors, $this->rules, $this->strictImports); + $rules = array(); + + $ruleset->originalRuleset = $this->ruleset_id; + + $ruleset->root = $this->root; + $ruleset->firstRoot = $this->firstRoot; + $ruleset->allowImports = $this->allowImports; + + // push the current ruleset to the frames stack + $env->unshiftFrame($ruleset); + + // currrent selectors + array_unshift($env->selectors,$this->selectors); + + + // Evaluate imports + if ($ruleset->root || $ruleset->allowImports || !$ruleset->strictImports) { + $ruleset->evalImports($env); + } + + + // Store the frames around mixin definitions, + // so they can be evaluated like closures when the time comes. + $ruleset_len = count($ruleset->rules); + for( $i = 0; $i < $ruleset_len; $i++ ){ + if( $ruleset->rules[$i] instanceof Less_Tree_Mixin_Definition ){ + $ruleset->rules[$i]->frames = array_slice($env->frames,0); + } + } + + $mediaBlockCount = 0; + if( $env instanceof Less_Environment ){ + $mediaBlockCount = count($env->mediaBlocks); + } + + // Evaluate mixin calls. + for($i=0; $i < $ruleset_len; $i++){ + $rule = $ruleset->rules[$i]; + if( $rule instanceof Less_Tree_Mixin_Call ){ + $rules = $rule->compile($env); + + $temp = array(); + foreach($rules as $r){ + if( ($r instanceof Less_Tree_Rule) && $r->variable ){ + // do not pollute the scope if the variable is + // already there. consider returning false here + // but we need a way to "return" variable from mixins + if( !$ruleset->variable($r->name) ){ + $temp[] = $r; + } + }else{ + $temp[] = $r; + } + } + $temp_count = count($temp)-1; + array_splice($ruleset->rules, $i, 1, $temp); + $ruleset_len += $temp_count; + $i += $temp_count; + $ruleset->resetCache(); + } + } + + + for( $i=0; $i<$ruleset_len; $i++ ){ + if(! ($ruleset->rules[$i] instanceof Less_Tree_Mixin_Definition) ){ + $ruleset->rules[$i] = $ruleset->rules[$i]->compile($env); + } + } + + + // Pop the stack + $env->shiftFrame(); + array_shift($env->selectors); + + if ($mediaBlockCount) { + $len = count($env->mediaBlocks); + for($i = $mediaBlockCount; $i < $len; $i++ ){ + $env->mediaBlocks[$i]->bubbleSelectors($selectors); + } + } + + return $ruleset; + } + + function evalImports($env) { + + $rules_len = count($this->rules); + for($i=0; $i < $rules_len; $i++){ + $rule = $this->rules[$i]; + + if( $rule instanceof Less_Tree_Import ){ + $rules = $rule->compile($env); + if( is_array($rules) ){ + array_splice($this->rules, $i, 1, $rules); + $temp_count = count($rules)-1; + $i += $temp_count; + $rules_len += $temp_count; + }else{ + array_splice($this->rules, $i, 1, array($rules)); + } + + $this->resetCache(); + } + } + } + + function makeImportant(){ + + $important_rules = array(); + foreach($this->rules as $rule){ + if( $rule instanceof Less_Tree_Rule || $rule instanceof Less_Tree_Ruleset ){ + $important_rules[] = $rule->makeImportant(); + }else{ + $important_rules[] = $rule; + } + } + + return new Less_Tree_Ruleset($this->selectors, $important_rules, $this->strictImports ); + } + + public function matchArgs($args){ + return !is_array($args) || !$args; + } + + public function matchCondition( $args, $env ){ + $lastSelector = end($this->selectors); + if( $lastSelector->condition && !$lastSelector->condition->compile( $env->copyEvalEnv( $env->frames ) ) ){ + return false; + } + return true; + } + + function resetCache() { + $this->_rulesets = null; + $this->_variables = null; + $this->lookups = array(); + } + + public function variables(){ + + if( !$this->_variables ){ + $this->_variables = array(); + foreach( $this->rules as $r){ + if ($r instanceof Less_Tree_Rule && $r->variable === true) { + $this->_variables[$r->name] = $r; + } + } + } + + return $this->_variables; + } + + public function variable($name){ + $vars = $this->variables(); + return isset($vars[$name]) ? $vars[$name] : null; + } + + public function find( $selector, $self = null, $env = null){ + + if( !$self ){ + $self = $this->ruleset_id; + } + + $key = $selector->toCSS($env); + + if( !array_key_exists($key, $this->lookups) ){ + $this->lookups[$key] = array(); + + + foreach($this->rules as $rule){ + + if( ($rule instanceof Less_Tree_Ruleset) || ($rule instanceof Less_Tree_Mixin_Definition) ){ + + if( $rule->ruleset_id == $self ){ + continue; + } + + foreach( $rule->selectors as $ruleSelector ){ + $match = $selector->match($ruleSelector); + if( $match ){ + if( $selector->elements_len > $match ){ + $this->lookups[$key] = array_merge($this->lookups[$key], $rule->find( new Less_Tree_Selector(array_slice($selector->elements, $match)), $self, $env)); + } else { + $this->lookups[$key][] = $rule; + } + break; + } + } + } + } + } + + return $this->lookups[$key]; + } + + public function genCSS( $env, &$strs ){ + $ruleNodes = array(); + $rulesetNodes = array(); + $firstRuleset = true; + + if( !$this->root ){ + $env->tabLevel++; + } + + $tabRuleStr = $tabSetStr = ''; + if( !Less_Environment::$compress && $env->tabLevel ){ + $tabRuleStr = str_repeat( ' ' , $env->tabLevel ); + $tabSetStr = str_repeat( ' ' , $env->tabLevel-1 ); + } + + foreach($this->rules as $rule){ + + $class = get_class($rule); + if( ($class === 'Less_Tree_Media') || ($class === 'Less_Tree_Directive') || ($this->root && $class === 'Less_Tree_Comment') || ($class === 'Less_Tree_Ruleset' && $rule->rules) ){ + $rulesetNodes[] = $rule; + }else{ + $ruleNodes[] = $rule; + } + } + + // If this is the root node, we don't render + // a selector, or {}. + if( !$this->root ){ + + /* + debugInfo = tree.debugInfo(env, this, tabSetStr); + + if (debugInfo) { + output.add(debugInfo); + output.add(tabSetStr); + } + */ + + for( $i = 0,$paths_len = count($this->paths); $i < $paths_len; $i++ ){ + $path = $this->paths[$i]; + Less_Environment::$firstSelector = true; + foreach($path as $p){ + $p->genCSS($env, $strs ); + Less_Environment::$firstSelector = false; + } + if( $i + 1 < $paths_len ){ + self::OutputAdd( $strs, Less_Environment::$compress ? ',' : (",\n" . $tabSetStr) ); + } + } + + self::OutputAdd( $strs, (Less_Environment::$compress ? '{' : " {\n") . $tabRuleStr ); + } + + // Compile rules and rulesets + $ruleNodes_len = count($ruleNodes); + $rulesetNodes_len = count($rulesetNodes); + for( $i = 0; $i < $ruleNodes_len; $i++ ){ + $rule = $ruleNodes[$i]; + + // @page{ directive ends up with root elements inside it, a mix of rules and rulesets + // In this instance we do not know whether it is the last property + if( $i + 1 === $ruleNodes_len && (!$this->root || $rulesetNodes_len === 0 || $this->firstRoot ) ){ + $env->lastRule = true; + } + + if( is_object($rule) ){ + if( method_exists($rule,'genCSS') ){ + $rule->genCSS( $env, $strs ); + }elseif( property_exists($rule,'value') && $rule->value ){ + self::OutputAdd( $strs, (string)$rule->value ); + } + } + + if( !$env->lastRule ){ + self::OutputAdd( $strs, Less_Environment::$compress ? '' : ("\n" . $tabRuleStr) ); + }else{ + $env->lastRule = false; + } + } + + if( !$this->root ){ + self::OutputAdd( $strs, (Less_Environment::$compress ? '}' : "\n" . $tabSetStr . '}')); + $env->tabLevel--; + } + + for( $i = 0; $i < $rulesetNodes_len; $i++ ){ + if( $ruleNodes_len && $firstRuleset ){ + self::OutputAdd( $strs, (Less_Environment::$compress ? "" : "\n") . ($this->root ? $tabRuleStr : $tabSetStr) ); + } + if( !$firstRuleset ){ + self::OutputAdd( $strs, (Less_Environment::$compress ? "" : "\n") . ($this->root ? $tabRuleStr : $tabSetStr)); + } + $firstRuleset = false; + $rulesetNodes[$i]->genCSS($env, $strs); + } + + if( !$strs && !Less_Environment::$compress && $this->firstRoot ){ + self::OutputAdd( $strs, "\n" ); + } + + } + + function markReferenced(){ + + foreach($this->selectors as $selector){ + $selector->markReferenced(); + } + } + + public function joinSelectors( $context, $selectors ){ + $paths = array(); + if( is_array($selectors) ){ + foreach($selectors as $selector) { + $this->joinSelector( $paths, $context, $selector); + } + } + return $paths; + } + + public function joinSelector( &$paths, $context, $selector){ + + $hasParentSelector = false; + + foreach($selector->elements as $el) { + if( $el->value === '&') { + $hasParentSelector = true; + } + } + + if( !$hasParentSelector ){ + if( $context ){ + foreach($context as $context_el){ + $paths[] = array_merge($context_el, array($selector) ); + } + }else { + $paths[] = array($selector); + } + return; + } + + + // The paths are [[Selector]] + // The first list is a list of comma seperated selectors + // The inner list is a list of inheritance seperated selectors + // e.g. + // .a, .b { + // .c { + // } + // } + // == [[.a] [.c]] [[.b] [.c]] + // + + // the elements from the current selector so far + $currentElements = array(); + // the current list of new selectors to add to the path. + // We will build it up. We initiate it with one empty selector as we "multiply" the new selectors + // by the parents + $newSelectors = array(array()); + + + foreach( $selector->elements as $el){ + + // non parent reference elements just get added + if( $el->value !== '&' ){ + $currentElements[] = $el; + } else { + // the new list of selectors to add + $selectorsMultiplied = array(); + + // merge the current list of non parent selector elements + // on to the current list of selectors to add + if( $currentElements ){ + $this->mergeElementsOnToSelectors( $currentElements, $newSelectors); + } + + // loop through our current selectors + foreach($newSelectors as $sel){ + + // if we don't have any parent paths, the & might be in a mixin so that it can be used + // whether there are parents or not + if( !$context ){ + // the combinator used on el should now be applied to the next element instead so that + // it is not lost + if( $sel ){ + $sel[0]->elements = array_slice($sel[0]->elements,0); + $sel[0]->elements[] = new Less_Tree_Element($el->combinator, '', 0, $el->index, $el->currentFileInfo ); + } + $selectorsMultiplied[] = $sel; + }else { + + // and the parent selectors + foreach($context as $parentSel){ + // We need to put the current selectors + // then join the last selector's elements on to the parents selectors + + // our new selector path + $newSelectorPath = array(); + // selectors from the parent after the join + $afterParentJoin = array(); + $newJoinedSelectorEmpty = true; + + //construct the joined selector - if & is the first thing this will be empty, + // if not newJoinedSelector will be the last set of elements in the selector + if( $sel ){ + $newSelectorPath = $sel; + $lastSelector = array_pop($newSelectorPath); + $newJoinedSelector = $selector->createDerived( array_slice($lastSelector->elements,0) ); + $newJoinedSelectorEmpty = false; + } + else { + $newJoinedSelector = $selector->createDerived(array()); + } + + //put together the parent selectors after the join + if ( count($parentSel) > 1) { + $afterParentJoin = array_merge($afterParentJoin, array_slice($parentSel,1) ); + } + + if ( $parentSel ){ + $newJoinedSelectorEmpty = false; + + // join the elements so far with the first part of the parent + $newJoinedSelector->elements[] = new Less_Tree_Element( $el->combinator, $parentSel[0]->elements[0]->value, 0, $el->index, $el->currentFileInfo); + + $newJoinedSelector->elements = array_merge( $newJoinedSelector->elements, array_slice($parentSel[0]->elements, 1) ); + } + + if (!$newJoinedSelectorEmpty) { + // now add the joined selector + $newSelectorPath[] = $newJoinedSelector; + } + + // and the rest of the parent + $newSelectorPath = array_merge($newSelectorPath, $afterParentJoin); + + // add that to our new set of selectors + $selectorsMultiplied[] = $newSelectorPath; + } + } + } + + // our new selectors has been multiplied, so reset the state + $newSelectors = $selectorsMultiplied; + $currentElements = array(); + } + } + + // if we have any elements left over (e.g. .a& .b == .b) + // add them on to all the current selectors + if( $currentElements ){ + $this->mergeElementsOnToSelectors($currentElements, $newSelectors); + } + foreach( $newSelectors as $new_sel){ + if( $new_sel ){ + $paths[] = $new_sel; + } + } + } + + function mergeElementsOnToSelectors( $elements, &$selectors){ + + if( !$selectors ){ + $selectors[] = array( new Less_Tree_Selector($elements) ); + return; + } + + + foreach( $selectors as &$sel){ + + // if the previous thing in sel is a parent this needs to join on to it + if( $sel ){ + $last = count($sel)-1; + $sel[$last] = $sel[$last]->createDerived( array_merge($sel[$last]->elements, $elements) ); + }else{ + $sel[] = new Less_Tree_Selector( $elements ); + } + } + } +} diff --git a/lib/Less/Tree/Selector.php b/lib/Less/Tree/Selector.php new file mode 100644 index 0000000000000000000000000000000000000000..2d2a8487c62733ab0866df468c6291e84111ab78 --- /dev/null +++ b/lib/Less/Tree/Selector.php @@ -0,0 +1,128 @@ +<?php + + +class Less_Tree_Selector extends Less_Tree{ + + public $elements; + public $extendList = array(); + public $_css; + public $index; + public $evaldCondition = false; + public $type = 'Selector'; + public $currentFileInfo = array(); + + public $elements_len = 0; + + public function __construct($elements = null, $extendList=null , $condition = null, $index=null, $currentFileInfo=null, $isReferenced=null ){ + + + + $this->elements = $elements; + $this->elements_len = count($elements); + if( $extendList ){ + $this->extendList = $extendList; + } + $this->condition = $condition; + if( $currentFileInfo ){ + $this->currentFileInfo = $currentFileInfo; + } + $this->isReferenced = $isReferenced; + if( !$condition ){ + $this->evaldCondition = true; + } + } + + function accept($visitor) { + $this->elements = $visitor->visitArray($this->elements); + $this->extendList = $visitor->visitArray($this->extendList); + if( $this->condition ){ + $this->condition = $visitor->visitObj($this->condition); + } + } + + function createDerived( $elements, $extendList = null, $evaldCondition = null ){ + $evaldCondition = $evaldCondition != null ? $evaldCondition : $this->evaldCondition; + $newSelector = new Less_Tree_Selector( $elements, ($extendList ? $extendList : $this->extendList), $this->condition, $this->index, $this->currentFileInfo, $this->isReferenced); + $newSelector->evaldCondition = $evaldCondition; + return $newSelector; + } + + public function match($other) { + global $debug; + + if( !$other ){ + return 0; + } + + $offset = 0; + $olen = $other->elements_len; + if( $olen ){ + if( $other->elements[0]->value === "&" ){ + $offset = 1; + } + $olen -= $offset; + } + + if( $olen === 0 ){ + return 0; + } + + if( $this->elements_len < $olen ){ + return 0; + } + + for ($i = 0; $i < $olen; $i ++) { + if ($this->elements[$i]->value !== $other->elements[$i + $offset]->value) { + return 0; + } + } + + return $olen; // return number of matched selectors + } + + public function compile($env) { + + $elements = array(); + foreach($this->elements as $el){ + $elements[] = $el->compile($env); + } + + $extendList = array(); + foreach($this->extendList as $el){ + $extendList[] = $el->compile($el); + } + + $evaldCondition = false; + if( $this->condition ){ + $evaldCondition = $this->condition->compile($env); + } + + return $this->createDerived( $elements, $extendList, $evaldCondition ); + } + + function genCSS( $env, &$strs ){ + + if( !Less_Environment::$firstSelector && $this->elements[0]->combinator->value === "" ){ + self::OutputAdd( $strs, ' ', $this->currentFileInfo, $this->index ); + } + if( !$this->_css ){ + //TODO caching? speed comparison? + foreach($this->elements as $element){ + $element->genCSS( $env, $strs ); + } + } + } + + function markReferenced(){ + $this->isReferenced = true; + } + + function getIsReferenced(){ + return !isset($this->currentFileInfo['reference']) || !$this->currentFileInfo['reference'] || $this->isReferenced; + } + + function getIsOutput(){ + return $this->evaldCondition; + } + +} diff --git a/lib/Less/Tree/UnicodeDescriptor.php b/lib/Less/Tree/UnicodeDescriptor.php new file mode 100644 index 0000000000000000000000000000000000000000..52ff142c502507c140d0864fafb6975ae272c408 --- /dev/null +++ b/lib/Less/Tree/UnicodeDescriptor.php @@ -0,0 +1,20 @@ +<?php + + +class Less_Tree_UnicodeDescriptor extends Less_Tree{ + + public $type = 'UnicodeDescriptor'; + + public function __construct($value){ + $this->value = $value; + } + + public function genCSS( $env, &$strs ){ + self::OutputAdd( $strs, $this->value ); + } + + public function compile($env){ + return $this; + } +} + diff --git a/lib/Less/Tree/Unit.php b/lib/Less/Tree/Unit.php new file mode 100644 index 0000000000000000000000000000000000000000..fdb25d3e157249cee1cf72693c10cc0fc42c4640 --- /dev/null +++ b/lib/Less/Tree/Unit.php @@ -0,0 +1,130 @@ +<?php + + +class Less_Tree_Unit extends Less_Tree{ + + var $numerator = array(); + var $denominator = array(); + public $type = 'Unit'; + + function __construct($numerator = array(), $denominator = array(), $backupUnit = null ){ + $this->numerator = $numerator; + $this->denominator = $denominator; + $this->backupUnit = $backupUnit; + } + + function __clone(){ + } + + function genCSS( $env, &$strs ){ + + if( $this->numerator ){ + self::OutputAdd( $strs, $this->numerator[0] ); + }elseif( $this->denominator ){ + self::OutputAdd( $strs, $this->denominator[0] ); + }elseif( (!$env || !$env->strictUnits) && $this->backupUnit ){ + self::OutputAdd( $strs, $this->backupUnit ); + return ; + } + } + + function toString(){ + $returnStr = implode('*',$this->numerator); + foreach($this->denominator as $d){ + $returnStr .= '/'.$d; + } + return $returnStr; + } + + function compare($other) { + return $this->is( $other->toString() ) ? 0 : -1; + } + + function is($unitString){ + return $this->toString() === $unitString; + } + + function isLength(){ + $css = $this->toCSS(); + return !!preg_match('/px|em|%|in|cm|mm|pc|pt|ex/',$css); + } + + function isAngle() { + return isset( Less_Tree_UnitConversions::$angle[$this->toCSS()] ); + } + + function isEmpty(){ + return !$this->numerator && !$this->denominator; + } + + function isSingular() { + return count($this->numerator) <= 1 && !$this->denominator; + } + + + function usedUnits(){ + $result = array(); + + foreach(Less_Tree_UnitConversions::$groups as $groupName){ + $group = Less_Tree_UnitConversions::${$groupName}; + + foreach($this->numerator as $atomicUnit){ + if( isset($group[$atomicUnit]) && !isset($result[$groupName]) ){ + $result[$groupName] = $atomicUnit; + } + } + + foreach($this->denominator as $atomicUnit){ + if( isset($group[$atomicUnit]) && !isset($result[$groupName]) ){ + $result[$groupName] = $atomicUnit; + } + } + } + + return $result; + } + + function cancel(){ + $counter = array(); + $backup = null; + + foreach($this->numerator as $atomicUnit){ + if( !$backup ){ + $backup = $atomicUnit; + } + $counter[$atomicUnit] = ( isset($counter[$atomicUnit]) ? $counter[$atomicUnit] : 0) + 1; + } + + foreach($this->denominator as $atomicUnit){ + if( !$backup ){ + $backup = $atomicUnit; + } + $counter[$atomicUnit] = ( isset($counter[$atomicUnit]) ? $counter[$atomicUnit] : 0) - 1; + } + + $this->numerator = array(); + $this->denominator = array(); + + foreach($counter as $atomicUnit => $count){ + if( $count > 0 ){ + for( $i = 0; $i < $count; $i++ ){ + $this->numerator[] = $atomicUnit; + } + }elseif( $count < 0 ){ + for( $i = 0; $i < -$count; $i++ ){ + $this->denominator[] = $atomicUnit; + } + } + } + + if( !$this->numerator && !$this->denominator && $backup ){ + $this->backupUnit = $backup; + } + + sort($this->numerator); + sort($this->denominator); + } + + +} + diff --git a/lib/Less/Tree/UnitConversions.php b/lib/Less/Tree/UnitConversions.php new file mode 100644 index 0000000000000000000000000000000000000000..82aa93b2e62e0c0e1fe8207202f5e5887d933838 --- /dev/null +++ b/lib/Less/Tree/UnitConversions.php @@ -0,0 +1,29 @@ +<?php + + +class Less_Tree_UnitConversions{ + + static $groups = array('length','duration','angle'); + + static $length = array( + 'm'=> 1, + 'cm'=> 0.01, + 'mm'=> 0.001, + 'in'=> 0.0254, + 'pt'=> 0.000352778, // 0.0254 / 72, + 'pc'=> 0.004233333, //0.0254 / 72 * 12 + ); + + static $duration = array( + 's'=> 1, + 'ms'=> 0.001 + ); + + static $angle = array( + 'rad' => 0.1591549430919, // 1/(2*M_PI), + 'deg' => 0.002777778, // 1/360, + 'grad'=> 0.0025, // 1/400, + 'turn'=> 1 + ); + +} \ No newline at end of file diff --git a/lib/Less/Tree/Url.php b/lib/Less/Tree/Url.php new file mode 100644 index 0000000000000000000000000000000000000000..999ca33f7c26230b1c604dfba3a40918428a6c90 --- /dev/null +++ b/lib/Less/Tree/Url.php @@ -0,0 +1,43 @@ +<?php + + +class Less_Tree_Url extends Less_Tree{ + + public $attrs; + public $value; + public $currentFileInfo; + public $type = 'Url'; + + public function __construct($value, $currentFileInfo = null){ + $this->value = $value; + $this->currentFileInfo = $currentFileInfo; + } + + function accept( $visitor ){ + $this->value = $visitor->visitObj($this->value); + } + + function genCSS( $env, &$strs ){ + self::OutputAdd( $strs, 'url(' ); + $this->value->genCSS( $env, $strs ); + self::OutputAdd( $strs, ')' ); + } + + public function compile($ctx){ + $val = $this->value->compile($ctx); + + // Add the base path if the URL is relative + if( $this->currentFileInfo && is_string($val->value) && Less_Environment::isPathRelative($val->value) ){ + $rootpath = $this->currentFileInfo['uri_root']; + if ( !$val->quote ){ + $rootpath = preg_replace('/[\(\)\'"\s]/', '\\$1', $rootpath ); + } + $val->value = $rootpath . $val->value; + } + + $val->value = Less_Environment::normalizePath( $val->value); + + return new Less_Tree_URL($val, null); + } + +} diff --git a/lib/Less/Tree/Value.php b/lib/Less/Tree/Value.php new file mode 100644 index 0000000000000000000000000000000000000000..86bd1759307b3e63cb2c3147ed3c3722ef53be8f --- /dev/null +++ b/lib/Less/Tree/Value.php @@ -0,0 +1,38 @@ +<?php + + +class Less_Tree_Value extends Less_Tree{ + + public $type = 'Value'; + + public function __construct($value=null){ + $this->value = $value; + } + + function accept($visitor) { + $this->value = $visitor->visitArray($this->value); + } + + public function compile($env){ + + $ret = array(); + foreach($this->value as $i => $v){ + $ret[] = $v->compile($env); + } + if( $i > 0 ){ + return new Less_Tree_Value($ret); + } + return $ret[0]; + } + + function genCSS( $env, &$strs ){ + $len = count($this->value); + for($i = 0; $i < $len; $i++ ){ + $this->value[$i]->genCSS( $env, $strs); + if( $i+1 < $len ){ + self::OutputAdd( $strs, Less_Environment::$comma_space ); + } + } + } + +} diff --git a/lib/Less/Tree/Variable.php b/lib/Less/Tree/Variable.php new file mode 100644 index 0000000000000000000000000000000000000000..74ac333a81cf7784cb2f710d4140e7df80a55f29 --- /dev/null +++ b/lib/Less/Tree/Variable.php @@ -0,0 +1,42 @@ +<?php + + +class Less_Tree_Variable extends Less_Tree{ + + public $name; + public $index; + public $currentFileInfo; + public $evaluating = false; + public $type = 'Variable'; + + public function __construct($name, $index, $currentFileInfo = null) { + $this->name = $name; + $this->index = $index; + $this->currentFileInfo = $currentFileInfo; + } + + public function compile($env) { + $name = $this->name; + if (strpos($name, '@@') === 0) { + $v = new Less_Tree_Variable(substr($name, 1), $this->index + 1); + $name = '@' . $v->compile($env)->value; + } + + if ($this->evaluating) { + throw new Less_Exception_Compiler("Recursive variable definition for " . $name, $this->index, null, $this->currentFileInfo['filename']); + } + + $this->evaluating = true; + + + foreach($env->frames as $frame){ + if( $v = $frame->variable($name) ){ + $this->evaluating = false; + return $v->value->compile($env); + } + } + + throw new Less_Exception_Compiler("variable " . $name . " is undefined", $this->index, null); + } + +} diff --git a/lib/Less/Visitor.php b/lib/Less/Visitor.php new file mode 100644 index 0000000000000000000000000000000000000000..760fa98304f78698e06ca55352257f507da4c58b --- /dev/null +++ b/lib/Less/Visitor.php @@ -0,0 +1,43 @@ +<?php + +class Less_Visitor{ + + var $methods = array(); + var $_visitFnCache = array(); + + function __construct(){ + $this->_visitFnCache = get_class_methods(get_class($this)); + $this->_visitFnCache = array_flip($this->_visitFnCache); + } + + function visitObj( $node ){ + + $funcName = 'visit'.$node->type; + if( isset($this->_visitFnCache[$funcName]) ){ + + $visitDeeper = true; + $this->$funcName( $node, $visitDeeper ); + + if( $visitDeeper ){ + $node->accept($this); + } + + $funcName = $funcName . "Out"; + if( isset($this->_visitFnCache[$funcName]) ){ + $this->$funcName( $node ); + } + + }else{ + $node->accept($this); + } + + return $node; + } + + function visitArray( $nodes ){ + + array_map( array($this,'visitObj'), $nodes); + return $nodes; + } +} + diff --git a/lib/Less/Visitor/extendFinder.php b/lib/Less/Visitor/extendFinder.php new file mode 100644 index 0000000000000000000000000000000000000000..c31de938b2fd4b00043dcceaac3344d281646bd7 --- /dev/null +++ b/lib/Less/Visitor/extendFinder.php @@ -0,0 +1,108 @@ +<?php + + +class Less_Visitor_extendFinder extends Less_Visitor{ + + public $contexts = array(); + public $allExtendsStack; + public $foundExtends; + + function __construct(){ + $this->contexts = array(); + $this->allExtendsStack = array(array()); + parent::__construct(); + } + + function run($root){ + $root = $this->visitObj($root); + $root->allExtends =& $this->allExtendsStack[0]; + return $root; + } + + function visitRule($ruleNode, &$visitDeeper ){ + $visitDeeper = false; + } + + function visitMixinDefinition( $mixinDefinitionNode, &$visitDeeper ){ + $visitDeeper = false; + } + + function visitRuleset($rulesetNode){ + + if( $rulesetNode->root ){ + return; + } + + $allSelectorsExtendList = array(); + + // get &:extend(.a); rules which apply to all selectors in this ruleset + $rules = $rulesetNode->rules; + $ruleCnt = count($rules); + for($i = 0; $i < $ruleCnt; $i++ ){ + if( $rules[$i] instanceof Less_Tree_Extend ){ + $allSelectorsExtendList[] = $rules[$i]; + $rulesetNode->extendOnEveryPath = true; + } + } + + + + // now find every selector and apply the extends that apply to all extends + // and the ones which apply to an individual extend + $paths = $rulesetNode->paths; + $paths_len = count($paths); + for($i = 0; $i < $paths_len; $i++ ){ + + $selectorPath = $paths[$i]; + $selector = end($selectorPath); //$selectorPath[ count($selectorPath)-1]; + + + $list = array_merge($selector->extendList, $allSelectorsExtendList); + + $extendList = array(); + foreach($list as $allSelectorsExtend){ + $extendList[] = clone $allSelectorsExtend; + } + + $extendList_len = count($extendList); + for($j = 0; $j < $extendList_len; $j++ ){ + $this->foundExtends = true; + $extend = $extendList[$j]; + $extend->findSelfSelectors( $selectorPath ); + $extend->ruleset = $rulesetNode; + if( $j === 0 ){ $extend->firstExtendOnThisSelectorPath = true; } + + $temp = count($this->allExtendsStack)-1; + $this->allExtendsStack[ $temp ][] = $extend; + } + } + + $this->contexts[] = $rulesetNode->selectors; + } + + function visitRulesetOut( $rulesetNode ){ + if( !is_object($rulesetNode) || !$rulesetNode->root ){ + array_pop($this->contexts); + } + } + + function visitMedia( $mediaNode ){ + $mediaNode->allExtends = array(); + $this->allExtendsStack[] =& $mediaNode->allExtends; + } + + function visitMediaOut( $mediaNode ){ + array_pop($this->allExtendsStack); + } + + function visitDirective( $directiveNode ){ + $directiveNode->allExtends = array(); + $this->allExtendsStack[] =& $directiveNode->allExtends; + } + + function visitDirectiveOut( $directiveNode ){ + array_pop($this->allExtendsStack); + } +} + + diff --git a/lib/Less/Visitor/import.php b/lib/Less/Visitor/import.php new file mode 100644 index 0000000000000000000000000000000000000000..6b1a7b43c3ca787b4229615d277f5332e89fad3f --- /dev/null +++ b/lib/Less/Visitor/import.php @@ -0,0 +1,95 @@ +<?php + +/* +class Less_Visitor_import extends Less_VisitorReplacing{ + + public $_visitor; + public $_importer; + public $importCount; + + function __construct( $importer = null, $evalEnv = null ){ + $this->_visitor = new Less_Visitor($this); + $this->_importer = $importer; + if( $evalEnv ){ + $this->env = $evalEnv; + }else{ + $this->env = new Less_Environment(); + } + $this->importCount = 0; + } + + + function run( $root ){ + // process the contents + $this->_visitor->visitObj($root); + + $this->isFinished = true; + + //if( $this->importCount === 0) { + // $this->_finish(); + //} + } + + function visitImport($importNode, &$visitArgs ){ + $importVisitor = $this; + + $visitArgs['visitDeeper'] = false; + + if( $importNode->css ){ + return $importNode; + } + + $evaldImportNode = $importNode->compileForImport($this->env); + + if( $evaldImportNode && !$evaldImportNode->css ){ + $importNode = $evaldImportNode; + $this->importCount++; + } + + return $importNode; + } + + + function visitRule( $ruleNode, &$visitArgs ){ + $visitArgs['visitDeeper'] = false; + return $ruleNode; + } + + function visitDirective($directiveNode, $visitArgs){ + array_unshift($this->env->frames,$directiveNode); + return $directiveNode; + } + + function visitDirectiveOut($directiveNode) { + array_shift($this->env->frames); + } + + function visitMixinDefinition($mixinDefinitionNode, $visitArgs) { + array_unshift($this->env->frames,$mixinDefinitionNode); + return $mixinDefinitionNode; + } + + function visitMixinDefinitionOut($mixinDefinitionNode) { + array_shift($this->env->frames); + } + + function visitRuleset($rulesetNode, $visitArgs) { + array_unshift($this->env->frames,$rulesetNode); + return $rulesetNode; + } + + function visitRulesetOut($rulesetNode) { + array_shift($this->env->frames); + } + + function visitMedia($mediaNode, $visitArgs) { + array_unshift($this->env->frames, $mediaNode->ruleset); + return $mediaNode; + } + + function visitMediaOut($mediaNode) { + array_shift($this->env->frames); + } + +} +*/ \ No newline at end of file diff --git a/lib/Less/Visitor/joinSelector.php b/lib/Less/Visitor/joinSelector.php new file mode 100644 index 0000000000000000000000000000000000000000..9f3ab9c95fa2eeb7e91238bc5e17f77cc43736e3 --- /dev/null +++ b/lib/Less/Visitor/joinSelector.php @@ -0,0 +1,61 @@ +<?php + +class Less_Visitor_joinSelector extends Less_Visitor{ + + public $contexts = array( array() ); + + function run( $root ){ + return $this->visitObj($root); + } + + function visitRule( $ruleNode, &$visitDeeper ){ + $visitDeeper = false; + } + + function visitMixinDefinition( $mixinDefinitionNode, &$visitDeeper ){ + $visitDeeper = false; + } + + function visitRuleset( $rulesetNode ){ + + $paths = array(); + + if( !$rulesetNode->root ){ + $selectors = array(); + + if( $rulesetNode->selectors && count($rulesetNode->selectors) ){ + foreach($rulesetNode->selectors as $selector){ + if( $selector->getIsOutput() ){ + $selectors[] = $selector; + } + } + } + + if( !count($selectors) ){ + $rulesetNode->selectors = $selectors = null; + $rulesetNode->rules = null; + }else{ + $context = end($this->contexts); //$context = $this->contexts[ count($this->contexts) - 1]; + $paths = $rulesetNode->joinSelectors( $context, $selectors); + } + + $rulesetNode->paths = $paths; + } + + $this->contexts[] = $paths; //different from less.js. Placed after joinSelectors() so that $this->contexts will get correct $paths + } + + function visitRulesetOut( $rulesetNode ){ + array_pop($this->contexts); + } + + function visitMedia($mediaNode) { + $context = end($this->contexts); //$context = $this->contexts[ count($this->contexts) - 1]; + + if( !count($context) || (is_object($context[0]) && @$context[0]->multiMedia) ){ + $mediaNode->rules[0]->root = true; + } + } + +} + diff --git a/lib/Less/Visitor/processExtends.php b/lib/Less/Visitor/processExtends.php new file mode 100644 index 0000000000000000000000000000000000000000..ee2931a283a1e30249b86db73a1b68ca78df18d1 --- /dev/null +++ b/lib/Less/Visitor/processExtends.php @@ -0,0 +1,361 @@ +<?php + + +class Less_Visitor_processExtends extends Less_Visitor{ + + public $allExtendsStack; + + function run( $root ){ + $extendFinder = new Less_Visitor_extendFinder(); + $extendFinder->run( $root ); + if( !$extendFinder->foundExtends) { return $root; } + + $root->allExtends = $this->doExtendChaining( $root->allExtends, $root->allExtends); + + $this->allExtendsStack = array(); + $this->allExtendsStack[] = &$root->allExtends; + + return $this->visitObj( $root ); + } + + function doExtendChaining( $extendsList, $extendsListTarget, $iterationCount = 0){ + // + // chaining is different from normal extension.. if we extend an extend then we are not just copying, altering and pasting + // the selector we would do normally, but we are also adding an extend with the same target selector + // this means this new extend can then go and alter other extends + // + // this method deals with all the chaining work - without it, extend is flat and doesn't work on other extend selectors + // this is also the most expensive.. and a match on one selector can cause an extension of a selector we had already processed if + // we look at each selector at a time, as is done in visitRuleset + + $extendsToAdd = array(); + + + //loop through comparing every extend with every target extend. + // a target extend is the one on the ruleset we are looking at copy/edit/pasting in place + // e.g. .a:extend(.b) {} and .b:extend(.c) {} then the first extend extends the second one + // and the second is the target. + // the seperation into two lists allows us to process a subset of chains with a bigger set, as is the + // case when processing media queries + for( $extendIndex = 0, $extendsList_len = count($extendsList); $extendIndex < $extendsList_len; $extendIndex++ ){ + for( $targetExtendIndex = 0; $targetExtendIndex < count($extendsListTarget); $targetExtendIndex++ ){ + + $extend = $extendsList[$extendIndex]; + $targetExtend = $extendsListTarget[$targetExtendIndex]; + + // look for circular references + if( in_array($targetExtend->object_id, $extend->parent_ids,true) ){ + continue; + } + + // find a match in the target extends self selector (the bit before :extend) + $selectorPath = array( $targetExtend->selfSelectors[0] ); + $matches = $this->findMatch( $extend, $selectorPath); + + + if( $matches ){ + + // we found a match, so for each self selector.. + foreach($extend->selfSelectors as $selfSelector ){ + + + // process the extend as usual + $newSelector = $this->extendSelector( $matches, $selectorPath, $selfSelector); + + // but now we create a new extend from it + $newExtend = new Less_Tree_Extend( $targetExtend->selector, $targetExtend->option, 0); + $newExtend->selfSelectors = $newSelector; + + // add the extend onto the list of extends for that selector + end($newSelector)->extendList = array($newExtend); + //$newSelector[ count($newSelector)-1]->extendList = array($newExtend); + + // record that we need to add it. + $extendsToAdd[] = $newExtend; + $newExtend->ruleset = $targetExtend->ruleset; + + //remember its parents for circular references + $newExtend->parent_ids = array_merge($newExtend->parent_ids,$targetExtend->parent_ids,$extend->parent_ids); + + // only process the selector once.. if we have :extend(.a,.b) then multiple + // extends will look at the same selector path, so when extending + // we know that any others will be duplicates in terms of what is added to the css + if( $targetExtend->firstExtendOnThisSelectorPath ){ + $newExtend->firstExtendOnThisSelectorPath = true; + $targetExtend->ruleset->paths[] = $newSelector; + } + } + } + } + } + + if( $extendsToAdd ){ + // try to detect circular references to stop a stack overflow. + // may no longer be needed. $this->extendChainCount++; + if( $iterationCount > 100) { + $selectorOne = "{unable to calculate}"; + $selectorTwo = "{unable to calculate}"; + try{ + $selectorOne = $extendsToAdd[0]->selfSelectors[0]->toCSS(); + $selectorTwo = $extendsToAdd[0]->selector->toCSS(); + }catch(Exception $e){} + throw new Less_Exception_Parser("extend circular reference detected. One of the circular extends is currently:"+$selectorOne+":extend(" + $selectorTwo+")"); + } + + // now process the new extends on the existing rules so that we can handle a extending b extending c ectending d extending e... + $extendsToAdd = $this->doExtendChaining( $extendsToAdd, $extendsListTarget, $iterationCount+1); + } + + return array_merge($extendsList, $extendsToAdd); + } + + + function visitRule( $ruleNode, &$visitDeeper ){ + $visitDeeper = false; + } + + function visitMixinDefinition( $mixinDefinitionNode, &$visitDeeper ){ + $visitDeeper = false; + } + + function visitSelector( $selectorNode, &$visitDeeper ){ + $visitDeeper = false; + } + + function visitRuleset($rulesetNode){ + + + if( $rulesetNode->root ){ + return; + } + + $allExtends = end($this->allExtendsStack); + $paths_len = count($rulesetNode->paths); + + // look at each selector path in the ruleset, find any extend matches and then copy, find and replace + for( $extendIndex = 0, $all_extend_len = count($allExtends); $extendIndex < $all_extend_len; $extendIndex++ ){ + for($pathIndex = 0; $pathIndex < $paths_len; $pathIndex++ ){ + + $selectorPath = $rulesetNode->paths[$pathIndex]; + + // extending extends happens initially, before the main pass + if( isset($rulesetNode->extendOnEveryPath) && $rulesetNode->extendOnEveryPath ){ continue; } + if( end($selectorPath)->extendList ){ continue; } + + $matches = $this->findMatch($allExtends[$extendIndex], $selectorPath); + + if( $matches ){ + foreach($allExtends[$extendIndex]->selfSelectors as $selfSelector ){ + $rulesetNode->paths[] = $this->extendSelector($matches, $selectorPath, $selfSelector); + } + } + } + } + } + + function findMatch($extend, $haystackSelectorPath ){ + + // + // look through the haystack selector path to try and find the needle - extend.selector + // returns an array of selector matches that can then be replaced + // + $needleElements = $extend->selector->elements; + $potentialMatches = array(); + $potentialMatches_len = 0; + $potentialMatch = null; + $matches = array(); + + // loop through the haystack elements + for($haystackSelectorIndex = 0, $haystack_path_len = count($haystackSelectorPath); $haystackSelectorIndex < $haystack_path_len; $haystackSelectorIndex++ ){ + $hackstackSelector = $haystackSelectorPath[$haystackSelectorIndex]; + + for($hackstackElementIndex = 0, $haystack_elements_len = count($hackstackSelector->elements); $hackstackElementIndex < $haystack_elements_len; $hackstackElementIndex++ ){ + + $haystackElement = $hackstackSelector->elements[$hackstackElementIndex]; + + // if we allow elements before our match we can add a potential match every time. otherwise only at the first element. + if( $extend->allowBefore || ($haystackSelectorIndex === 0 && $hackstackElementIndex === 0) ){ + $potentialMatches[] = array('pathIndex'=> $haystackSelectorIndex, 'index'=> $hackstackElementIndex, 'matched'=> 0, 'initialCombinator'=> $haystackElement->combinator); + $potentialMatches_len++; + } + + for($i = 0; $i < $potentialMatches_len; $i++ ){ + $potentialMatch = &$potentialMatches[$i]; + + // selectors add " " onto the first element. When we use & it joins the selectors together, but if we don't + // then each selector in haystackSelectorPath has a space before it added in the toCSS phase. so we need to work out + // what the resulting combinator will be + $targetCombinator = $haystackElement->combinator->value; + if( $targetCombinator === '' && $hackstackElementIndex === 0 ){ + $targetCombinator = ' '; + } + + // if we don't match, null our match to indicate failure + if( !$this->isElementValuesEqual( $needleElements[$potentialMatch['matched'] ]->value, $haystackElement->value) || + ($potentialMatch['matched'] > 0 && $needleElements[ $potentialMatch['matched'] ]->combinator->value !== $targetCombinator) ){ + $potentialMatch = null; + } else { + $potentialMatch['matched']++; + } + + // if we are still valid and have finished, test whether we have elements after and whether these are allowed + if( $potentialMatch ){ + + $potentialMatch['finished'] = ($potentialMatch['matched'] === $extend->selector->elements_len ); + + if( $potentialMatch['finished'] && + (!$extend->allowAfter && ($hackstackElementIndex+1 < $haystack_elements_len || $haystackSelectorIndex+1 < $haystack_path_len)) ){ + $potentialMatch = null; + } + } + // if null we remove, if not, we are still valid, so either push as a valid match or continue + if( $potentialMatch ){ + if( $potentialMatch['finished'] ){ + $potentialMatch['length'] = $extend->selector->elements_len; + $potentialMatch['endPathIndex'] = $haystackSelectorIndex; + $potentialMatch['endPathElementIndex'] = $hackstackElementIndex + 1; // index after end of match + $potentialMatches = array(); // we don't allow matches to overlap, so start matching again + $potentialMatches_len = 0; + $matches[] = $potentialMatch; + } + } else { + array_splice($potentialMatches, $i, 1); + $potentialMatches_len--; + $i--; + } + } + } + } + return $matches; + } + + function isElementValuesEqual( $elementValue1, $elementValue2 ){ + + if( $elementValue1 === $elementValue2 ){ + return true; + } + if( is_string($elementValue1) || is_string($elementValue2) ) { + return false; + } + + if( $elementValue1 instanceof Less_Tree_Attribute ){ + + if( $elementValue1->op !== $elementValue2->op || $elementValue1->key !== $elementValue2->key ){ + return false; + } + + if( !$elementValue1->value || !$elementValue2->value ){ + if( $elementValue1->value || $elementValue2->value ) { + return false; + } + return true; + } + $elementValue1 = ($elementValue1->value->value ? $elementValue1->value->value : $elementValue1->value ); + $elementValue2 = ($elementValue2->value->value ? $elementValue2->value->value : $elementValue2->value ); + return $elementValue1 === $elementValue2; + } + + $elementValue1 = $elementValue1->value; + if( $elementValue1 instanceof Less_Tree_Selector ){ + $elementValue2 = $elementValue2->value; + if( !($elementValue2 instanceof Less_Tree_Selector) || $elementValue1->elements_len !== $elementValue2->elements_len ){ + return false; + } + for( $i = 0; $i < $elementValue1->elements_len; $i++ ){ + if( $elementValue1->elements[$i]->combinator->value !== $elementValue2->elements[$i]->combinator->value ){ + if( $i !== 0 || ($elementValue1->elements[$i]->combinator->value || ' ') !== ($elementValue2->elements[$i]->combinator->value || ' ') ){ + return false; + } + } + if( !$this->isElementValuesEqual($elementValue1->elements[$i]->value, $elementValue2->elements[$i]->value) ){ + return false; + } + } + return true; + } + + return false; + } + + function extendSelector($matches, $selectorPath, $replacementSelector){ + + //for a set of matches, replace each match with the replacement selector + + $currentSelectorPathIndex = 0; + $currentSelectorPathElementIndex = 0; + $path = array(); + $selectorPath_len = count($selectorPath); + + for($matchIndex = 0, $matches_len = count($matches); $matchIndex < $matches_len; $matchIndex++ ){ + + + $match = $matches[$matchIndex]; + $selector = $selectorPath[ $match['pathIndex'] ]; + $firstElement = new Less_Tree_Element( + $match['initialCombinator'], + $replacementSelector->elements[0]->value, + $replacementSelector->elements[0]->index, + $replacementSelector->elements[0]->currentFileInfo + ); + + if( $match['pathIndex'] > $currentSelectorPathIndex && $currentSelectorPathElementIndex > 0 ){ + $last_path = end($path); + $last_path->elements = array_merge( $last_path->elements, array_slice( $selectorPath[$currentSelectorPathIndex]->elements, $currentSelectorPathElementIndex)); + $currentSelectorPathElementIndex = 0; + $currentSelectorPathIndex++; + } + + $newElements = array_merge( + array_slice($selector->elements, $currentSelectorPathElementIndex, ($match['index'] - $currentSelectorPathElementIndex) ) // last parameter of array_slice is different than the last parameter of javascript's slice + , array($firstElement) + , array_slice($replacementSelector->elements,1) + ); + + if( $currentSelectorPathIndex === $match['pathIndex'] && $matchIndex > 0 ){ + $last_key = count($path)-1; + $path[$last_key]->elements = array_merge($path[$last_key]->elements,$newElements); + }else{ + $path = array_merge( $path, array_slice( $selectorPath, $currentSelectorPathIndex, $match['pathIndex'] )); + $path[] = new Less_Tree_Selector( $newElements ); + } + + $currentSelectorPathIndex = $match['endPathIndex']; + $currentSelectorPathElementIndex = $match['endPathElementIndex']; + if( $currentSelectorPathElementIndex >= count($selectorPath[$currentSelectorPathIndex]->elements) ){ + $currentSelectorPathElementIndex = 0; + $currentSelectorPathIndex++; + } + } + + if( $currentSelectorPathIndex < $selectorPath_len && $currentSelectorPathElementIndex > 0 ){ + $last_path = end($path); + $last_path->elements = array_merge( $last_path->elements, array_slice($selectorPath[$currentSelectorPathIndex]->elements, $currentSelectorPathElementIndex)); + $currentSelectorPathIndex++; + } + + $slice_len = $selectorPath_len - $currentSelectorPathIndex; + $path = array_merge($path, array_slice($selectorPath, $currentSelectorPathIndex, $slice_len)); + + return $path; + } + + + function visitMedia( $mediaNode ){ + $newAllExtends = array_merge( $mediaNode->allExtends, end($this->allExtendsStack) ); + $this->allExtendsStack[] = $this->doExtendChaining($newAllExtends, $mediaNode->allExtends); + } + + function visitMediaOut( $mediaNode ){ + array_pop( $this->allExtendsStack ); + } + + function visitDirective( $directiveNode ){ + $newAllExtends = array_merge( $directiveNode->allExtends, end($this->allExtendsStack) ); + $this->allExtendsStack[] = $this->doExtendChaining($newAllExtends, $directiveNode->allExtends); + } + + function visitDirectiveOut( $directiveNode ){ + array_pop($this->allExtendsStack); + } + +} \ No newline at end of file diff --git a/lib/Less/Visitor/toCSS.php b/lib/Less/Visitor/toCSS.php new file mode 100644 index 0000000000000000000000000000000000000000..80da0b5b0c3cd38e4952e58469470d75d074b017 --- /dev/null +++ b/lib/Less/Visitor/toCSS.php @@ -0,0 +1,221 @@ +<?php + +class Less_Visitor_toCSS extends Less_VisitorReplacing{ + + function __construct($env){ + $this->_env = $env; + parent::__construct(); + } + + function run( $root ){ + return $this->visitObj($root); + } + + function visitRule( $ruleNode ){ + if( $ruleNode->variable ){ + return array(); + } + return $ruleNode; + } + + function visitMixinDefinition( $mixinNode ){ + return array(); + } + + function visitExtend( $extendNode ){ + return array(); + } + + function visitComment( $commentNode ){ + if( $commentNode->isSilent( $this->_env) ){ + return array(); + } + return $commentNode; + } + + function visitMedia( $mediaNode, &$visitDeeper ){ + $mediaNode->accept($this); + $visitDeeper = false; + + if( !$mediaNode->rules ){ + return array(); + } + return $mediaNode; + } + + function visitDirective( $directiveNode ){ + if( isset($directiveNode->currentFileInfo['reference']) && (!property_exists($directiveNode,'isReferenced') || !$directiveNode->isReferenced) ){ + return array(); + } + if( $directiveNode->name === '@charset' ){ + // Only output the debug info together with subsequent @charset definitions + // a comment (or @media statement) before the actual @charset directive would + // be considered illegal css as it has to be on the first line + if( isset($this->charset) && $this->charset ){ + + //if( $directiveNode->debugInfo ){ + // $comment = new Less_Tree_Comment('/* ' . str_replace("\n",'',$directiveNode->toCSS($this->_env))." */\n"); + // $comment->debugInfo = $directiveNode->debugInfo; + // return $this->visit($comment); + //} + + + return array(); + } + $this->charset = true; + } + return $directiveNode; + } + + function checkPropertiesInRoot( $rules ){ + foreach($rules as $ruleNode){ + if( $ruleNode instanceof Less_Tree_Rule && !$ruleNode->variable ){ + $msg = "properties must be inside selector blocks, they cannot be in the root. Index ".$ruleNode->index.($ruleNode->currentFileInfo ? (' Filename: '.$ruleNode->currentFileInfo['filename']) : null); + throw new Less_Exception_Compiler($msg); + } + } + } + + function visitRuleset( $rulesetNode, &$visitDeeper ){ + + $visitDeeper = false; + $rulesets = array(); + if( $rulesetNode->firstRoot ){ + $this->checkPropertiesInRoot( $rulesetNode->rules ); + } + if( !$rulesetNode->root ){ + + $paths = array(); + foreach($rulesetNode->paths as $p){ + if( $p[0]->elements[0]->combinator->value === ' ' ){ + $p[0]->elements[0]->combinator = new Less_Tree_Combinator(''); + } + + foreach($p as $pi){ + if( $pi->getIsReferenced() && $pi->getIsOutput() ){ + $paths[] = $p; + break; + } + } + } + + $rulesetNode->paths = $paths; + + // Compile rules and rulesets + $nodeRuleCnt = count($rulesetNode->rules); + for( $i = 0; $i < $nodeRuleCnt; ){ + $rule = $rulesetNode->rules[$i]; + + if( property_exists($rule,'rules') ){ + // visit because we are moving them out from being a child + $rulesets[] = $this->visitObj($rule); + array_splice($rulesetNode->rules,$i,1); + $nodeRuleCnt--; + continue; + } + $i++; + } + + + // accept the visitor to remove rules and refactor itself + // then we can decide now whether we want it or not + if( $nodeRuleCnt > 0 ){ + $rulesetNode->accept($this); + + if( $rulesetNode->rules ){ + + if( count($rulesetNode->rules) > 1 ){ + $this->_mergeRules( $rulesetNode->rules ); + $this->_removeDuplicateRules( $rulesetNode->rules ); + } + + // now decide whether we keep the ruleset + if( $rulesetNode->paths ){ + //array_unshift($rulesets, $rulesetNode); + array_splice($rulesets,0,0,array($rulesetNode)); + } + } + + } + + }else{ + $rulesetNode->accept( $this ); + if( $rulesetNode->firstRoot || $rulesetNode->rules ){ + return $rulesetNode; + //array_unshift($rulesets, $rulesetNode); + } + return $rulesets; + } + + if( count($rulesets) === 1 ){ + return $rulesets[0]; + } + return $rulesets; + } + + function _removeDuplicateRules( &$rules ){ + // remove duplicates + $ruleCache = array(); + for( $i = count($rules)-1; $i >= 0 ; $i-- ){ + $rule = $rules[$i]; + if( $rule instanceof Less_Tree_Rule ){ + if( !isset($ruleCache[$rule->name]) ){ + $ruleCache[$rule->name] = $rule; + }else{ + $ruleList =& $ruleCache[$rule->name]; + if( $ruleList instanceof Less_Tree_Rule ){ + $ruleList = $ruleCache[$rule->name] = array( $ruleCache[$rule->name]->toCSS($this->_env) ); + } + $ruleCSS = $rule->toCSS($this->_env); + if( array_search($ruleCSS,$ruleList) !== false ){ + array_splice($rules,$i,1); + }else{ + $ruleList[] = $ruleCSS; + } + } + } + } + } + + function _mergeRules( &$rules ){ + $groups = array(); + + $rules_len = count($rules); + for( $i = 0; $i < $rules_len; $i++ ){ + $rule = $rules[$i]; + + if( ($rule instanceof Less_Tree_Rule) && $rule->merge ){ + + $key = $rule->name; + if( $rule->important ){ + $key .= ',!'; + } + + if( !isset($groups[$key]) ){ + $groups[$key] = array(); + $parts =& $groups[$key]; + }else{ + array_splice($rules, $i--, 1); + $rules_len--; + } + + $parts[] = $rule; + } + } + + foreach($groups as $parts){ + + if( count($parts) > 1 ){ + $rule = $parts[0]; + + $values = array(); + foreach($parts as $p){ + $values[] = $p->value; + } + + $rule->value = new Less_Tree_Value( $values ); + } + } + } +} + diff --git a/lib/Less/VisitorReplacing.php b/lib/Less/VisitorReplacing.php new file mode 100644 index 0000000000000000000000000000000000000000..a8a245eb865120f95372bf2169aadb0cbeb6ef5f --- /dev/null +++ b/lib/Less/VisitorReplacing.php @@ -0,0 +1,70 @@ +<?php + + +class Less_VisitorReplacing extends Less_Visitor{ + + function visitObj( $node ){ + + $funcName = 'visit'.$node->type; + if( isset($this->_visitFnCache[$funcName]) ){ + + $visitDeeper = true; + $node = $this->$funcName( $node, $visitDeeper ); + + if( $node ){ + if( $visitDeeper && is_object($node) ){ + $node->accept($this); + } + + $funcName = $funcName . "Out"; + if( isset($this->_visitFnCache[$funcName]) ){ + $this->$funcName( $node ); + } + } + + }else{ + $node->accept($this); + } + + return $node; + } + + function visitArray( $nodes ){ + + $newNodes = array(); + foreach($nodes as $node){ + $evald = $this->visitObj($node); + if( $evald ){ + if( is_array($evald) ){ + self::flatten($evald,$newNodes); + }else{ + $newNodes[] = $evald; + } + } + } + return $newNodes; + } + + function flatten( $arr, &$out ){ + + foreach($arr as $item){ + if( !is_array($item) ){ + $out[] = $item; + continue; + } + + foreach($item as $nestedItem){ + if( is_array($nestedItem) ){ + self::flatten( $nestedItem, $out); + }else{ + $out[] = $nestedItem; + } + } + } + + return $out; + } + +} + + diff --git a/lib/Magento/Acl/Loader/DefaultLoader.php b/lib/Magento/Acl/Loader/DefaultLoader.php index 4a04cdc00ecf56ab662ed2011383b84e53e382c6..850421381d1a018b01e4c7aef7026422c8f257e7 100644 --- a/lib/Magento/Acl/Loader/DefaultLoader.php +++ b/lib/Magento/Acl/Loader/DefaultLoader.php @@ -31,7 +31,7 @@ class DefaultLoader implements \Magento\Acl\LoaderInterface * Don't do anything to acl object. * * @param \Magento\Acl $acl - * @return mixed + * @return void */ public function populateAcl(\Magento\Acl $acl) { diff --git a/lib/Magento/Acl/Loader/Resource.php b/lib/Magento/Acl/Loader/Resource.php index ca57659de8c3d5cda1770d1be7b4d70475d86311..4c0e6843d83987fbde469074ac64e5225ac1d836 100644 --- a/lib/Magento/Acl/Loader/Resource.php +++ b/lib/Magento/Acl/Loader/Resource.php @@ -25,29 +25,34 @@ */ namespace Magento\Acl\Loader; +use Magento\Acl; +use Magento\Acl\Resource as AclResource; +use Magento\Acl\Resource\ProviderInterface; +use Magento\Acl\ResourceFactory; + class Resource implements \Magento\Acl\LoaderInterface { /** * Acl resource config * - * @var \Magento\Acl\Resource\ProviderInterface $resourceProvider + * @var ProviderInterface $resourceProvider */ protected $_resourceProvider; /** * Resource factory * - * @var \Magento\Acl\ResourceFactory + * @var ResourceFactory */ protected $_resourceFactory; /** - * @param \Magento\Acl\Resource\ProviderInterface $resourceProvider - * @param \Magento\Acl\ResourceFactory $resourceFactory + * @param ProviderInterface $resourceProvider + * @param ResourceFactory $resourceFactory */ public function __construct( - \Magento\Acl\Resource\ProviderInterface $resourceProvider, - \Magento\Acl\ResourceFactory $resourceFactory + ProviderInterface $resourceProvider, + ResourceFactory $resourceFactory ) { $this->_resourceProvider = $resourceProvider; $this->_resourceFactory = $resourceFactory; @@ -56,9 +61,10 @@ class Resource implements \Magento\Acl\LoaderInterface /** * Populate ACL with resources from external storage * - * @param \Magento\Acl $acl + * @param Acl $acl + * @return void */ - public function populateAcl(\Magento\Acl $acl) + public function populateAcl(Acl $acl) { $this->_addResourceTree($acl, $this->_resourceProvider->getAclResources(), null); } @@ -66,18 +72,19 @@ class Resource implements \Magento\Acl\LoaderInterface /** * Add list of nodes and their children to acl * - * @param \Magento\Acl $acl + * @param Acl $acl * @param array $resources - * @param \Magento\Acl\Resource $parent + * @param AclResource $parent + * @return void * @throws \InvalidArgumentException */ - protected function _addResourceTree(\Magento\Acl $acl, array $resources, \Magento\Acl\Resource $parent = null) + protected function _addResourceTree(Acl $acl, array $resources, AclResource $parent = null) { foreach ($resources as $resourceConfig) { if (!isset($resourceConfig['id'])) { throw new \InvalidArgumentException('Missing ACL resource identifier'); } - /** @var $resource \Magento\Acl\Resource */ + /** @var $resource AclResource */ $resource = $this->_resourceFactory->createResource(array('resourceId' => $resourceConfig['id'])); $acl->addResource($resource, $parent); if (isset($resourceConfig['children'])) { diff --git a/lib/Magento/Acl/Resource/Config/Converter/Dom.php b/lib/Magento/Acl/Resource/Config/Converter/Dom.php index 365ecf81a0d8c8749585ef4c20a350317cde58e8..62412efb8a537e4084040a2b208ce44f6548fc85 100644 --- a/lib/Magento/Acl/Resource/Config/Converter/Dom.php +++ b/lib/Magento/Acl/Resource/Config/Converter/Dom.php @@ -27,6 +27,9 @@ class Dom implements \Magento\Config\ConverterInterface { /** * {@inheritdoc} + * + * @param \DOMDocument $source + * @return array */ public function convert($source) { diff --git a/lib/Magento/Acl/Resource/Config/Reader/Filesystem.php b/lib/Magento/Acl/Resource/Config/Reader/Filesystem.php index bb2fd6fc04264b631dd26d10fec90c9ff8655807..6cf7dbd9f9810a9d473415fac7ecba3d92db2f12 100644 --- a/lib/Magento/Acl/Resource/Config/Reader/Filesystem.php +++ b/lib/Magento/Acl/Resource/Config/Reader/Filesystem.php @@ -25,6 +25,15 @@ namespace Magento\Acl\Resource\Config\Reader; class Filesystem extends \Magento\Config\Reader\Filesystem { + /** + * List of id attributes for merge + * + * @var array + */ + protected $_idAttributes = array( + '/config/acl/resources(/resource)+' => 'id', + ); + /** * @param \Magento\Config\FileResolverInterface $fileResolver * @param \Magento\Config\ConverterInterface $converter @@ -42,7 +51,7 @@ class Filesystem extends \Magento\Config\Reader\Filesystem \Magento\Config\ValidationStateInterface $validationState, $fileName = 'acl.xml', $idAttributes = array(), - $domDocumentClass = 'Magento\Acl\Resource\Config\Dom', + $domDocumentClass = 'Magento\Config\Dom', $defaultScope = 'global' ) { parent::__construct( diff --git a/lib/Magento/Acl/ResourceFactory.php b/lib/Magento/Acl/ResourceFactory.php index e969eba23a7e35cd1602b9dccb8f4476d4241f93..aff0c8fcec34502866dabf5207aa33447ec8440f 100644 --- a/lib/Magento/Acl/ResourceFactory.php +++ b/lib/Magento/Acl/ResourceFactory.php @@ -25,19 +25,21 @@ */ namespace Magento\Acl; +use Magento\ObjectManager; + class ResourceFactory { const RESOURCE_CLASS_NAME = 'Magento\Acl\Resource'; /** - * @var \Magento\ObjectManager + * @var ObjectManager */ protected $_objectManager; /** - * @param \Magento\ObjectManager $objectManager + * @param ObjectManager $objectManager */ - public function __construct(\Magento\ObjectManager $objectManager) + public function __construct(ObjectManager $objectManager) { $this->_objectManager = $objectManager; } @@ -46,7 +48,7 @@ class ResourceFactory * Return new ACL resource model * * @param array $arguments - * @return \Magento\Acl\Resource + * @return Resource */ public function createResource(array $arguments = array()) { diff --git a/lib/Magento/Acl/Role/Registry.php b/lib/Magento/Acl/Role/Registry.php index ba2b456d3da652d34abffb70f3ff6ea703b0cde4..1beab39293200056b8d3545be5b7ef828480abc6 100644 --- a/lib/Magento/Acl/Role/Registry.php +++ b/lib/Magento/Acl/Role/Registry.php @@ -37,7 +37,7 @@ class Registry extends \Zend_Acl_Role_Registry * * @param \Zend_Acl_Role_Interface|string $role * @param array|Zend_Acl_Role_Interface|string $parents - * @return \Magento\Acl\Role\Registry + * @return $this * @throws \Zend_Acl_Role_Registry_Exception */ public function addParent($role, $parents) diff --git a/lib/Magento/App/Action/Action.php b/lib/Magento/App/Action/Action.php index e8642b63825fe8c62a40e0cdd4de94cca65d1a05..5a830c48d9259213b6c6414a29521526610b027f 100644 --- a/lib/Magento/App/Action/Action.php +++ b/lib/Magento/App/Action/Action.php @@ -144,6 +144,7 @@ class Action extends \Magento\App\Action\AbstractAction * @param string|null $controller * @param string|null $module * @param array|null $params + * @return void */ protected function _forward($action, $controller = null, $module = null, array $params = null) { @@ -173,7 +174,7 @@ class Action extends \Magento\App\Action\AbstractAction * * @param string $path * @param array $arguments - * @return \Magento\App\ResponseInterface + * @return ResponseInterface */ protected function _redirect($path, $arguments = array()) { diff --git a/lib/Magento/App/Action/Forward.php b/lib/Magento/App/Action/Forward.php index 547d14f7f1fc054e86ae1a103e0dd8620d3bb0a9..fd268983b9cb4c9fcd805bd5fbb330c767c262ba 100644 --- a/lib/Magento/App/Action/Forward.php +++ b/lib/Magento/App/Action/Forward.php @@ -26,12 +26,13 @@ namespace Magento\App\Action; use Magento\App\RequestInterface; +use Magento\App\ResponseInterface; class Forward extends AbstractAction { /** * @param RequestInterface $request - * @return \Magento\App\ResponseInterface|mixed + * @return ResponseInterface * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ public function dispatch(RequestInterface $request) diff --git a/lib/Magento/App/Action/Redirect.php b/lib/Magento/App/Action/Redirect.php index 0ea3714dbd5cfde27aac61f9a653b0dd7043e6ee..5875f1d1637897a784ac83838f9bfd678d256785 100644 --- a/lib/Magento/App/Action/Redirect.php +++ b/lib/Magento/App/Action/Redirect.php @@ -26,6 +26,7 @@ namespace Magento\App\Action; use \Magento\App\RequestInterface; +use \Magento\App\ResponseInterface; class Redirect extends AbstractAction { @@ -33,7 +34,7 @@ class Redirect extends AbstractAction * Redirect response * * @param RequestInterface $request - * @return \Magento\App\ResponseInterface|mixed + * @return ResponseInterface * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ public function dispatch(RequestInterface $request) diff --git a/lib/Magento/App/Action/Title.php b/lib/Magento/App/Action/Title.php index 2852f5d8c1d01e3eb632fd5fbc9cb48445acbbec..1fdde88b9c39f84a3e63ca5198cdeb3753b3cde8 100644 --- a/lib/Magento/App/Action/Title.php +++ b/lib/Magento/App/Action/Title.php @@ -29,14 +29,14 @@ class Title /** * Title parts to be rendered in the page head title * - * @var array + * @var string[] */ protected $_titles = array(); /** * @param string $text * @param bool $prepend - * @return Title + * @return $this */ public function add($text, $prepend = false) { @@ -51,7 +51,7 @@ class Title /** * Get titles * - * @return array + * @return string[] */ public function get() { diff --git a/lib/Magento/App/ActionFactory.php b/lib/Magento/App/ActionFactory.php index a84f5de6e1a0b265eb7c4904cc9abcf8ff640f8b..bf223a9c248c9a7bdd3d5543d3ede1c60450301b 100644 --- a/lib/Magento/App/ActionFactory.php +++ b/lib/Magento/App/ActionFactory.php @@ -25,6 +25,8 @@ */ namespace Magento\App; +use Magento\App\Action\AbstractAction; + class ActionFactory { /** @@ -43,7 +45,7 @@ class ActionFactory /** * @param string $controllerName * @param array $arguments - * @return mixed + * @return AbstractAction */ public function createController($controllerName, array $arguments = array()) { diff --git a/lib/Magento/App/ActionFlag.php b/lib/Magento/App/ActionFlag.php index 79b4cb888d5c49c5dad4d4e0076bf1c0082382e5..1d915cfedf25b3c1f1db8dbca4f800e5cb84ca40 100644 --- a/lib/Magento/App/ActionFlag.php +++ b/lib/Magento/App/ActionFlag.php @@ -50,6 +50,7 @@ class ActionFlag * @param string $action * @param string $flag * @param string $value + * @return void */ public function set($action, $flag, $value) { diff --git a/lib/Magento/App/AreaList.php b/lib/Magento/App/AreaList.php index d07dee412c2e74b4bb276b9bf1620fff9a66c5ac..83f1c6dfc5000e5efa205c01372ea1269e96aaf3 100644 --- a/lib/Magento/App/AreaList.php +++ b/lib/Magento/App/AreaList.php @@ -90,7 +90,7 @@ class AreaList /** * Retrieve area codes * - * @return array + * @return string[] */ public function getCodes() { diff --git a/lib/Magento/App/Arguments.php b/lib/Magento/App/Arguments.php new file mode 100644 index 0000000000000000000000000000000000000000..2fcbe005d5247507e1983d1bf959be395795c956 --- /dev/null +++ b/lib/Magento/App/Arguments.php @@ -0,0 +1,187 @@ +<?php +/** + * Magento application object manager. Configures and application application + * + * 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; + +class Arguments +{ + /** + * Config data + * + * @var array + */ + protected $_data; + + /** + * Configuration loader + * + * @var \Magento\App\Arguments\Loader + */ + protected $_loader; + + /** + * Application options + * + * @var array + */ + protected $_parameters; + + /** + * @param array $parameters + * @param \Magento\App\Arguments\Loader $loader + */ + public function __construct(array $parameters, \Magento\App\Arguments\Loader $loader) + { + $this->_loader = $loader; + $this->_parameters = $parameters; + $this->_data = array_replace_recursive($this->_parseParams($loader->load()), $parameters); + } + + /** + * @param array $input + * @return array + */ + protected function _parseParams(array $input) + { + $stack = $input; + unset($stack['resource']); + unset($stack['connection']); + unset($stack['cache']); + $output = $this->_flattenParams($stack); + $output['connection'] = isset($input['connection']) ? $input['connection'] : array(); + $output['resource'] = isset($input['resource']) ? $input['resource'] : array(); + $output['cache'] = isset($input['cache']) ? $input['cache'] : array(); + return $output; + } + + /** + * Convert associative array of arbitrary depth to a flat associative array with concatenated key path as keys + * + * @param array $params + * @param string $separator + * @return array + */ + protected function _flattenParams(array $params, $separator = '.') + { + $result = array(); + $stack = $params; + while ($stack) { + list($key, $value) = each($stack); + unset($stack[$key]); + if (is_array($value)) { + if (count($value)) { + foreach ($value as $subKey => $node) { + $build[$key . $separator . $subKey] = $node; + } + } else { + $build[$key] = null; + } + $stack = $build + $stack; + continue; + } + $result[$key] = $value; + } + return $result; + } + + /** + * Retrieve connection configuration by connection name + * + * @param string $connectionName + * @return array + */ + public function getConnection($connectionName) + { + return isset($this->_data['connection'][$connectionName]) + ? $this->_data['connection'][$connectionName] + : null; + } + + /** + * Retrieve list of connections + * + * @return array + */ + public function getConnections() + { + return isset($this->_data['connection']) ? $this->_data['connection'] : array(); + } + + /** + * Retrieve list of resources + * + * @return array + */ + public function getResources() + { + return $this->_data['resource']; + } + + /** + * Retrieve settings for all cache front-ends configured in the system + * + * @return array Format: array('<frontend_id>' => array(<cache_settings>), ...) + */ + public function getCacheFrontendSettings() + { + return isset($this->_data['cache']['frontend']) ? $this->_data['cache']['frontend'] : array(); + } + + /** + * Retrieve identifier of a cache frontend, configured to be used for a cache type + * + * @param string $cacheType Cache type identifier + * @return string|null + */ + public function getCacheTypeFrontendId($cacheType) + { + return isset($this->_data['cache']['type'][$cacheType]['frontend']) + ? $this->_data['cache']['type'][$cacheType]['frontend'] + : null; + } + + /** + * Retrieve key + * + * @param string $key + * @param mixed $defaultValue + * @return array|null + */ + public function get($key = null, $defaultValue = null) + { + if ($key === null) { + return $this->_data; + } + return isset($this->_data[$key]) ? $this->_data[$key] : $defaultValue; + } + + /** + * Reload local.xml + */ + public function reload() + { + $this->_data = array_replace_recursive($this->_parseParams($this->_loader->load()), $this->_parameters); + } +} diff --git a/lib/Magento/App/Config/FileResolver/Primary.php b/lib/Magento/App/Arguments/FileResolver/Primary.php similarity index 95% rename from lib/Magento/App/Config/FileResolver/Primary.php rename to lib/Magento/App/Arguments/FileResolver/Primary.php index 59885970779294a8dd45da69a72970dc2ca30102..034eb6c67086dc8afbba0351c24e694d8f778e5c 100644 --- a/lib/Magento/App/Config/FileResolver/Primary.php +++ b/lib/Magento/App/Arguments/FileResolver/Primary.php @@ -23,11 +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\App\Config\FileResolver; - -/*** - * @SuppressWarnings(PHPMD.UnusedFormalParameter) - */ +namespace Magento\App\Arguments\FileResolver; class Primary implements \Magento\Config\FileResolverInterface { @@ -59,8 +55,10 @@ class Primary implements \Magento\Config\FileResolverInterface $this->configDirectory = $filesystem->getDirectoryRead(\Magento\App\Filesystem::CONFIG_DIR); $this->iteratorFactory = $iteratorFactory; } + /** * @inheritdoc + * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ public function get($filename, $scope) { diff --git a/lib/Magento/App/Arguments/Loader.php b/lib/Magento/App/Arguments/Loader.php new file mode 100644 index 0000000000000000000000000000000000000000..b285790a332547abf482ad1bc90a9d8d3db455bd --- /dev/null +++ b/lib/Magento/App/Arguments/Loader.php @@ -0,0 +1,102 @@ +<?php +/** + * Local Application configuration loader (app/etc/local.xml) + * + * 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\Arguments; + +class Loader +{ + /** + * Local configuration file + */ + const PARAM_CUSTOM_FILE = 'custom.options.file'; + + /** + * Local configuration file + */ + const LOCAL_CONFIG_FILE = 'local.xml'; + + /** + * Directory registry + * + * @var string + */ + protected $_dir; + + /** + * Custom config file + * + * @var string + */ + protected $_customFile; + + /** + * Configuration identifier attributes + * + * @var array + */ + protected $_idAttributes = array( + '/config/resource' => 'name', + '/config/connection' => 'name', + '/config/cache/frontend' => 'name', + '/config/cache/type' => 'name', + ); + + /** + * @param \Magento\App\Filesystem\DirectoryList $dirList + * @param string $customFile + */ + public function __construct(\Magento\App\Filesystem\DirectoryList $dirList, $customFile = null) + { + $this->_dir = $dirList->getDir(\Magento\App\Filesystem::CONFIG_DIR); + $this->_customFile = $customFile; + } + + /** + * Load configuration + * + * @return array + */ + public function load() + { + $localConfig = new \Magento\Config\Dom('<config/>', $this->_idAttributes); + + $localConfigFile = $this->_dir . '/' . self::LOCAL_CONFIG_FILE; + if (file_exists($localConfigFile)) { + // 1. app/etc/local.xml + $localConfig->merge(file_get_contents($localConfigFile)); + + // 2. app/etc/<dir>/<file>.xml + if (preg_match('/^[a-z\d_-]+(\/|\\\)+[a-z\d_-]+\.xml$/', $this->_customFile)) { + $localConfigExtraFile = $this->_dir . '/' . $this->_customFile; + $localConfig->merge(file_get_contents($localConfigExtraFile)); + } + } + + $converter = new \Magento\Config\Converter\Dom\Flat($this->_idAttributes); + + $result = $converter->convert($localConfig->getDom()); + return !empty($result['config']) ? $result['config'] : array(); + } +} diff --git a/lib/Magento/App/Config/ValidationState.php b/lib/Magento/App/Arguments/ValidationState.php similarity index 97% rename from lib/Magento/App/Config/ValidationState.php rename to lib/Magento/App/Arguments/ValidationState.php index 63b074dc4e998950e53d2d105d25cfb942f0fa16..380cd51b03e07b95f9d01821b45c884877047ad3 100644 --- a/lib/Magento/App/Config/ValidationState.php +++ b/lib/Magento/App/Arguments/ValidationState.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\App\Config; +namespace Magento\App\Arguments; class ValidationState implements \Magento\Config\ValidationStateInterface { diff --git a/lib/Magento/App/Cache/Frontend/Pool.php b/lib/Magento/App/Cache/Frontend/Pool.php index 8ad9493e708a82dc10954cb715458e03c2ea9523..b489041f74237c2399476e34acb5674b49fb98d0 100644 --- a/lib/Magento/App/Cache/Frontend/Pool.php +++ b/lib/Magento/App/Cache/Frontend/Pool.php @@ -18,23 +18,26 @@ * 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) */ -/** - * In-memory readonly pool of cache front-end instances, specified in the configuration - */ namespace Magento\App\Cache\Frontend; +/** + * In-memory readonly pool of all cache front-end instances known to the system + */ class Pool implements \Iterator { /** * Frontend identifier associated with the default settings */ - const DEFAULT_FRONTEND_ID = 'generic'; + const DEFAULT_FRONTEND_ID = 'default'; + + /** + * @var \Magento\App\Arguments + */ + private $_arguments; /** * @var \Magento\App\Cache\Frontend\Factory @@ -47,54 +50,55 @@ class Pool implements \Iterator private $_instances; /** - * Advanced config settings - * * @var array */ - private $_advancedSettings; - - /** - * Default cache settings - * - * @var array - */ - private $_defaultSettings; + private $_frontendSettings; /** + * @param \Magento\App\Arguments $arguments * @param \Magento\App\Cache\Frontend\Factory $frontendFactory - * @param array $defaultSettings - * @param array $advancedSettings + * @param array $frontendSettings Format: array('<frontend_id>' => array(<cache_settings>), ...) */ public function __construct( + \Magento\App\Arguments $arguments, \Magento\App\Cache\Frontend\Factory $frontendFactory, - array $defaultSettings = array(), - array $advancedSettings = array() + array $frontendSettings = array() ) { + $this->_arguments = $arguments; $this->_factory = $frontendFactory; - $this->_advancedSettings = $advancedSettings; - $this->_defaultSettings = empty($defaultSettings) == false ? $defaultSettings : array(); + $this->_frontendSettings = $frontendSettings + array(self::DEFAULT_FRONTEND_ID => array()); } /** - * Load frontend instances from the configuration, to be used for delayed initialization + * Create instances of every cache frontend known to the system. + * Method is to be used for delayed initialization of the iterator. + * + * @return void */ protected function _initialize() { if ($this->_instances === null) { $this->_instances = array(); - // default front-end - $this->_instances[self::DEFAULT_FRONTEND_ID] = $this->_factory->create($this->_defaultSettings); - // additional front-ends - - if ($this->_advancedSettings) { - /** @var $frontendNode \Magento\Simplexml\Element */ - foreach ($this->_advancedSettings as $frontendId => $frontendOptions) { - $this->_instances[$frontendId] = $this->_factory->create($frontendOptions); - } + foreach ($this->_getCacheSettings() as $frontendId => $frontendOptions) { + $this->_instances[$frontendId] = $this->_factory->create($frontendOptions); } } } + /** + * Retrieve settings for all cache front-ends known to the system + * + * @return array Format: array('<frontend_id>' => array(<cache_settings>), ...) + */ + protected function _getCacheSettings() + { + /* + * Merging is intentionally implemented through array_merge() instead of array_replace_recursive() + * to avoid "inheritance" of the default settings that become irrelevant as soon as cache storage type changes + */ + return array_merge($this->_frontendSettings, $this->_arguments->getCacheFrontendSettings()); + } + /** * {@inheritdoc} * @@ -143,10 +147,11 @@ class Pool implements \Iterator } /** - * Retrieve frontend instance by its unique identifier, or return NULL, if identifier is not recognized + * Retrieve frontend instance by its unique identifier * * @param string $identifier Cache frontend identifier * @return \Magento\Cache\FrontendInterface Cache frontend instance + * @throws \InvalidArgumentException */ public function get($identifier) { @@ -154,6 +159,6 @@ class Pool implements \Iterator if (isset($this->_instances[$identifier])) { return $this->_instances[$identifier]; } - return null; + throw new \InvalidArgumentException("Cache frontend '$identifier' is not recognized."); } } diff --git a/lib/Magento/App/Cache/Proxy.php b/lib/Magento/App/Cache/Proxy.php index 0d5fec7f468cba825b6ed1589932cba45fc21253..15d6d55da21b1ed4a955300b362a748161fe79b5 100644 --- a/lib/Magento/App/Cache/Proxy.php +++ b/lib/Magento/App/Cache/Proxy.php @@ -29,7 +29,9 @@ */ namespace Magento\App\Cache; -class Proxy implements \Magento\App\CacheInterface +use Magento\App\CacheInterface; + +class Proxy implements CacheInterface { /** * @var \Magento\ObjectManager @@ -37,7 +39,7 @@ class Proxy implements \Magento\App\CacheInterface protected $_objectManager; /** - * @var \Magento\App\CacheInterface + * @var CacheInterface */ protected $_cache; @@ -52,7 +54,7 @@ class Proxy implements \Magento\App\CacheInterface /** * Create cache model * - * @return \Magento\App\CacheInterface|mixed + * @return CacheInterface */ protected function _getCache() { diff --git a/lib/Magento/App/Cache/State.php b/lib/Magento/App/Cache/State.php index 2dcdee3dd085a4e9840c7f71fcca1d1333101f8c..89948901d8b84aa08ce06b2bd51ae918607f68b3 100644 --- a/lib/Magento/App/Cache/State.php +++ b/lib/Magento/App/Cache/State.php @@ -76,6 +76,7 @@ class State implements \Magento\App\Cache\StateInterface * Load statuses (enabled/disabled) of cache types * * @param bool $forceDisableAll + * @return void */ private function _loadTypeStatuses($forceDisableAll = false) { @@ -111,6 +112,7 @@ class State implements \Magento\App\Cache\StateInterface * * @param string $cacheType * @param bool $isEnabled + * @return void */ public function setEnabled($cacheType, $isEnabled) { @@ -119,6 +121,8 @@ class State implements \Magento\App\Cache\StateInterface /** * Save the current statuses (enabled/disabled) of cache types to the persistent storage + * + * @return void */ public function persist() { diff --git a/lib/Magento/App/Cache/StateInterface.php b/lib/Magento/App/Cache/StateInterface.php index e5b26727167041cf9c827588d2d79be8e41f7d00..814fcc14d298d70448c2a0cdf5b26754ee7be6e4 100644 --- a/lib/Magento/App/Cache/StateInterface.php +++ b/lib/Magento/App/Cache/StateInterface.php @@ -26,12 +26,12 @@ namespace Magento\App\Cache; interface StateInterface { /** - * Check if cache can be used for specific data type + * Whether a cache type is enabled at the moment or not * - * @param string $typeCode + * @param string $cacheType * @return bool */ - public function isEnabled($typeCode); + public function isEnabled($cacheType); /** * Enable/disable a cache type in run-time diff --git a/lib/Magento/App/Cache/Type/FrontendPool.php b/lib/Magento/App/Cache/Type/FrontendPool.php index 456fd4258a9d88b358d9f5bd7a5117374604df48..cb1605414ef1d4fc59b26614123b49a258f326ed 100644 --- a/lib/Magento/App/Cache/Type/FrontendPool.php +++ b/lib/Magento/App/Cache/Type/FrontendPool.php @@ -18,17 +18,15 @@ * 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\App\Cache\Type; + /** * In-memory readonly pool of cache front-ends with enforced access control, specific to cache types */ -namespace Magento\App\Cache\Type; - class FrontendPool { /** @@ -36,11 +34,21 @@ class FrontendPool */ private $_objectManager; + /** + * @var \Magento\App\Arguments + */ + private $_arguments; + /** * @var \Magento\App\Cache\Frontend\Pool */ private $_frontendPool; + /** + * @var array + */ + private $_typeFrontendMap; + /** * @var \Magento\Cache\FrontendInterface[] */ @@ -48,40 +56,61 @@ class FrontendPool /** * @param \Magento\ObjectManager $objectManager + * @param \Magento\App\Arguments $arguments * @param \Magento\App\Cache\Frontend\Pool $frontendPool + * @param array $typeFrontendMap Format: array('<cache_type_id>' => '<cache_frontend_id>', ...) */ public function __construct( \Magento\ObjectManager $objectManager, - \Magento\App\Cache\Frontend\Pool $frontendPool + \Magento\App\Arguments $arguments, + \Magento\App\Cache\Frontend\Pool $frontendPool, + array $typeFrontendMap = array() ) { $this->_objectManager = $objectManager; + $this->_arguments = $arguments; $this->_frontendPool = $frontendPool; + $this->_typeFrontendMap = $typeFrontendMap; } /** - * Retrieve cache frontend instance by its unique identifier, enforcing identifier-scoped access control + * Retrieve cache frontend instance by a cache type identifier, enforcing identifier-scoped access control * - * @param string $identifier Cache frontend identifier + * @param string $cacheType Cache type identifier * @return \Magento\Cache\FrontendInterface Cache frontend instance */ - public function get($identifier) + public function get($cacheType) { - if (!isset($this->_instances[$identifier])) { - $frontendInstance = $this->_frontendPool->get($identifier); - if (!$frontendInstance) { - $frontendInstance = $this->_frontendPool->get( - \Magento\App\Cache\Frontend\Pool::DEFAULT_FRONTEND_ID - ); - } + if (!isset($this->_instances[$cacheType])) { + $frontendId = $this->_getCacheFrontendId($cacheType); + $frontendInstance = $this->_frontendPool->get($frontendId); /** @var $frontendInstance \Magento\App\Cache\Type\AccessProxy */ $frontendInstance = $this->_objectManager->create( 'Magento\App\Cache\Type\AccessProxy', array( 'frontend' => $frontendInstance, - 'identifier' => $identifier, + 'identifier' => $cacheType, ) ); - $this->_instances[$identifier] = $frontendInstance; + $this->_instances[$cacheType] = $frontendInstance; + } + return $this->_instances[$cacheType]; + } + + /** + * Retrieve cache frontend identifier, associated with a cache type + * + * @param string $cacheType + * @return string + */ + protected function _getCacheFrontendId($cacheType) + { + $result = $this->_arguments->getCacheTypeFrontendId($cacheType); + if (!$result) { + if (isset($this->_typeFrontendMap[$cacheType])) { + $result = $this->_typeFrontendMap[$cacheType]; + } else { + $result = \Magento\App\Cache\Frontend\Pool::DEFAULT_FRONTEND_ID; + } } - return $this->_instances[$identifier]; + return $result; } } diff --git a/lib/Magento/App/Cache/TypeList.php b/lib/Magento/App/Cache/TypeList.php index 28f58aeb304319359c1eac789765f38b28d00709..b5d512e9c183e5e9751b307eb6f7c0812afada13 100644 --- a/lib/Magento/App/Cache/TypeList.php +++ b/lib/Magento/App/Cache/TypeList.php @@ -101,6 +101,7 @@ class TypeList implements \Magento\App\Cache\TypeListInterface * Save invalidated cache types * * @param array $types + * @return void */ protected function _saveInvalidatedTypes($types) { @@ -159,6 +160,7 @@ class TypeList implements \Magento\App\Cache\TypeListInterface * Mark specific cache type(s) as invalidated * * @param string|array $typeCode + * @return void */ public function invalidate($typeCode) { @@ -176,6 +178,7 @@ class TypeList implements \Magento\App\Cache\TypeListInterface * Clean cached data for specific cache type * * @param string $typeCode + * @return void */ public function cleanType($typeCode) { diff --git a/lib/Magento/App/Config.php b/lib/Magento/App/Config.php index 0cfc5010902f1e67ebd3271f3748e87bfdcf0fd2..b6ba5c582157ff697d728424929510c4d854d834 100644 --- a/lib/Magento/App/Config.php +++ b/lib/Magento/App/Config.php @@ -1,6 +1,6 @@ <?php /** - * Magento application object manager. Configures and application application + * Application configuration object. Used to access configuration when application is initialized and installed. * * Magento * @@ -23,128 +23,61 @@ * @copyright Copyright (c) 2014 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; -class Config +class Config implements \Magento\App\ConfigInterface { /** - * Config data - * - * @var array - */ - protected $_data; - - /** - * Configuration loader - * * @var \Magento\App\Config\Loader */ protected $_loader; /** - * Application options - * - * @var array + * @var \Magento\App\Config\Data */ - protected $_parameters; + protected $_data; /** - * @param array $parameters - * @param Config\Loader $loader + * @param Arguments\Loader $loader */ - public function __construct(array $parameters, Config\Loader $loader) + public function __construct(Arguments\Loader $loader) { $this->_loader = $loader; - $this->_parameters = $parameters; - $this->_data = array_replace_recursive($this->_parseParams($loader->load()), $parameters); - } - - /** - * @param array $input - * @return array - */ - protected function _parseParams(array $input) - { - $stack = $input; - unset($stack['resource']); - unset($stack['connection']); - $separator = '.'; - $output = array(); - - while ($stack) { - list($key, $value) = each($stack); - unset($stack[$key]); - if (is_array($value)) { - if (count($value)) { - foreach ($value as $subKey => $node) { - $build[$key . $separator . $subKey] = $node; - } - } else { - $build[$key] = null; - } - $stack = $build + $stack; - continue; - } - $output[$key] = $value; - } - $output['connection'] = isset($input['connection']) ? $input['connection'] : array(); - $output['resource'] = isset($input['resource']) ? $input['resource'] : array(); - return $output; + $this->_data = $loader->load(); } /** - * Retrieve connection configuration by connection name + * Retrieve config value by path * - * @param string $connectionName - * @return array + * @param string $path + * @return mixed */ - public function getConnection($connectionName) + public function getValue($path = null) { - return isset($this->_data['connection'][$connectionName]) - ? $this->_data['connection'][$connectionName] - : null; + return $this->_data->getValue($path); } /** - * Retrieve list of connections + * Set config value * - * @return array + * @param string $path + * @param mixed $value + * @return void */ - public function getConnections() + public function setValue($path, $value) { - return isset($this->_data['connection']) ? $this->_data['connection'] : array(); + $this->_data->setValue($path, $value); } /** - * Retrieve list of resources + * Retrieve config flag * - * @return array - */ - public function getResources() - { - return $this->_data['resource']; - } - - /** - * Retrieve key - * - * @param string $key - * @param mixed $defaultValue - * @return array|null - */ - public function get($key = null, $defaultValue = null) - { - if ($key === null) { - return $this->_data; - } - return isset($this->_data[$key]) ? $this->_data[$key] : $defaultValue; - } - - /** - * Reload local.xml + * @param string $path + * @return bool */ - public function reload() + public function isSetFlag($path) { - $this->_data = array_replace_recursive($this->_parseParams($this->_loader->load()), $this->_parameters); + return (bool)$this->_data->getValue($path); } } diff --git a/lib/Magento/App/Config/Data.php b/lib/Magento/App/Config/Data.php new file mode 100644 index 0000000000000000000000000000000000000000..ec1b0e2571ac05cf0cbdcba65e263cd326bf876c --- /dev/null +++ b/lib/Magento/App/Config/Data.php @@ -0,0 +1,88 @@ +<?php +/** + * Configuration data container + * + * 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 Data implements \Magento\App\Config\DataInterface +{ + /** + * Config data + * + * @var array + */ + protected $_data = array(); + + /** + * @param \Magento\App\Config\MetadataProcessor $processor + * @param array $data + */ + public function __construct(\Magento\App\Config\MetadataProcessor $processor, array $data) + { + $this->_data = $processor->process($data); + } + + /** + * 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 + * + * @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/lib/Magento/App/Config/Data/ProcessorFactory.php b/lib/Magento/App/Config/Data/ProcessorFactory.php new file mode 100644 index 0000000000000000000000000000000000000000..34231c3338ee4a28922d7e94197c0a6f0f7dfe42 --- /dev/null +++ b/lib/Magento/App/Config/Data/ProcessorFactory.php @@ -0,0 +1,68 @@ +<?php +/** + * Config data Factory + * + * 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\Data; + +class ProcessorFactory +{ + /** + * @var \Magento\ObjectManager + */ + protected $_objectManager; + + /** + * @var \Magento\App\Config\Data\ProcessorInterface[] + */ + protected $_pool; + + /** + * @param \Magento\ObjectManager $objectManager + */ + public function __construct(\Magento\ObjectManager $objectManager) + { + $this->_objectManager = $objectManager; + } + + /** + * Get concrete Processor Interface instance + * + * @param string $model + * @return \Magento\App\Config\Data\ProcessorInterface + * @throws \InvalidArgumentException + */ + public function get($model) + { + if (!isset($this->_pool[$model])) { + $instance = $this->_objectManager->create($model); + if (!($instance instanceof \Magento\App\Config\Data\ProcessorInterface)) { + throw new \InvalidArgumentException( + $model . ' does not instance of \Magento\App\Config\Data\ProcessorInterface' + ); + } + $this->_pool[$model] = $instance; + } + return $this->_pool[$model]; + } +} diff --git a/lib/Magento/App/Config/Data/ProcessorInterface.php b/lib/Magento/App/Config/Data/ProcessorInterface.php new file mode 100644 index 0000000000000000000000000000000000000000..7e5bfd3b6cf46db2e6a6b673b59a359a51037bdb --- /dev/null +++ b/lib/Magento/App/Config/Data/ProcessorInterface.php @@ -0,0 +1,37 @@ +<?php +/** + * Processor 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\App\Config\Data; + +interface ProcessorInterface +{ + /** + * Process config value + * + * @param string $value + * @return mixed + */ + public function processValue($value); +} diff --git a/lib/Magento/App/Config/DataFactory.php b/lib/Magento/App/Config/DataFactory.php new file mode 100644 index 0000000000000000000000000000000000000000..84580fd03dc4041d15d3f0f4264b7f66538aaef8 --- /dev/null +++ b/lib/Magento/App/Config/DataFactory.php @@ -0,0 +1,63 @@ +<?php +/** + * Data Factory. + * + * 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 DataFactory +{ + /** + * Object manager + * + * @var \Magento\ObjectManager + */ + protected $_objectManager; + + /** + * Instance name to create + * + * @var string + */ + protected $_instanceName = null; + + /** + * @param \Magento\ObjectManager $objectManager + */ + public function __construct(\Magento\ObjectManager $objectManager, $instanceName = 'Magento\App\Config\Data') + { + $this->_objectManager = $objectManager; + $this->_instanceName = $instanceName; + } + + /** + * Create class instance with specified parameters + * + * @param array $data + * @return \Magento\Core\Model\Config\Data + */ + public function create(array $data = array()) + { + return $this->_objectManager->create($this->_instanceName, $data); + } +} diff --git a/lib/Magento/App/Config/DataInterface.php b/lib/Magento/App/Config/DataInterface.php new file mode 100644 index 0000000000000000000000000000000000000000..b5bd72eca6d61fab7ab953febe949b974f1c92a8 --- /dev/null +++ b/lib/Magento/App/Config/DataInterface.php @@ -0,0 +1,33 @@ +<?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; + +interface DataInterface +{ + /** + * @param $path + * @return mixed + */ + public function getValue($path); +} diff --git a/lib/Magento/App/Config/Initial.php b/lib/Magento/App/Config/Initial.php new file mode 100644 index 0000000000000000000000000000000000000000..772ad37f9070f82e4e3b2d6a921fd20b3a41b409 --- /dev/null +++ b/lib/Magento/App/Config/Initial.php @@ -0,0 +1,94 @@ +<?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\App\Config; + +class Initial +{ + /** + * Cache identifier used to store initial config + */ + const CACHE_ID = 'initial_config'; + + /** + * Config data + * + * @var array + */ + protected $_data = array(); + + /** + * Config metadata + * + * @var array + */ + protected $_metadata = array(); + + /** + * @param \Magento\App\Config\Initial\Reader $reader + * @param \Magento\App\Cache\Type\Config $cache + */ + public function __construct( + \Magento\App\Config\Initial\Reader $reader, + \Magento\App\Cache\Type\Config $cache + ) { + $data = $cache->load(self::CACHE_ID); + if (!$data) { + $data = $reader->read(); + $cache->save(serialize($data), self::CACHE_ID); + } else { + $data = unserialize($data); + } + $this->_data = $data['data']; + $this->_metadata = $data['metadata']; + } + + /** + * Get initial data by given scope + * + * @return mixed + */ + public function getData($scope) + { + list($scopeType, $scopeCode) = array_pad(explode('|', $scope), 2, null); + + if ('default' == $scopeType) { + return isset($this->_data[$scopeType]) ? $this->_data[$scopeType] : array(); + } elseif ($scopeCode) { + return isset($this->_data[$scopeType][$scopeCode]) ? $this->_data[$scopeType][$scopeCode] : array(); + } + return array(); + } + + /** + * Get configuration metadata + * + * @return array + */ + public function getMetadata() + { + return $this->_metadata; + } +} diff --git a/lib/Magento/App/Config/Initial/Reader.php b/lib/Magento/App/Config/Initial/Reader.php new file mode 100644 index 0000000000000000000000000000000000000000..acea58d6b3952c2d8539042a18e610cd1a34b5b4 --- /dev/null +++ b/lib/Magento/App/Config/Initial/Reader.php @@ -0,0 +1,138 @@ +<?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\App\Config\Initial; + +class Reader +{ + /** + * File locator + * + * @var \Magento\Config\FileResolverInterface + */ + protected $_fileResolver; + + /** + * Config converter + * + * @var \Magento\Config\ConverterInterface + */ + 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 \Magento\Config\ConverterInterface $converter + * @param \Magento\App\Config\Initial\SchemaLocator $schemaLocator + * @param \Magento\Config\ValidationStateInterface $validationState + * @param string $fileName + * @param string $domDocumentClass + */ + public function __construct( + \Magento\Config\FileResolverInterface $fileResolver, + \Magento\Config\ConverterInterface $converter, + \Magento\App\Config\Initial\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; + } + + /** + * Read configuration scope + * + * @return array + * + * @throws \Magento\Exception + */ + public function read() + { + $fileList = array(); + foreach ($this->_scopePriorityScheme as $scope) { + $fileList = array_merge($fileList, $this->_fileResolver->get($this->_fileName, $scope)); + } + + 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_get_contents($file), + array(), + $this->_schemaFile + ); + } else { + $domDocument->merge(file_get_contents($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/lib/Magento/App/Config/Initial/SchemaLocator.php b/lib/Magento/App/Config/Initial/SchemaLocator.php new file mode 100644 index 0000000000000000000000000000000000000000..aa44979186b9eb778c181e686b50cb80587ca0c2 --- /dev/null +++ b/lib/Magento/App/Config/Initial/SchemaLocator.php @@ -0,0 +1,65 @@ +<?php +/** + * Logging schema locator + * + * 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\Initial; + +class SchemaLocator implements \Magento\Config\SchemaLocatorInterface +{ + /** + * Path to corresponding XSD file with validation rules for config + * + * @var string + */ + protected $_schema = null; + + /** + * @param \Magento\Module\Dir\Reader $moduleReader + * @param strng $moduleName + */ + public function __construct(\Magento\Module\Dir\Reader $moduleReader, $moduleName) + { + $this->_schema = $moduleReader->getModuleDir('etc', $moduleName) . '/config.xsd'; + } + + /** + * Get path to merged config schema + * + * @return string|null + */ + public function getSchema() + { + return $this->_schema; + } + + /** + * Get path to pre file validation schema + * + * @return string|null + */ + public function getPerFileSchema() + { + return $this->_schema; + } +} diff --git a/lib/Magento/App/Config/Loader.php b/lib/Magento/App/Config/Loader.php index cc9b53bd766a400204e857edfa7662342e351896..d45fb0c7ed9387f9967955d60c3b7ff916c82acc 100644 --- a/lib/Magento/App/Config/Loader.php +++ b/lib/Magento/App/Config/Loader.php @@ -1,6 +1,6 @@ <?php /** - * Local Application configuration loader (app/etc/local.xml) + * Loader * * Magento * @@ -23,75 +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\App\Config; -class Loader +class Loader implements \Magento\App\Config\LoaderInterface { /** - * Local configuration file - */ - const PARAM_CUSTOM_FILE = 'custom.options.file'; - - /** - * Local configuration file - */ - const LOCAL_CONFIG_FILE = 'local.xml'; - - /** - * Directory registry - * - * @var string - */ - protected $_dir; - - /** - * Custom config file - * - * @var string + * @var \Magento\App\Config\Scope\Resolver */ - protected $_customFile; + protected $_scopeResolver; /** - * Configuration identifier attributes - * - * @var array + * @var \Magento\App\Config\ScopePool */ - protected $_idAttributes = array('/config/resource' => 'name', '/config/connection' => 'name'); + protected $_scopePool; /** - * @param \Magento\App\Filesystem\DirectoryList $dirList - * @param string $customFile + * @param \Magento\App\Config\Scope\Resolver $scopeResolver + * @param \Magento\App\Config\ScopePool $scopePool */ - public function __construct(\Magento\App\Filesystem\DirectoryList $dirList, $customFile = null) - { - $this->_dir = $dirList->getDir(\Magento\App\Filesystem::CONFIG_DIR); - $this->_customFile = $customFile; + public function __construct( + \Magento\App\Config\Scope\Resolver $scopeResolver, + \Magento\App\Config\ScopePool $scopePool + ) { + $this->_scopeResolver = $scopeResolver; + $this->_scopePool = $scopePool; } /** - * Load configuration + * Process of config loading * - * @return array + * @return \Magento\App\Config\DataInterface */ public function load() { - $localConfig = new \Magento\Config\Dom('<config/>', $this->_idAttributes); - - $localConfigFile = $this->_dir . '/' . self::LOCAL_CONFIG_FILE; - if (file_exists($localConfigFile)) { - // 1. app/etc/local.xml - $localConfig->merge(file_get_contents($localConfigFile)); - - // 2. app/etc/<dir>/<file>.xml - if (preg_match('/^[a-z\d_-]+(\/|\\\)+[a-z\d_-]+\.xml$/', $this->_customFile)) { - $localConfigExtraFile = $this->_dir . '/' . $this->_customFile; - $localConfig->merge(file_get_contents($localConfigExtraFile)); - } - } - - $converter = new \Magento\Config\Converter\Dom\Flat($this->_idAttributes); - - $result = $converter->convert($localConfig->getDom()); - return !empty($result['config']) ? $result['config'] : array(); + return $this->_scopePool->getScope($this->_scopeResolver->getScope()); } } diff --git a/lib/Magento/App/Config/LoaderInterface.php b/lib/Magento/App/Config/LoaderInterface.php new file mode 100644 index 0000000000000000000000000000000000000000..80c9c79a929008c667bdab698d5a43e0e9e017d0 --- /dev/null +++ b/lib/Magento/App/Config/LoaderInterface.php @@ -0,0 +1,35 @@ +<?php +/** + * Loader 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\App\Config; + +interface LoaderInterface +{ + /** + * Load configuration for current scope + */ + public function load(); +} diff --git a/lib/Magento/App/Config/MetadataProcessor.php b/lib/Magento/App/Config/MetadataProcessor.php new file mode 100644 index 0000000000000000000000000000000000000000..e1b4ea2c1241bfc45beb23a94eb8674af9ce3c7b --- /dev/null +++ b/lib/Magento/App/Config/MetadataProcessor.php @@ -0,0 +1,108 @@ +<?php +/** + * Configuration 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\App\Config; + +class MetadataProcessor +{ + /** + * @var \Magento\App\Config\Data\ProcessorFactory + */ + protected $_processorFactory; + + /** + * @var array + */ + protected $_metadata = array(); + + /** + * @param \Magento\App\Config\Data\ProcessorFactory $processorFactory + * @param \Magento\App\Config\Initial $initialConfig + */ + public function __construct( + \Magento\App\Config\Data\ProcessorFactory $processorFactory, + \Magento\App\Config\Initial $initialConfig + ) { + $this->_processorFactory = $processorFactory; + $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\App\Config\Data\ProcessorInterface $processor */ + $processor = $this->_processorFactory->get($metadata['backendModel']); + $value = $processor->processValue($this->_getValue($data, $path)); + $this->_setValue($data, $path, $value); + } + return $data; + } +} diff --git a/lib/Magento/App/Config/Scope/FactoryInterface.php b/lib/Magento/App/Config/Scope/FactoryInterface.php new file mode 100644 index 0000000000000000000000000000000000000000..2d9e7e9140b6e8205ce60ee8d29961d4721f20a4 --- /dev/null +++ b/lib/Magento/App/Config/Scope/FactoryInterface.php @@ -0,0 +1,37 @@ +<?php +/** + * Scoped Factory + * + * 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; + +interface FactoryInterface +{ + /** + * Create Scope class instance + * + * @param array $data + * @return \IteratorAggregate + */ + public function create(array $data = array()); +} diff --git a/lib/Magento/App/Config/Scope/HierarchyInterface.php b/lib/Magento/App/Config/Scope/HierarchyInterface.php new file mode 100644 index 0000000000000000000000000000000000000000..7cabce69944c24b9b0ca1d7280aa440e67d99b8f --- /dev/null +++ b/lib/Magento/App/Config/Scope/HierarchyInterface.php @@ -0,0 +1,37 @@ +<?php +/** + * Hierarchy 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\App\Config\Scope; + +interface HierarchyInterface +{ + /** + * Get Hierarchy by Scope + * + * @param string $scope + * @return array + */ + public function getHierarchy($scope); +} diff --git a/lib/Magento/App/Config/Scope/Reader.php b/lib/Magento/App/Config/Scope/Reader.php new file mode 100644 index 0000000000000000000000000000000000000000..dc37688cf676303b8ab402381a7e98011be96964 --- /dev/null +++ b/lib/Magento/App/Config/Scope/Reader.php @@ -0,0 +1,125 @@ +<?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/lib/Magento/App/Config/Scope/Resolver.php b/lib/Magento/App/Config/Scope/Resolver.php new file mode 100644 index 0000000000000000000000000000000000000000..e4ddd586d0a7ea64f9829071be75fcde04f90a23 --- /dev/null +++ b/lib/Magento/App/Config/Scope/Resolver.php @@ -0,0 +1,38 @@ +<?php +/** + * Scope Resolver + * + * 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 Resolver implements ResolverInterface +{ + /** + * @inheritdoc + */ + public function processValue($value) + { + return $value; + } + +} diff --git a/lib/Magento/App/Config/Scope/ResolverInterface.php b/lib/Magento/App/Config/Scope/ResolverInterface.php new file mode 100644 index 0000000000000000000000000000000000000000..eb0fa73c24502d2e55b83962e38c52b82957609e --- /dev/null +++ b/lib/Magento/App/Config/Scope/ResolverInterface.php @@ -0,0 +1,37 @@ +<?php +/** + * Resolver 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\App\Config\Scope; + +interface ResolverInterface +{ + /** + * Process config value + * + * @param string $value + * @return mixed + */ + public function processValue($value); +} diff --git a/lib/Magento/App/Config/ScopePool.php b/lib/Magento/App/Config/ScopePool.php new file mode 100644 index 0000000000000000000000000000000000000000..7c1f1e3238c86464b090f79a13f7c385b0a36740 --- /dev/null +++ b/lib/Magento/App/Config/ScopePool.php @@ -0,0 +1,103 @@ +<?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 ScopePool +{ + const CACHE_TAG = 'config_scopes'; + + /** + * @var \Magento\App\Config\Scope\Reader + */ + protected $_reader; + + /** + * @var \Magento\App\Config\DataFactory + */ + protected $_dataFactory; + + /** + * @var \Magento\Cache\FrontendInterface + */ + protected $_cache; + + /** + * @var string + */ + protected $_cacheId; + + /** + * @var \Magento\App\Config\DataInterface[] + */ + protected $_scopes = array(); + + /** + * @param \Magento\App\Config\Scope\Reader $reader + * @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\DataFactory $dataFactory, + \Magento\Cache\FrontendInterface $cache, + $cacheId = 'default_config_cache' + ) { + $this->_reader = $reader; + $this->_dataFactory = $dataFactory; + $this->_cache = $cache; + $this->_cacheId = $cacheId; + } + + /** + * Retrieve config section + * + * @param string $scope + * @return \Magento\App\Config\Data + */ + public function getScope($scope) + { + if (!isset($this->_scopes[$scope])) { + $cacheKey = $this->_cacheId . '|' . $scope; + $data = $this->_cache->load($cacheKey); + if ($data) { + $data = unserialize($data); + } else { + $data = $this->_reader->read($scope); + $this->_cache->save(serialize($data), $cacheKey, array(self::CACHE_TAG)); + } + $this->_scopes[$scope] = $this->_dataFactory->create(array('data' => $data)); + } + return $this->_scopes[$scope]; + } + + /** + * Clear all stired sections + */ + public function clean() + { + $this->_scopes = array(); + $this->_cache->clean(\Zend_Cache::CLEANING_MODE_MATCHING_TAG, array(self::CACHE_TAG)); + } +} diff --git a/lib/Magento/App/Config/ValueInterface.php b/lib/Magento/App/Config/ValueInterface.php new file mode 100644 index 0000000000000000000000000000000000000000..a245a7827c8a9a1cfe736d8602eb19b796c34bb2 --- /dev/null +++ b/lib/Magento/App/Config/ValueInterface.php @@ -0,0 +1,57 @@ +<?php +/** + * Value 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\App\Config; + +interface ValueInterface +{ + /** + * Table name + */ + const ENTITY = 'core_config_data'; + + /** + * Check if config data value was changed + * + * @return bool + */ + public function isValueChanged(); + + /** + * Get old value from existing config + * + * @return string + */ + public function getOldValue(); + + /** + * Get value by key for new user data from <section>/groups/<group>/fields/<field> + * + * @param string $key + * @return string + */ + public function getFieldsetDataValue($key); +} diff --git a/app/code/Magento/Core/Model/ConfigInterface.php b/lib/Magento/App/ConfigInterface.php similarity index 68% rename from app/code/Magento/Core/Model/ConfigInterface.php rename to lib/Magento/App/ConfigInterface.php index fd3f83e7e7aeaaf12285b818c43c052f1a8cdbe2..b162c13685c10b51e4286e8529ea455dce9fe457 100644 --- a/app/code/Magento/Core/Model/ConfigInterface.php +++ b/lib/Magento/App/ConfigInterface.php @@ -1,6 +1,6 @@ <?php /** - * Configuration model interface + * Configuration interface * * Magento * @@ -24,32 +24,31 @@ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -namespace Magento\Core\Model; +namespace Magento\App; interface ConfigInterface { /** - * Retrieve config value by path and scope + * Retrieve config value by path * * @param string $path - * @param string $scope - * @param string $scopeCode * @return mixed */ - public function getValue($path = null, $scope = 'default', $scopeCode = null); + public function getValue($path = null); /** - * Set config value in the corresponding config scope + * Set config value * * @param string $path * @param mixed $value - * @param string $scope - * @param null|string $scopeCode */ - public function setValue($path, $value, $scope = 'default', $scopeCode = null); + public function setValue($path, $value); /** - * Reinitialize config object + * Retrieve config flag + * + * @param string $path + * @return bool */ - public function reinit(); + public function isSetFlag($path); } diff --git a/lib/Magento/App/Cron.php b/lib/Magento/App/Cron.php index 553b6b56be2c2017e358c9d66db6de122b7f47e3..d503265ec659e408f8353d647ab23dad7ed92444 100644 --- a/lib/Magento/App/Cron.php +++ b/lib/Magento/App/Cron.php @@ -29,7 +29,7 @@ use Magento\App\Console\Response; use \Magento\App\ObjectManager\ConfigLoader, \Magento\Event\ManagerInterface; -class Cron implements \Magento\AppInterface +class Cron implements \Magento\LauncherInterface { /** * @var \Magento\Event\ManagerInterface @@ -66,7 +66,7 @@ class Cron implements \Magento\AppInterface * * @return ResponseInterface */ - public function execute() + public function launch() { $this->_state->setAreaCode('crontab'); $this->_eventManager->dispatch('default'); diff --git a/lib/Magento/App/EntryPoint/EntryPoint.php b/lib/Magento/App/EntryPoint/EntryPoint.php index 7b06d10e4f8eedd4286418e12c97fa4681c90911..15b73061158bbf51a2a60dcded097b55af29ceb3 100644 --- a/lib/Magento/App/EntryPoint/EntryPoint.php +++ b/lib/Magento/App/EntryPoint/EntryPoint.php @@ -79,7 +79,7 @@ class EntryPoint implements EntryPointInterface $this->_locator = $locatorFactory->create($this->_rootDir, $this->_parameters); } $application = $this->_locator->create($applicationName, $arguments); - $response = $application->execute(); + $response = $application->launch(); \Magento\Profiler::stop('magento'); $response->sendResponse(); } catch (\Exception $exception) { diff --git a/lib/Magento/App/Error/Handler.php b/lib/Magento/App/Error/Handler.php index fe9ec9bf17796a9a7723dcae2f0f29dbdb0607b2..48e60585a95b81044c9b9ab47724eb3d38d357da 100644 --- a/lib/Magento/App/Error/Handler.php +++ b/lib/Magento/App/Error/Handler.php @@ -64,6 +64,7 @@ class Handler extends \Magento\Error\Handler * * @param \Exception $exception * @param array $params + * @return void */ public function processException(\Exception $exception, array $params = array()) { @@ -87,7 +88,9 @@ class Handler extends \Magento\Error\Handler /** * Show error as exception or log it * + * @param string $errorMessage * @throws \Exception + * @return void */ protected function _processError($errorMessage) { diff --git a/lib/Magento/App/Filesystem/DirectoryList/Configuration.php b/lib/Magento/App/Filesystem/DirectoryList/Configuration.php index 10ab31caaa7d8b5a6fcf1dcdfa0787c3ed536213..120338b7d27abf6066935c00f064ea62497a603a 100644 --- a/lib/Magento/App/Filesystem/DirectoryList/Configuration.php +++ b/lib/Magento/App/Filesystem/DirectoryList/Configuration.php @@ -62,9 +62,9 @@ class Configuration /** * Store directory configuration * - * @param \Magento\Core\Model\ConfigInterface $config + * @param \Magento\App\ConfigInterface $config */ - public function __construct(\Magento\Core\Model\ConfigInterface $config) + public function __construct(\Magento\App\ConfigInterface $config) { $this->directories = $config->getValue(self::XML_FILESYSTEM_DIRECTORY_PATH) ?: array(); $this->protocols = $config->getValue(self::XML_FILESYSTEM_WRAPPER_PATH) ?: array(); @@ -74,6 +74,7 @@ class Configuration * Add directories from configuration to Filesystem * * @param DirectoryList $directoryList + * @return void */ public function configure(DirectoryList $directoryList) { diff --git a/lib/Magento/App/Filesystem/DirectoryList/Verification.php b/lib/Magento/App/Filesystem/DirectoryList/Verification.php index 4ceae682f96cc1f50c843e2df94151fca834078e..7d0e29933946b5f19053a67d8b1654d15778ddf6 100644 --- a/lib/Magento/App/Filesystem/DirectoryList/Verification.php +++ b/lib/Magento/App/Filesystem/DirectoryList/Verification.php @@ -25,16 +25,17 @@ */ namespace Magento\App\Filesystem\DirectoryList; -use Magento\App\State, - Magento\Filesystem\FilesystemException, - Magento\App\Filesystem; +use Magento\App\State; +use Magento\BootstrapException; +use Magento\App\Filesystem; +use Magento\Filesystem\FilesystemException; class Verification { /** * Codes of directories to create and verify in production mode * - * @var array + * @var string[] */ protected static $productionDirs = array( Filesystem::SESSION_DIR, @@ -45,7 +46,7 @@ class Verification /** * Codes of directories to create and verify in non-production mode * - * @var array + * @var string[] */ protected static $nonProductionDirs = array( Filesystem::SESSION_DIR, @@ -61,7 +62,7 @@ class Verification /** * Cached list of directories to create and verify write access * - * @var array + * @var string[] */ protected $dirsToVerify = array(); @@ -81,7 +82,7 @@ class Verification * Return list of directories, that must be verified according to the application mode * * @param State $appState - * @return array + * @return string[] */ protected function _getDirsToVerify(State $appState) { @@ -93,6 +94,10 @@ class Verification /** * Create the required directories, if they don't exist, and verify write access for existing directories + * + * @return void + * @throws BootstrapException + * */ public function createAndVerifyDirectories() { @@ -114,7 +119,7 @@ class Verification if ($fails) { $dirList = implode(', ', $fails); - throw new \Magento\BootstrapException( + throw new BootstrapException( "Cannot create or verify write access: {$dirList}" ); } diff --git a/lib/Magento/App/Http.php b/lib/Magento/App/Http.php index e1be703a08d8c2987444dc97249e2f8dfe342cfc..a396fed765d945803175ec5dde9dbee7cfadc3d9 100644 --- a/lib/Magento/App/Http.php +++ b/lib/Magento/App/Http.php @@ -31,7 +31,7 @@ use Magento\App\ObjectManager\ConfigLoader, /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class Http implements \Magento\AppInterface +class Http implements \Magento\LauncherInterface { /** * @var \Magento\ObjectManager @@ -108,7 +108,7 @@ class Http implements \Magento\AppInterface * * @return ResponseInterface */ - public function execute() + public function launch() { try { $areaCode = $this->_areaList->getCodeByFrontName($this->_request->getFrontName()); diff --git a/lib/Magento/App/ObjectManager.php b/lib/Magento/App/ObjectManager.php index b2a89e1431ab619df57a47a7b9e0396b6db8ad27..cb739abc5d6d2141c1fb6bb8bd0eaf167dc0602c 100644 --- a/lib/Magento/App/ObjectManager.php +++ b/lib/Magento/App/ObjectManager.php @@ -47,7 +47,7 @@ class ObjectManager extends \Magento\ObjectManager\ObjectManager * TODO: Temporary solution for serialization, should be removed when Serialization problem is resolved * * @deprecated - * @return \Magento\ObjectManager + * @return \Magento\App\ObjectManager * @throws \RuntimeException */ public static function getInstance() @@ -63,6 +63,7 @@ class ObjectManager extends \Magento\ObjectManager\ObjectManager * * @param \Magento\ObjectManager $objectManager * @throws \LogicException + * @return void */ public static function setInstance(\Magento\ObjectManager $objectManager) { diff --git a/lib/Magento/App/ObjectManager/ConfigCache.php b/lib/Magento/App/ObjectManager/ConfigCache.php index f929141ee8e273d4cfd086ff191c779396f9ef69..26640327d3c9ea783c8bb4ed5ca11dc925104e57 100644 --- a/lib/Magento/App/ObjectManager/ConfigCache.php +++ b/lib/Magento/App/ObjectManager/ConfigCache.php @@ -64,6 +64,7 @@ class ConfigCache implements \Magento\ObjectManager\ConfigCache * * @param array $config * @param string $key + * @return void */ public function save(array $config, $key) { diff --git a/lib/Magento/App/ObjectManager/ConfigLoader/Primary.php b/lib/Magento/App/ObjectManager/ConfigLoader/Primary.php index e3f7c36b74ab4b327278723a2ff00d3e5bc9f1d5..951fd0c29c87a53520cad904fd18b63468307b7a 100644 --- a/lib/Magento/App/ObjectManager/ConfigLoader/Primary.php +++ b/lib/Magento/App/ObjectManager/ConfigLoader/Primary.php @@ -59,7 +59,7 @@ class Primary public function load() { $reader = new \Magento\ObjectManager\Config\Reader\Dom( - new \Magento\App\Config\FileResolver\Primary( + new \Magento\App\Arguments\FileResolver\Primary( new \Magento\App\Filesystem( $this->_directoryList, new \Magento\Filesystem\Directory\ReadFactory(), @@ -69,7 +69,7 @@ class Primary ), new \Magento\ObjectManager\Config\Mapper\Dom(), new \Magento\ObjectManager\Config\SchemaLocator(), - new \Magento\App\Config\ValidationState($this->_appMode) + new \Magento\App\Arguments\ValidationState($this->_appMode) ); return $reader->read('primary'); diff --git a/lib/Magento/App/ObjectManagerFactory.php b/lib/Magento/App/ObjectManagerFactory.php index 336e9d9981a5197fa48ef24f74084578953a9d3e..f86e841841cd379998e446b905821025b690d721 100644 --- a/lib/Magento/App/ObjectManagerFactory.php +++ b/lib/Magento/App/ObjectManagerFactory.php @@ -26,7 +26,7 @@ namespace Magento\App; -use Magento\App\Config, +use Magento\App\Arguments, Magento\Profiler, Magento\App\Filesystem; @@ -73,12 +73,12 @@ class ObjectManagerFactory array($directoryList->getDir(\Magento\App\Filesystem::GENERATION_DIR)) ); - $options = new Config( + $options = new \Magento\App\Arguments( $arguments, - new Config\Loader( + new \Magento\App\Arguments\Loader( $directoryList, - isset($arguments[Config\Loader::PARAM_CUSTOM_FILE]) - ? $arguments[Config\Loader::PARAM_CUSTOM_FILE] + isset($arguments[\Magento\App\Arguments\Loader::PARAM_CUSTOM_FILE]) + ? $arguments[\Magento\App\Arguments\Loader::PARAM_CUSTOM_FILE] : null ) ); @@ -108,7 +108,7 @@ class ObjectManagerFactory $className = $this->_locatorClassName; /** @var \Magento\ObjectManager $objectManager */ $objectManager = new $className($factory, $diConfig, array( - 'Magento\App\Config' => $options, + 'Magento\App\Arguments' => $options, 'Magento\App\Filesystem\DirectoryList' => $directoryList, 'Magento\Filesystem\DirectoryList' => $directoryList )); diff --git a/lib/Magento/App/ReinitableConfigInterface.php b/lib/Magento/App/ReinitableConfigInterface.php new file mode 100644 index 0000000000000000000000000000000000000000..b202e5e9ac673d42716e85400ac273e47878e2ce --- /dev/null +++ b/lib/Magento/App/ReinitableConfigInterface.php @@ -0,0 +1,37 @@ +<?php +/** + * Configuration Reinitable 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\App; + +interface ReinitableConfigInterface extends \Magento\App\ConfigInterface +{ + /** + * Reinitialize config object + * + * @return \Magento\App\ReinitableConfigInterface + */ + public function reinit(); +} diff --git a/lib/Magento/App/Request/Http.php b/lib/Magento/App/Request/Http.php index 3601fa5da1aa0f30012e7e2185c2b454e105ee18..2422c32c07e9774c4a9c214c0e2ea3423e867b45 100644 --- a/lib/Magento/App/Request/Http.php +++ b/lib/Magento/App/Request/Http.php @@ -35,20 +35,42 @@ class Http extends \Zend_Controller_Request_Http implements \Magento\App\Request * @var string */ protected $_originalPathInfo= ''; + + /** + * @var string + */ protected $_requestString = ''; /** * Path info array used before applying rewrite from config * - * @var null || array + * @var null|array */ protected $_rewritedPathInfo= null; + + /** + * @var string + */ protected $_requestedRouteName = null; + + /** + * @var array + */ protected $_routingInfo = array(); + /** + * @var string + */ protected $_route; + /** + * @var array + */ protected $_directFrontNames; + + /** + * @var string + */ protected $_controllerModule = null; /** @@ -114,7 +136,7 @@ class Http extends \Zend_Controller_Request_Http implements \Magento\App\Request * Set the ORIGINAL_PATH_INFO string * * @param string|null $pathInfo - * @return \Zend_Controller_Request_Http + * @return $this */ public function setPathInfo($pathInfo = null) { @@ -153,8 +175,8 @@ class Http extends \Zend_Controller_Request_Http implements \Magento\App\Request * Specify new path info * It happen when occur rewrite based on configuration * - * @param string $pathInfo - * @return \Magento\App\RequestInterface + * @param string $pathInfo + * @return $this */ public function rewritePathInfo($pathInfo) { @@ -242,6 +264,11 @@ class Http extends \Zend_Controller_Request_Http implements \Magento\App\Request return reset($pathParts); } + /** + * Retrieve route name + * + * @return string|null + */ public function getRouteName() { return $this->_route; @@ -273,7 +300,7 @@ class Http extends \Zend_Controller_Request_Http implements \Magento\App\Request * @param string|array $key * @param mixed $value * - * @return \Magento\App\RequestInterface + * @return $this */ public function setPost($key, $value = null) { @@ -288,8 +315,8 @@ class Http extends \Zend_Controller_Request_Http implements \Magento\App\Request /** * Specify module name where was found currently used controller * - * @param string $module - * @return \Magento\App\RequestInterface + * @param string $module + * @return $this */ public function setControllerModule($module) { @@ -357,7 +384,7 @@ class Http extends \Zend_Controller_Request_Http implements \Magento\App\Request /** * Retrieve the list of all aliases * - * @return array + * @return array|string */ public function getAliases() { @@ -425,7 +452,7 @@ class Http extends \Zend_Controller_Request_Http implements \Magento\App\Request * Set routing info data * * @param array $data - * @return \Magento\App\RequestInterface + * @return $this */ public function setRoutingInfo($data) { @@ -439,7 +466,7 @@ class Http extends \Zend_Controller_Request_Http implements \Magento\App\Request * Collect properties changed by _forward in protected storage * before _forward was called first time. * - * @return \Magento\App\ActionInterface + * @return $this */ public function initForward() { @@ -511,8 +538,8 @@ class Http extends \Zend_Controller_Request_Http implements \Magento\App\Request * If no $key is passed, returns the entire $_FILES array. * * @param string $key - * @param mixed $default Default value to use if key not found - * @return mixed + * @param array $default Default value to use if key not found + * @return array */ public function getFiles($key = null, $default = null) { @@ -553,7 +580,7 @@ class Http extends \Zend_Controller_Request_Http implements \Magento\App\Request * Retrieve full action name * * @param string $delimiter - * @return mixed|string + * @return string */ public function getFullActionName($delimiter = '_') { diff --git a/lib/Magento/App/Resource.php b/lib/Magento/App/Resource.php index b27a23b064291b554fa7e2b719c47f421c9c4330..cb2f344bde516cd726a432be8cb5787063789aee 100644 --- a/lib/Magento/App/Resource.php +++ b/lib/Magento/App/Resource.php @@ -96,6 +96,7 @@ class Resource * Set cache instance * * @param \Magento\App\CacheInterface $cache + * @return void */ public function setCache(\Magento\App\CacheInterface $cache) { @@ -107,6 +108,7 @@ class Resource * Added for console installation * * @param string $tablePrefix + * @return void */ public function setTablePrefix($tablePrefix) { @@ -139,7 +141,7 @@ class Resource /** * Get resource table name, validated by db adapter * - * @param string|array $modelEntity + * @param string|string[] $modelEntity * @return string */ public function getTableName($modelEntity) @@ -172,7 +174,7 @@ class Resource * * @param string $tableName * @param string $mappedName - * @return \Magento\App\Resource + * @return $this */ public function setMappedTableName($tableName, $mappedName) { @@ -199,7 +201,7 @@ class Resource * Retrieve 32bit UNIQUE HASH for a Table index * * @param string $tableName - * @param array|string $fields + * @param string|string[] $fields * @param string $indexType * @return string */ diff --git a/lib/Magento/App/Resource/ConnectionFactory.php b/lib/Magento/App/Resource/ConnectionFactory.php index 36739bc81090ef0e0e45c5c4bc54b7b3a50f9b20..b19bba5f040a9f6e962e3ad5ede1d91e1f488688 100644 --- a/lib/Magento/App/Resource/ConnectionFactory.php +++ b/lib/Magento/App/Resource/ConnectionFactory.php @@ -33,15 +33,15 @@ class ConnectionFactory protected $_objectManager; /** - * @var \Magento\App\Config + * @var \Magento\App\Arguments */ protected $_localConfig; /** * @param \Magento\ObjectManager $objectManager - * @param \Magento\App\Config $localConfig + * @param \Magento\App\Arguments $localConfig */ - public function __construct(\Magento\ObjectManager $objectManager, \Magento\App\Config $localConfig) + public function __construct(\Magento\ObjectManager $objectManager, \Magento\App\Arguments $localConfig) { $this->_objectManager = $objectManager; $this->_localConfig = $localConfig; diff --git a/lib/Magento/App/Route/Config.php b/lib/Magento/App/Route/Config.php index a2eb55dc5ba6812e74f69a37084d2f7c8748c2df..3edddf058890d8fded5676df8a085353d91a1caf 100644 --- a/lib/Magento/App/Route/Config.php +++ b/lib/Magento/App/Route/Config.php @@ -136,7 +136,7 @@ class Config implements \Magento\App\Route\ConfigInterface /** * @param string $frontName * @param string $scope - * @return array + * @return string[] */ public function getModulesByFrontName($frontName, $scope = null) { diff --git a/lib/Magento/App/Route/Config/Converter.php b/lib/Magento/App/Route/Config/Converter.php index 23bea70fc000750ae40f18c87e5c8d826bfbc1b2..769c01e92970bbc971f1ddef79ed6f36f580f901 100644 --- a/lib/Magento/App/Route/Config/Converter.php +++ b/lib/Magento/App/Route/Config/Converter.php @@ -30,7 +30,7 @@ class Converter implements \Magento\Config\ConverterInterface /** * Convert config * - * @param mixed $source + * @param \DOMDocument $source * @return array */ public function convert($source) diff --git a/lib/Magento/App/Router/NoRouteHandlerList.php b/lib/Magento/App/Router/NoRouteHandlerList.php index 319dbf878248a01d5f8a34109fe99906d3453c45..3e37010e5da19aa643ad095b5f958fbcc20e8e3e 100644 --- a/lib/Magento/App/Router/NoRouteHandlerList.php +++ b/lib/Magento/App/Router/NoRouteHandlerList.php @@ -30,7 +30,7 @@ class NoRouteHandlerList /** * No route handlers instances * - * @var array + * @var NoRouteHandlerInterface[] */ protected $_handlers; @@ -59,7 +59,7 @@ class NoRouteHandlerList /** * Get noRoute handlers * - * @return array + * @return NoRouteHandlerInterface[] */ public function getHandlers() { diff --git a/lib/Magento/App/RouterList.php b/lib/Magento/App/RouterList.php index 57c0f73ce3f36150e58daf4499f77ecbce280a08..a3a2a4a84c758950cf8d64c4c72916e6111a1af0 100644 --- a/lib/Magento/App/RouterList.php +++ b/lib/Magento/App/RouterList.php @@ -96,7 +96,7 @@ class RouterList implements RouterListInterface * (PHP 5 >= 5.0.0)<br/> * Return the key of the current element * @link http://php.net/manual/en/iterator.key.php - * @return mixed scalar on success, or null on failure. + * @return void */ public function key() { diff --git a/lib/Magento/App/State.php b/lib/Magento/App/State.php index e0738c53d1995e636becda5a2ea5189d58c25a36..6841394294d1e12ac162f3ee715cf5b9c1e4721c 100644 --- a/lib/Magento/App/State.php +++ b/lib/Magento/App/State.php @@ -129,6 +129,7 @@ class State * Set update mode flag * * @param bool $value + * @return void */ public function setUpdateMode($value) { @@ -150,6 +151,7 @@ class State * Set is downloader flag * * @param bool $flag + * @return void */ public function setIsDownloader($flag = true) { @@ -160,6 +162,7 @@ class State * Set install date * * @param string $date + * @return void */ public function setInstallDate($date) { @@ -170,6 +173,7 @@ class State * Set area code * * @param string $code + * @return void * @throws \Magento\Exception */ public function setAreaCode($code) diff --git a/lib/Magento/App/View.php b/lib/Magento/App/View.php index 1c40719bf415a84e202e7187c1067b2161ffb02f..461b274acaa5e145d60401076f72cd416435a239 100644 --- a/lib/Magento/App/View.php +++ b/lib/Magento/App/View.php @@ -155,7 +155,7 @@ class View implements ViewInterface /** * Add layout handle by full controller action name * - * @return \Magento\App\ActionInterface + * @return $this */ public function addActionLayoutHandles() { @@ -168,12 +168,13 @@ class View implements ViewInterface /** * Add layout updates handles associated with the action page * - * @param array $parameters page parameters + * @param array|null $parameters page parameters + * @param string|null $defaultHandle * @return bool */ - public function addPageLayoutHandles(array $parameters = array()) + public function addPageLayoutHandles(array $parameters = array(), $defaultHandle = null) { - $handle = $this->getDefaultLayoutHandle(); + $handle = $defaultHandle ? $defaultHandle : $this->getDefaultLayoutHandle(); $pageHandles = array($handle); foreach ($parameters as $key => $value) { $pageHandles[] = $handle . '_' . $key . '_' . $value; @@ -185,7 +186,7 @@ class View implements ViewInterface /** * Load layout updates * - * @return \Magento\App\View + * @return $this */ public function loadLayoutUpdates() { @@ -209,7 +210,7 @@ class View implements ViewInterface /** * Generate layout xml * - * @return \Magento\App\View + * @return $this */ public function generateLayoutXml() { @@ -226,7 +227,7 @@ class View implements ViewInterface /** * Generate layout blocks * - * @return \Magento\App\View + * @return $this */ public function generateLayoutBlocks() { @@ -260,7 +261,7 @@ class View implements ViewInterface * Rendering layout * * @param string $output - * @return \Magento\App\View + * @return $this */ public function renderLayout($output = '') { @@ -294,6 +295,7 @@ class View implements ViewInterface * Set isLayoutLoaded flag * * @param bool $value + * @return void */ public function setIsLayoutLoaded($value) { diff --git a/lib/Magento/App/ViewInterface.php b/lib/Magento/App/ViewInterface.php index 426ff234583f7bf22b917b48ef5c8af915350b96..80c87c5da8bf8dc685709227c59ea232953b46f8 100644 --- a/lib/Magento/App/ViewInterface.php +++ b/lib/Magento/App/ViewInterface.php @@ -69,9 +69,10 @@ interface ViewInterface * Add layout updates handles associated with the action page * * @param array $parameters page parameters + * @param string $defaultHandle * @return bool */ - public function addPageLayoutHandles(array $parameters = array()); + public function addPageLayoutHandles(array $parameters = array(), $defaultHandle = null); /** * Generate layout blocks @@ -101,4 +102,4 @@ interface ViewInterface */ public function setIsLayoutLoaded($value); -} \ No newline at end of file +} diff --git a/lib/Magento/AppInterface.php b/lib/Magento/AppInterface.php index 4917d90d3bf56dd308c3a4280bf925c83b6dd4c6..f97208563466e0c815e23fff1261766cf7463dc8 100644 --- a/lib/Magento/AppInterface.php +++ b/lib/Magento/AppInterface.php @@ -1,6 +1,6 @@ <?php /** - * Application. Performs user requested actions. + * Application interface * * Magento * @@ -23,12 +23,188 @@ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ + namespace Magento; interface AppInterface { /** + * Default application locale + */ + const DISTRO_LOCALE_CODE = 'en_US'; + + /** + * Throw an exception, if the application has not been installed yet + * + * @throws \Magento\Exception + */ + public function requireInstalledInstance(); + + /** + * Retrieve cookie object + * + * @return \Magento\Stdlib\Cookie + */ + public function getCookie(); + + /** + * Re-declare custom error handler + * + * @param string $handler + * @return \Magento\AppInterface + */ + public function setErrorHandler($handler); + + /** + * Loading part of area data + * + * @param string $area + * @param string $part + * @return \Magento\AppInterface + */ + public function loadAreaPart($area, $part); + + /** + * Retrieve application area + * + * @param string $code + * @return \Magento\Core\Model\App\Area + */ + public function getArea($code); + + /** + * Get distributive locale code + * + * @return string + */ + public function getDistroLocaleCode(); + + /** + * Retrieve application locale object + * + * @return \Magento\Core\Model\LocaleInterface + */ + public function getLocale(); + + /** + * Retrieve layout object + * + * @return \Magento\View\LayoutInterface + */ + public function getLayout(); + + /** + * Retrieve application base currency code + * + * @return string + */ + public function getBaseCurrencyCode(); + + /** + * Retrieve configuration object + * + * @return \Magento\App\ConfigInterface + */ + public function getConfig(); + + /** + * Retrieve front controller object + * + * @return \Magento\App\FrontController + */ + public function getFrontController(); + + /** + * Get core cache model + * + * @return \Magento\App\CacheInterface + */ + public function getCacheInstance(); + + + /** + * Retrieve cache object + * + * @return \Zend_Cache_Core + */ + public function getCache(); + + /** + * Loading cache data + * + * @param string $cacheId + * @return mixed + */ + public function loadCache($cacheId); + + /** + * Saving cache data + * + * @param mixed $data + * @param string $cacheId + * @param array $tags + * @param bool $lifeTime + * @return \Magento\AppInterface + */ + public function saveCache($data, $cacheId, $tags = array(), $lifeTime = false); + + /** + * Remove cache + * + * @param string $cacheId + * @return \Magento\AppInterface + */ + public function removeCache($cacheId); + + /** + * Cleaning cache + * + * @param array $tags + * @return \Magento\AppInterface + */ + public function cleanCache($tags = array()); + + /** + * Deletes all session files + * + * @return \Magento\AppInterface + */ + public function cleanAllSessions(); + + /** + * Retrieve request object + * + * @return \Magento\App\RequestInterface + */ + public function getRequest(); + + /** + * Request setter + * + * @param \Magento\App\RequestInterface $request + * @return \Magento\AppInterface + */ + public function setRequest(\Magento\App\RequestInterface $request); + + /** + * Retrieve response object + * * @return \Magento\App\ResponseInterface */ - public function execute(); -} \ No newline at end of file + public function getResponse(); + + /** + * Response setter + * + * @param \Magento\App\ResponseInterface $response + * @return \Magento\AppInterface + */ + public function setResponse(\Magento\App\ResponseInterface $response); + + /** + * Check if developer mode is enabled. + * + * @return bool + */ + public function isDeveloperMode(); +} diff --git a/lib/Magento/Archive.php b/lib/Magento/Archive.php index f6cd6083799dd85a17fe44e188243c29d342b30b..6897de5ee3dde2fb9bdd9d728d98f4f3dce03f41 100644 --- a/lib/Magento/Archive.php +++ b/lib/Magento/Archive.php @@ -33,6 +33,10 @@ */ namespace Magento; +use Magento\Archive\Bz; +use Magento\Archive\Gz; +use Magento\Archive\Tar; + class Archive { @@ -77,7 +81,7 @@ class Archive * Create object of current archiver by $extension. * * @param string $extension - * @return \Magento\Archive\Tar|\Magento\Archive\Gz|\Magento\Archive\Bz + * @return Tar|Gz|Bz */ protected function _getArchiver($extension) { @@ -95,7 +99,7 @@ class Archive * Split current format to list of archivers. * * @param string $source - * @return array + * @return string[]|string */ protected function _getArchivers($source) { @@ -209,7 +213,7 @@ class Archive /** * Check file is TAR. * - * @param mixed $file + * @param string $file * @return boolean */ public function isTar($file) diff --git a/lib/Magento/Archive/AbstractArchive.php b/lib/Magento/Archive/AbstractArchive.php index 13e68c88705ebc0813f54297bf95fddbdc7dba8f..690ccbcf4710485f2c5280a8a0f46292c430affb 100644 --- a/lib/Magento/Archive/AbstractArchive.php +++ b/lib/Magento/Archive/AbstractArchive.php @@ -40,8 +40,8 @@ class AbstractArchive * * @param string $destination * @param string $data - * @return boolean - * @throws \Magento\Exception + * @return true + * @throws \Exception */ protected function _writeFile($destination, $data) { @@ -76,7 +76,7 @@ class AbstractArchive * * @param string $source * @param bool $withExtension - * @return mixed|string + * @return string */ public function getFilename($source, $withExtension=false) { diff --git a/lib/Magento/Archive/Helper/File.php b/lib/Magento/Archive/Helper/File.php index 06b3317f9b60d24e3a917271c93d2a13f583ef62..43de8bc9c62c5a18f8b33523edb8e4a1f2ad91ee 100644 --- a/lib/Magento/Archive/Helper/File.php +++ b/lib/Magento/Archive/Helper/File.php @@ -62,7 +62,7 @@ class File /** * File handler * - * @var pointer + * @var resource */ protected $_fileHandler; @@ -82,6 +82,8 @@ class File /** * Close file if it's not closed before object destruction + * + * @return void */ public function __destruct() { @@ -95,6 +97,7 @@ class File * * @param string $mode * @param int $chmod + * @return void * @throws \Magento\Exception */ public function open($mode = 'w+', $chmod = 0666) @@ -128,6 +131,7 @@ class File * Write data to file * * @param string $data + * @return void */ public function write($data) { @@ -165,6 +169,8 @@ class File /** * Close file + * + * @return void */ public function close() { @@ -178,6 +184,7 @@ class File * Implementation of file opening * * @param string $mode + * @return void * @throws \Magento\Exception */ protected function _open($mode) @@ -193,6 +200,7 @@ class File * Implementation of writing data to file * * @param string $data + * @return void * @throws \Magento\Exception */ protected function _write($data) @@ -208,6 +216,7 @@ class File * Implementation of file reading * * @param int $length + * @return string * @throws \Magento\Exception */ protected function _read($length) @@ -233,6 +242,8 @@ class File /** * Implementation of file closing + * + * @return void */ protected function _close() { @@ -243,6 +254,7 @@ class File * Check whether requested mode is writable mode * * @param string $mode + * @return int */ protected function _isWritableMode($mode) { @@ -253,6 +265,7 @@ class File * Check whether requested mode is readable mode * * @param string $mode + * @return bool */ protected function _isReadableMode($mode) { return !$this->_isWritableMode($mode); @@ -261,6 +274,7 @@ class File /** * Check whether file is opened * + * @return void * @throws \Magento\Exception */ protected function _checkFileOpened() diff --git a/lib/Magento/Archive/Helper/File/Bz.php b/lib/Magento/Archive/Helper/File/Bz.php index 93318c1110c0e4d8d0bc5fa8ae1d2bcbf8e4ea6d..6da426c5b380fdea8634c37785e3e0b67ccefb33 100644 --- a/lib/Magento/Archive/Helper/File/Bz.php +++ b/lib/Magento/Archive/Helper/File/Bz.php @@ -30,10 +30,7 @@ namespace Magento\Archive\Helper\File; class Bz extends \Magento\Archive\Helper\File { /** - * Open bz archive file - * - * @throws \Magento\Exception - * @param string $mode + * {@inheritdoc} */ protected function _open($mode) { @@ -45,10 +42,7 @@ class Bz extends \Magento\Archive\Helper\File } /** - * Write data to bz archive - * - * @throws \Magento\Exception - * @param $data + * {@inheritdoc} */ protected function _write($data) { @@ -60,11 +54,7 @@ class Bz extends \Magento\Archive\Helper\File } /** - * Read data from bz archive - * - * @throws \Magento\Exception - * @param int $length - * @return string + * {@inheritdoc} */ protected function _read($length) { @@ -78,7 +68,7 @@ class Bz extends \Magento\Archive\Helper\File } /** - * Close bz archive + * {@inheritdoc} */ protected function _close() { diff --git a/lib/Magento/Archive/Helper/File/Gz.php b/lib/Magento/Archive/Helper/File/Gz.php index 01ce30bf5cdeeedd8c49c909c1b9f6bee4419e26..4cc8bad5d38149e0f183af79deaa098b2a57e56a 100644 --- a/lib/Magento/Archive/Helper/File/Gz.php +++ b/lib/Magento/Archive/Helper/File/Gz.php @@ -30,7 +30,7 @@ namespace Magento\Archive\Helper\File; class Gz extends \Magento\Archive\Helper\File { /** - * @see \Magento\Archive\Helper\File::_open() + * {@inheritdoc} */ protected function _open($mode) { @@ -42,7 +42,7 @@ class Gz extends \Magento\Archive\Helper\File } /** - * @see \Magento\Archive\Helper\File::_write() + * {@inheritdoc} */ protected function _write($data) { @@ -54,7 +54,7 @@ class Gz extends \Magento\Archive\Helper\File } /** - * @see \Magento\Archive\Helper\File::_read() + * {@inheritdoc} */ protected function _read($length) { @@ -62,7 +62,7 @@ class Gz extends \Magento\Archive\Helper\File } /** - * @see \Magento\Archive\Helper\File::_eof() + * {@inheritdoc} */ protected function _eof() { @@ -70,7 +70,7 @@ class Gz extends \Magento\Archive\Helper\File } /** - * @see \Magento\Archive\Helper\File::_close() + * {@inheritdoc} */ protected function _close() { diff --git a/lib/Magento/Archive/Tar.php b/lib/Magento/Archive/Tar.php index 893b0117a2b50c0187353887f6efca38bc04b0c6..456d901ec0a4f21f4558a878231088c38e1165a7 100644 --- a/lib/Magento/Archive/Tar.php +++ b/lib/Magento/Archive/Tar.php @@ -33,6 +33,8 @@ */ namespace Magento\Archive; +use \Magento\Archive\Helper\File; + class Tar extends \Magento\Archive\AbstractArchive implements \Magento\Archive\ArchiveInterface { /** @@ -52,7 +54,7 @@ class Tar extends \Magento\Archive\AbstractArchive implements \Magento\Archive\A /** * Keep path to file or directory for packing. * - * @var mixed + * @var string */ protected $_currentPath; @@ -60,21 +62,21 @@ class Tar extends \Magento\Archive\AbstractArchive implements \Magento\Archive\A * Skip first level parent directory. Example: * use test/fip.php instead test/test/fip.php; * - * @var mixed + * @var bool */ protected $_skipRoot; /** * Tarball data writer * - * @var \Magento\Archive\Helper\File + * @var File */ protected $_writer; /** * Tarball data reader * - * @var \Magento\Archive\Helper\File + * @var File */ protected $_reader; @@ -88,11 +90,11 @@ class Tar extends \Magento\Archive\AbstractArchive implements \Magento\Archive\A /** * Initialize tarball writer * - * @return \Magento\Archive\Tar + * @return $this */ protected function _initWriter() { - $this->_writer = new \Magento\Archive\Helper\File($this->_destinationFilePath); + $this->_writer = new File($this->_destinationFilePath); $this->_writer->open('w'); return $this; @@ -112,11 +114,11 @@ class Tar extends \Magento\Archive\AbstractArchive implements \Magento\Archive\A /** * Destroy tarball writer * - * @return \Magento\Archive\Tar + * @return $this */ protected function _destroyWriter() { - if ($this->_writer instanceof \Magento\Archive\Helper\File) { + if ($this->_writer instanceof File) { $this->_writer->close(); $this->_writer = null; } @@ -127,7 +129,7 @@ class Tar extends \Magento\Archive\AbstractArchive implements \Magento\Archive\A /** * Get tarball writer * - * @return \Magento\Archive\Helper\File + * @return File */ protected function _getWriter() { @@ -141,11 +143,11 @@ class Tar extends \Magento\Archive\AbstractArchive implements \Magento\Archive\A /** * Initialize tarball reader * - * @return \Magento\Archive\Tar + * @return $this */ protected function _initReader() { - $this->_reader = new \Magento\Archive\Helper\File($this->_getCurrentFile()); + $this->_reader = new File($this->_getCurrentFile()); $this->_reader->open('r'); return $this; @@ -154,11 +156,11 @@ class Tar extends \Magento\Archive\AbstractArchive implements \Magento\Archive\A /** * Destroy tarball reader * - * @return \Magento\Archive\Tar + * @return $this */ protected function _destroyReader() { - if ($this->_reader instanceof \Magento\Archive\Helper\File) { + if ($this->_reader instanceof File) { $this->_reader->close(); $this->_reader = null; } @@ -169,7 +171,7 @@ class Tar extends \Magento\Archive\AbstractArchive implements \Magento\Archive\A /** * Get tarball reader * - * @return \Magento\Archive\Helper\File + * @return File */ protected function _getReader() { @@ -183,8 +185,8 @@ class Tar extends \Magento\Archive\AbstractArchive implements \Magento\Archive\A /** * Set option that define ability skip first catalog level. * - * @param mixed $skipRoot - * @return \Magento\Archive\Tar + * @param bool $skipRoot + * @return $this */ protected function _setSkipRoot($skipRoot) { @@ -196,7 +198,7 @@ class Tar extends \Magento\Archive\AbstractArchive implements \Magento\Archive\A * Set file which is packing. * * @param string $file - * @return \Magento\Archive\Tar + * @return $this */ protected function _setCurrentFile($file) { @@ -209,7 +211,7 @@ class Tar extends \Magento\Archive\AbstractArchive implements \Magento\Archive\A * Set path to file where tarball should be placed * * @param string $destinationFilePath - * @return \Magento\Archive\Tar + * @return $this */ protected function _setDestinationFilePath($destinationFilePath) { @@ -231,7 +233,7 @@ class Tar extends \Magento\Archive\AbstractArchive implements \Magento\Archive\A * Set path to file which is packing. * * @param string $path - * @return \Magento\Archive\Tar + * @return $this */ protected function _setCurrentPath($path) { @@ -261,6 +263,7 @@ class Tar extends \Magento\Archive\AbstractArchive implements \Magento\Archive\A * @deprecated after 1.7.0.0 * @param boolean $skipRoot * @return string + * @throws \Magento\Exception */ protected function _packToTar($skipRoot=false) { @@ -294,6 +297,7 @@ class Tar extends \Magento\Archive\AbstractArchive implements \Magento\Archive\A * * @param boolean $skipRoot * @param boolean $finalize + * @return void * @throws \Magento\Exception */ protected function _createTar($skipRoot = false, $finalize = false) @@ -326,6 +330,8 @@ class Tar extends \Magento\Archive\AbstractArchive implements \Magento\Archive\A /** * Write current file to tarball + * + * @return void */ protected function _packAndWriteCurrentFile() { @@ -337,7 +343,7 @@ class Tar extends \Magento\Archive\AbstractArchive implements \Magento\Archive\A $fileSize = 0; if (is_file($currentFile) && !is_link($currentFile)) { - $fileReader = new \Magento\Archive\Helper\File($currentFile); + $fileReader = new File($currentFile); $fileReader->open('r'); while (!$fileReader->eof()) { @@ -419,7 +425,7 @@ class Tar extends \Magento\Archive\AbstractArchive implements \Magento\Archive\A * in the string. * * @param string $destination path to file is unpacked - * @return array list of files + * @return string[] list of files * @throws \Magento\Exception */ protected function _unpackCurrentTar($destination) @@ -466,7 +472,6 @@ class Tar extends \Magento\Archive\AbstractArchive implements \Magento\Archive\A @symlink($header['symlink'], $currentFile); } } - return $list; } @@ -587,10 +592,11 @@ class Tar extends \Magento\Archive\AbstractArchive implements \Magento\Archive\A * * @param array $fileHeader * @param string $destination + * @return void */ protected function _extractAndWriteFile($fileHeader, $destination) { - $fileWriter = new \Magento\Archive\Helper\File($destination); + $fileWriter = new File($destination); $fileWriter->open('w', $fileHeader['mode']); $archiveReader = $this->_getReader(); diff --git a/lib/Magento/Authorization/Factory.php b/lib/Magento/Authorization/Factory.php index 3451f1514a2bb9f216740694174f21de165c88fb..3e0a1291a15b27d122be79993412141b7ccbf3c1 100644 --- a/lib/Magento/Authorization/Factory.php +++ b/lib/Magento/Authorization/Factory.php @@ -25,6 +25,9 @@ */ namespace Magento\Authorization; +use Magento\Authorization; +use Magento\ObjectManager; + class Factory { /** @@ -35,16 +38,16 @@ class Factory /** * Object Manager instance * - * @var \Magento\ObjectManager + * @var ObjectManager */ protected $_objectManager = null; /** * Factory constructor * - * @param \Magento\ObjectManager $objectManager + * @param ObjectManager $objectManager */ - public function __construct(\Magento\ObjectManager $objectManager) + public function __construct(ObjectManager $objectManager) { $this->_objectManager = $objectManager; } @@ -53,7 +56,7 @@ class Factory * Create class instance with specified parameters * * @param array $data - * @return \Magento\Authorization + * @return Authorization */ public function create(array $data = array()) { diff --git a/lib/Magento/Authorization/Policy.php b/lib/Magento/Authorization/Policy.php index 564d58f3c6b7ddba105d3d038ed6a5d9bb5f2d4e..db74a2d76afe30f102409fac1a2b2001be0f14b2 100644 --- a/lib/Magento/Authorization/Policy.php +++ b/lib/Magento/Authorization/Policy.php @@ -33,7 +33,7 @@ interface Policy * @abstract * @param string $roleId * @param string $resourceId - * @param mixed $privilege + * @param string|null $privilege * @return bool */ public function isAllowed($roleId, $resourceId, $privilege = null); diff --git a/lib/Magento/Authorization/Policy/Acl.php b/lib/Magento/Authorization/Policy/Acl.php index 608ae194c804cc90309dde416f7d4688996e1409..f2bb0001df3a924f302d4e9a222422bbb4aa8234 100644 --- a/lib/Magento/Authorization/Policy/Acl.php +++ b/lib/Magento/Authorization/Policy/Acl.php @@ -26,7 +26,10 @@ */ namespace Magento\Authorization\Policy; -class Acl implements \Magento\Authorization\Policy +use Magento\Acl\Builder; +use Magento\Authorization\Policy; + +class Acl implements Policy { /** * @var \Magento\Acl\Builder @@ -34,9 +37,9 @@ class Acl implements \Magento\Authorization\Policy protected $_aclBuilder; /** - * @param \Magento\Acl\Builder $aclBuilder + * @param Builder $aclBuilder */ - public function __construct(\Magento\Acl\Builder $aclBuilder) + public function __construct(Builder $aclBuilder) { $this->_aclBuilder = $aclBuilder; } @@ -46,7 +49,7 @@ class Acl implements \Magento\Authorization\Policy * * @param string $roleId * @param string $resourceId - * @param mixed $privilege + * @param string $privilege * @return bool */ public function isAllowed($roleId, $resourceId, $privilege = null) diff --git a/lib/Magento/Authorization/Policy/DefaultPolicy.php b/lib/Magento/Authorization/Policy/DefaultPolicy.php index 61d2714403a5b44e7d4dc99a5ce028edd462fbb5..3e92c9b142d656ec1f2e99027f5ac279b7751b00 100644 --- a/lib/Magento/Authorization/Policy/DefaultPolicy.php +++ b/lib/Magento/Authorization/Policy/DefaultPolicy.php @@ -37,8 +37,8 @@ class DefaultPolicy implements \Magento\Authorization\Policy * * @param string $roleId * @param string $resourceId - * @param mixed $privilege - * @return bool + * @param string $privilege + * @return true */ public function isAllowed($roleId, $resourceId, $privilege = null) { diff --git a/lib/Magento/Autoload/ClassMap.php b/lib/Magento/Autoload/ClassMap.php index d49cf30552ca78df6c225a00e7a324040d97956f..ccf484b83da3426735d0db73c0fad3480ca71c59 100644 --- a/lib/Magento/Autoload/ClassMap.php +++ b/lib/Magento/Autoload/ClassMap.php @@ -77,7 +77,7 @@ class ClassMap * Add classes files declaration to the map. New map will override existing values if such was defined before. * * @param array $map - * @return \Magento\Autoload\ClassMap + * @return $this */ public function addMap(array $map) { @@ -89,6 +89,7 @@ class ClassMap * Resolve a class file and include it * * @param string $class + * @return void */ public function load($class) { diff --git a/lib/Magento/Autoload/IncludePath.php b/lib/Magento/Autoload/IncludePath.php index 4af6c01c9beac89d885c64a1f521d6b3d5f2fdd7..3312e9a3c941e6d7f077283c24c6dfb6b55a1cba 100644 --- a/lib/Magento/Autoload/IncludePath.php +++ b/lib/Magento/Autoload/IncludePath.php @@ -64,6 +64,7 @@ class IncludePath * * @param string|array $path * @param bool $prepend Whether to prepend paths or to append them + * @return void */ public static function addIncludePath($path, $prepend = true) { @@ -81,7 +82,8 @@ class IncludePath /** * Resolve a class file and include it * - * @param $class + * @param string $class + * @return void */ public static function load($class) { diff --git a/lib/Magento/Autoload/Simple.php b/lib/Magento/Autoload/Simple.php index a4893e5b6243d6cd22b360aa2f87fb04eca19bc9..b1910aedb7fec4d345e943bfb083e8695bee2e3e 100644 --- a/lib/Magento/Autoload/Simple.php +++ b/lib/Magento/Autoload/Simple.php @@ -28,9 +28,15 @@ namespace Magento\Autoload; class Simple { - private static $_instance; - - public static function instance() + /** + * @var object + */ + private static $_instance; + + /** + * @return object + */ + public static function instance() { if (!self::$_instance) { $class = __CLASS__; @@ -38,13 +44,20 @@ class Simple } return self::$_instance; } - - public static function register() + + /** + * @return void + */ + public static function register() { spl_autoload_register(array(self::instance(), 'autoload')); } - - public function autoload($class) + + /** + * @param string $class + * @return void + */ + public function autoload($class) { $classFile = str_replace(' ', '/', ucwords(str_replace('_', ' ', $class))); $classFile.= '.php'; diff --git a/lib/Magento/Cache/Backend/Database.php b/lib/Magento/Cache/Backend/Database.php index 38a58709b41c1210dff958dec9ea10401a5a0207..e6b4a2cf3ccf990d668c484a5f13434c3046577c 100644 --- a/lib/Magento/Cache/Backend/Database.php +++ b/lib/Magento/Cache/Backend/Database.php @@ -68,6 +68,9 @@ class Database extends \Zend_Cache_Backend implements \Zend_Cache_Backend_Extend 'store_data' => true, ); + /** + * @var \Zend_Db_Adapter_Abstract + */ protected $_adapter = null; /** @@ -195,11 +198,11 @@ class Database extends \Zend_Cache_Backend implements \Zend_Cache_Backend_Extend * Note : $data is always "string" (serialization is done by the * core not by the backend) * - * @param string $data Datas to cache - * @param string $id Cache id - * @param array $tags Array of strings, the cache record will be tagged by each string entry - * @param int $specificLifetime If != false, set a specific lifetime for this cache record (null => infinite lifetime) - * @return boolean true if no problem + * @param string $data Datas to cache + * @param string $id Cache id + * @param string[] $tags Array of strings, the cache record will be tagged by each string entry + * @param int|bool $specificLifetime If != false, set a specific lifetime for this cache record (null => infinite lifetime) + * @return bool true if no problem */ public function save($data, $id, $tags = array(), $specificLifetime = false) { @@ -263,7 +266,7 @@ class Database extends \Zend_Cache_Backend implements \Zend_Cache_Backend_Extend * ($tags can be an array of strings or a single string) * * @param string $mode Clean mode - * @param array $tags Array of tags + * @param string[] $tags Array of tags * @return boolean true if no problem */ public function clean($mode = \Zend_Cache::CLEANING_MODE_ALL, $tags = array()) @@ -304,7 +307,7 @@ class Database extends \Zend_Cache_Backend implements \Zend_Cache_Backend_Extend /** * Return an array of stored cache ids * - * @return array array of stored cache ids (string) + * @return string[] array of stored cache ids (string) */ public function getIds() { @@ -320,7 +323,7 @@ class Database extends \Zend_Cache_Backend implements \Zend_Cache_Backend_Extend /** * Return an array of stored tags * - * @return array array of stored tags (string) + * @return string[] array of stored tags (string) */ public function getTags() { @@ -335,8 +338,8 @@ class Database extends \Zend_Cache_Backend implements \Zend_Cache_Backend_Extend * * In case of multiple tags, a logical AND is made between tags * - * @param array $tags array of tags - * @return array array of matching cache ids (string) + * @param string[] $tags array of tags + * @return string[] array of matching cache ids (string) */ public function getIdsMatchingTags($tags = array()) { @@ -354,8 +357,8 @@ class Database extends \Zend_Cache_Backend implements \Zend_Cache_Backend_Extend * * In case of multiple tags, a logical OR is made between tags * - * @param array $tags array of tags - * @return array array of not matching cache ids (string) + * @param string[] $tags array of tags + * @return string[] array of not matching cache ids (string) */ public function getIdsNotMatchingTags($tags = array()) { @@ -367,8 +370,8 @@ class Database extends \Zend_Cache_Backend implements \Zend_Cache_Backend_Extend * * In case of multiple tags, a logical AND is made between tags * - * @param array $tags array of tags - * @return array array of any matching cache ids (string) + * @param string[] $tags array of tags + * @return string[] array of any matching cache ids (string) */ public function getIdsMatchingAnyTags($tags = array()) { @@ -398,7 +401,7 @@ class Database extends \Zend_Cache_Backend implements \Zend_Cache_Backend_Extend * - mtime : timestamp of last modification time * * @param string $id cache id - * @return array array of metadatas (false if the cache id is not found) + * @return array|false array of metadatas (false if the cache id is not found) */ public function getMetadatas($id) { @@ -472,7 +475,7 @@ class Database extends \Zend_Cache_Backend implements \Zend_Cache_Backend_Extend * Save tags related to specific id * * @param string $id - * @param array $tags + * @param string[] $tags * @return bool */ protected function _saveTags($id, $tags) @@ -513,7 +516,7 @@ class Database extends \Zend_Cache_Backend implements \Zend_Cache_Backend_Extend * Remove cache data by tags with specified mode * * @param string $mode - * @param array $tags + * @param string[] $tags * @return bool */ protected function _cleanByTags($mode, $tags) diff --git a/lib/Magento/Cache/Backend/Decorator/AbstractDecorator.php b/lib/Magento/Cache/Backend/Decorator/AbstractDecorator.php index 1221995f2ee21ffdf835e6e3e5601f20cff0481e..9dfd0dfbc07f53dee142b01c26566f99ee0732ec 100644 --- a/lib/Magento/Cache/Backend/Decorator/AbstractDecorator.php +++ b/lib/Magento/Cache/Backend/Decorator/AbstractDecorator.php @@ -108,12 +108,12 @@ abstract class AbstractDecorator extends \Zend_Cache_Backend * * @param string $data Datas to cache * @param string $cacheId Cache id - * @param array $tags Array of strings, the cache record will be tagged by each string entry - * @param bool $specificLifetime If != false, set a specific lifetime for this cache record + * @param string[] $tags Array of strings, the cache record will be tagged by each string entry + * @param bool $specificLifetime If != false, set a specific lifetime for this cache record * (null => infinite lifetime) - * @param int $priority integer between 0 (very low priority) and 10 (maximum priority) used by + * @param int $priority integer between 0 (very low priority) and 10 (maximum priority) used by * some particular backends - * @return boolean true if no problem + * @return bool true if no problem */ public function save($data, $cacheId, $tags = array(), $specificLifetime = false, $priority = 8) { @@ -123,8 +123,8 @@ abstract class AbstractDecorator extends \Zend_Cache_Backend /** * Remove a cache record * - * @param string $cacheId Cache id - * @return boolean True if no problem + * @param string $cacheId Cache id + * @return bool true if no problem */ public function remove($cacheId) { @@ -145,8 +145,8 @@ abstract class AbstractDecorator extends \Zend_Cache_Backend * ($tags can be an array of strings or a single string) * * @param string $mode Clean mode - * @param array $tags Array of tags - * @return boolean true if no problem + * @param string[] $tags Array of tags + * @return bool true if no problem */ public function clean($mode = \Zend_Cache::CLEANING_MODE_ALL, $tags = array()) { @@ -156,7 +156,7 @@ abstract class AbstractDecorator extends \Zend_Cache_Backend /** * Return an array of stored cache ids * - * @return array array of stored cache ids (string) + * @return string[] array of stored cache ids (string) */ public function getIds() { @@ -166,7 +166,7 @@ abstract class AbstractDecorator extends \Zend_Cache_Backend /** * Return an array of stored tags * - * @return array array of stored tags (string) + * @return string[] array of stored tags (string) */ public function getTags() { @@ -178,8 +178,8 @@ abstract class AbstractDecorator extends \Zend_Cache_Backend * * In case of multiple tags, a logical AND is made between tags * - * @param array $tags array of tags - * @return array array of matching cache ids (string) + * @param string[] $tags array of tags + * @return string[] array of matching cache ids (string) */ public function getIdsMatchingTags($tags = array()) { @@ -191,8 +191,8 @@ abstract class AbstractDecorator extends \Zend_Cache_Backend * * In case of multiple tags, a logical OR is made between tags * - * @param array $tags array of tags - * @return array array of not matching cache ids (string) + * @param string[] $tags array of tags + * @return string[] array of not matching cache ids (string) */ public function getIdsNotMatchingTags($tags = array()) { @@ -204,8 +204,8 @@ abstract class AbstractDecorator extends \Zend_Cache_Backend * * In case of multiple tags, a logical AND is made between tags * - * @param array $tags array of tags - * @return array array of any matching cache ids (string) + * @param string[] $tags array of tags + * @return string[] array of any matching cache ids (string) */ public function getIdsMatchingAnyTags($tags = array()) { @@ -231,7 +231,7 @@ abstract class AbstractDecorator extends \Zend_Cache_Backend * - mtime : timestamp of last modification time * * @param string $cacheId cache id - * @return array array of metadatas (false if the cache id is not found) + * @return array|bool array of metadatas (false if the cache id is not found) */ public function getMetadatas($cacheId) { diff --git a/lib/Magento/Cache/Backend/Decorator/Compression.php b/lib/Magento/Cache/Backend/Decorator/Compression.php index 4af86344cb3a716bde8d6df9bf9c047fbe4dedbd..31583ae666a2524d9ca62423fd077e70027623e4 100644 --- a/lib/Magento/Cache/Backend/Decorator/Compression.php +++ b/lib/Magento/Cache/Backend/Decorator/Compression.php @@ -70,14 +70,14 @@ class Compression extends \Magento\Cache\Backend\Decorator\AbstractDecorator * Note : $data is always "string" (serialization is done by the * core not by the backend) * - * @param string $data Datas to cache - * @param string $cacheId Cache id - * @param array $tags Array of strings, the cache record will be tagged by each string entry - * @param bool $specificLifetime If != false, set a specific lifetime for this cache record + * @param string $data Datas to cache + * @param string $cacheId Cache id + * @param string[] $tags Array of strings, the cache record will be tagged by each string entry + * @param bool $specificLifetime If != false, set a specific lifetime for this cache record * (null => infinite lifetime) - * @param int $priority integer between 0 (very low priority) and 10 (maximum priority) used by + * @param int $priority integer between 0 (very low priority) and 10 (maximum priority) used by * some particular backends - * @return boolean true if no problem + * @return bool true if no problem */ public function save($data, $cacheId, $tags = array(), $specificLifetime = false, $priority = 8) { diff --git a/lib/Magento/Cache/Backend/Eaccelerator.php b/lib/Magento/Cache/Backend/Eaccelerator.php index bedc0350e728ec92f3b53fa21c68108dec081708..1760e8e47370c52ced5e7acb15520d02bab6c49e 100644 --- a/lib/Magento/Cache/Backend/Eaccelerator.php +++ b/lib/Magento/Cache/Backend/Eaccelerator.php @@ -39,7 +39,6 @@ class Eaccelerator extends \Zend_Cache_Backend implements \Zend_Cache_Backend_Ex * * @param array $options associative array of options * @throws \Zend_Cache_Exception - * @return void */ public function __construct(array $options = array()) { @@ -90,9 +89,9 @@ class Eaccelerator extends \Zend_Cache_Backend implements \Zend_Cache_Backend_Ex * * @param string $data datas to cache * @param string $id cache id - * @param array $tags array of strings, the cache record will be tagged by each string entry + * @param string[] $tags array of strings, the cache record will be tagged by each string entry * @param int $specificLifetime if != false, set a specific lifetime for this cache record (null => infinite lifetime) - * @return boolean true if no problem + * @return bool true if no problem */ public function save($data, $id, $tags = array(), $specificLifetime = false) { @@ -108,7 +107,7 @@ class Eaccelerator extends \Zend_Cache_Backend implements \Zend_Cache_Backend_Ex * Remove a cache record * * @param string $id cache id - * @return boolean true if no problem + * @return bool true if no problem */ public function remove($id) { @@ -125,10 +124,10 @@ class Eaccelerator extends \Zend_Cache_Backend implements \Zend_Cache_Backend_Ex * 'notMatchingTag' => unsupported * 'matchingAnyTag' => unsupported * - * @param string $mode clean mode - * @param array $tags array of tags + * @param string $mode clean mode + * @param string[] $tags array of tags * @throws \Zend_Cache_Exception - * @return boolean true if no problem + * @return bool true if no problem */ public function clean($mode = \Zend_Cache::CLEANING_MODE_ALL, $tags = array()) { @@ -174,7 +173,7 @@ class Eaccelerator extends \Zend_Cache_Backend implements \Zend_Cache_Backend_Ex /** * Return an array of stored tags * - * @return array array of stored tags (string) + * @return string[] array of stored tags (string) */ public function getTags() { @@ -188,7 +187,7 @@ class Eaccelerator extends \Zend_Cache_Backend implements \Zend_Cache_Backend_Ex * In case of multiple tags, a logical AND is made between tags * * @param array $tags array of tags - * @return array array of matching cache ids (string) + * @return string[] array of matching cache ids (string) */ public function getIdsMatchingTags($tags = array()) { @@ -201,8 +200,8 @@ class Eaccelerator extends \Zend_Cache_Backend implements \Zend_Cache_Backend_Ex * * In case of multiple tags, a logical OR is made between tags * - * @param array $tags array of tags - * @return array array of not matching cache ids (string) + * @param string[] $tags array of tags + * @return string[] array of not matching cache ids (string) */ public function getIdsNotMatchingTags($tags = array()) { @@ -215,8 +214,8 @@ class Eaccelerator extends \Zend_Cache_Backend implements \Zend_Cache_Backend_Ex * * In case of multiple tags, a logical AND is made between tags * - * @param array $tags array of tags - * @return array array of any matching cache ids (string) + * @param string[] $tags array of tags + * @return string[] array of any matching cache ids (string) */ public function getIdsMatchingAnyTags($tags = array()) { @@ -227,7 +226,7 @@ class Eaccelerator extends \Zend_Cache_Backend implements \Zend_Cache_Backend_Ex /** * Return an array of stored cache ids * - * @return array array of stored cache ids (string) + * @return string[] array of stored cache ids (string) */ public function getIds() { @@ -248,7 +247,7 @@ class Eaccelerator extends \Zend_Cache_Backend implements \Zend_Cache_Backend_Ex * - mtime : timestamp of last modification time * * @param string $id cache id - * @return array array of metadatas (false if the cache id is not found) + * @return array|false array of metadatas (false if the cache id is not found) */ public function getMetadatas($id) { @@ -276,7 +275,7 @@ class Eaccelerator extends \Zend_Cache_Backend implements \Zend_Cache_Backend_Ex * * @param string $id cache id * @param int $extraLifetime - * @return boolean true if ok + * @return bool true if ok */ public function touch($id, $extraLifetime) { diff --git a/lib/Magento/Cache/Backend/Memcached.php b/lib/Magento/Cache/Backend/Memcached.php index 67172cd578f51364836054606e7893dc69a8f717..8d5c03fc3da8580318fa78453f03afb8fe8a4955 100644 --- a/lib/Magento/Cache/Backend/Memcached.php +++ b/lib/Magento/Cache/Backend/Memcached.php @@ -43,8 +43,8 @@ class Memcached /** * Constructor * - * @throws \Magento\Exception * @param array $options @see \Zend_Cache_Backend_Memcached::__construct() + * @throws \Magento\Exception */ public function __construct(array $options = array()) { @@ -94,8 +94,8 @@ class Memcached * * @param string $data @see \Zend_Cache_Backend_Memcached::save() * @param string $id @see \Zend_Cache_Backend_Memcached::save() - * @param array $tags @see \Zend_Cache_Backend_Memcached::save() - * @param bool $specificLifetime @see \Zend_Cache_Backend_Memcached::save() + * @param string[] $tags @see \Zend_Cache_Backend_Memcached::save() + * @param bool $specificLifetime @see \Zend_Cache_Backend_Memcached::save() * @return bool */ public function save($data, $id, $tags = array(), $specificLifetime = false) diff --git a/lib/Magento/Cache/Backend/MongoDb.php b/lib/Magento/Cache/Backend/MongoDb.php index e253a99ade9f332422ce0c646f5c0f349b2ed29c..82236a028ba727e5eacc00c41f811b1ee54701bf 100644 --- a/lib/Magento/Cache/Backend/MongoDb.php +++ b/lib/Magento/Cache/Backend/MongoDb.php @@ -97,7 +97,7 @@ class MongoDb extends \Zend_Cache_Backend implements \Zend_Cache_Backend_Extende /** * Return an array of stored cache ids * - * @return array array of stored cache ids (string) + * @return string[] array of stored cache ids (string) */ public function getIds() { @@ -107,7 +107,7 @@ class MongoDb extends \Zend_Cache_Backend implements \Zend_Cache_Backend_Extende /** * Return an array of stored tags * - * @return array array of stored tags (string) + * @return string[] array of stored tags (string) */ public function getTags() { @@ -120,8 +120,8 @@ class MongoDb extends \Zend_Cache_Backend implements \Zend_Cache_Backend_Extende * * In case of multiple tags, a logical AND is made between tags * - * @param array $tags array of tags - * @return array array of matching cache ids (string) + * @param string[] $tags array of tags + * @return string[] array of matching cache ids (string) */ public function getIdsMatchingTags($tags = array()) { @@ -138,8 +138,8 @@ class MongoDb extends \Zend_Cache_Backend implements \Zend_Cache_Backend_Extende * * In case of multiple tags, a logical OR is made between tags * - * @param array $tags array of tags - * @return array array of not matching cache ids (string) + * @param string[] $tags array of tags + * @return string[] array of not matching cache ids (string) */ public function getIdsNotMatchingTags($tags = array()) { @@ -156,8 +156,8 @@ class MongoDb extends \Zend_Cache_Backend implements \Zend_Cache_Backend_Extende * * In case of multiple tags, a logical AND is made between tags * - * @param array $tags array of tags - * @return array array of any matching cache ids (string) + * @param string[] $tags array of tags + * @return string[] array of any matching cache ids (string) */ public function getIdsMatchingAnyTags($tags = array()) { @@ -172,7 +172,7 @@ class MongoDb extends \Zend_Cache_Backend implements \Zend_Cache_Backend_Extende /** * Get query to filter by specified tags and comparison mode * - * @param array $tags + * @param string[] $tags * @param string $comparisonMode * @return array */ @@ -214,7 +214,7 @@ class MongoDb extends \Zend_Cache_Backend implements \Zend_Cache_Backend_Extende * - mtime : timestamp of last modification time * * @param string $cacheId cache id - * @return array array of metadatas (false if the cache id is not found) + * @return array|false array of metadatas (false if the cache id is not found) */ public function getMetadatas($cacheId) { @@ -326,7 +326,7 @@ class MongoDb extends \Zend_Cache_Backend implements \Zend_Cache_Backend_Extende * * @param string $data Datas to cache * @param string $cacheId Cache id - * @param array $tags Array of strings, the cache record will be tagged by each string entry + * @param string[] $tags Array of strings, the cache record will be tagged by each string entry * @param int|bool $specificLifetime If != false, set a specific lifetime (null => infinite lifetime) * @return boolean true if no problem */ @@ -371,8 +371,8 @@ class MongoDb extends \Zend_Cache_Backend implements \Zend_Cache_Backend_Extende * ($tags can be an array of strings or a single string) * * @param string $mode Clean mode - * @param array $tags Array of tags - * @return boolean true if no problem + * @param string[] $tags Array of tags + * @return bool true if no problem */ public function clean($mode = \Zend_Cache::CLEANING_MODE_ALL, $tags = array()) { @@ -402,7 +402,7 @@ class MongoDb extends \Zend_Cache_Backend implements \Zend_Cache_Backend_Extende /** * Quote specified value to be used in query as string * - * @param $value + * @param string $value * @return string */ protected function _quoteString($value) diff --git a/lib/Magento/Cache/Config.php b/lib/Magento/Cache/Config.php index 69b47a901873b3bf85d0e9ef4cb4be53775261f7..783b86e8f5daf003f0117d1460f1020b7d0a8186 100644 --- a/lib/Magento/Cache/Config.php +++ b/lib/Magento/Cache/Config.php @@ -42,6 +42,8 @@ class Config implements ConfigInterface /** * {inheritdoc} + * + * @return array */ public function getTypes() { @@ -50,6 +52,9 @@ class Config implements ConfigInterface /** * {inheritdoc} + * + * @param string $type + * @return array */ public function getType($type) { diff --git a/lib/Magento/Cache/Config/Data.php b/lib/Magento/Cache/Config/Data.php index b646a37e55d39c46827f0f2ef5972403c3a0efe1..638739b20bb0b139de75d34583640f9921ce751d 100644 --- a/lib/Magento/Cache/Config/Data.php +++ b/lib/Magento/Cache/Config/Data.php @@ -30,7 +30,7 @@ class Data extends \Magento\Config\Data\Scoped /** * Scope priority loading scheme * - * @var array + * @var string[] */ protected $_scopePriorityScheme = array('global'); diff --git a/lib/Magento/Cache/Core.php b/lib/Magento/Cache/Core.php index 2a66c623c0d19e69a6eb27359688e29b97aff2a2..2800a7f1d187ab0d46304e278dec85eda65d4e6b 100644 --- a/lib/Magento/Cache/Core.php +++ b/lib/Magento/Cache/Core.php @@ -64,8 +64,8 @@ class Core extends \Zend_Cache_Core /** * Prepare tags * - * @param array $tags - * @return array + * @param string[] $tags + * @return string[] */ protected function _tags($tags) { @@ -81,12 +81,12 @@ class Core extends \Zend_Cache_Core * @param mixed $data Data to put in cache (can be another type than string if * automatic_serialization is on) * @param null|string $cacheId Cache id (if not set, the last cache id will be used) - * @param array $tags Cache tags + * @param string[] $tags Cache tags * @param bool|int $specificLifetime If != false, set a specific lifetime for this cache record * (null => infinite lifetime) * @param int $priority integer between 0 (very low priority) and 10 (maximum priority) used by * some particular backends - * @return boolean True if no problem + * @return bool True if no problem */ public function save($data, $cacheId = null, $tags = array(), $specificLifetime = false, $priority = 8) { @@ -110,10 +110,10 @@ class Core extends \Zend_Cache_Core * 'matchingAnyTag' => remove cache entries matching any given tags * ($tags can be an array of strings or a single string) * - * @param string $mode - * @param array|string $tags + * @param string $mode + * @param string[] $tags * @throws \Zend_Cache_Exception - * @return boolean True if ok + * @return bool True if ok */ public function clean($mode = 'all', $tags = array()) { @@ -126,8 +126,8 @@ class Core extends \Zend_Cache_Core * * In case of multiple tags, a logical AND is made between tags * - * @param array $tags array of tags - * @return array array of matching cache ids (string) + * @param string[] $tags array of tags + * @return string[] array of matching cache ids (string) */ public function getIdsMatchingTags($tags = array()) { @@ -140,8 +140,8 @@ class Core extends \Zend_Cache_Core * * In case of multiple tags, a logical OR is made between tags * - * @param array $tags array of tags - * @return array array of not matching cache ids (string) + * @param string[] $tags array of tags + * @return string[] array of not matching cache ids (string) */ public function getIdsNotMatchingTags($tags = array()) { @@ -164,7 +164,7 @@ class Core extends \Zend_Cache_Core /** * Decorate cache backend with additional functionality * - * @param \Zend_Cache_Backend + * @param \Zend_Cache_Backend $backendObject * @return \Zend_Cache_Backend */ protected function _decorateBackend(\Zend_Cache_Backend $backendObject) diff --git a/lib/Magento/Cache/Frontend/Decorator/Profiler.php b/lib/Magento/Cache/Frontend/Decorator/Profiler.php index 43c9536381dd5a5afc71a6220af92c721703f843..898ca3baa6df7d97349ffbb4bdd14424a767a024 100644 --- a/lib/Magento/Cache/Frontend/Decorator/Profiler.php +++ b/lib/Magento/Cache/Frontend/Decorator/Profiler.php @@ -34,13 +34,13 @@ class Profiler extends \Magento\Cache\Frontend\Decorator\Bare /** * Backend class prefixes to be striped from profiler tags * - * @var array + * @var string[] */ private $_backendPrefixes = array(); /** * @param \Magento\Cache\FrontendInterface $frontend - * @param array $backendPrefixes Backend class prefixes to be striped for profiling informativeness + * @param string[] $backendPrefixes Backend class prefixes to be striped for profiling informativeness */ public function __construct(\Magento\Cache\FrontendInterface $frontend, $backendPrefixes = array()) { diff --git a/lib/Magento/Code/Generator.php b/lib/Magento/Code/Generator.php index 232b3f2cf46d50706a3158b42b4466cfa045337a..bac451c7f1d0651315eb91ee4331e2861a90e6dc 100644 --- a/lib/Magento/Code/Generator.php +++ b/lib/Magento/Code/Generator.php @@ -48,7 +48,7 @@ class Generator protected $_ioObject; /** - * @var array + * @var string[] */ protected $_generatedEntities = array( \Magento\Code\Generator\Factory::ENTITY_TYPE, @@ -76,7 +76,9 @@ class Generator } /** - * @return array + * Get generated entities + * + * @return string[] */ public function getGeneratedEntities() { diff --git a/lib/Magento/Code/Generator/Autoloader.php b/lib/Magento/Code/Generator/Autoloader.php index 498cd1ee088051f8cbd03b4738a5f5f928dffba4..25a7e062764730876e5efd5a8061212ec4163d77 100644 --- a/lib/Magento/Code/Generator/Autoloader.php +++ b/lib/Magento/Code/Generator/Autoloader.php @@ -43,6 +43,7 @@ class Autoloader * Load specified class name and generate it if necessary * * @param string $className + * @return void */ public function load($className) { diff --git a/lib/Magento/Code/Generator/CodeGenerator/Zend.php b/lib/Magento/Code/Generator/CodeGenerator/Zend.php index ff5fd4e46cd63ad0b6cb5d95ba4c347c09be7233..e426eb500063363a7f91a3ca2409f7cb8e895420 100644 --- a/lib/Magento/Code/Generator/CodeGenerator/Zend.php +++ b/lib/Magento/Code/Generator/CodeGenerator/Zend.php @@ -26,6 +26,9 @@ namespace Magento\Code\Generator\CodeGenerator; +use \Zend\Code\Generator\MethodGenerator; +use \Zend\Code\Generator\PropertyGenerator; + class Zend extends \Zend\Code\Generator\ClassGenerator implements \Magento\Code\Generator\CodeGenerator\CodeGeneratorInterface { @@ -98,7 +101,7 @@ class Zend extends \Zend\Code\Generator\ClassGenerator * Set class dock block * * @param array $docBlock - * @return \Magento\Code\Generator\CodeGenerator\Zend + * @return $this */ public function setClassDocBlock(array $docBlock) { @@ -112,12 +115,12 @@ class Zend extends \Zend\Code\Generator\ClassGenerator * addMethods() * * @param array $methods - * @return \Magento\Code\Generator\CodeGenerator\Zend + * @return $this */ public function addMethods(array $methods) { foreach ($methods as $methodOptions) { - $methodObject = new \Zend\Code\Generator\MethodGenerator(); + $methodObject = new MethodGenerator(); $this->_setDataToObject($methodObject, $methodOptions, $this->_methodOptions); if (isset($methodOptions['parameters']) && is_array($methodOptions['parameters']) @@ -148,11 +151,11 @@ class Zend extends \Zend\Code\Generator\ClassGenerator /** * Add method from MethodGenerator * - * @param \Zend\Code\Generator\MethodGenerator $method - * @return \Magento\Code\Generator\CodeGenerator\Zend + * @param MethodGenerator $method + * @return $this * @throws \InvalidArgumentException */ - public function addMethodFromGenerator(\Zend\Code\Generator\MethodGenerator $method) + public function addMethodFromGenerator(MethodGenerator $method) { if (!is_string($method->getName())) { throw new \InvalidArgumentException( @@ -167,13 +170,13 @@ class Zend extends \Zend\Code\Generator\ClassGenerator * addProperties() * * @param array $properties - * @return \Magento\Code\Generator\CodeGenerator\Zend + * @return $this * @throws \InvalidArgumentException */ public function addProperties(array $properties) { foreach ($properties as $propertyOptions) { - $propertyObject = new \Zend\Code\Generator\PropertyGenerator(); + $propertyObject = new PropertyGenerator(); $this->_setDataToObject($propertyObject, $propertyOptions, $this->_propertyOptions); if (isset($propertyOptions['docblock'])) { @@ -194,11 +197,11 @@ class Zend extends \Zend\Code\Generator\ClassGenerator /** * Add property from PropertyGenerator * - * @param \Zend\Code\Generator\PropertyGenerator $property + * @param PropertyGenerator $property + * @return $this * @throws \InvalidArgumentException - * @return \Magento\Code\Generator\CodeGenerator\Zend */ - public function addPropertyFromGenerator(\Zend\Code\Generator\PropertyGenerator $property) + public function addPropertyFromGenerator(PropertyGenerator $property) { if (!is_string($property->getName())) { throw new \InvalidArgumentException( diff --git a/lib/Magento/Code/Generator/EntityAbstract.php b/lib/Magento/Code/Generator/EntityAbstract.php index 21f7259e6ca8b703a9a46291b959cd26a16beebc..b1067eeb27c1a653bfbb945506bef618529d5e59 100644 --- a/lib/Magento/Code/Generator/EntityAbstract.php +++ b/lib/Magento/Code/Generator/EntityAbstract.php @@ -26,6 +26,8 @@ namespace Magento\Code\Generator; +use \Magento\Autoload\IncludePath; + abstract class EntityAbstract { /** @@ -34,7 +36,7 @@ abstract class EntityAbstract const ENTITY_TYPE = 'abstract'; /** - * @var array + * @var string[] */ private $_errors = array(); @@ -53,47 +55,47 @@ abstract class EntityAbstract private $_resultClassName; /** - * @var \Magento\Code\Generator\Io + * @var Io */ private $_ioObject; /** * Autoloader instance * - * @var \Magento\Autoload\IncludePath + * @var IncludePath */ private $_autoloader; /** * Class generator object * - * @var \Magento\Code\Generator\CodeGenerator\CodeGeneratorInterface + * @var CodeGenerator\CodeGeneratorInterface */ protected $_classGenerator; /** - * @param null $sourceClassName - * @param null $resultClassName + * @param null|string $sourceClassName + * @param null|string $resultClassName * @param Io $ioObject * @param CodeGenerator\CodeGeneratorInterface $classGenerator - * @param \Magento\Autoload\IncludePath $autoLoader + * @param IncludePath $autoLoader */ public function __construct( $sourceClassName = null, $resultClassName = null, - \Magento\Code\Generator\Io $ioObject = null, - \Magento\Code\Generator\CodeGenerator\CodeGeneratorInterface $classGenerator = null, - \Magento\Autoload\IncludePath $autoLoader = null + Io $ioObject = null, + CodeGenerator\CodeGeneratorInterface $classGenerator = null, + IncludePath $autoLoader = null ) { if ($autoLoader) { $this->_autoloader = $autoLoader; } else { - $this->_autoloader = new \Magento\Autoload\IncludePath(); + $this->_autoloader = new IncludePath(); } if ($ioObject) { $this->_ioObject = $ioObject; } else { - $this->_ioObject = new \Magento\Code\Generator\Io( + $this->_ioObject = new Io( new \Magento\Filesystem\Driver\File(), $this->_autoloader ); @@ -101,10 +103,10 @@ abstract class EntityAbstract if ($classGenerator) { $this->_classGenerator = $classGenerator; } else { - $this->_classGenerator = new \Magento\Code\Generator\CodeGenerator\Zend(); + $this->_classGenerator = new CodeGenerator\Zend(); } - $this->_sourceClassName = ltrim($sourceClassName, \Magento\Autoload\IncludePath::NS_SEPARATOR); + $this->_sourceClassName = ltrim($sourceClassName, IncludePath::NS_SEPARATOR); if ($resultClassName) { $this->_resultClassName = $resultClassName; } elseif ($sourceClassName) { @@ -139,7 +141,7 @@ abstract class EntityAbstract /** * List of occurred generation errors * - * @return array + * @return string[] */ public function getErrors() { @@ -147,6 +149,8 @@ abstract class EntityAbstract } /** + * Get source class name + * * @return string */ protected function _getSourceClassName() @@ -155,16 +159,20 @@ abstract class EntityAbstract } /** + * Get fully qualified class name + * * @param string $className * @return string */ protected function _getFullyQualifiedClassName($className) { - return \Magento\Autoload\IncludePath::NS_SEPARATOR - . ltrim($className, \Magento\Autoload\IncludePath::NS_SEPARATOR); + return IncludePath::NS_SEPARATOR + . ltrim($className, IncludePath::NS_SEPARATOR); } /** + * Get result class name + * * @return string */ protected function _getResultClassName() @@ -173,6 +181,8 @@ abstract class EntityAbstract } /** + * Get default result class name + * * @param string $modelClassName * @return string */ @@ -213,11 +223,13 @@ abstract class EntityAbstract /** * Returns list of methods for class generator * - * @return mixed + * @return array */ abstract protected function _getClassMethods(); /** + * Generate code + * * @return string */ protected function _generateCode() @@ -232,8 +244,10 @@ abstract class EntityAbstract } /** + * Add error message + * * @param string $message - * @return \Magento\Code\Generator\EntityAbstract + * @return $this */ protected function _addError($message) { @@ -307,7 +321,7 @@ abstract class EntityAbstract /** * @param string $sourceCode - * @return mixed + * @return string */ protected function _fixCodeStyle($sourceCode) { @@ -379,6 +393,7 @@ abstract class EntityAbstract * * @param string $sourceClassName * @param string $resultClassName + * @return void */ public function init($sourceClassName, $resultClassName) { diff --git a/lib/Magento/Code/Generator/Interceptor.php b/lib/Magento/Code/Generator/Interceptor.php index 6810de5d5f4a4214da7a62a77165359891c16fb9..c78ff822a347d9d5aeff19a0a205cb6b0ada4434 100644 --- a/lib/Magento/Code/Generator/Interceptor.php +++ b/lib/Magento/Code/Generator/Interceptor.php @@ -164,7 +164,7 @@ class Interceptor extends \Magento\Code\Generator\EntityAbstract /** * Returns list of methods for class generator * - * @return mixed + * @return array */ protected function _getClassMethods() { diff --git a/lib/Magento/Code/Generator/Io.php b/lib/Magento/Code/Generator/Io.php index c91582e787f5f385a05c287a493cb9291faadecf..9b6fb187d26b575aeac851f8a783b12b4cad96fe 100644 --- a/lib/Magento/Code/Generator/Io.php +++ b/lib/Magento/Code/Generator/Io.php @@ -75,7 +75,7 @@ class Io /** * Get path to generation directory * - * @param $directory + * @param null|string $directory * @return string */ protected function initGeneratorDirectory($directory = null) diff --git a/lib/Magento/Code/Minifier/Strategy/Generate.php b/lib/Magento/Code/Minifier/Strategy/Generate.php index 1529cdc461ad95e2a421d6217a6401d695876aa1..2a1e775e6730894ae0730892dd9041dae12bf43e 100644 --- a/lib/Magento/Code/Minifier/Strategy/Generate.php +++ b/lib/Magento/Code/Minifier/Strategy/Generate.php @@ -65,6 +65,7 @@ class Generate implements \Magento\Code\Minifier\StrategyInterface * * @param string $originalFile path to original file relative to pub/view_cache * @param string $targetFile path relative to pub/view_cache + * @return void */ public function minifyFile($originalFile, $targetFile) { diff --git a/lib/Magento/Code/Minifier/Strategy/Lite.php b/lib/Magento/Code/Minifier/Strategy/Lite.php index 6cbc0064ab9f075eca3aa3cf0377dbaca8d246ad..6b959700a2b2fe70178702ca0ebd2fffae7e770f 100644 --- a/lib/Magento/Code/Minifier/Strategy/Lite.php +++ b/lib/Magento/Code/Minifier/Strategy/Lite.php @@ -68,6 +68,7 @@ class Lite implements \Magento\Code\Minifier\StrategyInterface * * @param string $originalFile path to original file relative to pub/view_cache * @param string $targetFile path relative to pub/view_cache + * @return void */ public function minifyFile($originalFile, $targetFile) { diff --git a/lib/Magento/Code/Reader/ClassReader.php b/lib/Magento/Code/Reader/ClassReader.php index f53ea5fe538a20353d83ff65e88a132cbae7ebf7..dd868f97ad65c80840cf04d5cde7849ac884708f 100644 --- a/lib/Magento/Code/Reader/ClassReader.php +++ b/lib/Magento/Code/Reader/ClassReader.php @@ -70,7 +70,7 @@ class ClassReader * ) * * @param string $className - * @return array + * @return string[] */ public function getParents($className) { diff --git a/lib/Magento/Code/Validator.php b/lib/Magento/Code/Validator.php index 2e0c73a1064b67a11add6bd2cbdfb96fa923bd29..dcfb16296f743589edf05dd20287a43116829722 100644 --- a/lib/Magento/Code/Validator.php +++ b/lib/Magento/Code/Validator.php @@ -35,6 +35,7 @@ class Validator implements ValidatorInterface * Add validator * * @param ValidatorInterface $validator + * @return void */ public function add(ValidatorInterface $validator) { diff --git a/lib/Magento/Config/Data.php b/lib/Magento/Config/Data.php index 300e41f7bd9b811c6cd94f0be26bf059c87a5dbb..3d5fad64a48cafd97a17e4de17c9c98fbb8025f2 100644 --- a/lib/Magento/Config/Data.php +++ b/lib/Magento/Config/Data.php @@ -90,7 +90,7 @@ class Data implements \Magento\Config\DataInterface * Get config value by key * * @param string $path - * @param null $default + * @param mixed $default * @return mixed */ public function get($path = null, $default = null) diff --git a/lib/Magento/Config/Dom.php b/lib/Magento/Config/Dom.php index 6cd579b3984dd819d1613d76386cdb29d1de2548..94edf8bfb2b4011d263ab423ee4ad446f71317aa 100644 --- a/lib/Magento/Config/Dom.php +++ b/lib/Magento/Config/Dom.php @@ -87,7 +87,6 @@ class Dom * @param array $idAttributes * @param string $schemaFile * @param string $errorFormat - * @throws \Magento\Config\Dom\ValidationException */ public function __construct( $xml, array $idAttributes = array(), $schemaFile = null, $errorFormat = self::ERROR_FORMAT_DEFAULT @@ -104,7 +103,6 @@ class Dom * * @param string $xml * @return void - * @throws \Magento\Config\Dom\ValidationException */ public function merge($xml) { @@ -209,7 +207,12 @@ class Dom { $path = preg_replace('/\[@[^\]]+?\]/', '', $xPath); $path = preg_replace('/\/[^:]+?\:/', '/', $path); - return isset($this->_idAttributes[$path]) ? $this->_idAttributes[$path] : false; + foreach ($this->_idAttributes as $pathPattern => $id) { + if (preg_match("#^$pathPattern$#", $path)) { + return $id; + } + } + return false; } /** diff --git a/lib/Magento/Config/Dom/Converter/ArrayConverter.php b/lib/Magento/Config/Dom/Converter/ArrayConverter.php deleted file mode 100644 index e3c6ea49bc80dab0f377f0c889da394f0d68aa32..0000000000000000000000000000000000000000 --- a/lib/Magento/Config/Dom/Converter/ArrayConverter.php +++ /dev/null @@ -1,67 +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\Config\Dom\Converter; - -class ArrayConverter -{ - const ATTRIBUTES = '__attributes__'; - const CONTENT = '__content__'; - - /** - * Convert dom node tree to array - * - * @param \DOMNodeList $input - * @return array - */ - public function convert(\DOMNodeList $input) - { - $array = array(); - - /** @var $item \DOMNode */ - foreach ($input as $item) { - if ($item->nodeType == XML_ELEMENT_NODE) { - $arrayElement = array(); - /** @var $attribute \DOMNode */ - foreach ($item->attributes as $attribute) { - if ($attribute->nodeType == XML_ATTRIBUTE_NODE) { - $arrayElement[self::ATTRIBUTES][$attribute->nodeName] = $attribute->nodeValue; - } - } - $children = $this->convert($item->childNodes); - - if (is_array($children)) { - $arrayElement = array_merge($arrayElement, $children); - } else { - $arrayElement[self::CONTENT] = $children; - } - $array[$item->nodeName][] = $arrayElement; - } elseif ($item->nodeType == XML_CDATA_SECTION_NODE - || ($item->nodeType == XML_TEXT_NODE && trim($item->nodeValue) != '') - ) { - return $item->nodeValue; - } - } - return $array; - } -} diff --git a/lib/Magento/Config/FileIterator.php b/lib/Magento/Config/FileIterator.php index eafd7478d05ccf3bfac3c2b94edb52f8dcb76080..3a9f24152580a8c3600f3f6cefb8f5e4b7b4a500 100644 --- a/lib/Magento/Config/FileIterator.php +++ b/lib/Magento/Config/FileIterator.php @@ -112,7 +112,7 @@ class FileIterator implements \Iterator, \Countable public function toArray() { $result = []; - foreach($this as $item) { + foreach ($this as $item) { $result[$this->key()] = $item; } return $result; diff --git a/lib/Magento/Config/FileIteratorFactory.php b/lib/Magento/Config/FileIteratorFactory.php index 9d94ea4b384c199fe36267f01e42de5b7d3c5d0f..74b1e44e7b44d0123aa0ce4a25cfa96cfae46f81 100644 --- a/lib/Magento/Config/FileIteratorFactory.php +++ b/lib/Magento/Config/FileIteratorFactory.php @@ -26,6 +26,13 @@ namespace Magento\Config; class FileIteratorFactory { + /** + * Create file iterator + * + * @param \Magento\Filesystem\Directory\ReadInterface $readDirectory + * @param array $paths + * @return FileIterator + */ public function create(\Magento\Filesystem\Directory\ReadInterface $readDirectory, $paths) { return new \Magento\Config\FileIterator($readDirectory, $paths); diff --git a/lib/Magento/Config/Reader/Filesystem.php b/lib/Magento/Config/Reader/Filesystem.php index e71430462aa78b6a8c0ff27f3a26407f933c9108..bcf3da125e83a3d444b5018783c3ad4baf3a0842 100644 --- a/lib/Magento/Config/Reader/Filesystem.php +++ b/lib/Magento/Config/Reader/Filesystem.php @@ -142,6 +142,8 @@ class Filesystem implements \Magento\Config\ReaderInterface } /** + * Read configuration files + * * @param array $fileList * @return array * @throws \Magento\Exception @@ -154,11 +156,7 @@ class Filesystem implements \Magento\Config\ReaderInterface try { if (is_null($domDocument)) { $class = $this->_domDocumentClass; - $domDocument = new $class( - $content, - $this->_idAttributes, - $this->_perFileSchema - ); + $domDocument = new $class($content, $this->_idAttributes, $this->_perFileSchema); } else { $domDocument->merge($content); } diff --git a/lib/Magento/Config/Theme.php b/lib/Magento/Config/Theme.php index 96082df8503001361a7a0f47b9d5191759d373d7..9b8db0a67ccd9280476ac54a84f37d07e8fd8ee1 100644 --- a/lib/Magento/Config/Theme.php +++ b/lib/Magento/Config/Theme.php @@ -30,13 +30,31 @@ */ namespace Magento\Config; -class Theme extends \Magento\Config\AbstractXml +class Theme { /** * Is used for separation path of themes */ const THEME_PATH_SEPARATOR = '/'; + /** + * Data extracted from the configuration file + * + * @var array + */ + protected $_data; + + /** + * @param string $configContent + */ + public function __construct($configContent) + { + $config = new \DOMDocument; + $config->loadXML($configContent); + // todo: validation of the document + $this->_data = $this->_extractData($config); + } + /** * Get absolute path to theme.xsd * @@ -118,24 +136,4 @@ class Theme extends \Magento\Config\AbstractXml } return explode(self::THEME_PATH_SEPARATOR, $parentTheme); } - - /** - * Get initial XML of a valid document - * - * @return string - */ - protected function _getInitialXml() - { - return '<?xml version="1.0" encoding="UTF-8"?><theme></theme>'; - } - - /** - * Design packages are unique by code. Themes are unique by code. - * - * @return array - */ - protected function _getIdAttributes() - { - return array('/theme' => 'theme'); - } } diff --git a/lib/Magento/Controller/Router/Route/Factory.php b/lib/Magento/Controller/Router/Route/Factory.php index 6b805eb08138f1701da35b8b9d5f88c6b338da81..70e140159934659d9236cccfa4a67b65c3dadb39 100644 --- a/lib/Magento/Controller/Router/Route/Factory.php +++ b/lib/Magento/Controller/Router/Route/Factory.php @@ -24,7 +24,7 @@ class Factory /** * Create route instance. * - * @param $routeClass + * @param string $routeClass * @param string $route Map used to match with later submitted URL path * @param array $defaults Defaults for map variables with keys as variable names * @param array $reqs Regular expression requirements for variables (keys as variable names) diff --git a/lib/Magento/Convert/Container/AbstractContainer.php b/lib/Magento/Convert/Container/AbstractContainer.php index 2d3f8910d50f50462df833a6a0704c39803ebda1..75800696aa6e46bf7a6937b00720e469949f8d43 100644 --- a/lib/Magento/Convert/Container/AbstractContainer.php +++ b/lib/Magento/Convert/Container/AbstractContainer.php @@ -34,12 +34,30 @@ */ namespace Magento\Convert\Container; +use Magento\Convert\ConvertException; + abstract class AbstractContainer { + /** + * @var array + */ protected $_vars; + + /** + * @var array + */ protected $_data; + + /** + * @var int + */ protected $_position; + /** + * @param string $key + * @param string|null $default + * @return array + */ public function getVar($key, $default=null) { if (!isset($this->_vars[$key])) { @@ -48,11 +66,19 @@ abstract class AbstractContainer return $this->_vars[$key]; } + /** + * @return array + */ public function getVars() { return $this->_vars; } + /** + * @param array|string $key + * @param string|null $value + * @return $this + */ public function setVar($key, $value=null) { if (is_array($key) && is_null($value)) { @@ -63,28 +89,43 @@ abstract class AbstractContainer return $this; } + /** + * @return array + */ public function getData() { return $this->_data; } + /** + * @param array $data + * @return $this + */ public function setData($data) { $this->_data = $data; return $this; } + /** + * @param string|null $data + * @return true + */ public function validateDataString($data=null) { if (is_null($data)) { $data = $this->getData(); } if (!is_string($data)) { - $this->addException("Invalid data type, expecting string.", \Magento\Convert\ConvertException::FATAL); + $this->addException("Invalid data type, expecting string.", ConvertException::FATAL); } return true; } + /** + * @param array|null $data + * @return true + */ public function validateDataGrid($data=null) { if (is_null($data)) { @@ -95,11 +136,15 @@ abstract class AbstractContainer return true; } $this->addException( - "Invalid data type, expecting 2D grid array.", \Magento\Convert\ConvertException::FATAL); + "Invalid data type, expecting 2D grid array.", ConvertException::FATAL); } return true; } + /** + * @param array $grid + * @return array + */ public function getGridFields($grid) { $fields = array(); @@ -113,21 +158,33 @@ abstract class AbstractContainer return $fields; } + /** + * @param string $error + * @param string|null $level + * @return ConvertException + */ public function addException($error, $level=null) { - $exception = new \Magento\Convert\ConvertException($error); - $exception->setLevel(!is_null($level) ? $level : \Magento\Convert\ConvertException::NOTICE); + $exception = new ConvertException($error); + $exception->setLevel(!is_null($level) ? $level : ConvertException::NOTICE); $exception->setContainer($this); $exception->setPosition($this->getPosition()); return $exception; } + /** + * @return int + */ public function getPosition() { return $this->_position; } + /** + * @param int $position + * @return $this + */ public function setPosition($position) { $this->_position = $position; diff --git a/lib/Magento/Convert/ConvertArray.php b/lib/Magento/Convert/ConvertArray.php index b3bbe2be0b68020d4490dbf16d1e2e882ad0613d..4b08296d37ede0e51e22affcded077f1beb710d1 100644 --- a/lib/Magento/Convert/ConvertArray.php +++ b/lib/Magento/Convert/ConvertArray.php @@ -24,6 +24,8 @@ namespace Magento\Convert; +use Magento\Exception; + /** * Convert the array data to SimpleXMLElement object */ @@ -36,12 +38,12 @@ class ConvertArray * @param array $array * @param string $rootName * @return \SimpleXMLElement - * @throws \Magento\Exception + * @throws Exception */ public function assocToXml(array $array, $rootName = '_') { if (empty($rootName) || is_numeric($rootName)) { - throw new \Magento\Exception('Root element must not be empty or numeric'); + throw new Exception('Root element must not be empty or numeric'); } $xmlStr = <<<XML @@ -51,7 +53,7 @@ XML; $xml = new \SimpleXMLElement($xmlStr); foreach (array_keys($array) as $key) { if (is_numeric($key)) { - throw new \Magento\Exception('Array root keys must not be numeric.'); + throw new Exception('Array root keys must not be numeric.'); } } return self::_assocToXml($array, $rootName, $xml); @@ -64,7 +66,7 @@ XML; * @param string $rootName * @param \SimpleXMLElement $xml * @return \SimpleXMLElement - * @throws \Magento\Exception + * @throws Exception */ private function _assocToXml(array $array, $rootName, \SimpleXMLElement &$xml) { @@ -74,7 +76,7 @@ XML; if (!is_array($value)) { if (is_string($key)) { if ($key === $rootName) { - throw new \Magento\Exception( + throw new Exception( 'Associative key must not be the same as its parent associative key.' ); } @@ -89,7 +91,7 @@ XML; } } if ($hasNumericKey && $hasStringKey) { - throw new \Magento\Exception('Associative and numeric keys must not be mixed at one level.'); + throw new Exception('Associative and numeric keys must not be mixed at one level.'); } return $xml; } diff --git a/lib/Magento/Convert/ConvertException.php b/lib/Magento/Convert/ConvertException.php index dac1a2b28e45f0d77f98086ac309933dd25fe39b..b2e78aa750ee03983393a2e40e76c26d1e62c66b 100644 --- a/lib/Magento/Convert/ConvertException.php +++ b/lib/Magento/Convert/ConvertException.php @@ -25,50 +25,82 @@ */ namespace Magento\Convert; +use Magento\Convert\Container\AbstractContainer; +use Magento\Exception; /** * Convert exception */ -class ConvertException extends \Magento\Exception +class ConvertException extends Exception { const NOTICE = 'NOTICE'; const WARNING = 'WARNING'; const ERROR = 'ERROR'; const FATAL = 'FATAL'; + /** + * @var AbstractContainer + */ protected $_container; + /** + * @var string + */ protected $_level; + /** + * @var int + */ protected $_position; + /** + * @param AbstractContainer $container + * @return $this + */ public function setContainer($container) { $this->_container = $container; return $this; } + /** + * @return AbstractContainer + */ public function getContainer() { return $this->_container; } + /** + * @return string + */ public function getLevel() { return $this->_level; } + /** + * @param string $level + * @return $this + */ public function setLevel($level) { $this->_level = $level; return $this; } + /** + * @return int + */ public function getPosition() { return $this->_position; } + /** + * @param int $position + * @return $this + */ public function setPosition($position) { $this->_position = $position; diff --git a/lib/Magento/Convert/Excel.php b/lib/Magento/Convert/Excel.php index a1fb3e3b051e988be0d6f836b7acf70d10ba76ac..0646649c5c32d2c01f00715c78d6302d2f3143e1 100644 --- a/lib/Magento/Convert/Excel.php +++ b/lib/Magento/Convert/Excel.php @@ -26,6 +26,8 @@ namespace Magento\Convert; +use Magento\Filesystem\File\WriteInterface; + /** * Convert the data to XML Excel */ @@ -163,6 +165,7 @@ class Excel * Set Data Header * * @param array $data + * @return void */ public function setDataHeader($data) { @@ -173,6 +176,7 @@ class Excel * Set Data Footer * * @param array $data + * @return void */ public function setDataFooter($data) { @@ -200,10 +204,11 @@ class Excel /** * Write Converted XML Data to Temporary File * - * @param \Magento\Filesystem\File\WriteInterface $stream + * @param WriteInterface $stream * @param string $sheetName + * @return void */ - public function write(\Magento\Filesystem\File\WriteInterface $stream, $sheetName = '') + public function write(WriteInterface $stream, $sheetName = '') { $stream->write($this->_getXmlHeader($sheetName)); diff --git a/lib/Magento/Convert/Mapper/Column.php b/lib/Magento/Convert/Mapper/Column.php index b8b541cb20dc9b6da2767b02ae1bea49d434af8d..59ddd941bdffbd442e6b9e79366017586d74907c 100644 --- a/lib/Magento/Convert/Mapper/Column.php +++ b/lib/Magento/Convert/Mapper/Column.php @@ -34,9 +34,14 @@ */ namespace Magento\Convert\Mapper; -class Column extends \Magento\Convert\Container\AbstractContainer - implements \Magento\Convert\Mapper\MapperInterface +use Magento\Convert\Container\AbstractContainer; + +class Column extends AbstractContainer + implements MapperInterface { + /** + * @return $this + */ public function map() { $data = $this->getData(); diff --git a/lib/Magento/Convert/Object.php b/lib/Magento/Convert/Object.php index 488407282a75503ec5fbef13a0b8d91a672387e3..dac8d7696e89cb76aa8225052997ef7e4f9619a9 100644 --- a/lib/Magento/Convert/Object.php +++ b/lib/Magento/Convert/Object.php @@ -43,7 +43,7 @@ class Object * Convert input data into an array and return the resulting array. * The resulting array should not contain any objects. * - * @param mixed $data input data + * @param array $data input data * @return array Data converted to an array */ public function convertDataToArray($data) @@ -107,7 +107,6 @@ class Object * @param array $items * @param string|callable $idField * @param string|callable $valueField - * * @return array */ public function toOptionArray(array $items, $idField, $valueField) @@ -130,7 +129,6 @@ class Object * @param array $items * @param string|callable $idField * @param string|callable $valueField - * * @return array */ public function toOptionHash(array $items, $idField, $valueField) @@ -151,7 +149,6 @@ class Object * * @param mixed $item * @param string|callable $field - * * @return mixed */ protected function _invokeGetter($item, $field) diff --git a/lib/Magento/Css/PreProcessor/Adapter/Oyejorge.php b/lib/Magento/Css/PreProcessor/Adapter/Oyejorge.php new file mode 100644 index 0000000000000000000000000000000000000000..eccc8dd6d25bf9c88d04e6310e362d26ca0c29ea --- /dev/null +++ b/lib/Magento/Css/PreProcessor/Adapter/Oyejorge.php @@ -0,0 +1,42 @@ +<?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\Css\PreProcessor\Adapter; + +/** + * Oyejorge adapter model + */ +class Oyejorge implements \Magento\Css\PreProcessor\AdapterInterface +{ + /** + * @param string $sourceFilePath + * @return string + */ + public function process($sourceFilePath) + { + $parser = new \Less_Parser(); + $parser->parseFile($sourceFilePath, ''); + return $parser->getCss(); + } +} diff --git a/lib/Magento/Css/PreProcessor/AdapterInterface.php b/lib/Magento/Css/PreProcessor/AdapterInterface.php new file mode 100644 index 0000000000000000000000000000000000000000..11b4a95ca453c6e9ede340ac80e4c6598bee66d8 --- /dev/null +++ b/lib/Magento/Css/PreProcessor/AdapterInterface.php @@ -0,0 +1,37 @@ +<?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\Css\PreProcessor; + +/** + * Css pre-processor adapter interface + */ +interface AdapterInterface +{ + /** + * @param string $sourceFilePath + * @return string + */ + public function process($sourceFilePath); +} diff --git a/lib/Magento/Css/PreProcessor/Less.php b/lib/Magento/Css/PreProcessor/Less.php new file mode 100644 index 0000000000000000000000000000000000000000..7a6515d76af90ff64cc1eccfbac35ae6d4719280 --- /dev/null +++ b/lib/Magento/Css/PreProcessor/Less.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\Css\PreProcessor; + +/** + * Css pre-processor less + */ +class Less implements \Magento\View\Asset\PreProcessor\PreProcessorInterface +{ + /** + * @var \Magento\View\FileSystem + */ + protected $viewFileSystem; + + /** + * @var \Magento\Less\PreProcessor + */ + protected $lessPreProcessor; + + /** + * @var \Magento\Css\PreProcessor\AdapterInterface + */ + protected $adapter; + + /** + * @param \Magento\View\FileSystem $viewFileSystem + * @param \Magento\Less\PreProcessor $lessPreProcessor + * @param AdapterInterface $adapter + */ + public function __construct( + \Magento\View\FileSystem $viewFileSystem, + \Magento\Less\PreProcessor $lessPreProcessor, + \Magento\Css\PreProcessor\AdapterInterface $adapter + ) { + $this->viewFileSystem = $viewFileSystem; + $this->lessPreProcessor = $lessPreProcessor; + $this->adapter = $adapter; + } + + /** + * @param string $filePath + * @param array $params + * @param \Magento\Filesystem\Directory\WriteInterface $targetDirectory + * @param null|string $sourcePath + * @return string + */ + public function process($filePath, $params, $targetDirectory, $sourcePath = null) + { + // if css file has being already discovered/prepared by previous pre-processor + if ($sourcePath) { + return $sourcePath; + } + + // TODO: if css file is already exist. May compare modification time of .less and .css files here. + $sourcePath = $this->viewFileSystem->getViewFile($filePath, $params); + + $lessFilePath = str_replace('.css', '.less', $filePath); + $preparedLessFileSourcePath = $this->lessPreProcessor->processLessInstructions($lessFilePath, $params); + $cssContent = $this->adapter->process($preparedLessFileSourcePath); + + // doesn't matter where exact file has been found, we use original file identifier + // see \Magento\View\Publisher::_buildPublishedFilePath() for details + $targetDirectory->writeFile($filePath, $cssContent); + return $targetDirectory->getAbsolutePath($filePath); + } +} diff --git a/lib/Magento/DB/Adapter/AdapterInterface.php b/lib/Magento/DB/Adapter/AdapterInterface.php index 2aebd42a9999bdcc0fa1150146e980934901eb45..20077c703c3861984966dba1ff6fe10276c4bdf6 100644 --- a/lib/Magento/DB/Adapter/AdapterInterface.php +++ b/lib/Magento/DB/Adapter/AdapterInterface.php @@ -1023,4 +1023,21 @@ interface AdapterInterface * @return int */ public function getTransactionLevel(); + + /** + * Create trigger + * + * @param \Magento\DB\Ddl\Trigger $trigger + * @return \Zend_Db_Statement_Pdo + */ + public function createTrigger(\Magento\DB\Ddl\Trigger $trigger); + + /** + * Drop trigger from database + * + * @param $triggerName + * @param null $schemaName + * @return mixed + */ + public function dropTrigger($triggerName, $schemaName = null); } diff --git a/lib/Magento/DB/Adapter/Pdo/Mysql.php b/lib/Magento/DB/Adapter/Pdo/Mysql.php index 7a1fd5b68ea7f01e0bb1b84cba6e285a784c5976..b1e63e1e79c515d2edfb073d26f60601489e7481 100644 --- a/lib/Magento/DB/Adapter/Pdo/Mysql.php +++ b/lib/Magento/DB/Adapter/Pdo/Mysql.php @@ -25,7 +25,19 @@ */ namespace Magento\DB\Adapter\Pdo; -class Mysql extends \Zend_Db_Adapter_Pdo_Mysql implements \Magento\DB\Adapter\AdapterInterface +use Magento\App\Filesystem; +use Magento\Cache\FrontendInterface; +use Magento\DB\Adapter\AdapterInterface; +use Magento\DB\Ddl\Table; +use Magento\DB\Helper; +use Magento\DB\Profiler; +use Magento\DB\Select; +use Magento\DB\Statement\Parameter; +use Magento\Debug; +use Magento\Stdlib\DateTime; +use Magento\Stdlib\String; + +class Mysql extends \Zend_Db_Adapter_Pdo_Mysql implements AdapterInterface { const DEBUG_CONNECT = 0; const DEBUG_TRANSACTION = 1; @@ -143,7 +155,7 @@ class Mysql extends \Zend_Db_Adapter_Pdo_Mysql implements \Magento\DB\Adapter\Ad /** * Filesystem class * - * @var \Magento\App\Filesystem + * @var Filesystem */ protected $_filesystem; @@ -157,7 +169,7 @@ class Mysql extends \Zend_Db_Adapter_Pdo_Mysql implements \Magento\DB\Adapter\Ad /** * Cache frontend adapter instance * - * @var \Magento\Cache\FrontendInterface + * @var FrontendInterface */ protected $_cacheAdapter; @@ -173,26 +185,26 @@ class Mysql extends \Zend_Db_Adapter_Pdo_Mysql implements \Magento\DB\Adapter\Ad * @var array */ protected $_ddlColumnTypes = array( - \Magento\DB\Ddl\Table::TYPE_BOOLEAN => 'bool', - \Magento\DB\Ddl\Table::TYPE_SMALLINT => 'smallint', - \Magento\DB\Ddl\Table::TYPE_INTEGER => 'int', - \Magento\DB\Ddl\Table::TYPE_BIGINT => 'bigint', - \Magento\DB\Ddl\Table::TYPE_FLOAT => 'float', - \Magento\DB\Ddl\Table::TYPE_DECIMAL => 'decimal', - \Magento\DB\Ddl\Table::TYPE_NUMERIC => 'decimal', - \Magento\DB\Ddl\Table::TYPE_DATE => 'date', - \Magento\DB\Ddl\Table::TYPE_TIMESTAMP => 'timestamp', - \Magento\DB\Ddl\Table::TYPE_DATETIME => 'datetime', - \Magento\DB\Ddl\Table::TYPE_TEXT => 'text', - \Magento\DB\Ddl\Table::TYPE_BLOB => 'blob', - \Magento\DB\Ddl\Table::TYPE_VARBINARY => 'blob' + Table::TYPE_BOOLEAN => 'bool', + Table::TYPE_SMALLINT => 'smallint', + Table::TYPE_INTEGER => 'int', + Table::TYPE_BIGINT => 'bigint', + Table::TYPE_FLOAT => 'float', + Table::TYPE_DECIMAL => 'decimal', + Table::TYPE_NUMERIC => 'decimal', + Table::TYPE_DATE => 'date', + Table::TYPE_TIMESTAMP => 'timestamp', + Table::TYPE_DATETIME => 'datetime', + Table::TYPE_TEXT => 'text', + Table::TYPE_BLOB => 'blob', + Table::TYPE_VARBINARY => 'blob' ); /** * All possible DDL statements * First 3 symbols for each statement * - * @var array + * @var string[] */ protected $_ddlRoutines = array('alt', 'cre', 'ren', 'dro', 'tru'); @@ -218,25 +230,25 @@ class Mysql extends \Zend_Db_Adapter_Pdo_Mysql implements \Magento\DB\Adapter\Ad protected $_queryHook = null; /** - * @var \Magento\Stdlib\String + * @var String */ protected $string; /** - * @var \Magento\Stdlib\DateTime + * @var DateTime */ protected $dateTime; /** - * @param \Magento\App\Filesystem $filesystem - * @param \Magento\Stdlib\String $string - * @param \Magento\Stdlib\DateTime $dateTime + * @param Filesystem $filesystem + * @param String $string + * @param DateTime $dateTime * @param array $config */ public function __construct( - \Magento\App\Filesystem $filesystem, - \Magento\Stdlib\String $string, - \Magento\Stdlib\DateTime $dateTime, + Filesystem $filesystem, + String $string, + DateTime $dateTime, array $config = array() ) { $this->_filesystem = $filesystem; @@ -248,13 +260,13 @@ class Mysql extends \Zend_Db_Adapter_Pdo_Mysql implements \Magento\DB\Adapter\Ad /** * Begin new DB transaction for connection * - * @return \Magento\DB\Adapter\Pdo\Mysql + * @return $this * @throws \Exception */ public function beginTransaction() { if ($this->_isRolledBack) { - throw new \Exception(\Magento\DB\Adapter\AdapterInterface::ERROR_ROLLBACK_INCOMPLETE_MESSAGE); + throw new \Exception(AdapterInterface::ERROR_ROLLBACK_INCOMPLETE_MESSAGE); } if ($this->_transactionLevel === 0) { $this->_debugTimer(); @@ -268,7 +280,7 @@ class Mysql extends \Zend_Db_Adapter_Pdo_Mysql implements \Magento\DB\Adapter\Ad /** * Commit DB transaction * - * @return \Magento\DB\Adapter\Pdo\Mysql + * @return $this */ public function commit() { @@ -277,9 +289,9 @@ class Mysql extends \Zend_Db_Adapter_Pdo_Mysql implements \Magento\DB\Adapter\Ad parent::commit(); $this->_debugStat(self::DEBUG_TRANSACTION, 'COMMIT'); } elseif ($this->_transactionLevel === 0) { - throw new \Exception(\Magento\DB\Adapter\AdapterInterface::ERROR_ASYMMETRIC_COMMIT_MESSAGE); + throw new \Exception(AdapterInterface::ERROR_ASYMMETRIC_COMMIT_MESSAGE); } elseif ($this->_isRolledBack) { - throw new \Exception(\Magento\DB\Adapter\AdapterInterface::ERROR_ROLLBACK_INCOMPLETE_MESSAGE); + throw new \Exception(AdapterInterface::ERROR_ROLLBACK_INCOMPLETE_MESSAGE); } --$this->_transactionLevel; return $this; @@ -288,7 +300,7 @@ class Mysql extends \Zend_Db_Adapter_Pdo_Mysql implements \Magento\DB\Adapter\Ad /** * Rollback DB transaction * - * @return \Magento\DB\Adapter\Pdo\Mysql + * @return $this */ public function rollBack() { @@ -298,7 +310,7 @@ class Mysql extends \Zend_Db_Adapter_Pdo_Mysql implements \Magento\DB\Adapter\Ad $this->_isRolledBack = false; $this->_debugStat(self::DEBUG_TRANSACTION, 'ROLLBACK'); } elseif ($this->_transactionLevel === 0) { - throw new \Exception(\Magento\DB\Adapter\AdapterInterface::ERROR_ASYMMETRIC_ROLLBACK_MESSAGE); + throw new \Exception(AdapterInterface::ERROR_ASYMMETRIC_ROLLBACK_MESSAGE); } else { $this->_isRolledBack = true; } @@ -319,8 +331,8 @@ class Mysql extends \Zend_Db_Adapter_Pdo_Mysql implements \Magento\DB\Adapter\Ad /** * Convert date to DB format * - * @param mixed $date - * @return string + * @param int|string|\Zend_Date $date + * @return \Zend_Db_Expr */ public function convertDate($date) { @@ -330,8 +342,8 @@ class Mysql extends \Zend_Db_Adapter_Pdo_Mysql implements \Magento\DB\Adapter\Ad /** * Convert date and time to DB format * - * @param mixed $date - * @return string + * @param int|string|\Zend_Date $datetime + * @return \Zend_Db_Expr */ public function convertDateTime($datetime) { @@ -341,6 +353,7 @@ class Mysql extends \Zend_Db_Adapter_Pdo_Mysql implements \Magento\DB\Adapter\Ad /** * Creates a PDO object and connects to the database. * + * @return void * @throws \Zend_Db_Adapter_Exception */ protected function _connect() @@ -406,7 +419,7 @@ class Mysql extends \Zend_Db_Adapter_Pdo_Mysql implements \Magento\DB\Adapter\Ad * * @param string $sql * @param string|int $field - * @return boolean + * @return mixed|null */ public function raw_fetchRow($sql, $field = null) { @@ -430,7 +443,8 @@ class Mysql extends \Zend_Db_Adapter_Pdo_Mysql implements \Magento\DB\Adapter\Ad /** * Check transaction level in case of DDL query * - * @param string|Zend_Db_Select $sql + * @param string|\Zend_Db_Select $sql + * @return void * @throws \Zend_Db_Adapter_Exception */ protected function _checkDdlTransaction($sql) @@ -438,7 +452,7 @@ class Mysql extends \Zend_Db_Adapter_Pdo_Mysql implements \Magento\DB\Adapter\Ad if (is_string($sql) && $this->getTransactionLevel() > 0) { $startSql = strtolower(substr(ltrim($sql), 0, 3)); if (in_array($startSql, $this->_ddlRoutines)) { - trigger_error(\Magento\DB\Adapter\AdapterInterface::ERROR_DDL_MESSAGE, E_USER_ERROR); + trigger_error(AdapterInterface::ERROR_DDL_MESSAGE, E_USER_ERROR); } } } @@ -447,7 +461,7 @@ class Mysql extends \Zend_Db_Adapter_Pdo_Mysql implements \Magento\DB\Adapter\Ad * Special handling for PDO query(). * All bind parameter names must begin with ':'. * - * @param string|Zend_Db_Select $sql The SQL statement with placeholders. + * @param string|\Zend_Db_Select $sql The SQL statement with placeholders. * @param mixed $bind An array of data or data itself to bind to the placeholders. * @return \Zend_Db_Statement_Pdo * @throws \Zend_Db_Adapter_Exception To re-throw \PDOException. @@ -471,8 +485,8 @@ class Mysql extends \Zend_Db_Adapter_Pdo_Mysql implements \Magento\DB\Adapter\Ad } catch (\Exception $e) { // Finalize broken query $profiler = $this->getProfiler(); - if ($profiler instanceof \Magento\DB\Profiler) { - /** @var \Magento\DB\Profiler $profiler */ + if ($profiler instanceof Profiler) { + /** @var Profiler $profiler */ $profiler->queryEndLast(); } @@ -509,7 +523,7 @@ class Mysql extends \Zend_Db_Adapter_Pdo_Mysql implements \Magento\DB\Adapter\Ad * * @param \Zend_Db_Select|string $sql * @param mixed $bind - * @return \Magento\DB\Adapter\Pdo\Mysql + * @return $this */ protected function _prepareQuery(&$sql, &$bind = array()) { @@ -548,7 +562,7 @@ class Mysql extends \Zend_Db_Adapter_Pdo_Mysql implements \Magento\DB\Adapter\Ad * This method writes to $_bindParams, where query bind parameters are kept. * This method requires further normalizing, if bind array is positional. * - * @param array $matches + * @param string[] $matches * @return string */ public function proccessBindCallback($matches) @@ -591,7 +605,7 @@ class Mysql extends \Zend_Db_Adapter_Pdo_Mysql implements \Magento\DB\Adapter\Ad * * @param string $sql * @param array $bind - * @return \Magento\DB\Adapter\Pdo\Mysql + * @return $this */ protected function _convertMixedBind(&$sql, &$bind) { @@ -646,7 +660,7 @@ class Mysql extends \Zend_Db_Adapter_Pdo_Mysql implements \Magento\DB\Adapter\Ad * Previous hook is returned. * * @param array $hook - * @return mixed + * @return array|null */ public function setQueryHook($hook) { @@ -660,7 +674,7 @@ class Mysql extends \Zend_Db_Adapter_Pdo_Mysql implements \Magento\DB\Adapter\Ad * * @param string $sql * @throws \Zend_Db_Exception - * @return \Magento\DB\Adapter\Pdo\Mysql + * @return array */ public function multiQuery($sql) { @@ -698,7 +712,7 @@ class Mysql extends \Zend_Db_Adapter_Pdo_Mysql implements \Magento\DB\Adapter\Ad /** * Split multi statement query * - * @param $sql string + * @param string $sql * @return array */ protected function _splitMultiQuery($sql) @@ -759,7 +773,7 @@ class Mysql extends \Zend_Db_Adapter_Pdo_Mysql implements \Magento\DB\Adapter\Ad * @param string $tableName * @param string $fkName * @param string $schemaName - * @return \Magento\DB\Adapter\Pdo\Mysql + * @return $this */ public function dropForeignKey($tableName, $fkName, $schemaName = null) { @@ -789,14 +803,14 @@ class Mysql extends \Zend_Db_Adapter_Pdo_Mysql implements \Magento\DB\Adapter\Ad * @param string $refTableName * @param string $refColumnName * @param string $onDelete - * @return \Magento\DB\Adapter\Pdo\Mysql + * @return $this */ public function purgeOrphanRecords($tableName, $columnName, $refTableName, $refColumnName, - $onDelete = \Magento\DB\Adapter\AdapterInterface::FK_ACTION_CASCADE) + $onDelete = AdapterInterface::FK_ACTION_CASCADE) { $onDelete = strtoupper($onDelete); - if ($onDelete == \Magento\DB\Adapter\AdapterInterface::FK_ACTION_CASCADE - || $onDelete == \Magento\DB\Adapter\AdapterInterface::FK_ACTION_RESTRICT + if ($onDelete == AdapterInterface::FK_ACTION_CASCADE + || $onDelete == AdapterInterface::FK_ACTION_RESTRICT ) { $sql = sprintf("DELETE p.* FROM %s AS p LEFT JOIN %s AS r ON p.%s = r.%s WHERE r.%s IS NULL", $this->quoteIdentifier($tableName), @@ -805,7 +819,7 @@ class Mysql extends \Zend_Db_Adapter_Pdo_Mysql implements \Magento\DB\Adapter\Ad $this->quoteIdentifier($refColumnName), $this->quoteIdentifier($refColumnName)); $this->raw_query($sql); - } elseif ($onDelete == \Magento\DB\Adapter\AdapterInterface::FK_ACTION_SET_NULL) { + } elseif ($onDelete == AdapterInterface::FK_ACTION_SET_NULL) { $sql = sprintf("UPDATE %s AS p LEFT JOIN %s AS r ON p.%s = r.%s SET p.%s = NULL WHERE r.%s IS NULL", $this->quoteIdentifier($tableName), $this->quoteIdentifier($refTableName), @@ -825,7 +839,7 @@ class Mysql extends \Zend_Db_Adapter_Pdo_Mysql implements \Magento\DB\Adapter\Ad * @param string $tableName * @param string $columnName * @param string $schemaName - * @return boolean + * @return bool */ public function tableColumnExists($tableName, $columnName, $schemaName = null) { @@ -849,7 +863,7 @@ class Mysql extends \Zend_Db_Adapter_Pdo_Mysql implements \Magento\DB\Adapter\Ad * @param string $columnName * @param array|string $definition string specific or universal array DB Server definition * @param string $schemaName - * @return int|boolean + * @return true|\Zend_Db_Statement_Pdo * @throws \Zend_Db_Exception */ public function addColumn($tableName, $columnName, $definition, $schemaName = null) @@ -890,7 +904,7 @@ class Mysql extends \Zend_Db_Adapter_Pdo_Mysql implements \Magento\DB\Adapter\Ad * @param string $tableName * @param string $columnName * @param string $schemaName - * @return bool + * @return true|\Zend_Db_Statement_Pdo */ public function dropColumn($tableName, $columnName, $schemaName = null) { @@ -959,7 +973,7 @@ class Mysql extends \Zend_Db_Adapter_Pdo_Mysql implements \Magento\DB\Adapter\Ad * @param array $definition * @param boolean $flushData flush table statistic * @param string $schemaName - * @return \Magento\DB\Adapter\Pdo\Mysql + * @return \Zend_Db_Statement_Pdo * @throws \Zend_Db_Exception */ public function changeColumn($tableName, $oldColumnName, $newColumnName, $definition, $flushData = false, @@ -1001,7 +1015,7 @@ class Mysql extends \Zend_Db_Adapter_Pdo_Mysql implements \Magento\DB\Adapter\Ad * @param array|string $definition * @param boolean $flushData * @param string $schemaName - * @return \Magento\DB\Adapter\Pdo\Mysql + * @return $this * @throws \Zend_Db_Exception */ public function modifyColumn($tableName, $columnName, $definition, $flushData = false, $schemaName = null) @@ -1032,7 +1046,7 @@ class Mysql extends \Zend_Db_Adapter_Pdo_Mysql implements \Magento\DB\Adapter\Ad * * @param string $tableName * @param string $schemaName - * @return array|false + * @return mixed */ public function showTableStatus($tableName, $schemaName = null) { @@ -1151,7 +1165,8 @@ class Mysql extends \Zend_Db_Adapter_Pdo_Mysql implements \Magento\DB\Adapter\Ad * comment => string; table comment * engine => string; table engine * - * @return \Magento\DB\Adapter\Pdo\Mysql + * @param array $tables + * @return $this */ public function modifyTables($tables) { @@ -1182,8 +1197,8 @@ class Mysql extends \Zend_Db_Adapter_Pdo_Mysql implements \Magento\DB\Adapter\Ad $onDelete = $options['ON_DELETE']; $onUpdate = $options['ON_UPDATE']; - if ($onDelete == \Magento\DB\Adapter\AdapterInterface::FK_ACTION_SET_NULL - || $onUpdate == \Magento\DB\Adapter\AdapterInterface::FK_ACTION_SET_NULL) { + if ($onDelete == AdapterInterface::FK_ACTION_SET_NULL + || $onUpdate == AdapterInterface::FK_ACTION_SET_NULL) { $columnDefinition['nullable'] = true; } $this->modifyColumn($options['TABLE_NAME'], $options['COLUMN_NAME'], $columnDefinition); @@ -1193,8 +1208,8 @@ class Mysql extends \Zend_Db_Adapter_Pdo_Mysql implements \Magento\DB\Adapter\Ad $options['COLUMN_NAME'], $options['REF_TABLE_NAME'], $options['REF_COLUMN_NAME'], - ($onDelete) ? $onDelete : \Magento\DB\Adapter\AdapterInterface::FK_ACTION_NO_ACTION, - ($onUpdate) ? $onUpdate : \Magento\DB\Adapter\AdapterInterface::FK_ACTION_NO_ACTION + ($onDelete) ? $onDelete : AdapterInterface::FK_ACTION_NO_ACTION, + ($onUpdate) ? $onUpdate : AdapterInterface::FK_ACTION_NO_ACTION ); } } @@ -1229,7 +1244,7 @@ class Mysql extends \Zend_Db_Adapter_Pdo_Mysql implements \Magento\DB\Adapter\Ad * * @param string $tableName * @param string $schemaName - * @return array + * @return array|string|int */ public function getIndexList($tableName, $schemaName = null) { @@ -1246,14 +1261,14 @@ class Mysql extends \Zend_Db_Adapter_Pdo_Mysql implements \Magento\DB\Adapter\Ad $fieldColumn = 'Column_name'; $fieldIndexType = 'Index_type'; - if (strtolower($row[$fieldKeyName]) == \Magento\DB\Adapter\AdapterInterface::INDEX_TYPE_PRIMARY) { - $indexType = \Magento\DB\Adapter\AdapterInterface::INDEX_TYPE_PRIMARY; + if (strtolower($row[$fieldKeyName]) == AdapterInterface::INDEX_TYPE_PRIMARY) { + $indexType = AdapterInterface::INDEX_TYPE_PRIMARY; } elseif ($row[$fieldNonUnique] == 0) { - $indexType = \Magento\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE; - } elseif (strtolower($row[$fieldIndexType]) == \Magento\DB\Adapter\AdapterInterface::INDEX_TYPE_FULLTEXT) { - $indexType = \Magento\DB\Adapter\AdapterInterface::INDEX_TYPE_FULLTEXT; + $indexType = AdapterInterface::INDEX_TYPE_UNIQUE; + } elseif (strtolower($row[$fieldIndexType]) == AdapterInterface::INDEX_TYPE_FULLTEXT) { + $indexType = AdapterInterface::INDEX_TYPE_FULLTEXT; } else { - $indexType = \Magento\DB\Adapter\AdapterInterface::INDEX_TYPE_INDEX; + $indexType = AdapterInterface::INDEX_TYPE_INDEX; } $upperKeyName = strtoupper($row[$fieldKeyName]); @@ -1284,8 +1299,8 @@ class Mysql extends \Zend_Db_Adapter_Pdo_Mysql implements \Magento\DB\Adapter\Ad * * @param string $table * @param array $fields - * @param array $ids - * @return \Magento\DB\Adapter\Pdo\Mysql + * @param string[] $ids + * @return $this */ protected function _removeDuplicateEntry($table, $fields, $ids) { @@ -1317,17 +1332,17 @@ class Mysql extends \Zend_Db_Adapter_Pdo_Mysql implements \Magento\DB\Adapter\Ad /** * Creates and returns a new \Zend_Db_Select object for this adapter. * - * @return \Magento\DB\Select + * @return Select */ public function select() { - return new \Magento\DB\Select($this); + return new Select($this); } /** * Start debug timer * - * @return \Magento\DB\Adapter\Pdo\Mysql + * @return $this */ protected function _debugTimer() { @@ -1345,7 +1360,7 @@ class Mysql extends \Zend_Db_Adapter_Pdo_Mysql implements \Magento\DB\Adapter\Ad * @param string $sql * @param array $bind * @param \Zend_Db_Statement_Pdo $result - * @return \Magento\DB\Adapter\Pdo\Mysql + * @return $this */ protected function _debugStat($type, $sql, $bind = array(), $result = null) { @@ -1381,7 +1396,7 @@ class Mysql extends \Zend_Db_Adapter_Pdo_Mysql implements \Magento\DB\Adapter\Ad $code .= 'TIME: ' . $time . $nl; if ($this->_logCallStack) { - $code .= 'TRACE: ' . \Magento\Debug::backtrace(true, false) . $nl; + $code .= 'TRACE: ' . Debug::backtrace(true, false) . $nl; } $code .= $nl; @@ -1395,6 +1410,7 @@ class Mysql extends \Zend_Db_Adapter_Pdo_Mysql implements \Magento\DB\Adapter\Ad * Write exception and thow * * @param \Exception $e + * @return void * @throws \Exception */ protected function _debugException(\Exception $e) @@ -1414,12 +1430,13 @@ class Mysql extends \Zend_Db_Adapter_Pdo_Mysql implements \Magento\DB\Adapter\Ad * Debug write to file process * * @param string $str + * @return void */ protected function _debugWriteToFile($str) { $str = '## ' . date('Y-m-d H:i:s') . "\r\n" . $str; - $stream = $this->_filesystem->getDirectoryWrite(\Magento\App\Filesystem::ROOT_DIR)->openFile($this->_debugFile, 'a'); + $stream = $this->_filesystem->getDirectoryWrite(Filesystem::ROOT_DIR)->openFile($this->_debugFile, 'a'); $stream->lock(); $stream->write($str); $stream->unlock(); @@ -1451,6 +1468,7 @@ class Mysql extends \Zend_Db_Adapter_Pdo_Mysql implements \Magento\DB\Adapter\Ad * * @param string $tableName * @param string $schemaName + * @return string */ protected function _getTableName($tableName, $schemaName = null) { @@ -1504,7 +1522,8 @@ class Mysql extends \Zend_Db_Adapter_Pdo_Mysql implements \Magento\DB\Adapter\Ad * * @param string $tableCacheKey * @param int $ddlType - * @return \Magento\DB\Adapter\Pdo\Mysql + * @param array $data + * @return $this */ public function saveDdlCache($tableCacheKey, $ddlType, $data) { @@ -1528,7 +1547,7 @@ class Mysql extends \Zend_Db_Adapter_Pdo_Mysql implements \Magento\DB\Adapter\Ad * * @param string $tableName * @param string $schemaName OPTIONAL - * @return \Magento\DB\Adapter\Pdo\Mysql + * @return $this */ public function resetDdlCache($tableName = null, $schemaName = null) { @@ -1561,7 +1580,7 @@ class Mysql extends \Zend_Db_Adapter_Pdo_Mysql implements \Magento\DB\Adapter\Ad /** * Disallow DDL caching - * @return \Magento\DB\Adapter\Pdo\Mysql + * @return $this */ public function disallowDdlCache() { @@ -1571,7 +1590,7 @@ class Mysql extends \Zend_Db_Adapter_Pdo_Mysql implements \Magento\DB\Adapter\Ad /** * Allow DDL caching - * @return \Magento\DB\Adapter\Pdo\Mysql + * @return $this */ public function allowDdlCache() { @@ -1648,7 +1667,7 @@ class Mysql extends \Zend_Db_Adapter_Pdo_Mysql implements \Magento\DB\Adapter\Ad $options['unsigned'] = true; } if ($columnData['NULLABLE'] === false - && !($type == \Magento\DB\Ddl\Table::TYPE_TEXT && strlen($columnData['DEFAULT']) != 0) + && !($type == Table::TYPE_TEXT && strlen($columnData['DEFAULT']) != 0) ) { $options['nullable'] = false; } @@ -1656,7 +1675,7 @@ class Mysql extends \Zend_Db_Adapter_Pdo_Mysql implements \Magento\DB\Adapter\Ad $options['primary'] = true; } if (!is_null($columnData['DEFAULT']) - && $type != \Magento\DB\Ddl\Table::TYPE_TEXT + && $type != Table::TYPE_TEXT ) { $options['default'] = $this->quote($columnData['DEFAULT']); } @@ -1683,9 +1702,9 @@ class Mysql extends \Zend_Db_Adapter_Pdo_Mysql implements \Magento\DB\Adapter\Ad /** * Create \Magento\DB\Ddl\Table object by data from describe table * - * @param $tableName - * @param $newTableName - * @return \Magento\DB\Ddl\Table + * @param string $tableName + * @param string $newTableName + * @return Table */ public function createTableByDdl($tableName, $newTableName) { @@ -1712,7 +1731,7 @@ class Mysql extends \Zend_Db_Adapter_Pdo_Mysql implements \Magento\DB\Adapter\Ad * For reliability check both name and type, because these values can start to differ in future. */ if (($indexData['KEY_NAME'] == 'PRIMARY') - || ($indexData['INDEX_TYPE'] == \Magento\DB\Adapter\AdapterInterface::INDEX_TYPE_PRIMARY) + || ($indexData['INDEX_TYPE'] == AdapterInterface::INDEX_TYPE_PRIMARY) ) { continue; } @@ -1751,7 +1770,7 @@ class Mysql extends \Zend_Db_Adapter_Pdo_Mysql implements \Magento\DB\Adapter\Ad * @param array $definition * @param boolean $flushData * @param string $schemaName - * @return \Magento\DB\Adapter\Pdo\Mysql + * @return $this */ public function modifyColumnByDdl($tableName, $columnName, $definition, $flushData = false, $schemaName = null) { @@ -1774,37 +1793,37 @@ class Mysql extends \Zend_Db_Adapter_Pdo_Mysql implements \Magento\DB\Adapter\Ad { switch ($column['DATA_TYPE']) { case 'bool': - return \Magento\DB\Ddl\Table::TYPE_BOOLEAN; + return Table::TYPE_BOOLEAN; case 'tinytext': case 'char': case 'varchar': case 'text': case 'mediumtext': case 'longtext': - return \Magento\DB\Ddl\Table::TYPE_TEXT; + return Table::TYPE_TEXT; case 'blob': case 'mediumblob': case 'longblob': - return \Magento\DB\Ddl\Table::TYPE_BLOB; + return Table::TYPE_BLOB; case 'tinyint': case 'smallint': - return \Magento\DB\Ddl\Table::TYPE_SMALLINT; + return Table::TYPE_SMALLINT; case 'mediumint': case 'int': - return \Magento\DB\Ddl\Table::TYPE_INTEGER; + return Table::TYPE_INTEGER; case 'bigint': - return \Magento\DB\Ddl\Table::TYPE_BIGINT; + return Table::TYPE_BIGINT; case 'datetime': - return \Magento\DB\Ddl\Table::TYPE_DATETIME; + return Table::TYPE_DATETIME; case 'timestamp': - return \Magento\DB\Ddl\Table::TYPE_TIMESTAMP; + return Table::TYPE_TIMESTAMP; case 'date': - return \Magento\DB\Ddl\Table::TYPE_DATE; + return Table::TYPE_DATE; case 'float': - return \Magento\DB\Ddl\Table::TYPE_FLOAT; + return Table::TYPE_FLOAT; case 'decimal': case 'numeric': - return \Magento\DB\Ddl\Table::TYPE_DECIMAL; + return Table::TYPE_DECIMAL; } } @@ -1814,7 +1833,7 @@ class Mysql extends \Zend_Db_Adapter_Pdo_Mysql implements \Magento\DB\Adapter\Ad * @param string $tableName * @param string $engine * @param string $schemaName - * @return mixed + * @return \Zend_Db_Statement_Pdo */ public function changeTableEngine($tableName, $engine, $schemaName = null) { @@ -1830,7 +1849,7 @@ class Mysql extends \Zend_Db_Adapter_Pdo_Mysql implements \Magento\DB\Adapter\Ad * @param string $tableName * @param string $comment * @param string $schemaName - * @return mixed + * @return \Zend_Db_Statement_Pdo */ public function changeTableComment($tableName, $comment, $schemaName = null) { @@ -1860,7 +1879,7 @@ class Mysql extends \Zend_Db_Adapter_Pdo_Mysql implements \Magento\DB\Adapter\Ad /** * Inserts a table row with specified data. * - * @param mixed $table The table to insert data into. + * @param string $table The table to insert data into. * @param array $data Column-value pairs or array of column-value pairs. * @param array $fields update fields pairs or values * @return int The number of affected rows. @@ -1931,7 +1950,7 @@ class Mysql extends \Zend_Db_Adapter_Pdo_Mysql implements \Magento\DB\Adapter\Ad /** * Inserts a table multiply rows with specified data. * - * @param mixed $table The table to insert data into. + * @param string|array|\Zend_Db_Expr $table The table to insert data into. * @param array $data Column-value pairs or array of Column-value pairs. * @return int The number of affected rows. * @throws \Zend_Db_Exception @@ -2004,10 +2023,10 @@ class Mysql extends \Zend_Db_Adapter_Pdo_Mysql implements \Magento\DB\Adapter\Ad /** * Set cache adapter * - * @param \Magento\Cache\FrontendInterface $adapter - * @return \Magento\DB\Adapter\Pdo\Mysql + * @param FrontendInterface $adapter + * @return $this */ - public function setCacheAdapter(\Magento\Cache\FrontendInterface $adapter) + public function setCacheAdapter(FrontendInterface $adapter) { $this->_cacheAdapter = $adapter; return $this; @@ -2018,11 +2037,11 @@ class Mysql extends \Zend_Db_Adapter_Pdo_Mysql implements \Magento\DB\Adapter\Ad * * @param string $tableName the table name * @param string $schemaName the database/schema name - * @return \Magento\DB\Ddl\Table + * @return Table */ public function newTable($tableName = null, $schemaName = null) { - $table = new \Magento\DB\Ddl\Table(); + $table = new Table(); if ($tableName !== null) { $table->setName($tableName); } @@ -2036,11 +2055,11 @@ class Mysql extends \Zend_Db_Adapter_Pdo_Mysql implements \Magento\DB\Adapter\Ad /** * Create table * - * @param \Magento\DB\Ddl\Table $table + * @param Table $table * @throws \Zend_Db_Exception - * @return \Zend_Db_Pdo_Statement + * @return \Zend_Db_Statement_Pdo */ - public function createTable(\Magento\DB\Ddl\Table $table) + public function createTable(Table $table) { $columns = $table->getColumns(); foreach ($columns as $columnEntry) { @@ -2066,11 +2085,11 @@ class Mysql extends \Zend_Db_Adapter_Pdo_Mysql implements \Magento\DB\Adapter\Ad /** * Retrieve columns and primary keys definition array for create table * - * @param \Magento\DB\Ddl\Table $table - * @return array + * @param Table $table + * @return string[] * @throws \Zend_Db_Exception */ - protected function _getColumnsDefinition(\Magento\DB\Ddl\Table $table) + protected function _getColumnsDefinition(Table $table) { $definition = array(); $primary = array(); @@ -2104,10 +2123,10 @@ class Mysql extends \Zend_Db_Adapter_Pdo_Mysql implements \Magento\DB\Adapter\Ad /** * Retrieve table indexes definition array for create table * - * @param \Magento\DB\Ddl\Table $table - * @return array + * @param Table $table + * @return string[] */ - protected function _getIndexesDefinition(\Magento\DB\Ddl\Table $table) + protected function _getIndexesDefinition(Table $table) { $definition = array(); $indexes = $table->getIndexes(); @@ -2150,10 +2169,10 @@ class Mysql extends \Zend_Db_Adapter_Pdo_Mysql implements \Magento\DB\Adapter\Ad /** * Retrieve table foreign keys definition array for create table * - * @param \Magento\DB\Ddl\Table $table - * @return array + * @param Table $table + * @return string[] */ - protected function _getForeignKeysDefinition(\Magento\DB\Ddl\Table $table) + protected function _getForeignKeysDefinition(Table $table) { $definition = array(); $relations = $table->getForeignKeys(); @@ -2180,11 +2199,11 @@ class Mysql extends \Zend_Db_Adapter_Pdo_Mysql implements \Magento\DB\Adapter\Ad /** * Retrieve table options definition array for create table * - * @param \Magento\DB\Ddl\Table $table - * @return array + * @param Table $table + * @return string[] * @throws \Zend_Db_Exception */ - protected function _getOptionsDefinition(\Magento\DB\Ddl\Table $table) + protected function _getOptionsDefinition(Table $table) { $definition = array(); $comment = $table->getComment(); @@ -2262,15 +2281,15 @@ class Mysql extends \Zend_Db_Adapter_Pdo_Mysql implements \Magento\DB\Adapter\Ad // column size $cType = $this->_ddlColumnTypes[$ddlType]; switch ($ddlType) { - case \Magento\DB\Ddl\Table::TYPE_SMALLINT: - case \Magento\DB\Ddl\Table::TYPE_INTEGER: - case \Magento\DB\Ddl\Table::TYPE_BIGINT: + case Table::TYPE_SMALLINT: + case Table::TYPE_INTEGER: + case Table::TYPE_BIGINT: if (!empty($options['UNSIGNED'])) { $cUnsigned = true; } break; - case \Magento\DB\Ddl\Table::TYPE_DECIMAL: - case \Magento\DB\Ddl\Table::TYPE_NUMERIC: + case Table::TYPE_DECIMAL: + case Table::TYPE_NUMERIC: $precision = 10; $scale = 0; $match = array(); @@ -2287,23 +2306,23 @@ class Mysql extends \Zend_Db_Adapter_Pdo_Mysql implements \Magento\DB\Adapter\Ad } $cType .= sprintf('(%d,%d)', $precision, $scale); break; - case \Magento\DB\Ddl\Table::TYPE_TEXT: - case \Magento\DB\Ddl\Table::TYPE_BLOB: - case \Magento\DB\Ddl\Table::TYPE_VARBINARY: + case Table::TYPE_TEXT: + case Table::TYPE_BLOB: + case Table::TYPE_VARBINARY: if (empty($options['LENGTH'])) { - $length = \Magento\DB\Ddl\Table::DEFAULT_TEXT_SIZE; + $length = Table::DEFAULT_TEXT_SIZE; } else { $length = $this->_parseTextSize($options['LENGTH']); } if ($length <= 255) { - $cType = $ddlType == \Magento\DB\Ddl\Table::TYPE_TEXT ? 'varchar' : 'varbinary'; + $cType = $ddlType == Table::TYPE_TEXT ? 'varchar' : 'varbinary'; $cType = sprintf('%s(%d)', $cType, $length); } else if ($length > 255 && $length <= 65536) { - $cType = $ddlType == \Magento\DB\Ddl\Table::TYPE_TEXT ? 'text' : 'blob'; + $cType = $ddlType == Table::TYPE_TEXT ? 'text' : 'blob'; } else if ($length > 65536 && $length <= 16777216) { - $cType = $ddlType == \Magento\DB\Ddl\Table::TYPE_TEXT ? 'mediumtext' : 'mediumblob'; + $cType = $ddlType == Table::TYPE_TEXT ? 'mediumtext' : 'mediumblob'; } else { - $cType = $ddlType == \Magento\DB\Ddl\Table::TYPE_TEXT ? 'longtext' : 'longblob'; + $cType = $ddlType == Table::TYPE_TEXT ? 'longtext' : 'longblob'; } break; } @@ -2327,14 +2346,14 @@ class Mysql extends \Zend_Db_Adapter_Pdo_Mysql implements \Magento\DB\Adapter\Ad } // prepare default value string - if ($ddlType == \Magento\DB\Ddl\Table::TYPE_TIMESTAMP) { + if ($ddlType == Table::TYPE_TIMESTAMP) { if ($cDefault === null) { $cDefault = new \Zend_Db_Expr('NULL'); - } elseif ($cDefault == \Magento\DB\Ddl\Table::TIMESTAMP_INIT) { + } elseif ($cDefault == Table::TIMESTAMP_INIT) { $cDefault = new \Zend_Db_Expr('CURRENT_TIMESTAMP'); - } else if ($cDefault == \Magento\DB\Ddl\Table::TIMESTAMP_UPDATE) { + } else if ($cDefault == Table::TIMESTAMP_UPDATE) { $cDefault = new \Zend_Db_Expr('0 ON UPDATE CURRENT_TIMESTAMP'); - } else if ($cDefault == \Magento\DB\Ddl\Table::TIMESTAMP_INIT_UPDATE) { + } else if ($cDefault == Table::TIMESTAMP_INIT_UPDATE) { $cDefault = new \Zend_Db_Expr('CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP'); } else if ($cNullable && !$cDefault) { $cDefault = new \Zend_Db_Expr('NULL'); @@ -2366,7 +2385,7 @@ class Mysql extends \Zend_Db_Adapter_Pdo_Mysql implements \Magento\DB\Adapter\Ad * * @param string $tableName * @param string $schemaName - * @return boolean + * @return true */ public function dropTable($tableName, $schemaName = null) { @@ -2382,7 +2401,7 @@ class Mysql extends \Zend_Db_Adapter_Pdo_Mysql implements \Magento\DB\Adapter\Ad * * @param string $tableName * @param string $schemaName - * @return \Magento\DB\Adapter\Pdo\Mysql + * @return $this * @throws \Zend_Db_Exception */ public function truncateTable($tableName, $schemaName = null) @@ -2403,7 +2422,7 @@ class Mysql extends \Zend_Db_Adapter_Pdo_Mysql implements \Magento\DB\Adapter\Ad * * @param string $tableName * @param string $schemaName - * @return boolean + * @return bool */ public function isTableExists($tableName, $schemaName = null) { @@ -2416,7 +2435,7 @@ class Mysql extends \Zend_Db_Adapter_Pdo_Mysql implements \Magento\DB\Adapter\Ad * @param string $oldTableName * @param string $newTableName * @param string $schemaName - * @return boolean + * @return true * @throws \Zend_Db_Exception */ public function renameTable($oldTableName, $newTableName, $schemaName = null) @@ -2451,14 +2470,14 @@ class Mysql extends \Zend_Db_Adapter_Pdo_Mysql implements \Magento\DB\Adapter\Ad * @throws \Zend_Db_Exception|Exception */ public function addIndex($tableName, $indexName, $fields, - $indexType = \Magento\DB\Adapter\AdapterInterface::INDEX_TYPE_INDEX, $schemaName = null) + $indexType = AdapterInterface::INDEX_TYPE_INDEX, $schemaName = null) { $columns = $this->describeTable($tableName, $schemaName); $keyList = $this->getIndexList($tableName, $schemaName); $query = sprintf('ALTER TABLE %s', $this->quoteIdentifier($this->_getTableName($tableName, $schemaName))); if (isset($keyList[strtoupper($indexName)])) { - if ($keyList[strtoupper($indexName)]['INDEX_TYPE'] == \Magento\DB\Adapter\AdapterInterface::INDEX_TYPE_PRIMARY) { + if ($keyList[strtoupper($indexName)]['INDEX_TYPE'] == AdapterInterface::INDEX_TYPE_PRIMARY) { $query .= ' DROP PRIMARY KEY,'; } else { $query .= sprintf(' DROP INDEX %s,', $this->quoteIdentifier($indexName)); @@ -2481,13 +2500,13 @@ class Mysql extends \Zend_Db_Adapter_Pdo_Mysql implements \Magento\DB\Adapter\Ad $fieldSql = implode(',', $fieldSql); switch (strtolower($indexType)) { - case \Magento\DB\Adapter\AdapterInterface::INDEX_TYPE_PRIMARY: + case AdapterInterface::INDEX_TYPE_PRIMARY: $condition = 'PRIMARY KEY'; break; - case \Magento\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE: + case AdapterInterface::INDEX_TYPE_UNIQUE: $condition = 'UNIQUE ' . $this->quoteIdentifier($indexName); break; - case \Magento\DB\Adapter\AdapterInterface::INDEX_TYPE_FULLTEXT: + case AdapterInterface::INDEX_TYPE_FULLTEXT: $condition = 'FULLTEXT ' . $this->quoteIdentifier($indexName); break; default: @@ -2526,7 +2545,7 @@ class Mysql extends \Zend_Db_Adapter_Pdo_Mysql implements \Magento\DB\Adapter\Ad * @param string $tableName * @param string $keyName * @param string $schemaName - * @return bool|Zend_Db_Statement_Interface + * @return true|\Zend_Db_Statement_Interface */ public function dropIndex($tableName, $keyName, $schemaName = null) { @@ -2561,14 +2580,14 @@ class Mysql extends \Zend_Db_Adapter_Pdo_Mysql implements \Magento\DB\Adapter\Ad * @param string $refColumnName * @param string $onDelete * @param string $onUpdate - * @param boolean $purge trying remove invalid data + * @param bool $purge trying remove invalid data * @param string $schemaName * @param string $refSchemaName - * @return \Magento\DB\Adapter\Pdo\Mysql + * @return \Zend_Db_Statement_Interface */ public function addForeignKey($fkName, $tableName, $columnName, $refTableName, $refColumnName, - $onDelete = \Magento\DB\Adapter\AdapterInterface::FK_ACTION_CASCADE, - $onUpdate = \Magento\DB\Adapter\AdapterInterface::FK_ACTION_CASCADE, + $onDelete = AdapterInterface::FK_ACTION_CASCADE, + $onUpdate = AdapterInterface::FK_ACTION_CASCADE, $purge = false, $schemaName = null, $refSchemaName = null) { $this->dropForeignKey($tableName, $fkName, $schemaName); @@ -2600,8 +2619,8 @@ class Mysql extends \Zend_Db_Adapter_Pdo_Mysql implements \Magento\DB\Adapter\Ad /** * Format Date to internal database date format * - * @param int|string|Zend_Date $date - * @param boolean $includeTime + * @param int|string|\Zend_Date $date + * @param bool $includeTime * @return \Zend_Db_Expr */ public function formatDate($date, $includeTime = true) @@ -2618,7 +2637,7 @@ class Mysql extends \Zend_Db_Adapter_Pdo_Mysql implements \Magento\DB\Adapter\Ad /** * Run additional environment before setup * - * @return \Magento\DB\Adapter\Pdo\Mysql + * @return $this */ public function startSetup() { @@ -2632,7 +2651,7 @@ class Mysql extends \Zend_Db_Adapter_Pdo_Mysql implements \Magento\DB\Adapter\Ad /** * Run additional environment after setup * - * @return \Magento\DB\Adapter\Pdo\Mysql + * @return $this */ public function endSetup() { @@ -2668,7 +2687,7 @@ class Mysql extends \Zend_Db_Adapter_Pdo_Mysql implements \Magento\DB\Adapter\Ad * If non matched - sequential array is expected and OR conditions * will be built using above mentioned structure * - * @param string|array $fieldName + * @param string $fieldName * @param integer|string|array $condition * @return string */ @@ -2739,7 +2758,7 @@ class Mysql extends \Zend_Db_Adapter_Pdo_Mysql implements \Magento\DB\Adapter\Ad /** * Prepare Sql condition * - * @param $text Condition value + * @param string $text Condition value * @param mixed $value * @param string $fieldName * @return string @@ -2783,7 +2802,7 @@ class Mysql extends \Zend_Db_Adapter_Pdo_Mysql implements \Magento\DB\Adapter\Ad if ($value instanceof \Zend_Db_Expr) { return $value; } - if ($value instanceof \Magento\DB\Statement\Parameter) { + if ($value instanceof Parameter) { return $value; } @@ -2857,9 +2876,10 @@ class Mysql extends \Zend_Db_Adapter_Pdo_Mysql implements \Magento\DB\Adapter\Ad /** * Generate fragment of SQL, that check condition and return true or false value * - * @param \Zend_Db_Expr|Zend_Db_Select|string $expression + * @param \Zend_Db_Expr|\Zend_Db_Select|string $expression * @param string $true true value * @param string $false false value + * @return \Zend_Db_Expr */ public function getCheckSql($expression, $true, $false) { @@ -2875,8 +2895,8 @@ class Mysql extends \Zend_Db_Adapter_Pdo_Mysql implements \Magento\DB\Adapter\Ad /** * Returns valid IFNULL expression * - * @param \Zend_Db_Expr|Zend_Db_Select|string $expression - * @param string $value OPTIONAL. Applies when $expression is NULL + * @param \Zend_Db_Expr|\Zend_Db_Select|string $expression + * @param string|int $value OPTIONAL. Applies when $expression is NULL * @return \Zend_Db_Expr */ public function getIfNullSql($expression, $value = 0) @@ -2897,6 +2917,7 @@ class Mysql extends \Zend_Db_Adapter_Pdo_Mysql implements \Magento\DB\Adapter\Ad * @param string $valueName Name of value to check * @param array $casesResults Cases and results * @param string $defaultValue value to use if value doesn't confirm to any cases + * @return \Zend_Db_Expr */ public function getCaseSql($valueName, $casesResults, $defaultValue = null) { @@ -2916,7 +2937,7 @@ class Mysql extends \Zend_Db_Adapter_Pdo_Mysql implements \Magento\DB\Adapter\Ad * Generate fragment of SQL, that combine together (concatenate) the results from data array * All arguments in data must be quoted * - * @param array $data + * @param string[] $data * @param string $separator concatenate with separator * @return \Zend_Db_Expr */ @@ -2943,7 +2964,7 @@ class Mysql extends \Zend_Db_Adapter_Pdo_Mysql implements \Magento\DB\Adapter\Ad * (minimum-valued) argument * All arguments in data must be quoted * - * @param array $data + * @param string[] $data * @return \Zend_Db_Expr */ public function getLeastSql(array $data) @@ -2956,7 +2977,7 @@ class Mysql extends \Zend_Db_Adapter_Pdo_Mysql implements \Magento\DB\Adapter\Ad * (maximum-valued) argument * All arguments in data must be quoted * - * @param array $data + * @param string[] $data * @return \Zend_Db_Expr */ public function getGreatestSql(array $data) @@ -3050,8 +3071,8 @@ class Mysql extends \Zend_Db_Adapter_Pdo_Mysql implements \Magento\DB\Adapter\Ad * Prepare substring sql function * * @param \Zend_Db_Expr|string $stringExpression quoted field name or SQL statement - * @param int|string|Zend_Db_Expr $pos - * @param int|string|Zend_Db_Expr|null $len + * @param int|string|\Zend_Db_Expr $pos + * @param int|string|\Zend_Db_Expr|null $len * @return \Zend_Db_Expr */ public function getSubstringSql($stringExpression, $pos, $len = null) @@ -3096,9 +3117,9 @@ class Mysql extends \Zend_Db_Adapter_Pdo_Mysql implements \Magento\DB\Adapter\Ad /** * Minus superfluous characters from hash. * - * @param $hash - * @param $prefix - * @param $maxCharacters + * @param string $hash + * @param string $prefix + * @param int $maxCharacters * @return string */ protected function _minusSuperfluous($hash, $prefix, $maxCharacters) @@ -3121,7 +3142,7 @@ class Mysql extends \Zend_Db_Adapter_Pdo_Mysql implements \Magento\DB\Adapter\Ad { $prefix = 't_'; if (strlen($tableName) > self::LENGTH_TABLE_NAME) { - $shortName = \Magento\DB\Helper::shortName($tableName); + $shortName = Helper::shortName($tableName); if (strlen($shortName) > self::LENGTH_TABLE_NAME) { $hash = md5($tableName); if (strlen($prefix.$hash) > self::LENGTH_TABLE_NAME) { @@ -3142,7 +3163,7 @@ class Mysql extends \Zend_Db_Adapter_Pdo_Mysql implements \Magento\DB\Adapter\Ad * Check index name length and allowed symbols * * @param string $tableName - * @param string|array $fields the columns list + * @param string|string[] $fields the columns list * @param string $indexType * @return string */ @@ -3153,15 +3174,15 @@ class Mysql extends \Zend_Db_Adapter_Pdo_Mysql implements \Magento\DB\Adapter\Ad } switch (strtolower($indexType)) { - case \Magento\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE: + case AdapterInterface::INDEX_TYPE_UNIQUE: $prefix = 'unq_'; $shortPrefix = 'u_'; break; - case \Magento\DB\Adapter\AdapterInterface::INDEX_TYPE_FULLTEXT: + case AdapterInterface::INDEX_TYPE_FULLTEXT: $prefix = 'fti_'; $shortPrefix = 'f_'; break; - case \Magento\DB\Adapter\AdapterInterface::INDEX_TYPE_INDEX: + case AdapterInterface::INDEX_TYPE_INDEX: default: $prefix = 'idx_'; $shortPrefix = 'i_'; @@ -3170,7 +3191,7 @@ class Mysql extends \Zend_Db_Adapter_Pdo_Mysql implements \Magento\DB\Adapter\Ad $hash = $tableName . '_' . $fields; if (strlen($hash) + strlen($prefix) > self::LENGTH_INDEX_NAME) { - $short = \Magento\DB\Helper::shortName($prefix . $hash); + $short = Helper::shortName($prefix . $hash); if (strlen($short) > self::LENGTH_INDEX_NAME) { $hash = md5($hash); if (strlen($hash) + strlen($shortPrefix) > self::LENGTH_INDEX_NAME) { @@ -3201,7 +3222,7 @@ class Mysql extends \Zend_Db_Adapter_Pdo_Mysql implements \Magento\DB\Adapter\Ad $prefix = 'fk_'; $hash = sprintf('%s_%s_%s_%s', $priTableName, $priColumnName, $refTableName, $refColumnName); if (strlen($prefix.$hash) > self::LENGTH_FOREIGN_NAME) { - $short = \Magento\DB\Helper::shortName($prefix.$hash); + $short = Helper::shortName($prefix.$hash); if (strlen($short) > self::LENGTH_FOREIGN_NAME) { $hash = md5($hash); if (strlen($prefix.$hash) > self::LENGTH_FOREIGN_NAME) { @@ -3224,7 +3245,7 @@ class Mysql extends \Zend_Db_Adapter_Pdo_Mysql implements \Magento\DB\Adapter\Ad * * @param string $tableName * @param string $schemaName - * @return \Magento\DB\Adapter\Pdo\Mysql + * @return $this */ public function disableTableKeys($tableName, $schemaName = null) { @@ -3240,7 +3261,7 @@ class Mysql extends \Zend_Db_Adapter_Pdo_Mysql implements \Magento\DB\Adapter\Ad * * @param string $tableName * @param string $schemaName - * @return \Magento\DB\Adapter\Pdo\Mysql + * @return $this */ public function enableTableKeys($tableName, $schemaName = null) { @@ -3254,13 +3275,13 @@ class Mysql extends \Zend_Db_Adapter_Pdo_Mysql implements \Magento\DB\Adapter\Ad /** * Get insert from Select object query * - * @param \Magento\DB\Select $select + * @param Select $select * @param string $table insert into table * @param array $fields * @param int $mode * @return string */ - public function insertFromSelect(\Magento\DB\Select $select, $table, array $fields = array(), $mode = false) + public function insertFromSelect(Select $select, $table, array $fields = array(), $mode = false) { $query = 'INSERT'; if ($mode == self::INSERT_IGNORE) { @@ -3299,11 +3320,11 @@ class Mysql extends \Zend_Db_Adapter_Pdo_Mysql implements \Magento\DB\Adapter\Ad /** * Get update table query using select object for join and update * - * @param \Magento\DB\Select $select + * @param Select $select * @param string|array $table * @return string */ - public function updateFromSelect(\Magento\DB\Select $select, $table) + public function updateFromSelect(Select $select, $table) { if (!is_array($table)) { $table = array($table => $table); @@ -3374,11 +3395,11 @@ class Mysql extends \Zend_Db_Adapter_Pdo_Mysql implements \Magento\DB\Adapter\Ad /** * Get delete from select object query * - * @param \Magento\DB\Select $select + * @param Select $select * @param string $table the table name or alias used in select - * @return string|int + * @return string */ - public function deleteFromSelect(\Magento\DB\Select $select, $table) + public function deleteFromSelect(Select $select, $table) { $select = clone $select; $select->reset(\Zend_Db_Select::DISTINCT); @@ -3394,7 +3415,7 @@ class Mysql extends \Zend_Db_Adapter_Pdo_Mysql implements \Magento\DB\Adapter\Ad * * @param array|string $tableNames array of tables names | table name * @param string $schemaName schema name - * @return arrray + * @return array */ public function getTablesChecksum($tableNames, $schemaName = null) { @@ -3413,7 +3434,7 @@ class Mysql extends \Zend_Db_Adapter_Pdo_Mysql implements \Magento\DB\Adapter\Ad /** * Check if the database support STRAIGHT JOIN * - * @return boolean + * @return true */ public function supportStraightJoin() { @@ -3424,11 +3445,11 @@ class Mysql extends \Zend_Db_Adapter_Pdo_Mysql implements \Magento\DB\Adapter\Ad * Adds order by random to select object * Possible using integer field for optimization * - * @param \Magento\DB\Select $select + * @param Select $select * @param string $field - * @return \Magento\DB\Adapter\Pdo\Mysql + * @return $this */ - public function orderRand(\Magento\DB\Select $select, $field = null) + public function orderRand(Select $select, $field = null) { if ($field !== null) { $expression = new \Zend_Db_Expr(sprintf('RAND() * %s', $this->quoteIdentifier($field))); @@ -3524,14 +3545,14 @@ class Mysql extends \Zend_Db_Adapter_Pdo_Mysql implements \Magento\DB\Adapter\Ad protected function _getDdlAction($action) { switch ($action) { - case \Magento\DB\Adapter\AdapterInterface::FK_ACTION_CASCADE: - return \Magento\DB\Ddl\Table::ACTION_CASCADE; - case \Magento\DB\Adapter\AdapterInterface::FK_ACTION_SET_NULL: - return \Magento\DB\Ddl\Table::ACTION_SET_NULL; - case \Magento\DB\Adapter\AdapterInterface::FK_ACTION_RESTRICT: - return \Magento\DB\Ddl\Table::ACTION_RESTRICT; + case AdapterInterface::FK_ACTION_CASCADE: + return Table::ACTION_CASCADE; + case AdapterInterface::FK_ACTION_SET_NULL: + return Table::ACTION_SET_NULL; + case AdapterInterface::FK_ACTION_RESTRICT: + return Table::ACTION_RESTRICT; default: - return \Magento\DB\Ddl\Table::ACTION_NO_ACTION; + return Table::ACTION_NO_ACTION; } } @@ -3599,10 +3620,10 @@ class Mysql extends \Zend_Db_Adapter_Pdo_Mysql implements \Magento\DB\Adapter\Ad } if (empty($size)) { - return \Magento\DB\Ddl\Table::DEFAULT_TEXT_SIZE; + return Table::DEFAULT_TEXT_SIZE; } - if ($size >= \Magento\DB\Ddl\Table::MAX_TEXT_SIZE) { - return \Magento\DB\Ddl\Table::MAX_TEXT_SIZE; + if ($size >= Table::MAX_TEXT_SIZE) { + return Table::MAX_TEXT_SIZE; } return intval($size); @@ -3612,7 +3633,7 @@ class Mysql extends \Zend_Db_Adapter_Pdo_Mysql implements \Magento\DB\Adapter\Ad * Converts fetched blob into raw binary PHP data. * The MySQL drivers do it nice, no processing required. * - * @mixed $value + * @param mixed $value * @return mixed */ public function decodeVarbinary($value) @@ -3620,8 +3641,58 @@ class Mysql extends \Zend_Db_Adapter_Pdo_Mysql implements \Magento\DB\Adapter\Ad return $value; } + /** + * Create trigger + * + * @param \Magento\DB\Ddl\Trigger $trigger + * @throws \Zend_Db_Exception + * @return \Zend_Db_Statement_Pdo + */ + public function createTrigger(\Magento\DB\Ddl\Trigger $trigger) + { + if (!$trigger->getStatements()) { + throw new \Zend_Db_Exception(sprintf(__('Trigger %s has not statements available'), $trigger->getName())); + } + + $statements = implode("\n", $trigger->getStatements()); + + $sql = sprintf("CREATE TRIGGER %s %s %s ON %s FOR EACH ROW\nBEGIN\n%s\nEND", + $trigger->getName(), + $trigger->getTime(), + $trigger->getEvent(), + $trigger->getTable(), + $statements + ); + + return $this->query($sql); + } + + /** + * Drop trigger from database + * + * @param string $triggerName + * @param string $schemaName + * @throws \InvalidArgumentException + * @return bool + */ + public function dropTrigger($triggerName, $schemaName = null) + { + if (empty($triggerName)) { + throw new \InvalidArgumentException(__('Trigger name is not defined')); + } + + $triggerName = ($schemaName ? $schemaName . '.' : '') . $triggerName; + + $sql = 'DROP TRIGGER IF EXISTS ' . $this->quoteIdentifier($triggerName); + $this->query($sql); + + return true; + } + /** * Check if all transactions have been committed + * + * @return void */ public function __destruct() { diff --git a/lib/Magento/DB/Ddl/Table.php b/lib/Magento/DB/Ddl/Table.php index 0a6f4ca7ee1f761082933f7a87295d6fb5a46a85..1355ea20717c07357ef1de4038351f500be575e9 100644 --- a/lib/Magento/DB/Ddl/Table.php +++ b/lib/Magento/DB/Ddl/Table.php @@ -34,6 +34,8 @@ */ namespace Magento\DB\Ddl; +use \Magento\DB\Adapter\AdapterInterface; + class Table { /** @@ -182,7 +184,7 @@ class Table * Set table name * * @param string $name - * @return \Magento\DB\Ddl\Table + * @return $this */ public function setName($name) { @@ -197,7 +199,7 @@ class Table * Set schema name * * @param string $name - * @return \Magento\DB\Ddl\Table + * @return $this */ public function setSchema($name) { @@ -209,7 +211,7 @@ class Table * Set comment for table * * @param string $comment - * @return \Magento\DB\Ddl\Table + * @return $this */ public function setComment($comment) { @@ -220,8 +222,8 @@ class Table /** * Retrieve name of table * - * @throws \Zend_Db_Exception * @return string + * @throws \Zend_Db_Exception */ public function getName() { @@ -269,8 +271,8 @@ class Table * @param string|int|array $size the column length * @param array $options array of additional options * @param string $comment column description + * @return $this * @throws \Zend_Db_Exception - * @return \Magento\DB\Ddl\Table */ public function addColumn($name, $type, $size = null, $options = array(), $comment = null) { @@ -404,8 +406,8 @@ class Table * @param string $refColumn the reference table column name * @param string $onDelete the action on delete row * @param string $onUpdate the action on update + * @return $this * @throws \Zend_Db_Exception - * @return \Magento\DB\Ddl\Table */ public function addForeignKey($fkName, $column, $refTable, $refColumn, $onDelete = null, $onUpdate = null) { @@ -451,14 +453,15 @@ class Table /** * Add index to table * - * @param string $indexName the index name - * @param array|string $columns array of columns or column string - * @param array $options array of additional options - * @return \Magento\DB\Ddl\Table + * @param string $indexName the index name + * @param array|string $fields array of columns or column string + * @param array $options array of additional options + * @return $this + * @throws \Zend_Db_Exception */ public function addIndex($indexName, $fields, $options = array()) { - $idxType = \Magento\DB\Adapter\AdapterInterface::INDEX_TYPE_INDEX; + $idxType = AdapterInterface::INDEX_TYPE_INDEX; $position = 0; $columns = array(); if (!is_array($fields)) { @@ -532,7 +535,7 @@ class Table * * @param array $column * @see $this->_columns - * @return \Magento\DB\Ddl\Table + * @return $this */ public function setColumn($column) { @@ -568,7 +571,7 @@ class Table * * @param string $key * @param string $value - * @return \Magento\DB\Ddl\Table + * @return $this */ public function setOption($key, $value) { @@ -581,7 +584,7 @@ class Table * Return null if option does not exits * * @param string $key - * @return mixed + * @return null|string */ public function getOption($key) { diff --git a/lib/Magento/DB/Ddl/Trigger.php b/lib/Magento/DB/Ddl/Trigger.php new file mode 100644 index 0000000000000000000000000000000000000000..3ccd17ce3c61d5a6745935c551ae311d99a1243a --- /dev/null +++ b/lib/Magento/DB/Ddl/Trigger.php @@ -0,0 +1,273 @@ +<?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\DB\Ddl; + +class Trigger +{ + /**#@+ + * Trigger times + */ + const TIME_BEFORE = 'BEFORE'; + const TIME_AFTER = 'AFTER'; + /**#@-*/ + + /**#@+ + * Trigger events + */ + const EVENT_INSERT = 'INSERT'; + const EVENT_UPDATE = 'UPDATE'; + const EVENT_DELETE = 'DELETE'; + /**#@-*/ + + /** + * List of times available for trigger + * + * @var array + */ + protected static $listOfTimes = array( + self::TIME_BEFORE, + self::TIME_AFTER, + ); + + /** + * List of events available for trigger + * + * @var array + */ + protected static $listOfEvents = array( + self::EVENT_INSERT, + self::EVENT_UPDATE, + self::EVENT_DELETE, + ); + + /** + * Name of trigger + * + * @var string + */ + protected $name; + + /** + * Time of trigger + * + * @var string + */ + protected $time; + + /** + * Time of trigger + * + * @var string + */ + protected $event; + + /** + * Table name + * + * @var string + */ + protected $tableName; + + /** + * List of statements for trigger body + * + * @var array + */ + protected $statements = array(); + + /** + * Set trigger name + * + * @param string $name + * @throws \InvalidArgumentException + * @return \Magento\DB\Ddl\Trigger + */ + public function setName($name) + { + if (!is_string($name)) { + throw new \InvalidArgumentException(__('Trigger name should be a string')); + } + + $this->name = strtolower($name); + return $this; + } + + /** + * Retrieve name of trigger + * + * @throws \Zend_Db_Exception + * @return string + */ + public function getName() + { + if (empty($this->name)) { + throw new \Zend_Db_Exception(__('Trigger name is not defined')); + } + return $this->name; + } + + /** + * Set trigger time + * + * @param string $time + * @throws \InvalidArgumentException + * @return \Magento\DB\Ddl\Trigger + */ + public function setTime($time) + { + if (in_array($time, self::$listOfTimes)) { + $this->time = strtoupper($time); + } else { + throw new \InvalidArgumentException(__('Trigger unsupported time type')); + } + return $this; + } + + /** + * Retrieve time of trigger + * + * @throws \Zend_Db_Exception + * @return string + */ + public function getTime() + { + if (is_null($this->time)) { + throw new \Zend_Db_Exception(__('Trigger time is not defined')); + } + return $this->time; + } + + /** + * Set trigger event + * + * @param string $event + * @throws \InvalidArgumentException + * @return \Magento\DB\Ddl\Trigger + */ + public function setEvent($event) + { + if (in_array($event, self::$listOfEvents)) { + $this->event = strtoupper($event); + } else { + throw new \InvalidArgumentException(__('Trigger unsupported event type')); + } + return $this; + } + + /** + * Retrieve event of trigger + * + * @throws \Zend_Db_Exception + * @return string + */ + public function getEvent() + { + if (is_null($this->event)) { + throw new \Zend_Db_Exception(__('Trigger event is not defined')); + } + return $this->event; + } + + /** + * Set table name + * + * @param string $name + * @throws \InvalidArgumentException + * @return \Magento\DB\Ddl\Trigger + */ + public function setTable($name) + { + if (!is_string($name)) { + throw new \InvalidArgumentException(__('Trigger table name should be a string')); + } + $this->tableName = strtolower($name); + return $this; + } + + /** + * Retrieve table name + * + * @throws \Zend_Db_Exception + * @return string + */ + public function getTable() + { + if (empty($this->tableName)) { + throw new \Zend_Db_Exception(__('Trigger table name is not defined')); + } + return $this->tableName; + } + + /** + * Add statement to trigger + * + * @param string $statement + * @throws \InvalidArgumentException + * @return \Magento\DB\Ddl\Trigger + */ + public function addStatement($statement) + { + if (!is_string($statement)) { + throw new \InvalidArgumentException(__('Trigger statement should be a string')); + } + + $statement = trim($statement); + $statement = rtrim($statement, ';') . ';'; + + $this->statements[] = $statement; + + return $this; + } + + /** + * Retrieve list of statements of trigger + * + * @return array + */ + public function getStatements() + { + return $this->statements; + } + + /** + * Retrieve list of times available for trigger + * + * @return array + */ + public static function getListOfTimes() + { + return self::$listOfTimes; + } + + /** + * Retrieve list of events available for trigger + * + * @return array + */ + public static function getListOfEvents() + { + return self::$listOfEvents; + } +} diff --git a/lib/Magento/DB/Ddl/TriggerFactory.php b/lib/Magento/DB/Ddl/TriggerFactory.php new file mode 100644 index 0000000000000000000000000000000000000000..067844a03ed9d8c9814867834ce5978e02c6e29b --- /dev/null +++ b/lib/Magento/DB/Ddl/TriggerFactory.php @@ -0,0 +1,57 @@ +<?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\DB\Ddl; + +class TriggerFactory +{ + /** + * @var \Magento\ObjectManager + */ + protected $objectManager; + + /** + * @var string + */ + const INSTANCE_NAME = 'Magento\DB\Ddl\Trigger'; + + /** + * @param \Magento\ObjectManager $objectManager + */ + public function __construct(\Magento\ObjectManager $objectManager) + { + $this->_objectManager = $objectManager; + } + + /** + * Create class instance with specified parameters + * + * @param array $data + * @return \Magento\DB\Ddl\Trigger + */ + public function create(array $data = array()) + { + return $this->_objectManager->create(self::INSTANCE_NAME, $data); + } +} diff --git a/lib/Magento/DB/Helper.php b/lib/Magento/DB/Helper.php index e14b803220337af7f260a7dd6cb08c836e6eede1..7ac11cdd41aa2e0e7fadcce61bbf753767ad7ee9 100644 --- a/lib/Magento/DB/Helper.php +++ b/lib/Magento/DB/Helper.php @@ -104,6 +104,7 @@ class Helper * * @param string $from * @param string $to + * @return void */ public static function addTranslate($from, $to) { diff --git a/lib/Magento/DB/Select.php b/lib/Magento/DB/Select.php index be28f0de8db86de1b27f58e35ea3fb5ef64c448d..9ccfc285dd48c4d05bdc085c9a8e0c304c518b85 100644 --- a/lib/Magento/DB/Select.php +++ b/lib/Magento/DB/Select.php @@ -52,6 +52,8 @@ */ namespace Magento\DB; +use Magento\DB\Adapter\AdapterInterface; + class Select extends \Zend_Db_Select { /** @@ -111,9 +113,9 @@ class Select extends \Zend_Db_Select * $db->fetchAll($select, array('id' => 5)); * </code> * - * @param string $cond The WHERE condition. - * @param string $value OPTIONAL A single value to quote into the condition. - * @param string|int|null $type OPTIONAL The type of the given value + * @param string $cond The WHERE condition. + * @param string $value OPTIONAL A single value to quote into the condition. + * @param string|int|null $type OPTIONAL The type of the given value * @return \Magento\DB\Select */ public function where($cond, $value = null, $type = null) @@ -133,7 +135,7 @@ class Select extends \Zend_Db_Select /** * Reset unused LEFT JOIN(s) * - * @return \Magento\DB\Select + * @return $this */ public function resetJoinLeft() { @@ -193,7 +195,7 @@ class Select extends \Zend_Db_Select /** * Validate LEFT joins, and remove it if not exists * - * @return \Magento\DB\Select + * @return $this */ protected function _resetJoinLeft() { @@ -293,7 +295,7 @@ class Select extends \Zend_Db_Select * * @param int $count OPTIONAL The number of rows to return. * @param int $offset OPTIONAL Start returning after this many rows. - * @return \Zend_Db_Select This \Zend_Db_Select object. + * @return $this */ public function limit($count = null, $offset = null) { @@ -331,7 +333,7 @@ class Select extends \Zend_Db_Select */ public function insertFromSelect($tableName, $fields = array(), $onDuplicate = true) { - $mode = $onDuplicate ? \Magento\DB\Adapter\AdapterInterface::INSERT_ON_DUPLICATE : false; + $mode = $onDuplicate ? AdapterInterface::INSERT_ON_DUPLICATE : false; return $this->getAdapter()->insertFromSelect($this, $tableName, $fields, $mode); } @@ -345,7 +347,7 @@ class Select extends \Zend_Db_Select public function insertIgnoreFromSelect($tableName, $fields = array()) { return $this->getAdapter() - ->insertFromSelect($this, $tableName, $fields, \Magento\DB\Adapter\AdapterInterface::INSERT_IGNORE); + ->insertFromSelect($this, $tableName, $fields, AdapterInterface::INSERT_IGNORE); } /** @@ -364,7 +366,7 @@ class Select extends \Zend_Db_Select * * @param string $part * @param mixed $value - * @return \Magento\DB\Select + * @return $this * @throws \Zend_Db_Select_Exception */ public function setPart($part, $value) @@ -381,7 +383,7 @@ class Select extends \Zend_Db_Select * Use a STRAIGHT_JOIN for the SQL Select * * @param bool $flag Whether or not the SELECT use STRAIGHT_JOIN (default true). - * @return \Zend_Db_Select This \Zend_Db_Select object. + * @return $this */ public function useStraightJoin($flag = true) { @@ -412,6 +414,7 @@ class Select extends \Zend_Db_Select * but possibly as a string containing one column. * @param bool|string $afterCorrelationName True if it should be prepended, * a correlation name if it should be inserted + * @return void */ protected function _tableCols($correlationName, $cols, $afterCorrelationName = null) { @@ -420,7 +423,7 @@ class Select extends \Zend_Db_Select } foreach ($cols as $k => $v) { - if ($v instanceof \Magento\DB\Select) { + if ($v instanceof Select) { $cols[$k] = new \Zend_Db_Expr(sprintf('(%s)', $v->assemble())); } } @@ -432,7 +435,7 @@ class Select extends \Zend_Db_Select * Adds the random order to query * * @param string $field integer field name - * @return \Magento\DB\Select + * @return $this */ public function orderRand($field = null) { @@ -454,13 +457,14 @@ class Select extends \Zend_Db_Select return $sql; } + /** * Add EXISTS clause * - * @param \Magento\DB\Select $select + * @param Select $select * @param string $joinCondition * @param bool $isExists - * @return \Magento\DB\Select + * @return $this */ public function exists($select, $joinCondition, $isExists = true) { diff --git a/lib/Magento/DB/Statement/Parameter.php b/lib/Magento/DB/Statement/Parameter.php index a33d953d7a85588e32b4510a7108e243995c14fa..a9fd3f778733302b5a9d861672accc0316926846 100644 --- a/lib/Magento/DB/Statement/Parameter.php +++ b/lib/Magento/DB/Statement/Parameter.php @@ -43,6 +43,8 @@ class Parameter { /** * Actual parameter value + * + * @var mixed */ protected $_value = null; @@ -52,26 +54,31 @@ class Parameter * A shortcut setting to notify DB adapter, that value must be bound in a default way, as adapter binds * BLOB data to query placeholders. If FALSE, then specific settings from $_dataType, $_length, * $_driverOptions will be used. + * @var bool */ protected $_isBlob = false; /* * Data type to set to DB driver during parameter bind + * @var mixed */ protected $_dataType = null; /* * Length to set to DB driver during parameter bind + * @var mixed */ protected $_length = null; /* * Specific driver options to set to DB driver during parameter bind + * @var mixed */ protected $_driverOptions = null; /* * Additional information to be used by DB adapter internally + * @var \Magento\Object */ protected $_additional = null; @@ -79,7 +86,7 @@ class Parameter * Inits instance * * @param mixed $value - * @return \Magento\DB\Statement\Parameter + * @return $this */ public function __construct($value) { @@ -92,7 +99,7 @@ class Parameter * Sets parameter value. * * @param mixed $value - * @return \Magento\DB\Statement\Parameter + * @return $this */ public function setValue($value) { @@ -118,7 +125,7 @@ class Parameter * as a BLOB value. * * @param bool $isBlob - * @return \Magento\DB\Statement\Parameter + * @return $this */ public function setIsBlob($isBlob) { @@ -143,7 +150,7 @@ class Parameter * Sets data type option to be used during binding parameter value. * * @param mixed $dataType - * @return \Magento\DB\Statement\Parameter + * @return $this */ public function setDataType($dataType) { @@ -165,7 +172,7 @@ class Parameter * Sets length option to be used during binding parameter value. * * @param mixed $length - * @return \Magento\DB\Statement\Parameter + * @return $this */ public function setLength($length) { @@ -187,7 +194,7 @@ class Parameter * Sets specific driver options to be used during binding parameter value. * * @param mixed $driverOptions - * @return \Magento\DB\Statement\Parameter + * @return $this */ public function setDriverOptions($driverOptions) { @@ -210,7 +217,7 @@ class Parameter * Set there any data you want to pass along with query parameter. * * @param \Magento\Object $additional - * @return \Magento\DB\Statement\Parameter + * @return $this */ public function setAdditional($additional) { diff --git a/lib/Magento/DB/Statement/Pdo/Mysql.php b/lib/Magento/DB/Statement/Pdo/Mysql.php index 73b6f6fce90cd1fec03d82f66d2ee77ce5d02f7c..82ccb446977dfea9f81dd3be51135350c1c59ce3 100644 --- a/lib/Magento/DB/Statement/Pdo/Mysql.php +++ b/lib/Magento/DB/Statement/Pdo/Mysql.php @@ -34,6 +34,8 @@ */ namespace Magento\DB\Statement\Pdo; +use Magento\DB\Statement\Parameter; + class Mysql extends \Zend_Db_Statement_Pdo { /** @@ -63,7 +65,7 @@ class Mysql extends \Zend_Db_Statement_Pdo $length = null; $driverOptions = null; - if ($param instanceof \Magento\DB\Statement\Parameter) { + if ($param instanceof Parameter) { if ($param->getIsBlob()) { // Nothing to do there - default options are fine for MySQL driver } else { @@ -99,7 +101,7 @@ class Mysql extends \Zend_Db_Statement_Pdo $specialExecute = false; if ($params) { foreach ($params as $param) { - if ($param instanceof \Magento\DB\Statement\Parameter) { + if ($param instanceof Parameter) { $specialExecute = true; break; } diff --git a/lib/Magento/DB/Tree.php b/lib/Magento/DB/Tree.php index 0f26844807f402c3544c7771a5734dd1ade9f0ef..906d4b14ecd332d326f6a9420fcc7473c9c6bf7e 100644 --- a/lib/Magento/DB/Tree.php +++ b/lib/Magento/DB/Tree.php @@ -27,17 +27,44 @@ namespace Magento\DB; \Zend_Loader::loadClass('\Zend_Db_Select'); \Zend_Loader::loadClass('\Magento\DB\Tree\Node'); \Zend_Loader::loadClass('\Magento\DB\Tree\NodeSet'); +use Magento\DB\Tree\Node; +use Magento\DB\Tree\NodeSet; +use Magento\DB\Tree\TreeException; + /** * Magento Library */ require_once 'Tree/TreeException.php'; class Tree { + /** + * @var string|int + */ private $_id; + + /** + * @var int + */ private $_left; + + /** + * @var int + */ private $_right; + + /** + * @var int + */ private $_level; + + /** + * @var int + */ private $_pid; + + /** + * @var array + */ private $_nodesInfo = array(); /** @@ -61,11 +88,14 @@ class Tree */ private $_db; + /** + * @var string + */ private $_table; /** * @param array $config - * @throws \Magento\DB\Tree\TreeException + * @throws TreeException */ public function __construct($config = array()) { @@ -82,7 +112,7 @@ class Tree // make sure it's a \Zend_Db_Adapter if (! $connection instanceof \Zend_Db_Adapter_Abstract) { - throw new \Magento\DB\Tree\TreeException('db object does not implement \Zend_Db_Adapter_Abstract'); + throw new TreeException('db object does not implement \Zend_Db_Adapter_Abstract'); } // save the connection @@ -92,7 +122,7 @@ class Tree $conn->setAttribute (\PDO::ATTR_EMULATE_PREPARES, true); } } else { - throw new \Magento\DB\Tree\TreeException('db object is not set in config'); + throw new TreeException('db object is not set in config'); } if (!empty($config['table'])) { @@ -134,7 +164,7 @@ class Tree * set name of id field * * @param string $name - * @return \Magento\DB\Tree + * @return $this */ public function setIdField($name) { @@ -146,7 +176,7 @@ class Tree * set name of left field * * @param string $name - * @return \Magento\DB\Tree + * @return $this */ public function setLeftField($name) { @@ -158,7 +188,7 @@ class Tree * set name of right field * * @param string $name - * @return \Magento\DB\Tree + * @return $this */ public function setRightField($name) { @@ -170,7 +200,7 @@ class Tree * set name of level field * * @param string $name - * @return \Magento\DB\Tree + * @return $this */ public function setLevelField($name) { @@ -182,7 +212,7 @@ class Tree * set name of pid Field * * @param string $name - * @return \Magento\DB\Tree + * @return $this */ public function setPidField($name) { @@ -194,7 +224,7 @@ class Tree * set table name * * @param string $name - * @return \Magento\DB\Tree + * @return $this */ public function setTable($name) { @@ -262,8 +292,8 @@ class Tree /** * @param string|int $nodeId - * @param mixed $data - * @return bool|string + * @param array $data + * @return false|string */ public function appendChild($nodeId, $data) { @@ -331,7 +361,7 @@ class Tree /** * @param string|int $nodeId - * @return bool|\Magento\DB\Tree\Node + * @return bool|Node */ public function removeNode($nodeId) { @@ -365,7 +395,7 @@ class Tree . $this->_right . ' > ' . $info[$this->_right]; $this->_db->query($sql); $this->_db->commit(); - return new \Magento\DB\Tree\Node($info, $this->getKeys()); + return new Node($info, $this->getKeys()); } catch (\Exception $e) { $this->_db->rollBack(); echo $e->getMessage(); @@ -471,6 +501,7 @@ class Tree * @param string|int $eId * @param string|int $pId * @param string|int $aId + * @return void */ public function moveNodes($eId, $pId, $aId = 0) { @@ -562,6 +593,7 @@ class Tree * @param string $tableName * @param string $joinCondition * @param string $fields + * @return void */ public function addTable($tableName, $joinCondition, $fields = '*') { @@ -573,6 +605,7 @@ class Tree /** * @param \Zend_Db_Select $select + * @return void */ protected function _addExtTablesToSelect(\Zend_Db_Select &$select) { @@ -585,7 +618,7 @@ class Tree * @param string|int $nodeId * @param int $startLevel * @param int $endLevel - * @return \Magento\DB\Tree\NodeSet + * @return NodeSet */ public function getChildren($nodeId, $startLevel = 0, $endLevel = 0) { @@ -616,16 +649,16 @@ class Tree //echo $dbSelect->__toString(); $data = $this->_db->fetchAll($dbSelect, $data); - $nodeSet = new \Magento\DB\Tree\NodeSet(); + $nodeSet = new NodeSet(); foreach ($data as $node) { - $nodeSet->addNode(new \Magento\DB\Tree\Node($node, $this->getKeys())); + $nodeSet->addNode(new Node($node, $this->getKeys())); } return $nodeSet; } /** * @param string|int $nodeId - * @return \Magento\DB\Tree\Node + * @return Node */ public function getNode($nodeId) { @@ -640,6 +673,6 @@ class Tree $data = $this->_db->fetchRow($dbSelect, $data); - return new \Magento\DB\Tree\Node($data, $this->getKeys()); + return new Node($data, $this->getKeys()); } } diff --git a/lib/Magento/DB/Tree/Node.php b/lib/Magento/DB/Tree/Node.php index 15586bbfaf80319aef5bd42f2929806f6704728a..b9982998ced3d80fa549c9438aae11b0ed91a6e0 100644 --- a/lib/Magento/DB/Tree/Node.php +++ b/lib/Magento/DB/Tree/Node.php @@ -27,29 +27,68 @@ namespace Magento\DB\Tree; - +use Magento\DB\Tree\Node\NodeException; class Node { + /** + * @var int + */ private $left; + + /** + * @var int + */ private $right; + + /** + * @var string|int + */ private $id; + + /** + * @var string|int + */ private $pid; + + /** + * @var int + */ private $level; + + /** + * @var string + */ private $title; - private $data; + /** + * @var array + */ + private $data; + /** + * @var bool + */ public $hasChild = false; + + /** + * @var float|int + */ public $numChild = 0; + /** + * @param array $nodeData + * @param array $keys + * @return $this + * @throws NodeException + */ function __construct($nodeData, $keys) { if (empty($nodeData)) { - throw new \Magento\DB\Tree\Node\NodeException('Empty array of node information'); + throw new NodeException('Empty array of node information'); } if (empty($keys)) { - throw new \Magento\DB\Tree\Node\NodeException('Empty keys array'); + throw new NodeException('Empty keys array'); } $this->id = $nodeData[$keys['id']]; @@ -67,6 +106,10 @@ class Node { return $this; } + /** + * @param string $name + * @return null|array + */ function getData($name) { if (isset($this->data[$name])) { return $this->data[$name]; @@ -75,30 +118,45 @@ class Node { } } + /** + * @return int + */ function getLevel() { return $this->level; } + /** + * @return int + */ function getLeft() { return $this->left; } + /** + * @return int + */ function getRight() { return $this->right; } + /** + * @return string|int + */ function getPid() { return $this->pid; } + /** + * @return string|int + */ function getId() { return $this->id; } /** - * Return true if node have chield + * Return true if node has child * - * @return boolean + * @return bool */ function isParent() { if ($this->right - $this->left > 1) { diff --git a/lib/Magento/DB/Tree/NodeSet.php b/lib/Magento/DB/Tree/NodeSet.php index 128025653b42ecd12c482d2336b4f14fcce1c877..5bc14f9e50f6cfde31b93c54f0ee24c397e51567 100644 --- a/lib/Magento/DB/Tree/NodeSet.php +++ b/lib/Magento/DB/Tree/NodeSet.php @@ -33,10 +33,20 @@ namespace Magento\DB\Tree; class NodeSet implements \Iterator { + /** + * @var Node[] + */ private $_nodes = array(); + + /** + * @var int + */ private $_currentNode = 0; - private $_current = 0; + /** + * @var int + */ + private $_current = 0; function __construct() { $this->_nodes = array(); @@ -45,23 +55,33 @@ class NodeSet implements \Iterator $this->count = 0; } - - - function addNode(\Magento\DB\Tree\Node $node) { + /** + * @param Node $node + * @return int + */ + function addNode(Node $node) { $this->_nodes[$this->_currentNode] = $node; $this->count++; return ++$this->_currentNode; } + /** + * @return int + */ function count() { return $this->count; } - + /** + * @return bool + */ function valid() { return isset($this->_nodes[$this->_current]); } + /** + * @return false|int + */ function next() { if ($this->_current > $this->_currentNode) { return false; @@ -70,15 +90,23 @@ class NodeSet implements \Iterator } } + /** + * @return int + */ function key() { return $this->_current; } - + /** + * @return Node + */ function current() { return $this->_nodes[$this->_current]; } + /** + * @return void + */ function rewind() { $this->_current = 0; } diff --git a/lib/Magento/Data/Collection.php b/lib/Magento/Data/Collection.php index d39caed4dd9b86ebd0b0cdec831d72540974d9a1..a4d58e3b0f558d4ec74f287501d22b38161cb0f3 100644 --- a/lib/Magento/Data/Collection.php +++ b/lib/Magento/Data/Collection.php @@ -38,6 +38,8 @@ */ namespace Magento\Data; +use Magento\Data\Collection\EntityFactoryInterface; + class Collection implements \IteratorAggregate, \Countable, \Magento\Core\Model\Option\ArrayInterface { const SORT_ORDER_ASC = 'ASC'; @@ -46,7 +48,7 @@ class Collection implements \IteratorAggregate, \Countable, \Magento\Core\Model\ /** * Collection items * - * @var array + * @var \Magento\Object[] */ protected $_items = array(); @@ -67,7 +69,7 @@ class Collection implements \IteratorAggregate, \Countable, \Magento\Core\Model\ /** * Filters configuration * - * @var array + * @var \Magento\Object[] */ protected $_filters = array(); @@ -116,14 +118,14 @@ class Collection implements \IteratorAggregate, \Countable, \Magento\Core\Model\ protected $_flags = array(); /** - * @var \Magento\Data\Collection\EntityFactoryInterface + * @var EntityFactoryInterface */ protected $_entityFactory; /** - * @param \Magento\Data\Collection\EntityFactoryInterface $entityFactory + * @param EntityFactoryInterface $entityFactory */ - public function __construct(\Magento\Data\Collection\EntityFactoryInterface $entityFactory) + public function __construct(EntityFactoryInterface $entityFactory) { $this->_entityFactory = $entityFactory; } @@ -134,7 +136,7 @@ class Collection implements \IteratorAggregate, \Countable, \Magento\Core\Model\ * @param string $field * @param string $value * @param string $type and|or|string - * @return \Magento\Data\Collection + * @return $this */ public function addFilter($field, $value, $type = 'and') { @@ -157,8 +159,8 @@ class Collection implements \IteratorAggregate, \Countable, \Magento\Core\Model\ * - array('foo', 'bar') -- get all filters with field name 'foo' or 'bar' * - array() -- get all filters * - * @param string|array $field - * @return \Magento\Object|array|null + * @param string|string[] $field + * @return \Magento\Object|\Magento\Object[]|null */ public function getFilter($field) { @@ -301,7 +303,7 @@ class Collection implements \IteratorAggregate, \Countable, \Magento\Core\Model\ /** * Retrieve collection items * - * @return array + * @return \Magento\Object[] */ public function getItems() { @@ -369,7 +371,7 @@ class Collection implements \IteratorAggregate, \Countable, \Magento\Core\Model\ * Adding item to item array * * @param \Magento\Object $item - * @return \Magento\Data\Collection + * @return $this * @throws \Exception */ public function addItem(\Magento\Object $item) @@ -393,7 +395,7 @@ class Collection implements \IteratorAggregate, \Countable, \Magento\Core\Model\ * Add item that has no id to collection * * @param \Magento\Object $item - * @return \Magento\Data\Collection + * @return $this */ protected function _addItem($item) { @@ -413,7 +415,7 @@ class Collection implements \IteratorAggregate, \Countable, \Magento\Core\Model\ } /** - * Retrieve ids of all tems + * Retrieve ids of all items * * @return array */ @@ -430,7 +432,7 @@ class Collection implements \IteratorAggregate, \Countable, \Magento\Core\Model\ * Remove item from collection by item key * * @param mixed $key - * @return \Magento\Data\Collection + * @return $this */ public function removeItemByKey($key) { @@ -443,7 +445,7 @@ class Collection implements \IteratorAggregate, \Countable, \Magento\Core\Model\ /** * Remove all items from collection * - * @return \Magento\Data\Collection + * @return $this */ public function removeAllItems() { @@ -454,7 +456,7 @@ class Collection implements \IteratorAggregate, \Countable, \Magento\Core\Model\ /** * Clear collection * - * @return \Magento\Data\Collection + * @return $this */ public function clear() { @@ -493,6 +495,7 @@ class Collection implements \IteratorAggregate, \Countable, \Magento\Core\Model\ /** * @param string|array $objMethod * @param array $args + * @return void */ public function each($objMethod, $args = array()) { @@ -506,7 +509,7 @@ class Collection implements \IteratorAggregate, \Countable, \Magento\Core\Model\ * * @param mixed $key * @param mixed $value - * @return \Magento\Data\Collection + * @return $this */ public function setDataToAll($key, $value = null) { @@ -526,7 +529,7 @@ class Collection implements \IteratorAggregate, \Countable, \Magento\Core\Model\ * Set current page * * @param int $page - * @return \Magento\Data\Collection + * @return $this */ public function setCurPage($page) { @@ -538,7 +541,7 @@ class Collection implements \IteratorAggregate, \Countable, \Magento\Core\Model\ * Set collection page size * * @param int $size - * @return \Magento\Data\Collection + * @return $this */ public function setPageSize($size) { @@ -551,7 +554,7 @@ class Collection implements \IteratorAggregate, \Countable, \Magento\Core\Model\ * * @param string $field * @param string $direction - * @return \Magento\Data\Collection + * @return $this */ public function setOrder($field, $direction = self::SORT_ORDER_DESC) { @@ -563,7 +566,7 @@ class Collection implements \IteratorAggregate, \Countable, \Magento\Core\Model\ * Set collection item class name * * @param string $className - * @return \Magento\Data\Collection + * @return $this * @throws \InvalidArgumentException */ function setItemObjectClass($className) @@ -588,7 +591,7 @@ class Collection implements \IteratorAggregate, \Countable, \Magento\Core\Model\ /** * Render sql select conditions * - * @return \Magento\Data\Collection + * @return $this */ protected function _renderFilters() { @@ -598,7 +601,7 @@ class Collection implements \IteratorAggregate, \Countable, \Magento\Core\Model\ /** * Render sql select orders * - * @return \Magento\Data\Collection + * @return $this */ protected function _renderOrders() { @@ -608,7 +611,7 @@ class Collection implements \IteratorAggregate, \Countable, \Magento\Core\Model\ /** * Render sql select limit * - * @return \Magento\Data\Collection + * @return $this */ protected function _renderLimit() { @@ -631,7 +634,7 @@ class Collection implements \IteratorAggregate, \Countable, \Magento\Core\Model\ * * @param bool $printQuery * @param bool $logQuery - * @return \Magento\Data\Collection + * @return $this */ public function loadData($printQuery = false, $logQuery = false) { @@ -643,7 +646,7 @@ class Collection implements \IteratorAggregate, \Countable, \Magento\Core\Model\ * * @param bool $printQuery * @param bool $logQuery - * @return \Magento\Data\Collection + * @return $this */ public function load($printQuery = false, $logQuery = false) { @@ -771,6 +774,8 @@ class Collection implements \IteratorAggregate, \Countable, \Magento\Core\Model\ /** * Implementation of \IteratorAggregate::getIterator() + * + * @return \ArrayIterator */ public function getIterator() { @@ -779,7 +784,7 @@ class Collection implements \IteratorAggregate, \Countable, \Magento\Core\Model\ } /** - * Retireve count of collection loaded items + * Retrieve count of collection loaded items * * @return int */ @@ -793,7 +798,7 @@ class Collection implements \IteratorAggregate, \Countable, \Magento\Core\Model\ * Retrieve Flag * * @param string $flag - * @return mixed + * @return bool|null */ public function getFlag($flag) { @@ -804,8 +809,8 @@ class Collection implements \IteratorAggregate, \Countable, \Magento\Core\Model\ * Set Flag * * @param string $flag - * @param mixed $value - * @return \Magento\Data\Collection + * @param bool|null $value + * @return $this */ public function setFlag($flag, $value = null) { diff --git a/lib/Magento/Data/Collection/Db.php b/lib/Magento/Data/Collection/Db.php index de0c761e1f2c0cd0cbf4489f8298788a5ec320be..e5e21378b1a38a348e0be09e13362c8f981fed63 100644 --- a/lib/Magento/Data/Collection/Db.php +++ b/lib/Magento/Data/Collection/Db.php @@ -30,6 +30,11 @@ */ namespace Magento\Data\Collection; +use Magento\Data\Collection\Db\FetchStrategyInterface; +use Magento\DB\Adapter\AdapterInterface; +use Magento\DB\Select; +use Magento\Logger; + class Db extends \Magento\Data\Collection { /** @@ -92,25 +97,25 @@ class Db extends \Magento\Data\Collection protected $_isOrdersRendered = false; /** - * @var \Magento\Logger + * @var Logger */ protected $_logger; /** - * @var \Magento\Data\Collection\Db\FetchStrategyInterface + * @var FetchStrategyInterface */ private $_fetchStrategy; /** - * @param \Magento\Data\Collection\EntityFactoryInterface $entityFactory - * @param \Magento\Logger $logger - * @param \Magento\Data\Collection\Db\FetchStrategyInterface $fetchStrategy - * @param mixed $connection + * @param EntityFactoryInterface $entityFactory + * @param Logger $logger + * @param FetchStrategyInterface $fetchStrategy + * @param \Zend_Db_Adapter_Abstract $connection */ public function __construct( - \Magento\Data\Collection\EntityFactoryInterface $entityFactory, - \Magento\Logger $logger, - \Magento\Data\Collection\Db\FetchStrategyInterface $fetchStrategy, + EntityFactoryInterface $entityFactory, + Logger $logger, + FetchStrategyInterface $fetchStrategy, $connection = null ) { parent::__construct($entityFactory); @@ -126,7 +131,7 @@ class Db extends \Magento\Data\Collection * * @param string $name * @param mixed $value - * @return \Magento\Data\Collection\Db + * @return $this */ public function addBindParam($name, $value) { @@ -138,7 +143,7 @@ class Db extends \Magento\Data\Collection * Specify collection objects id field name * * @param string $fieldName - * @return \Magento\Data\Collection\Db + * @return $this */ protected function _setIdFieldName($fieldName) { @@ -174,7 +179,7 @@ class Db extends \Magento\Data\Collection * Set database connection adapter * * @param \Zend_Db_Adapter_Abstract $conn - * @return \Magento\Data\Collection\Db + * @return $this * @throws \Zend_Exception */ public function setConnection($conn) @@ -192,7 +197,7 @@ class Db extends \Magento\Data\Collection /** * Get \Zend_Db_Select instance * - * @return \Magento\DB\Select + * @return Select */ public function getSelect() { @@ -202,7 +207,7 @@ class Db extends \Magento\Data\Collection /** * Retrieve connection object * - * @return \Magento\DB\Adapter\AdapterInterface + * @return AdapterInterface */ public function getConnection() { @@ -226,7 +231,7 @@ class Db extends \Magento\Data\Collection /** * Get SQL for get record count * - * @return \Magento\DB\Select + * @return Select */ public function getSelectCountSql() { @@ -262,7 +267,7 @@ class Db extends \Magento\Data\Collection * * @param string $field * @param string $direction - * @return \Magento\Data\Collection\Db + * @return $this */ public function setOrder($field, $direction = self::SORT_ORDER_DESC) { @@ -274,7 +279,7 @@ class Db extends \Magento\Data\Collection * * @param string $field * @param string $direction - * @return \Magento\Data\Collection\Db + * @return $this */ public function addOrder($field, $direction = self::SORT_ORDER_DESC) { @@ -286,7 +291,7 @@ class Db extends \Magento\Data\Collection * * @param string $field * @param string $direction - * @return \Magento\Data\Collection\Db + * @return $this */ public function unshiftOrder($field, $direction = self::SORT_ORDER_DESC) { @@ -299,7 +304,7 @@ class Db extends \Magento\Data\Collection * @param string $field * @param string $direction * @param bool $unshift - * @return \Magento\Data\Collection\Db + * @return $this */ private function _setOrder($field, $direction, $unshift = false) { @@ -323,7 +328,7 @@ class Db extends \Magento\Data\Collection /** * Render sql select conditions * - * @return \Magento\Data\Collection\Db + * @return $this */ protected function _renderFilters() { @@ -346,7 +351,7 @@ class Db extends \Magento\Data\Collection $field = $this->_getMappedField($filter['field']); $condition = $filter['value']; $this->_select->where( - $this->_getConditionSql($field, $condition), null, \Magento\DB\Select::TYPE_CONDITION + $this->_getConditionSql($field, $condition), null, Select::TYPE_CONDITION ); break; default: @@ -360,6 +365,7 @@ class Db extends \Magento\Data\Collection /** * Hook for operations before rendering filters + * @return void */ protected function _renderFiltersBefore() { @@ -372,7 +378,7 @@ class Db extends \Magento\Data\Collection * * @param string|array $field * @param null|string|array $condition - * @return \Magento\Data\Collection\Db + * @return $this */ public function addFieldToFilter($field, $condition = null) { @@ -387,7 +393,7 @@ class Db extends \Magento\Data\Collection $resultCondition = $this->_translateCondition($field, $condition); } - $this->_select->where($resultCondition, null, \Magento\DB\Select::TYPE_CONDITION); + $this->_select->where($resultCondition, null, Select::TYPE_CONDITION); return $this; } @@ -397,7 +403,6 @@ class Db extends \Magento\Data\Collection * * @param string|array $field * @param null|string|array $condition - * * @return string */ protected function _translateCondition($field, $condition) @@ -417,12 +422,12 @@ class Db extends \Magento\Data\Collection $mapper = $this->_getMapper(); if (isset($mapper['fields'][$field])) { - $mappedFiled = $mapper['fields'][$field]; + $mappedField = $mapper['fields'][$field]; } else { - $mappedFiled = $field; + $mappedField = $field; } - return $mappedFiled; + return $mappedField; } /** @@ -475,6 +480,12 @@ class Db extends \Magento\Data\Collection return $this->getConnection()->prepareSqlCondition($fieldName, $condition); } + /** + * Return the field name for the condition. + * + * @param string $fieldName + * @return string + */ protected function _getConditionFieldName($fieldName) { return $fieldName; @@ -483,7 +494,7 @@ class Db extends \Magento\Data\Collection /** * Render sql select orders * - * @return \Magento\Data\Collection\Db + * @return $this */ protected function _renderOrders() { @@ -500,7 +511,7 @@ class Db extends \Magento\Data\Collection /** * Render sql select limit * - * @return \Magento\Data\Collection\Db + * @return $this */ protected function _renderLimit() { @@ -515,8 +526,7 @@ class Db extends \Magento\Data\Collection * Set select distinct * * @param bool $flag - * - * @return \Magento\Data\Collection\Db + * @return $this */ public function distinct($flag) { @@ -527,7 +537,7 @@ class Db extends \Magento\Data\Collection /** * Before load action * - * @return \Magento\Data\Collection\Db + * @return $this */ protected function _beforeLoad() { @@ -539,8 +549,7 @@ class Db extends \Magento\Data\Collection * * @param bool $printQuery * @param bool $logQuery - * - * @return \Magento\Data\Collection\Db + * @return $this */ public function load($printQuery = false, $logQuery = false) { @@ -681,7 +690,7 @@ class Db extends \Magento\Data\Collection /** * Process loaded collection data * - * @return \Magento\Data\Collection\Db + * @return $this */ protected function _afterLoadData() { @@ -691,7 +700,7 @@ class Db extends \Magento\Data\Collection /** * Reset loaded for collection data array * - * @return \Magento\Data\Collection\Db + * @return $this */ public function resetData() { @@ -699,11 +708,23 @@ class Db extends \Magento\Data\Collection return $this; } + /** + * Process loaded collection + * + * @return $this + */ protected function _afterLoad() { return $this; } + /** + * Load the data. + * + * @param bool $printQuery + * @param bool $logQuery + * @return $this + */ public function loadData($printQuery = false, $logQuery = false) { return $this->load($printQuery, $logQuery); @@ -715,8 +736,7 @@ class Db extends \Magento\Data\Collection * @param bool $printQuery * @param bool $logQuery * @param string $sql - * - * @return \Magento\Data\Collection\Db + * @return $this */ public function printLogQuery($printQuery = false, $logQuery = false, $sql = null) { @@ -734,6 +754,7 @@ class Db extends \Magento\Data\Collection * Log query * * @param string $sql + * @return void */ protected function _logQuery($sql) { @@ -743,7 +764,7 @@ class Db extends \Magento\Data\Collection /** * Reset collection * - * @return \Magento\Data\Collection\Db + * @return $this */ protected function _reset() { @@ -772,8 +793,7 @@ class Db extends \Magento\Data\Collection * @param string $filter * @param string $alias * @param string $group default 'fields' - * - * @return \Magento\Data\Collection\Db + * @return $this */ public function addFilterToMap($filter, $alias, $group = 'fields') { @@ -799,6 +819,8 @@ class Db extends \Magento\Data\Collection /** * Init select + * + * @return void */ protected function _initSelect() { diff --git a/lib/Magento/Data/Collection/Filesystem.php b/lib/Magento/Data/Collection/Filesystem.php index a12cfdc939b6080024d8c61c1cf8fb87a4eae9eb..9e48e20d52a16bdc46133d8f2f71e8e21eeeb9c0 100644 --- a/lib/Magento/Data/Collection/Filesystem.php +++ b/lib/Magento/Data/Collection/Filesystem.php @@ -41,6 +41,8 @@ */ namespace Magento\Data\Collection; +use Magento\Data\Collection; + class Filesystem extends \Magento\Data\Collection { /** @@ -100,21 +102,45 @@ class Filesystem extends \Magento\Data\Collection protected $_disallowedFilesMask = ''; /** - * Filter rendering helper variables + * Filter rendering helper variable * - * @see \Magento\Data\Collection::$_filter - * @see \Magento\Data\Collection::$_isFiltersRendered + * @var int + * @see Collection::$_filter + * @see Collection::$_isFiltersRendered */ private $_filterIncrement = 0; + + + /** + * Filter rendering helper variable + * + * @var array + * @see Collection::$_filter + * @see Collection::$_isFiltersRendered + */ private $_filterBrackets = array(); + + /** + * Filter rendering helper variable + * + * @var string + * @see Collection::$_filter + * @see Collection::$_isFiltersRendered + */ private $_filterEvalRendered = ''; /** - * Collecting items helper variables + * Collecting items helper variable * * @var array */ protected $_collectedDirs = array(); + + /** + * Collecting items helper variable + * + * @var array + */ protected $_collectedFiles = array(); /** @@ -122,7 +148,7 @@ class Filesystem extends \Magento\Data\Collection * Set empty to not filter * * @param string $regex - * @return \Magento\Data\Collection\Filesystem + * @return $this */ public function setDirsFilter($regex) { @@ -135,7 +161,7 @@ class Filesystem extends \Magento\Data\Collection * Set empty to not filter * * @param string $regex - * @return \Magento\Data\Collection\Filesystem + * @return $this */ public function setFilesFilter($regex) { @@ -148,7 +174,7 @@ class Filesystem extends \Magento\Data\Collection * Set empty value to not use this filter * * @param string $regex - * @return \Magento\Data\Collection\Filesystem + * @return $this */ public function setDisallowedFilesFilter($regex) { @@ -160,7 +186,7 @@ class Filesystem extends \Magento\Data\Collection * Set whether to collect dirs * * @param bool $value - * @return \Magento\Data\Collection\Filesystem + * @return $this */ public function setCollectDirs($value) { @@ -172,7 +198,7 @@ class Filesystem extends \Magento\Data\Collection * Set whether to collect files * * @param bool $value - * @return \Magento\Data\Collection\Filesystem + * @return $this */ public function setCollectFiles($value) { @@ -184,7 +210,7 @@ class Filesystem extends \Magento\Data\Collection * Set whether to collect recursively * * @param bool $value - * @return \Magento\Data\Collection\Filesystem + * @return $this */ public function setCollectRecursively($value) { @@ -196,7 +222,8 @@ class Filesystem extends \Magento\Data\Collection * Target directory setter. Adds directory to be scanned * * @param string $value - * @return \Magento\Data\Collection\Filesystem + * @return $this + * @throws \Exception */ public function addTargetDir($value) { @@ -213,7 +240,7 @@ class Filesystem extends \Magento\Data\Collection * Works *before* sorting. * * @param bool $value - * @return \Magento\Data\Collection\Filesystem + * @return $this */ public function setDirsFirst($value) { @@ -225,6 +252,7 @@ class Filesystem extends \Magento\Data\Collection * Get files from specified directory recursively (if needed) * * @param string|array $dir + * @return void */ protected function _collectRecursive($dir) { @@ -270,7 +298,8 @@ class Filesystem extends \Magento\Data\Collection * * @param bool $printQuery * @param bool $logQuery - * @return \Magento\Data\Collection\Filesystem + * @return $this + * @throws \Exception */ public function loadData($printQuery = false, $logQuery = false) { @@ -322,6 +351,7 @@ class Filesystem extends \Magento\Data\Collection * - sort * * @param string $attributeName '_collectedFiles' | '_collectedDirs' + * @return void */ private function _generateAndFilterAndSort($attributeName) { @@ -368,7 +398,7 @@ class Filesystem extends \Magento\Data\Collection * * @param string $field * @param string $direction - * @return \Magento\Data\Collection + * @return Collection */ public function setOrder($field, $direction = self::SORT_ORDER_DESC) { @@ -395,14 +425,14 @@ class Filesystem extends \Magento\Data\Collection * The callback must take 3 params: * string $field - field key, * mixed $filterValue - value to filter by, - * array $row - a generated row (before generaring varien objects) + * array $row - a generated row (before generating varien objects) * * @param string $field * @param mixed $value * @param string $type 'and'|'or' * @param callback $callback * @param bool $isInverted - * @return \Magento\Data\Collection\Filesystem + * @return $this */ public function addCallbackFilter($field, $value, $type, $callback, $isInverted = false) { @@ -419,7 +449,7 @@ class Filesystem extends \Magento\Data\Collection /** * The filters renderer and caller - * Aplies to each row, renders once. + * Applies to each row, renders once. * * @param array $row * @return bool @@ -474,8 +504,8 @@ class Filesystem extends \Magento\Data\Collection * @param string $field * @param mixed $cond * @param string $type 'and' | 'or' - * @see \Magento\Data\Collection\Db::addFieldToFilter() - * @return \Magento\Data\Collection\Filesystem + * @see Db::addFieldToFilter() + * @return $this */ public function addFieldToFilter($field, $cond, $type = 'and') { @@ -555,7 +585,7 @@ class Filesystem extends \Magento\Data\Collection * * @param string $bracket * @param bool $isAnd - * @return \Magento\Data\Collection\Filesystem + * @return $this */ protected function _addFilterBracket($bracket = '(', $isAnd = true) { @@ -592,8 +622,10 @@ class Filesystem extends \Magento\Data\Collection /** * Does nothing. Intentionally disabled parent method - * - * @return \Magento\Data\Collection\Filesystem + * @param string $field + * @param string $value + * @param string $type + * @return $this */ public function addFilter($field, $value, $type = 'and') { diff --git a/lib/Magento/Data/Form.php b/lib/Magento/Data/Form.php index 109f17f782e9acbb1ca29e484455424346a3fe71..f9f3c5a7bbd5240f5b349c1ac2eb78ae181f4db9 100644 --- a/lib/Magento/Data/Form.php +++ b/lib/Magento/Data/Form.php @@ -26,12 +26,20 @@ namespace Magento\Data; +use Magento\Data\Form\Element\AbstractElement; +use Magento\Data\Form\Element\Collection as ElementCollection; +use Magento\Data\Form\Element\CollectionFactory as ElementCollectionFactory; +use Magento\Data\Form\Element\Factory; +use Magento\Data\Form\Element\Renderer\RendererInterface; +use Magento\Data\Form\FormKey; +use Magento\Profiler; + class Form extends \Magento\Data\Form\AbstractForm { /** * All form elements collection * - * @var \Magento\Data\Form\Element\Collection + * @var ElementCollection */ protected $_allElements; @@ -43,24 +51,35 @@ class Form extends \Magento\Data\Form\AbstractForm protected $_elementsIndex; /** - * @var Form\FormKey + * @var FormKey */ protected $formKey; + /** + * @var RendererInterface + */ static protected $_defaultElementRenderer; + + /** + * @var RendererInterface + */ static protected $_defaultFieldsetRenderer; + + /** + * @var RendererInterface + */ static protected $_defaultFieldsetElementRenderer; /** - * @param Form\Element\Factory $factoryElement - * @param Form\Element\CollectionFactory $factoryCollection - * @param Form\FormKey $formKey + * @param Factory $factoryElement + * @param ElementCollectionFactory $factoryCollection + * @param FormKey $formKey * @param array $data */ public function __construct( - \Magento\Data\Form\Element\Factory $factoryElement, - \Magento\Data\Form\Element\CollectionFactory $factoryCollection, - \Magento\Data\Form\FormKey $formKey, + Factory $factoryElement, + ElementCollectionFactory $factoryCollection, + FormKey $formKey, $data = array() ) { parent::__construct($factoryElement, $factoryCollection, $data); @@ -68,31 +87,52 @@ class Form extends \Magento\Data\Form\AbstractForm $this->formKey = $formKey; } - public static function setElementRenderer(\Magento\Data\Form\Element\Renderer\RendererInterface $renderer = null) + /** + * @param RendererInterface $renderer + * @return void + */ + public static function setElementRenderer(RendererInterface $renderer = null) { self::$_defaultElementRenderer = $renderer; } - public static function setFieldsetRenderer(\Magento\Data\Form\Element\Renderer\RendererInterface $renderer = null) + /** + * @param RendererInterface $renderer + * @return void + */ + public static function setFieldsetRenderer(RendererInterface $renderer = null) { self::$_defaultFieldsetRenderer = $renderer; } - public static function setFieldsetElementRenderer(\Magento\Data\Form\Element\Renderer\RendererInterface $renderer = null) + /** + * @param RendererInterface $renderer + * @return void + */ + public static function setFieldsetElementRenderer(RendererInterface $renderer = null) { self::$_defaultFieldsetElementRenderer = $renderer; } + /** + * @return RendererInterface + */ public static function getElementRenderer() { return self::$_defaultElementRenderer; } + /** + * @return RendererInterface + */ public static function getFieldsetRenderer() { return self::$_defaultFieldsetRenderer; } + /** + * @return RendererInterface + */ public static function getFieldsetElementRenderer() { return self::$_defaultFieldsetElementRenderer; @@ -100,7 +140,8 @@ class Form extends \Magento\Data\Form\AbstractForm /** * Return allowed HTML form attributes - * @return array + * + * @return string[] */ public function getHtmlAttributes() { @@ -110,11 +151,11 @@ class Form extends \Magento\Data\Form\AbstractForm /** * Add form element * - * @param \Magento\Data\Form\Element\AbstractElement $element + * @param AbstractElement $element * @param bool $after - * @return \Magento\Data\Form + * @return $this */ - public function addElement(\Magento\Data\Form\Element\AbstractElement $element, $after = false) + public function addElement(AbstractElement $element, $after = false) { $this->checkElementId($element->getId()); parent::addElement($element, $after); @@ -134,7 +175,7 @@ class Form extends \Magento\Data\Form\AbstractForm } /** - * @param \Magento\Data\Form\Element\AbstractElement $element + * @param AbstractElement $element * @return $this */ public function addElementToCollection($element) @@ -169,7 +210,7 @@ class Form extends \Magento\Data\Form\AbstractForm * Retrieve form element by id * * @param string $elementId - * @return null|\Magento\Data\Form\Element\AbstractElement + * @return null|AbstractElement */ public function getElement($elementId) { @@ -217,7 +258,7 @@ class Form extends \Magento\Data\Form\AbstractForm * Add suffix to name of all elements * * @param string $suffix - * @return \Magento\Data\Form + * @return $this */ public function addFieldNameSuffix($suffix) { @@ -253,7 +294,7 @@ class Form extends \Magento\Data\Form\AbstractForm /** * @param string $elementId - * @return $this|Form\AbstractForm + * @return $this */ public function removeField($elementId) { @@ -286,7 +327,7 @@ class Form extends \Magento\Data\Form\AbstractForm */ public function toHtml() { - \Magento\Profiler::start('form/toHtml'); + Profiler::start('form/toHtml'); $html = ''; $useContainer = $this->getUseContainer(); if ($useContainer) { @@ -307,10 +348,13 @@ class Form extends \Magento\Data\Form\AbstractForm if ($useContainer) { $html.= '</form>'; } - \Magento\Profiler::stop('form/toHtml'); + Profiler::stop('form/toHtml'); return $html; } + /** + * @return string + */ public function getHtml() { return $this->toHtml(); diff --git a/lib/Magento/Data/Form/AbstractForm.php b/lib/Magento/Data/Form/AbstractForm.php index 45da8c4f99a0adb0dce0b9b627d451794c94e1b2..2ea51029267284fd51b3290fc31142ec37217bcb 100644 --- a/lib/Magento/Data/Form/AbstractForm.php +++ b/lib/Magento/Data/Form/AbstractForm.php @@ -34,12 +34,19 @@ */ namespace Magento\Data\Form; +use Magento\Data\Form\Element\AbstractElement; +use Magento\Data\Form\Element\Collection; +use Magento\Data\Form\Element\CollectionFactory; +use Magento\Data\Form\Element\Column; +use Magento\Data\Form\Element\Factory; +use Magento\Data\Form\Element\Fieldset; + class AbstractForm extends \Magento\Object { /** * Form level elements collection * - * @var \Magento\Data\Form\Element\Collection + * @var Collection */ protected $_elements; @@ -51,23 +58,23 @@ class AbstractForm extends \Magento\Object protected $_types = array(); /** - * @var \Magento\Data\Form\Element\Factory + * @var Factory */ protected $_factoryElement; /** - * @var \Magento\Data\Form\Element\CollectionFactory + * @var CollectionFactory */ protected $_factoryCollection; /** - * @param \Magento\Data\Form\Element\Factory $factoryElement - * @param \Magento\Data\Form\Element\CollectionFactory $factoryCollection + * @param Factory $factoryElement + * @param CollectionFactory $factoryCollection * @param array $data */ public function __construct( - \Magento\Data\Form\Element\Factory $factoryElement, - \Magento\Data\Form\Element\CollectionFactory $factoryCollection, + Factory $factoryElement, + CollectionFactory $factoryCollection, $data = array() ) { $this->_factoryElement = $factoryElement; @@ -91,7 +98,7 @@ class AbstractForm extends \Magento\Object * * @param string $type * @param string $className - * @return \Magento\Data\Form\AbstractForm + * @return $this */ public function addType($type, $className) { @@ -102,7 +109,7 @@ class AbstractForm extends \Magento\Object /** * Get elements collection * - * @return \Magento\Data\Form\Element\Collection + * @return Collection */ public function getElements() { @@ -117,7 +124,7 @@ class AbstractForm extends \Magento\Object * * @param boolean $readonly * @param boolean $useDisabled - * @return \Magento\Data\Form\AbstractForm + * @return $this */ public function setReadonly($readonly, $useDisabled = false) { @@ -137,12 +144,11 @@ class AbstractForm extends \Magento\Object /** * Add form element * - * @param \Magento\Data\Form\Element\AbstractElement $element + * @param AbstractElement $element * @param bool|string|null $after - * - * @return \Magento\Data\Form + * @return $this */ - public function addElement(\Magento\Data\Form\Element\AbstractElement $element, $after = null) + public function addElement(AbstractElement $element, $after = null) { $element->setForm($this); $this->getElements()->add($element, $after); @@ -159,8 +165,8 @@ class AbstractForm extends \Magento\Object * @param string $elementId * @param string $type * @param array $config - * @param mixed $after - * @return \Magento\Data\Form\Element\AbstractElement + * @param bool|string|null $after + * @return AbstractElement */ public function addField($elementId, $type, $config, $after = false) { @@ -177,7 +183,7 @@ class AbstractForm extends \Magento\Object * Enter description here... * * @param string $elementId - * @return \Magento\Data\Form\AbstractForm + * @return $this */ public function removeField($elementId) { @@ -192,7 +198,7 @@ class AbstractForm extends \Magento\Object * @param array $config * @param bool|string|null $after * @param bool $isAdvanced - * @return \Magento\Data\Form\Element\Fieldset + * @return Fieldset */ public function addFieldset($elementId, $config, $after = false, $isAdvanced = false) { @@ -208,7 +214,7 @@ class AbstractForm extends \Magento\Object * * @param string $elementId * @param array $config - * @return \Magento\Data\Form\Element\Column + * @return Column */ public function addColumn($elementId, $config) { diff --git a/lib/Magento/Data/Form/Element/AbstractElement.php b/lib/Magento/Data/Form/Element/AbstractElement.php index ee560a7f4521df3eed7c0de5645643db691ae3c4..26600626b466a0c7f32ecbc968bf0005c47fc544 100644 --- a/lib/Magento/Data/Form/Element/AbstractElement.php +++ b/lib/Magento/Data/Form/Element/AbstractElement.php @@ -34,13 +34,36 @@ */ namespace Magento\Data\Form\Element; -abstract class AbstractElement extends \Magento\Data\Form\AbstractForm +use Magento\Data\Form; +use Magento\Data\Form\AbstractForm; +use Magento\Data\Form\Element\Renderer\RendererInterface; +use Magento\Escaper; + +abstract class AbstractElement extends AbstractForm { + /** + * @var string|int + */ protected $_id; + + /** + * @var string + */ protected $_type; - /** @var \Magento\Data\Form */ + + /** + * @var Form + */ protected $_form; + + /** + * @var + */ protected $_elements; + + /** + * @var RendererInterface + */ protected $_renderer; /** @@ -51,7 +74,7 @@ abstract class AbstractElement extends \Magento\Data\Form\AbstractForm protected $_advanced = false; /** - * @var \Magento\Escaper + * @var Escaper */ protected $_escaper; @@ -63,15 +86,15 @@ abstract class AbstractElement extends \Magento\Data\Form\AbstractForm private $lockHtmlAttribute = 'data-locked'; /** - * @param \Magento\Data\Form\Element\Factory $factoryElement - * @param \Magento\Data\Form\Element\CollectionFactory $factoryCollection - * @param \Magento\Escaper $escaper + * @param Factory $factoryElement + * @param CollectionFactory $factoryCollection + * @param Escaper $escaper * @param array $data */ public function __construct( - \Magento\Data\Form\Element\Factory $factoryElement, - \Magento\Data\Form\Element\CollectionFactory $factoryCollection, - \Magento\Escaper $escaper, + Factory $factoryElement, + CollectionFactory $factoryCollection, + Escaper $escaper, $data = array() ) { $this->_escaper = $escaper; @@ -82,11 +105,11 @@ abstract class AbstractElement extends \Magento\Data\Form\AbstractForm /** * Add form element * - * @param \Magento\Data\Form\Element\AbstractElement $element + * @param AbstractElement $element * @param bool $after - * @return \Magento\Data\Form + * @return Form */ - public function addElement(\Magento\Data\Form\Element\AbstractElement $element, $after = false) + public function addElement(AbstractElement $element, $after = false) { if ($this->getForm()) { $this->getForm()->checkElementId($element->getId()); @@ -100,7 +123,7 @@ abstract class AbstractElement extends \Magento\Data\Form\AbstractForm /** * Shows whether current element belongs to Basic or Advanced form layout * - * @return bool + * @return bool */ public function isAdvanced() { return $this->_advanced; @@ -110,18 +133,28 @@ abstract class AbstractElement extends \Magento\Data\Form\AbstractForm * Set _advanced layout property * * @param bool $advanced - * @return \Magento\Data\Form\Element\AbstractElement + * @return $this */ public function setAdvanced($advanced) { $this->_advanced = $advanced; return $this; } + /** + * Get id. + * + * @return string|int + */ public function getId() { return $this->_id; } + /** + * Get type. + * + * @return string + */ public function getType() { return $this->_type; @@ -130,13 +163,19 @@ abstract class AbstractElement extends \Magento\Data\Form\AbstractForm /** * Get form * - * @return \Magento\Data\Form + * @return Form */ public function getForm() { return $this->_form; } + /** + * Set the Id. + * + * @param string|int $id + * @return $this + */ public function setId($id) { $this->_id = $id; @@ -144,11 +183,21 @@ abstract class AbstractElement extends \Magento\Data\Form\AbstractForm return $this; } + /** + * Get the Html Id. + * + * @return string + */ public function getHtmlId() { return $this->getForm()->getHtmlIdPrefix() . $this->getData('html_id') . $this->getForm()->getHtmlIdSuffix(); } + /** + * Get the name. + * + * @return mixed + */ public function getName() { $name = $this->getData('name'); @@ -158,6 +207,12 @@ abstract class AbstractElement extends \Magento\Data\Form\AbstractForm return $name; } + /** + * Set the type. + * + * @param string $type + * @return $this + */ public function setType($type) { $this->_type = $type; @@ -165,23 +220,44 @@ abstract class AbstractElement extends \Magento\Data\Form\AbstractForm return $this; } + /** + * @param Form $form + * @return $this + */ public function setForm($form) { $this->_form = $form; return $this; } + /** + * Remove field + * + * @param string $elementId + * @return AbstractForm + */ public function removeField($elementId) { $this->getForm()->removeField($elementId); return parent::removeField($elementId); } + /** + * Return the attributes for Html. + * + * @return string[] + */ public function getHtmlAttributes() { return array('type', 'title', 'class', 'style', 'onclick', 'onchange', 'disabled', 'readonly', 'tabindex', 'placeholder'); } + /** + * Add a class. + * + * @param string $class + * @return $this + */ public function addClass($class) { $oldClass = $this->getClass(); @@ -193,7 +269,7 @@ abstract class AbstractElement extends \Magento\Data\Form\AbstractForm * Remove CSS class * * @param string $class - * @return \Magento\Data\Form\Element\AbstractElement + * @return $this */ public function removeClass($class) { @@ -205,11 +281,23 @@ abstract class AbstractElement extends \Magento\Data\Form\AbstractForm return $this; } + /** + * Escape a string's contents. + * + * @param string $string + * @return string + */ protected function _escape($string) { return htmlspecialchars($string, ENT_COMPAT); } + /** + * Return the escaped value of the element specified by the given index. + * + * @param null|int|string $index + * @return string + */ public function getEscapedValue($index=null) { $value = $this->getValue($index); @@ -220,17 +308,32 @@ abstract class AbstractElement extends \Magento\Data\Form\AbstractForm return $this->_escape($value); } - public function setRenderer(\Magento\Data\Form\Element\Renderer\RendererInterface $renderer) + /** + * Set the renderer. + * + * @param RendererInterface $renderer + * @return $this + */ + public function setRenderer(RendererInterface $renderer) { $this->_renderer = $renderer; return $this; } + /** + * Get the renderer. + * + * @return RendererInterface + */ public function getRenderer() { return $this->_renderer; } + /** + * @param null|string $suffix + * @return string + */ protected function _getUiId($suffix = null) { if ($this->_renderer instanceof \Magento\View\Element\AbstractBlock) { @@ -240,6 +343,11 @@ abstract class AbstractElement extends \Magento\Data\Form\AbstractForm } } + /** + * Get the Html for the element. + * + * @return string + */ public function getElementHtml() { $html = ''; @@ -258,16 +366,31 @@ abstract class AbstractElement extends \Magento\Data\Form\AbstractForm return $html; } + /** + * Get the before element html. + * + * @return mixed + */ public function getBeforeElementHtml() { return $this->getData('before_element_html'); } + /** + * Get the after element html. + * + * @return mixed + */ public function getAfterElementHtml() { return $this->getData('after_element_html'); } + /** + * Get the after element Javascript. + * + * @return mixed + */ public function getAfterElementJs() { return $this->getData('after_element_js'); @@ -292,6 +415,11 @@ abstract class AbstractElement extends \Magento\Data\Form\AbstractForm return $html; } + /** + * Get the default html. + * + * @return mixed + */ public function getDefaultHtml() { $html = $this->getData('default_html'); @@ -304,6 +432,11 @@ abstract class AbstractElement extends \Magento\Data\Form\AbstractForm return $html; } + /** + * Get the html. + * + * @return mixed + */ public function getHtml() { if ($this->getRequired()) { @@ -317,11 +450,25 @@ abstract class AbstractElement extends \Magento\Data\Form\AbstractForm return $html; } + /** + * Get the html. + * + * @return mixed + */ public function toHtml() { return $this->getHtml(); } + /** + * Serialize the element. + * + * @param string[] $attributes + * @param string $valueSeparator + * @param string $fieldSeparator + * @param string $quote + * @return string + */ public function serialize($attributes = array(), $valueSeparator='=', $fieldSeparator=' ', $quote='"') { if ($this->isLocked() && !empty($attributes)) { @@ -340,6 +487,11 @@ abstract class AbstractElement extends \Magento\Data\Form\AbstractForm return parent::serialize($attributes, $valueSeparator, $fieldSeparator, $quote); } + /** + * Indicates the elements readonly status. + * + * @return mixed + */ public function getReadonly() { if ($this->hasData('readonly_disabled')) { @@ -349,6 +501,11 @@ abstract class AbstractElement extends \Magento\Data\Form\AbstractForm return $this->_getData('readonly'); } + /** + * Get the container Id. + * + * @return mixed + */ public function getHtmlContainerId() { if ($this->hasData('container_id')) { @@ -364,7 +521,7 @@ abstract class AbstractElement extends \Magento\Data\Form\AbstractForm * * @param string|int|array $values * @param bool $overwrite - * @return \Magento\Data\Form\Element\AbstractElement + * @return $this */ public function addElementValues($values, $overwrite = false) { @@ -391,6 +548,8 @@ abstract class AbstractElement extends \Magento\Data\Form\AbstractForm /** * Lock element + * + * @return void */ public function lock() { diff --git a/lib/Magento/Data/Form/Element/Button.php b/lib/Magento/Data/Form/Element/Button.php index 7f13ea63c1eb33beffc10b7b2f75d20fd478345f..db741317a891aa01fb9be25d8450f707065906c4 100644 --- a/lib/Magento/Data/Form/Element/Button.php +++ b/lib/Magento/Data/Form/Element/Button.php @@ -33,25 +33,27 @@ */ namespace Magento\Data\Form\Element; -class Button extends \Magento\Data\Form\Element\AbstractElement +use Magento\Escaper; + +class Button extends AbstractElement { /** * Additional html attributes * - * @var array + * @var string[] */ protected $_htmlAttributes = array('data-mage-init'); /** - * @param \Magento\Data\Form\Element\Factory $factoryElement - * @param \Magento\Data\Form\Element\CollectionFactory $factoryCollection - * @param \Magento\Escaper $escaper + * @param Factory $factoryElement + * @param CollectionFactory $factoryCollection + * @param Escaper $escaper * @param array $data */ public function __construct( - \Magento\Data\Form\Element\Factory $factoryElement, - \Magento\Data\Form\Element\CollectionFactory $factoryCollection, - \Magento\Escaper $escaper, + Factory $factoryElement, + CollectionFactory $factoryCollection, + Escaper $escaper, $data = array() ) { parent::__construct($factoryElement, $factoryCollection, $escaper, $data); @@ -62,7 +64,7 @@ class Button extends \Magento\Data\Form\Element\AbstractElement /** * Html attributes * - * @return array + * @return string[] */ public function getHtmlAttributes() { diff --git a/lib/Magento/Data/Form/Element/Checkbox.php b/lib/Magento/Data/Form/Element/Checkbox.php index 0076c5e4decfeedf843424dbdbb8ae3907c38e04..7c6610178ef439410729eb42658685a88217a7ce 100644 --- a/lib/Magento/Data/Form/Element/Checkbox.php +++ b/lib/Magento/Data/Form/Element/Checkbox.php @@ -33,18 +33,20 @@ */ namespace Magento\Data\Form\Element; -class Checkbox extends \Magento\Data\Form\Element\AbstractElement +use Magento\Escaper; + +class Checkbox extends AbstractElement { /** - * @param \Magento\Data\Form\Element\Factory $factoryElement - * @param \Magento\Data\Form\Element\CollectionFactory $factoryCollection - * @param \Magento\Escaper $escaper + * @param Factory $factoryElement + * @param CollectionFactory $factoryCollection + * @param Escaper $escaper * @param array $data */ public function __construct( - \Magento\Data\Form\Element\Factory $factoryElement, - \Magento\Data\Form\Element\CollectionFactory $factoryCollection, - \Magento\Escaper $escaper, + Factory $factoryElement, + CollectionFactory $factoryCollection, + Escaper $escaper, $data = array() ) { parent::__construct($factoryElement, $factoryCollection, $escaper, $data); @@ -52,11 +54,17 @@ class Checkbox extends \Magento\Data\Form\Element\AbstractElement $this->setExtType('checkbox'); } + /** + * @return string[] + */ public function getHtmlAttributes() { return array('type', 'title', 'class', 'style', 'checked', 'onclick', 'onchange', 'disabled', 'tabindex'); } + /** + * @return string + */ public function getElementHtml() { if ($checked = $this->getChecked()) { @@ -72,7 +80,7 @@ class Checkbox extends \Magento\Data\Form\Element\AbstractElement * Set check status of checkbox * * @param boolean $value - * @return \Magento\Data\Form\Element\Checkbox + * @return Checkbox */ public function setIsChecked($value=false) { diff --git a/lib/Magento/Data/Form/Element/Checkboxes.php b/lib/Magento/Data/Form/Element/Checkboxes.php index 52971734929cf921e7d20291e0b159bfa1392d42..8568ff0330e3806a77bb6a26a0f3871802ad6253 100644 --- a/lib/Magento/Data/Form/Element/Checkboxes.php +++ b/lib/Magento/Data/Form/Element/Checkboxes.php @@ -33,18 +33,20 @@ */ namespace Magento\Data\Form\Element; -class Checkboxes extends \Magento\Data\Form\Element\AbstractElement +use Magento\Escaper; + +class Checkboxes extends AbstractElement { /** - * @param \Magento\Data\Form\Element\Factory $factoryElement - * @param \Magento\Data\Form\Element\CollectionFactory $factoryCollection - * @param \Magento\Escaper $escaper + * @param Factory $factoryElement + * @param CollectionFactory $factoryCollection + * @param Escaper $escaper * @param array $data */ public function __construct( - \Magento\Data\Form\Element\Factory $factoryElement, - \Magento\Data\Form\Element\CollectionFactory $factoryCollection, - \Magento\Escaper $escaper, + Factory $factoryElement, + CollectionFactory $factoryCollection, + Escaper $escaper, $data = array() ) { parent::__construct($factoryElement, $factoryCollection, $escaper, $data); @@ -55,7 +57,7 @@ class Checkboxes extends \Magento\Data\Form\Element\AbstractElement /** * Retrieve allow attributes * - * @return array + * @return string[] */ public function getHtmlAttributes() { @@ -127,6 +129,10 @@ class Checkboxes extends \Magento\Data\Form\Element\AbstractElement return $html; } + /** + * @param mixed $value + * @return string + */ public function getChecked($value) { if ($checked = $this->getValue()) { @@ -150,6 +156,10 @@ class Checkboxes extends \Magento\Data\Form\Element\AbstractElement return ; } + /** + * @param mixed $value + * @return string + */ public function getDisabled($value) { if ($disabled = $this->getData('disabled')) { @@ -168,6 +178,10 @@ class Checkboxes extends \Magento\Data\Form\Element\AbstractElement return ; } + /** + * @param mixed $value + * @return mixed + */ public function getOnclick($value) { if ($onclick = $this->getData('onclick')) { @@ -176,6 +190,10 @@ class Checkboxes extends \Magento\Data\Form\Element\AbstractElement return ; } + /** + * @param mixed $value + * @return mixed + */ public function getOnchange($value) { if ($onchange = $this->getData('onchange')) { @@ -192,6 +210,10 @@ class Checkboxes extends \Magento\Data\Form\Element\AbstractElement // return ; // } + /** + * @param array $option + * @return string + */ protected function _optionToHtml($option) { $id = $this->getHtmlId().'_'.$this->_escape($option['value']); diff --git a/lib/Magento/Data/Form/Element/Collection.php b/lib/Magento/Data/Form/Element/Collection.php index 5bb9dabad6cb92a86d48c85ce559e0cfd88192ee..74e68f18e981f95d362780ad28d89470fa65fe2c 100644 --- a/lib/Magento/Data/Form/Element/Collection.php +++ b/lib/Magento/Data/Form/Element/Collection.php @@ -33,6 +33,9 @@ */ namespace Magento\Data\Form\Element; +use Magento\Data\Form; +use Magento\Data\Form\AbstractForm; + class Collection implements \ArrayAccess, \IteratorAggregate { @@ -46,16 +49,16 @@ class Collection implements \ArrayAccess, \IteratorAggregate /** * Elements container * - * @var \Magento\Data\Form\AbstractForm + * @var AbstractForm */ private $_container; /** * Class constructor * - * @param \Magento\Data\Form\AbstractForm $container + * @param AbstractForm $container */ - public function __construct(\Magento\Data\Form\AbstractForm $container) + public function __construct(AbstractForm $container) { $this->_elements = array(); $this->_container = $container; @@ -76,6 +79,7 @@ class Collection implements \ArrayAccess, \IteratorAggregate * * @param mixed $key * @param mixed $value + * @return void */ public function offsetSet($key, $value) { @@ -86,6 +90,7 @@ class Collection implements \ArrayAccess, \IteratorAggregate * Implementation of \ArrayAccess:offsetGet() * * @param mixed $key + * @return AbstractElement */ public function offsetGet($key) { @@ -96,6 +101,7 @@ class Collection implements \ArrayAccess, \IteratorAggregate * Implementation of \ArrayAccess:offsetUnset() * * @param mixed $key + * @return void */ public function offsetUnset($key) { @@ -117,15 +123,14 @@ class Collection implements \ArrayAccess, \IteratorAggregate * Add element to collection * * @todo get it straight with $after - * @param \Magento\Data\Form\Element\AbstractElement $element + * @param AbstractElement $element * @param bool|string $after - * - * @return \Magento\Data\Form\Element\Collection + * @return AbstractElement */ - public function add(\Magento\Data\Form\Element\AbstractElement $element, $after = false) + public function add(AbstractElement $element, $after = false) { // Set the Form for the node - if ($this->_container->getForm() instanceof \Magento\Data\Form) { + if ($this->_container->getForm() instanceof Form) { $element->setContainer($this->_container); $element->setForm($this->_container->getForm()); } @@ -157,7 +162,7 @@ class Collection implements \ArrayAccess, \IteratorAggregate * Sort elements by values using a user-defined comparison function * * @param mixed $callback - * @return \Magento\Data\Form\Element\Collection + * @return $this */ public function usort($callback) { @@ -169,7 +174,7 @@ class Collection implements \ArrayAccess, \IteratorAggregate * Remove element from collection * * @param mixed $elementId - * @return \Magento\Data\Form\Element\Collection + * @return $this */ public function remove($elementId) { @@ -197,7 +202,7 @@ class Collection implements \ArrayAccess, \IteratorAggregate * Find element by ID * * @param mixed $elementId - * @return \Magento\Data\Form\Element\AbstractElement|null + * @return AbstractElement */ public function searchById($elementId) { diff --git a/lib/Magento/Data/Form/Element/CollectionFactory.php b/lib/Magento/Data/Form/Element/CollectionFactory.php index 120cf6694c64bf074df9eda480f0d39204cb924a..7494a20d7ae361dbf847642202ca6abab4f9dff1 100644 --- a/lib/Magento/Data/Form/Element/CollectionFactory.php +++ b/lib/Magento/Data/Form/Element/CollectionFactory.php @@ -26,18 +26,21 @@ namespace Magento\Data\Form\Element; +use Magento\ObjectManager; + + class CollectionFactory { /** - * @var \Magento\ObjectManager + * @var ObjectManager */ protected $_objectManager; /** - * @param \Magento\ObjectManager $objectManager + * @param ObjectManager $objectManager */ - public function __construct(\Magento\ObjectManager $objectManager) + public function __construct(ObjectManager $objectManager) { $this->_objectManager = $objectManager; } @@ -46,7 +49,7 @@ class CollectionFactory * Create collection factory with specified parameters * * @param array $data - * @return \Magento\Data\Form\Element\Collection + * @return Collection */ public function create(array $data = array()) { diff --git a/lib/Magento/Data/Form/Element/Date.php b/lib/Magento/Data/Form/Element/Date.php index 892f97e9c60c74468dbee622619c670fb7c14c71..3abff8db7476cf815d1de3aa9d6e4fbf23c9b10b 100644 --- a/lib/Magento/Data/Form/Element/Date.php +++ b/lib/Magento/Data/Form/Element/Date.php @@ -33,7 +33,10 @@ */ namespace Magento\Data\Form\Element; -class Date extends \Magento\Data\Form\Element\AbstractElement +use Magento\Escaper; +use Magento\Stdlib\DateTime; + +class Date extends AbstractElement { /** * @var \Zend_Date @@ -41,15 +44,15 @@ class Date extends \Magento\Data\Form\Element\AbstractElement protected $_value; /** - * @param \Magento\Data\Form\Element\Factory $factoryElement - * @param \Magento\Data\Form\Element\CollectionFactory $factoryCollection - * @param \Magento\Escaper $escaper + * @param Factory $factoryElement + * @param CollectionFactory $factoryCollection + * @param Escaper $escaper * @param array $data */ public function __construct( - \Magento\Data\Form\Element\Factory $factoryElement, - \Magento\Data\Form\Element\CollectionFactory $factoryCollection, - \Magento\Escaper $escaper, + Factory $factoryElement, + CollectionFactory $factoryCollection, + Escaper $escaper, $data = array() ) { parent::__construct($factoryElement, $factoryCollection, $escaper, $data); @@ -63,6 +66,9 @@ class Date extends \Magento\Data\Form\Element\AbstractElement /** * If script executes on x64 system, converts large * numeric values to timestamp limit + * + * @param int $value + * @return int */ protected function _toTimestamp($value) { @@ -84,7 +90,7 @@ class Date extends \Magento\Data\Form\Element\AbstractElement * @param mixed $value * @param string $format * @param string $locale - * @return \Magento\Data\Form\Element\Date + * @return $this */ public function setValue($value, $format = null, $locale = null) { @@ -103,7 +109,7 @@ class Date extends \Magento\Data\Form\Element\AbstractElement } // last check, if input format was set if (null === $format) { - $format = \Magento\Stdlib\DateTime::DATETIME_INTERNAL_FORMAT; + $format = DateTime::DATETIME_INTERNAL_FORMAT; if ($this->getInputFormat()) { $format = $this->getInputFormat(); } diff --git a/lib/Magento/Data/Form/Element/Editablemultiselect.php b/lib/Magento/Data/Form/Element/Editablemultiselect.php index 3680f27058cc6dc25352a1a915eb48ec614dcf68..d9f8c9cb86a316fc1b6b5b0d7cda4b9d1cdd9e73 100644 --- a/lib/Magento/Data/Form/Element/Editablemultiselect.php +++ b/lib/Magento/Data/Form/Element/Editablemultiselect.php @@ -79,7 +79,7 @@ class Editablemultiselect extends \Magento\Data\Form\Element\Multiselect * Retrieve HTML markup of given select option * * @param array $option - * @param array $selected + * @param string[] $selected * @return string */ protected function _optionToHtml($option, $selected) diff --git a/lib/Magento/Data/Form/Element/Editor.php b/lib/Magento/Data/Form/Element/Editor.php index 8863fc719d8a2ba2d806408fe99450a2623338fe..d731bbd3f3d5510dd03715bf63a8b7676c55fb2c 100644 --- a/lib/Magento/Data/Form/Element/Editor.php +++ b/lib/Magento/Data/Form/Element/Editor.php @@ -33,18 +33,20 @@ */ namespace Magento\Data\Form\Element; -class Editor extends \Magento\Data\Form\Element\Textarea +use Magento\Escaper; + +class Editor extends Textarea { /** - * @param \Magento\Data\Form\Element\Factory $factoryElement - * @param \Magento\Data\Form\Element\CollectionFactory $factoryCollection - * @param \Magento\Escaper $escaper + * @param Factory $factoryElement + * @param CollectionFactory $factoryCollection + * @param Escaper $escaper * @param array $data */ public function __construct( - \Magento\Data\Form\Element\Factory $factoryElement, - \Magento\Data\Form\Element\CollectionFactory $factoryCollection, - \Magento\Escaper $escaper, + Factory $factoryElement, + CollectionFactory $factoryCollection, + Escaper $escaper, $data = array() ) { parent::__construct($factoryElement, $factoryCollection, $escaper, $data); @@ -58,6 +60,9 @@ class Editor extends \Magento\Data\Form\Element\Textarea } } + /** + * @return string + */ public function getElementHtml() { $js = ' @@ -153,6 +158,9 @@ class Editor extends \Magento\Data\Form\Element\Textarea } } + /** + * @return mixed + */ public function getTheme() { if(!$this->hasData('theme')) { @@ -183,6 +191,7 @@ class Editor extends \Magento\Data\Form\Element\Textarea /** * Return HTML button to toggling WYSIWYG * + * @param bool $visible * @return string */ protected function _getToggleButtonHtml($visible = true) diff --git a/lib/Magento/Data/Form/Element/Factory.php b/lib/Magento/Data/Form/Element/Factory.php index 3a892b316ee718385d2970be40e309a8369e74d4..673dd7438ad3fa3441bede53e7323bc16cdd7408 100644 --- a/lib/Magento/Data/Form/Element/Factory.php +++ b/lib/Magento/Data/Form/Element/Factory.php @@ -32,17 +32,19 @@ */ namespace Magento\Data\Form\Element; +use Magento\ObjectManager; + class Factory { /** - * @var \Magento\ObjectManager + * @var ObjectManager */ protected $_objectManager; /** * Standard library element types * - * @var array + * @var string[] */ protected $_standardTypes = array( 'button', @@ -76,9 +78,9 @@ class Factory ); /** - * @param \Magento\ObjectManager $objectManager + * @param ObjectManager $objectManager */ - public function __construct(\Magento\ObjectManager $objectManager) + public function __construct(ObjectManager $objectManager) { $this->_objectManager = $objectManager; } @@ -88,7 +90,7 @@ class Factory * * @param string $elementType Standard element type or Custom element class * @param array $config - * @return \Magento\Data\Form\Element\AbstractElement + * @return AbstractElement * @throws \InvalidArgumentException */ public function create($elementType, array $config = array()) @@ -100,7 +102,7 @@ class Factory } $element = $this->_objectManager->create($className, $config); - if (!($element instanceof \Magento\Data\Form\Element\AbstractElement)) { + if (!($element instanceof AbstractElement)) { throw new \InvalidArgumentException($className . ' doesn\'n extend \Magento\Data\Form\Element\AbstractElement'); } diff --git a/lib/Magento/Data/Form/Element/Fieldset.php b/lib/Magento/Data/Form/Element/Fieldset.php index a1adc7672a9d52c1108a29bb0f878cf01db228aa..8b8c3b6ee8bf637d8736bff4fda5ca41c5cc7fdd 100644 --- a/lib/Magento/Data/Form/Element/Fieldset.php +++ b/lib/Magento/Data/Form/Element/Fieldset.php @@ -33,22 +33,25 @@ */ namespace Magento\Data\Form\Element; -class Fieldset extends \Magento\Data\Form\Element\AbstractElement +use Magento\Data\Form; +use Magento\Escaper; + +class Fieldset extends AbstractElement { /** - * @param \Magento\Data\Form\Element\Factory $factoryElement - * @param \Magento\Data\Form\Element\CollectionFactory $factoryCollection - * @param \Magento\Escaper $escaper + * @param Factory $factoryElement + * @param CollectionFactory $factoryCollection + * @param Escaper $escaper * @param array $data */ public function __construct( - \Magento\Data\Form\Element\Factory $factoryElement, - \Magento\Data\Form\Element\CollectionFactory $factoryCollection, - \Magento\Escaper $escaper, + Factory $factoryElement, + CollectionFactory $factoryCollection, + Escaper $escaper, $data = array() ) { parent::__construct($factoryElement, $factoryCollection, $escaper, $data); - $this->_renderer = \Magento\Data\Form::getFieldsetRenderer(); + $this->_renderer = Form::getFieldsetRenderer(); $this->setType('fieldset'); if (isset($data['advancedSection'])) { $this->setAdvancedLabel($data['advancedSection']); @@ -76,7 +79,7 @@ class Fieldset extends \Magento\Data\Form\Element\AbstractElement /** * Get Children element's array * - * @return array + * @return AbstractElement[] */ public function getChildren() { @@ -102,7 +105,7 @@ class Fieldset extends \Magento\Data\Form\Element\AbstractElement /** * Get Basic elements' array * - * @return array + * @return AbstractElement[] */ public function getBasicChildren() { @@ -126,7 +129,7 @@ class Fieldset extends \Magento\Data\Form\Element\AbstractElement } /** - * Get Number of Bacic Children + * Get Number of Basic Children * * @return int */ @@ -179,7 +182,7 @@ class Fieldset extends \Magento\Data\Form\Element\AbstractElement /** * Get SubFieldset * - * @return array + * @return AbstractElement[] */ public function getSubFieldset() { @@ -222,12 +225,12 @@ class Fieldset extends \Magento\Data\Form\Element\AbstractElement * @param string $type * @param array $config * @param boolean $after - * @return \Magento\Data\Form\Element\AbstractElement + * @return AbstractElement */ public function addField($elementId, $type, $config, $after = false, $isAdvanced = false) { $element = parent::addField($elementId, $type, $config, $after); - if ($renderer = \Magento\Data\Form::getFieldsetElementRenderer()) { + if ($renderer = Form::getFieldsetElementRenderer()) { $element->setRenderer($renderer); } $element->setAdvanced($isAdvanced); @@ -237,7 +240,7 @@ class Fieldset extends \Magento\Data\Form\Element\AbstractElement /** * Return elements as html string * - * @param array $elements + * @param AbstractElement[] $elements * @return string */ protected function _elementsToHtml($elements) diff --git a/lib/Magento/Data/Form/Element/Gallery.php b/lib/Magento/Data/Form/Element/Gallery.php index 319382e3f20fc04411849ce379aa7f018cc19a88..ab450c6ec8f8f26edd76dee1a59a5363cb281eff 100644 --- a/lib/Magento/Data/Form/Element/Gallery.php +++ b/lib/Magento/Data/Form/Element/Gallery.php @@ -33,24 +33,29 @@ */ namespace Magento\Data\Form\Element; -class Gallery extends \Magento\Data\Form\Element\AbstractElement +use Magento\Escaper; + +class Gallery extends AbstractElement { /** - * @param \Magento\Data\Form\Element\Factory $factoryElement - * @param \Magento\Data\Form\Element\CollectionFactory $factoryCollection - * @param \Magento\Escaper $escaper + * @param Factory $factoryElement + * @param CollectionFactory $factoryCollection + * @param Escaper $escaper * @param array $data */ public function __construct( - \Magento\Data\Form\Element\Factory $factoryElement, - \Magento\Data\Form\Element\CollectionFactory $factoryCollection, - \Magento\Escaper $escaper, + Factory $factoryElement, + CollectionFactory $factoryCollection, + Escaper $escaper, $data = array() ) { parent::__construct($factoryElement, $factoryCollection, $escaper, $data); $this->setType('file'); } + /** + * @return string + */ public function getElementHtml() { $gallery = $this->getValue(); @@ -173,11 +178,17 @@ EndSCRIPT; return $html; } + /** + * @return mixed + */ public function getName() { return $this->getData('name'); } + /** + * @return mixed + */ public function getParentName() { return parent::getName(); diff --git a/lib/Magento/Data/Form/Element/Hidden.php b/lib/Magento/Data/Form/Element/Hidden.php index 202b3a72ee01f72e973c9e5b2d9552cd7d890590..35af26af0e5f0ded487fde037f010bd3cd36f22f 100644 --- a/lib/Magento/Data/Form/Element/Hidden.php +++ b/lib/Magento/Data/Form/Element/Hidden.php @@ -33,18 +33,20 @@ */ namespace Magento\Data\Form\Element; -class Hidden extends \Magento\Data\Form\Element\AbstractElement +use Magento\Escaper; + +class Hidden extends AbstractElement { /** - * @param \Magento\Data\Form\Element\Factory $factoryElement - * @param \Magento\Data\Form\Element\CollectionFactory $factoryCollection - * @param \Magento\Escaper $escaper + * @param Factory $factoryElement + * @param CollectionFactory $factoryCollection + * @param Escaper $escaper * @param array $data */ public function __construct( - \Magento\Data\Form\Element\Factory $factoryElement, - \Magento\Data\Form\Element\CollectionFactory $factoryCollection, - \Magento\Escaper $escaper, + Factory $factoryElement, + CollectionFactory $factoryCollection, + Escaper $escaper, $data = array() ) { parent::__construct($factoryElement, $factoryCollection, $escaper, $data); @@ -52,6 +54,9 @@ class Hidden extends \Magento\Data\Form\Element\AbstractElement $this->setExtType('hiddenfield'); } + /** + * @return mixed + */ public function getDefaultHtml() { $html = $this->getData('default_html'); diff --git a/lib/Magento/Data/Form/Element/Link.php b/lib/Magento/Data/Form/Element/Link.php index 34d338aa36c7dad6b968cae0137ae91d3a1af28d..92e74b8867e8214a6f70ff0114f574bce77fb14c 100644 --- a/lib/Magento/Data/Form/Element/Link.php +++ b/lib/Magento/Data/Form/Element/Link.php @@ -33,18 +33,20 @@ */ namespace Magento\Data\Form\Element; -class Link extends \Magento\Data\Form\Element\AbstractElement +use Magento\Escaper; + +class Link extends AbstractElement { /** - * @param \Magento\Data\Form\Element\Factory $factoryElement - * @param \Magento\Data\Form\Element\CollectionFactory $factoryCollection - * @param \Magento\Escaper $escaper + * @param Factory $factoryElement + * @param CollectionFactory $factoryCollection + * @param Escaper $escaper * @param array $data */ public function __construct( - \Magento\Data\Form\Element\Factory $factoryElement, - \Magento\Data\Form\Element\CollectionFactory $factoryCollection, - \Magento\Escaper $escaper, + Factory $factoryElement, + CollectionFactory $factoryCollection, + Escaper $escaper, $data = array() ) { parent::__construct($factoryElement, $factoryCollection, $escaper, $data); @@ -68,7 +70,7 @@ class Link extends \Magento\Data\Form\Element\AbstractElement /** * Prepare array of anchor attributes * - * @return array + * @return string[] */ public function getHtmlAttributes() { diff --git a/lib/Magento/Data/Form/Element/Multiline.php b/lib/Magento/Data/Form/Element/Multiline.php index d9e9fe26c2ace8d1cde7414dd31541eec4fba98d..c36f344ed458a0f32e6a101eda1a59add0ed21b5 100644 --- a/lib/Magento/Data/Form/Element/Multiline.php +++ b/lib/Magento/Data/Form/Element/Multiline.php @@ -31,18 +31,20 @@ */ namespace Magento\Data\Form\Element; -class Multiline extends \Magento\Data\Form\Element\AbstractElement +use Magento\Escaper; + +class Multiline extends AbstractElement { /** - * @param \Magento\Data\Form\Element\Factory $factoryElement - * @param \Magento\Data\Form\Element\CollectionFactory $factoryCollection - * @param \Magento\Escaper $escaper + * @param Factory $factoryElement + * @param CollectionFactory $factoryCollection + * @param Escaper $escaper * @param array $data */ public function __construct( - \Magento\Data\Form\Element\Factory $factoryElement, - \Magento\Data\Form\Element\CollectionFactory $factoryCollection, - \Magento\Escaper $escaper, + Factory $factoryElement, + CollectionFactory $factoryCollection, + Escaper $escaper, $data = array() ) { parent::__construct($factoryElement, $factoryCollection, $escaper, $data); @@ -50,11 +52,18 @@ class Multiline extends \Magento\Data\Form\Element\AbstractElement $this->setLineCount(2); } + /** + * @return string[] + */ public function getHtmlAttributes() { return array('type', 'title', 'class', 'style', 'onclick', 'onchange', 'disabled', 'maxlength'); } + /** + * @param int $suffix + * @return string + */ public function getLabelHtml($suffix = 0) { return parent::getLabelHtml($suffix); @@ -87,6 +96,9 @@ class Multiline extends \Magento\Data\Form\Element\AbstractElement return $html; } + /** + * @return mixed + */ public function getDefaultHtml() { $html = ''; diff --git a/lib/Magento/Data/Form/Element/Multiselect.php b/lib/Magento/Data/Form/Element/Multiselect.php index 55288127551809ce435c17c6d946d782460486f1..4d25bd6f6925efd21b6ce448cfcf2e197eba4edc 100644 --- a/lib/Magento/Data/Form/Element/Multiselect.php +++ b/lib/Magento/Data/Form/Element/Multiselect.php @@ -33,18 +33,20 @@ */ namespace Magento\Data\Form\Element; -class Multiselect extends \Magento\Data\Form\Element\AbstractElement +use Magento\Escaper; + +class Multiselect extends AbstractElement { /** - * @param \Magento\Data\Form\Element\Factory $factoryElement - * @param \Magento\Data\Form\Element\CollectionFactory $factoryCollection - * @param \Magento\Escaper $escaper + * @param Factory $factoryElement + * @param CollectionFactory $factoryCollection + * @param Escaper $escaper * @param array $data */ public function __construct( - \Magento\Data\Form\Element\Factory $factoryElement, - \Magento\Data\Form\Element\CollectionFactory $factoryCollection, - \Magento\Escaper $escaper, + Factory $factoryElement, + CollectionFactory $factoryCollection, + Escaper $escaper, $data = array() ) { parent::__construct($factoryElement, $factoryCollection, $escaper, $data); @@ -53,6 +55,11 @@ class Multiselect extends \Magento\Data\Form\Element\AbstractElement $this->setSize(10); } + /** + * Get the name + * + * @return string + */ public function getName() { $name = parent::getName(); @@ -62,6 +69,11 @@ class Multiselect extends \Magento\Data\Form\Element\AbstractElement return $name; } + /** + * Get the element as HTML + * + * @return string + */ public function getElementHtml() { $this->addClass('select multiselect'); @@ -98,11 +110,21 @@ class Multiselect extends \Magento\Data\Form\Element\AbstractElement return $html; } + /** + * Get the HTML attributes + * + * @return string[] + */ public function getHtmlAttributes() { return array('title', 'class', 'style', 'onclick', 'onchange', 'disabled', 'size', 'tabindex'); } + /** + * Get the default HTML + * + * @return string + */ public function getDefaultHtml() { $result = $this->getNoSpan() === true ? '' : '<span class="field-row">' . "\n"; @@ -142,11 +164,21 @@ class Multiselect extends \Magento\Data\Form\Element\AbstractElement return $result; } + /** + * Get the name of the JS object + * + * @return string + */ public function getJsObjectName() { return $this->getHtmlId() . 'ElementControl'; } + /** + * @param array $option + * @param array $selected + * @return string + */ protected function _optionToHtml($option, $selected) { $html = '<option value="'.$this->_escape($option['value']).'"'; diff --git a/lib/Magento/Data/Form/Element/Note.php b/lib/Magento/Data/Form/Element/Note.php index b8eb1a53bc571d12f7ff4c1eff4a8032f7bd787c..e0d978056c389c5980f9242554951ee8ae64fd94 100644 --- a/lib/Magento/Data/Form/Element/Note.php +++ b/lib/Magento/Data/Form/Element/Note.php @@ -33,24 +33,29 @@ */ namespace Magento\Data\Form\Element; -class Note extends \Magento\Data\Form\Element\AbstractElement +use Magento\Escaper; + +class Note extends AbstractElement { /** - * @param \Magento\Data\Form\Element\Factory $factoryElement - * @param \Magento\Data\Form\Element\CollectionFactory $factoryCollection - * @param \Magento\Escaper $escaper + * @param Factory $factoryElement + * @param CollectionFactory $factoryCollection + * @param Escaper $escaper * @param array $data */ public function __construct( - \Magento\Data\Form\Element\Factory $factoryElement, - \Magento\Data\Form\Element\CollectionFactory $factoryCollection, - \Magento\Escaper $escaper, + Factory $factoryElement, + CollectionFactory $factoryCollection, + Escaper $escaper, $data = array() ) { parent::__construct($factoryElement, $factoryCollection, $escaper, $data); $this->setType('note'); } + /** + * @return string + */ public function getElementHtml() { $html = '<div id="' . $this->getHtmlId() . '" class="control-value">' . $this->getText() . '</div>'; diff --git a/lib/Magento/Data/Form/Element/Obscure.php b/lib/Magento/Data/Form/Element/Obscure.php index b287795cc830d21f99203cb3afd4d09f0c759285..7ded3b6d972a01f3de150fb23203bd721c44f064 100644 --- a/lib/Magento/Data/Form/Element/Obscure.php +++ b/lib/Magento/Data/Form/Element/Obscure.php @@ -58,7 +58,7 @@ class Obscure extends \Magento\Data\Form\Element\Password /** * Returns list of html attributes possible to output in HTML * - * @return array() + * @return string[] */ public function getHtmlAttributes() { diff --git a/lib/Magento/Data/Form/Element/Password.php b/lib/Magento/Data/Form/Element/Password.php index 11ef95739da962e5c7f4d6071eb7108c03d3b854..554504db6effbb541543bf92f88e7229c9323684 100644 --- a/lib/Magento/Data/Form/Element/Password.php +++ b/lib/Magento/Data/Form/Element/Password.php @@ -33,25 +33,30 @@ */ namespace Magento\Data\Form\Element; -class Password extends \Magento\Data\Form\Element\AbstractElement +use Magento\Escaper; + +class Password extends AbstractElement { /** - * @param \Magento\Data\Form\Element\Factory $factoryElement - * @param \Magento\Data\Form\Element\CollectionFactory $factoryCollection - * @param \Magento\Escaper $escaper + * @param Factory $factoryElement + * @param CollectionFactory $factoryCollection + * @param Escaper $escaper * @param array $data */ public function __construct( - \Magento\Data\Form\Element\Factory $factoryElement, - \Magento\Data\Form\Element\CollectionFactory $factoryCollection, - \Magento\Escaper $escaper, + Factory $factoryElement, + CollectionFactory $factoryCollection, + Escaper $escaper, $data = array() ) { parent::__construct($factoryElement, $factoryCollection, $escaper, $data); $this->setType('password'); $this->setExtType('textfield'); } - + + /** + * @return mixed + */ public function getHtml() { $this->addClass('input-text'); diff --git a/lib/Magento/Data/Form/Element/Radios.php b/lib/Magento/Data/Form/Element/Radios.php index a3467358684e88aba0c6b25abe17210ae77e6b36..081d74e367a7a8d6472338ef0fdcae2f8b2668d9 100644 --- a/lib/Magento/Data/Form/Element/Radios.php +++ b/lib/Magento/Data/Form/Element/Radios.php @@ -33,24 +33,29 @@ */ namespace Magento\Data\Form\Element; -class Radios extends \Magento\Data\Form\Element\AbstractElement +use Magento\Escaper; + +class Radios extends AbstractElement { /** - * @param \Magento\Data\Form\Element\Factory $factoryElement - * @param \Magento\Data\Form\Element\CollectionFactory $factoryCollection - * @param \Magento\Escaper $escaper + * @param Factory $factoryElement + * @param CollectionFactory $factoryCollection + * @param Escaper $escaper * @param array $data */ public function __construct( - \Magento\Data\Form\Element\Factory $factoryElement, - \Magento\Data\Form\Element\CollectionFactory $factoryCollection, - \Magento\Escaper $escaper, + Factory $factoryElement, + CollectionFactory $factoryCollection, + Escaper $escaper, $data = array() ) { parent::__construct($factoryElement, $factoryCollection, $escaper, $data); $this->setType('radios'); } + /** + * @return mixed + */ public function getSeparator() { $separator = $this->getData('separator'); @@ -60,6 +65,9 @@ class Radios extends \Magento\Data\Form\Element\AbstractElement return $separator; } + /** + * @return string + */ public function getElementHtml() { $html = ''; @@ -73,6 +81,11 @@ class Radios extends \Magento\Data\Form\Element\AbstractElement return $html; } + /** + * @param array $option + * @param array $selected + * @return string + */ protected function _optionToHtml($option, $selected) { $html = '<input type="radio"'.$this->serialize(array('name', 'class', 'style')); diff --git a/lib/Magento/Data/Form/Element/Select.php b/lib/Magento/Data/Form/Element/Select.php index a34858321a4a493d32435c2a11e94d8a8795c467..20cfd1b6e64a3e1594302d1c4a7c3c1ccaac0a39 100644 --- a/lib/Magento/Data/Form/Element/Select.php +++ b/lib/Magento/Data/Form/Element/Select.php @@ -33,18 +33,20 @@ */ namespace Magento\Data\Form\Element; -class Select extends \Magento\Data\Form\Element\AbstractElement +use Magento\Escaper; + +class Select extends AbstractElement { /** - * @param \Magento\Data\Form\Element\Factory $factoryElement - * @param \Magento\Data\Form\Element\CollectionFactory $factoryCollection - * @param \Magento\Escaper $escaper + * @param Factory $factoryElement + * @param CollectionFactory $factoryCollection + * @param Escaper $escaper * @param array $data */ public function __construct( - \Magento\Data\Form\Element\Factory $factoryElement, - \Magento\Data\Form\Element\CollectionFactory $factoryCollection, - \Magento\Escaper $escaper, + Factory $factoryElement, + CollectionFactory $factoryCollection, + Escaper $escaper, $data = array() ) { parent::__construct($factoryElement, $factoryCollection, $escaper, $data); @@ -53,6 +55,11 @@ class Select extends \Magento\Data\Form\Element\AbstractElement $this->_prepareOptions(); } + /** + * Get the element Html. + * + * @return string + */ public function getElementHtml() { $this->addClass('select'); @@ -100,6 +107,13 @@ class Select extends \Magento\Data\Form\Element\AbstractElement return $html; } + /** + * Format an option as Html + * + * @param array $option + * @param array $selected + * @return string + */ protected function _optionToHtml($option, $selected) { if (is_array($option['value'])) { @@ -121,6 +135,11 @@ class Select extends \Magento\Data\Form\Element\AbstractElement return $html; } + /** + * Prepare options. + * + * @return void + */ protected function _prepareOptions() { $values = $this->getValues(); @@ -138,6 +157,11 @@ class Select extends \Magento\Data\Form\Element\AbstractElement } } + /** + * Get the Html attributes. + * + * @return string[] + */ public function getHtmlAttributes() { return array('title', 'class', 'style', 'onclick', 'onchange', 'disabled', 'readonly', 'tabindex'); diff --git a/lib/Magento/Data/Form/Element/Submit.php b/lib/Magento/Data/Form/Element/Submit.php index 558019f51fbd16ca5425820153c8f71579aca78e..fb9f8344d7338cb8c08259a87b443947e659ad48 100644 --- a/lib/Magento/Data/Form/Element/Submit.php +++ b/lib/Magento/Data/Form/Element/Submit.php @@ -33,18 +33,20 @@ */ namespace Magento\Data\Form\Element; -class Submit extends \Magento\Data\Form\Element\AbstractElement +use Magento\Escaper; + +class Submit extends AbstractElement { /** - * @param \Magento\Data\Form\Element\Factory $factoryElement - * @param \Magento\Data\Form\Element\CollectionFactory $factoryCollection - * @param \Magento\Escaper $escaper + * @param Factory $factoryElement + * @param CollectionFactory $factoryCollection + * @param Escaper $escaper * @param array $data */ public function __construct( - \Magento\Data\Form\Element\Factory $factoryElement, - \Magento\Data\Form\Element\CollectionFactory $factoryCollection, - \Magento\Escaper $escaper, + Factory $factoryElement, + CollectionFactory $factoryCollection, + Escaper $escaper, $data = array() ) { parent::__construct($factoryElement, $factoryCollection, $escaper, $data); @@ -52,6 +54,9 @@ class Submit extends \Magento\Data\Form\Element\AbstractElement $this->setType('submit'); } + /** + * @return mixed + */ public function getHtml() { $this->addClass('submit'); diff --git a/lib/Magento/Data/Form/Element/Text.php b/lib/Magento/Data/Form/Element/Text.php index 6006f763625a53c72f656b02f202fe7c9a33a1a9..91d39ef1d7148e500e01bb7b4341b9c613f80f1b 100644 --- a/lib/Magento/Data/Form/Element/Text.php +++ b/lib/Magento/Data/Form/Element/Text.php @@ -33,18 +33,20 @@ */ namespace Magento\Data\Form\Element; -class Text extends \Magento\Data\Form\Element\AbstractElement +use Magento\Escaper; + +class Text extends AbstractElement { /** - * @param \Magento\Data\Form\Element\Factory $factoryElement - * @param \Magento\Data\Form\Element\CollectionFactory $factoryCollection - * @param \Magento\Escaper $escaper + * @param Factory $factoryElement + * @param CollectionFactory $factoryCollection + * @param Escaper $escaper * @param array $data */ public function __construct( - \Magento\Data\Form\Element\Factory $factoryElement, - \Magento\Data\Form\Element\CollectionFactory $factoryCollection, - \Magento\Escaper $escaper, + Factory $factoryElement, + CollectionFactory $factoryCollection, + Escaper $escaper, $data = array() ) { parent::__construct($factoryElement, $factoryCollection, $escaper, $data); @@ -52,12 +54,22 @@ class Text extends \Magento\Data\Form\Element\AbstractElement $this->setExtType('textfield'); } + /** + * Get the HTML + * + * @return mixed + */ public function getHtml() { $this->addClass('input-text'); return parent::getHtml(); } + /** + * Get the attributes + * + * @return string[] + */ public function getHtmlAttributes() { return array('type', 'title', 'class', 'style', 'onclick', 'onchange', 'onkeyup', 'disabled', 'readonly', diff --git a/lib/Magento/Data/Form/Element/Textarea.php b/lib/Magento/Data/Form/Element/Textarea.php index 889a7ae91b60ce50c512b9af4b1f0d4dd10e50bd..75a460fb8e2a7d3eebb11157d861ff4a0849d68c 100644 --- a/lib/Magento/Data/Form/Element/Textarea.php +++ b/lib/Magento/Data/Form/Element/Textarea.php @@ -33,18 +33,20 @@ */ namespace Magento\Data\Form\Element; -class Textarea extends \Magento\Data\Form\Element\AbstractElement +use Magento\Escaper; + +class Textarea extends AbstractElement { /** - * @param \Magento\Data\Form\Element\Factory $factoryElement - * @param \Magento\Data\Form\Element\CollectionFactory $factoryCollection - * @param \Magento\Escaper $escaper + * @param Factory $factoryElement + * @param CollectionFactory $factoryCollection + * @param Escaper $escaper * @param array $data */ public function __construct( - \Magento\Data\Form\Element\Factory $factoryElement, - \Magento\Data\Form\Element\CollectionFactory $factoryCollection, - \Magento\Escaper $escaper, + Factory $factoryElement, + CollectionFactory $factoryCollection, + Escaper $escaper, $data = array() ) { parent::__construct($factoryElement, $factoryCollection, $escaper, $data); @@ -54,12 +56,22 @@ class Textarea extends \Magento\Data\Form\Element\AbstractElement $this->setCols(15); } + /** + * Return the HTML attributes + * + * @return string[] + */ public function getHtmlAttributes() { return array('title', 'class', 'style', 'onclick', 'onchange', 'rows', 'cols', 'readonly', 'disabled', 'onkeyup', 'tabindex'); } + /** + * Return the element as HTML + * + * @return string + */ public function getElementHtml() { $this->addClass('textarea'); diff --git a/lib/Magento/Data/Form/Element/Time.php b/lib/Magento/Data/Form/Element/Time.php index 29da1f78be073fa863b3b5e8248d21c4588238a7..06d3556941dda5b1d79151f4caebc057cb9be7dc 100644 --- a/lib/Magento/Data/Form/Element/Time.php +++ b/lib/Magento/Data/Form/Element/Time.php @@ -33,24 +33,29 @@ */ namespace Magento\Data\Form\Element; -class Time extends \Magento\Data\Form\Element\AbstractElement +use Magento\Escaper; + +class Time extends AbstractElement { /** - * @param \Magento\Data\Form\Element\Factory $factoryElement - * @param \Magento\Data\Form\Element\CollectionFactory $factoryCollection - * @param \Magento\Escaper $escaper + * @param Factory $factoryElement + * @param CollectionFactory $factoryCollection + * @param Escaper $escaper * @param array $data */ public function __construct( - \Magento\Data\Form\Element\Factory $factoryElement, - \Magento\Data\Form\Element\CollectionFactory $factoryCollection, - \Magento\Escaper $escaper, + Factory $factoryElement, + CollectionFactory $factoryCollection, + Escaper $escaper, $data = array() ) { parent::__construct($factoryElement, $factoryCollection, $escaper, $data); $this->setType('time'); } + /** + * @return mixed + */ public function getName() { $name = parent::getName(); @@ -60,6 +65,9 @@ class Time extends \Magento\Data\Form\Element\AbstractElement return $name; } + /** + * @return string + */ public function getElementHtml() { $this->addClass('select'); diff --git a/lib/Magento/Data/Graph.php b/lib/Magento/Data/Graph.php index 69f5029decdfd43d823db55e95c19cd601bca59a..e7e71161560f450c1625bde2f9bced597d30e084 100755 --- a/lib/Magento/Data/Graph.php +++ b/lib/Magento/Data/Graph.php @@ -61,7 +61,7 @@ class Graph * * @param string|int $fromNode * @param string|int $toNode - * @return \Magento\Data\Graph + * @return $this * @throws \InvalidArgumentException */ public function addRelation($fromNode, $toNode) @@ -185,6 +185,7 @@ class Graph * * @param string|int $node * @param bool $mustExist + * @return void * @throws \InvalidArgumentException according to assertion rules */ protected function _assertNode($node, $mustExist) diff --git a/lib/Magento/Data/Schema.php b/lib/Magento/Data/Schema.php index dcc7f6afde44353b9ce9ed612cd58e16e537443f..d8c54fb43736d5c9782c2001b13affb4397bbfc1 100644 --- a/lib/Magento/Data/Schema.php +++ b/lib/Magento/Data/Schema.php @@ -10,6 +10,10 @@ namespace Magento\Data; class Schema extends \Magento\Object { + /** + * @param mixed $schema + * @return void + */ public function load($schema) { if (is_array($schema)) { @@ -22,9 +26,13 @@ class Schema extends \Magento\Object } } + /** + * @param mixed $rawData + * @return DataArray + */ public function extract($rawData) { $elements = $rawData; - return new \Magento\Data\DataArray($elements); + return new DataArray($elements); } } diff --git a/lib/Magento/Data/Structure.php b/lib/Magento/Data/Structure.php index ce93b7fb82151ebc726afdd2f37df8e1512c266d..0b08990e96198bbd44dd23c639fe367ca956d50b 100644 --- a/lib/Magento/Data/Structure.php +++ b/lib/Magento/Data/Structure.php @@ -9,6 +9,8 @@ */ namespace Magento\Data; +use Magento\Exception; + class Structure { /** @@ -39,14 +41,15 @@ class Structure * Set elements from external source * * @param array $elements - * @throws \Magento\Exception if any format issues identified + * @return void + * @throws Exception if any format issues identified */ public function importElements(array $elements) { $this->_elements = $elements; foreach ($elements as $elementId => $element) { if (is_numeric($elementId)) { - throw new \Magento\Exception("Element ID must not be numeric: '{$elementId}'."); + throw new Exception("Element ID must not be numeric: '{$elementId}'."); } $this->_assertParentRelation($elementId); if (isset($element[self::GROUPS])) { @@ -55,7 +58,7 @@ class Structure foreach ($groups as $groupName => $group) { $this->_assertArray($group); if ($group !== array_flip($group)) { - throw new \Magento\Exception( + throw new Exception( "Invalid format of group '{$groupName}': " . var_export($group, 1) ); } @@ -71,7 +74,8 @@ class Structure * Verify relations of parent-child * * @param string $elementId - * @throws \Magento\Exception + * @return void + * @throws Exception */ protected function _assertParentRelation($elementId) { @@ -82,7 +86,7 @@ class Structure $parentId = $element[self::PARENT]; $this->_assertElementExists($parentId); if (empty($this->_elements[$parentId][self::CHILDREN][$elementId])) { - throw new \Magento\Exception( + throw new Exception( "Broken parent-child relation: the '{$elementId}' is not in the nested set of '{$parentId}'." ); } @@ -93,14 +97,14 @@ class Structure $children = $element[self::CHILDREN]; $this->_assertArray($children); if ($children !== array_flip(array_flip($children))) { - throw new \Magento\Exception('Invalid format of children: ' . var_export($children, 1)); + throw new Exception('Invalid format of children: ' . var_export($children, 1)); } foreach (array_keys($children) as $childId) { $this->_assertElementExists($childId); if (!isset($this->_elements[$childId][self::PARENT]) || $elementId !== $this->_elements[$childId][self::PARENT] ) { - throw new \Magento\Exception( + throw new Exception( "Broken parent-child relation: the '{$childId}' is supposed to have '{$elementId}' as parent." ); } @@ -123,12 +127,13 @@ class Structure * * @param string $elementId * @param array $data - * @throws \Magento\Exception if an element with this id already exists + * @return void + * @throws Exception if an element with this id already exists */ public function createElement($elementId, array $data) { if (isset($this->_elements[$elementId])) { - throw new \Magento\Exception("Element with ID '{$elementId}' already exists."); + throw new Exception("Element with ID '{$elementId}' already exists."); } $this->_elements[$elementId] = array(); foreach ($data as $key => $value) { @@ -192,7 +197,7 @@ class Structure * @param string $attribute * @param mixed $value * @throws \InvalidArgumentException - * @return \Magento\Data\Structure + * @return $this */ public function setAttribute($elementId, $attribute, $value) { @@ -213,7 +218,7 @@ class Structure * * @param string $elementId * @param string $attribute - * @return bool|mixed + * @return mixed */ public function getAttribute($elementId, $attribute) { @@ -229,14 +234,14 @@ class Structure * * @param string $oldId * @param string $newId - * @return \Magento\Data\Structure - * @throws \Magento\Exception if trying to overwrite another element + * @return $this + * @throws Exception if trying to overwrite another element */ public function renameElement($oldId, $newId) { $this->_assertElementExists($oldId); if (!$newId || isset($this->_elements[$newId])) { - throw new \Magento\Exception("Element with ID '{$newId}' is already defined."); + throw new Exception("Element with ID '{$newId}' is already defined."); } // rename in registry @@ -270,15 +275,16 @@ class Structure * @param string $alias * @param int|null $position * @see _insertChild() for position explanation - * @throws \Magento\Exception if attempting to set parent as child to its child (recursively) + * @return void + * @throws Exception if attempting to set parent as child to its child (recursively) */ public function setAsChild($elementId, $parentId, $alias = '', $position = null) { if ($elementId == $parentId) { - throw new \Magento\Exception("The '{$elementId}' cannot be set as child to itself."); + throw new Exception("The '{$elementId}' cannot be set as child to itself."); } if ($this->_isParentRecursively($elementId, $parentId)) { - throw new \Magento\Exception("The '{$elementId}' is a parent of '{$parentId}' recursively, " + throw new Exception("The '{$elementId}' is a parent of '{$parentId}' recursively, " . "therefore '{$elementId}' cannot be set as child to it." ); } @@ -297,7 +303,7 @@ class Structure * * @param string $elementId ID of an element or its parent element * @param string|null $alias - * @return \Magento\Data\Structure + * @return $this */ public function unsetChild($elementId, $alias = null) { @@ -503,13 +509,13 @@ class Structure * @param string $parentId * @param string $childId * @return int - * @throws \Magento\Exception if specified elements have no parent-child relation + * @throws Exception if specified elements have no parent-child relation */ protected function _getChildOffset($parentId, $childId) { $index = array_search($childId, array_keys($this->getChildren($parentId))); if (false === $index) { - throw new \Magento\Exception("The '{$childId}' is not a child of '{$parentId}'."); + throw new Exception("The '{$childId}' is not a child of '{$parentId}'."); } return $index; } @@ -549,7 +555,8 @@ class Structure * @param string $elementId * @param int|null $offset * @param string $alias - * @throws \Magento\Exception + * @return void + * @throws Exception */ protected function _insertChild($targetParentId, $elementId, $offset, $alias) { @@ -558,17 +565,17 @@ class Structure // validate $this->_assertElementExists($elementId); if (!empty($this->_elements[$elementId][self::PARENT])) { - throw new \Magento\Exception( + throw new Exception( "The element '{$elementId}' already has a parent: '{$this->_elements[$elementId][self::PARENT]}'" ); } $this->_assertElementExists($targetParentId); $children = $this->getChildren($targetParentId); if (isset($children[$elementId])) { - throw new \Magento\Exception("The element '{$elementId}' already a child of '{$targetParentId}'"); + throw new Exception("The element '{$elementId}' already a child of '{$targetParentId}'"); } if (false !== array_search($alias, $children)) { - throw new \Magento\Exception("The element '{$targetParentId}' already has a child with alias '{$alias}'"); + throw new Exception("The element '{$targetParentId}' already has a child with alias '{$alias}'"); } // insert @@ -587,12 +594,13 @@ class Structure * Check if specified element exists * * @param string $elementId - * @throws \Magento\Exception if doesn't exist + * @return void + * @throws Exception if doesn't exist */ private function _assertElementExists($elementId) { if (!isset($this->_elements[$elementId])) { - throw new \Magento\Exception("No element found with ID '{$elementId}'."); + throw new Exception("No element found with ID '{$elementId}'."); } } @@ -600,12 +608,13 @@ class Structure * Check if it is an array * * @param array $value - * @throws \Magento\Exception + * @return void + * @throws Exception */ private function _assertArray($value) { if (!is_array($value)) { - throw new \Magento\Exception("An array expected: " . var_export($value, 1)); + throw new Exception("An array expected: " . var_export($value, 1)); } } } diff --git a/lib/Magento/Data/Tree.php b/lib/Magento/Data/Tree.php index 5509c81017b4d1766d7a9327a8fb68c55ef301ba..fe6b63dcb93b773df3c764fa6c53fd46b09a593b 100644 --- a/lib/Magento/Data/Tree.php +++ b/lib/Magento/Data/Tree.php @@ -34,13 +34,16 @@ */ namespace Magento\Data; +use Magento\Data\Tree\Node; +use Magento\Data\Tree\Node\Collection as NodeCollection; + class Tree { /** * Nodes collection * - * @var \Magento\Data\Tree\Node\Collection + * @var NodeCollection */ protected $_nodes; @@ -50,7 +53,7 @@ class Tree */ public function __construct() { - $this->_nodes = new \Magento\Data\Tree\Node\Collection($this); + $this->_nodes = new NodeCollection($this); } /** @@ -66,7 +69,8 @@ class Tree /** * Enter description here... * - * @param \Magento\Data\Tree\Node $parentNode + * @param Node $parentNode + * @return void */ public function load($parentNode=null) { @@ -76,76 +80,79 @@ class Tree * Enter description here... * * @param unknown_type $nodeId + * @return void */ public function loadNode($nodeId) { } /** - * Enter description here... + * Append child * - * @param array|\Magento\Data\Tree\Node $data - * @param \Magento\Data\Tree\Node $parentNode - * @param \Magento\Data\Tree\Node $prevNode - * @return \Magento\Data\Tree\Node + * @param array|Node $data + * @param Node $parentNode + * @param Node $prevNode + * @return Node */ public function appendChild($data, $parentNode, $prevNode=null) { if (is_array($data)) { $node = $this->addNode( - new \Magento\Data\Tree\Node($data, $parentNode->getIdField(), $this), + new Node($data, $parentNode->getIdField(), $this), $parentNode ); - } elseif ($data instanceof \Magento\Data\Tree\Node) { + } elseif ($data instanceof Node) { $node = $this->addNode($data, $parentNode); } return $node; } /** - * Enter description here... + * Add node * - * @param \Magento\Data\Tree\Node $node - * @param \Magento\Data\Tree\Node $parent - * @return \Magento\Data\Tree\Node + * @param Node $node + * @param Node $parent + * @return Node */ public function addNode($node, $parent=null) { $this->_nodes->add($node); $node->setParent($parent); - if (!is_null($parent) && ($parent instanceof \Magento\Data\Tree\Node) ) { + if (!is_null($parent) && ($parent instanceof Node) ) { $parent->addChild($node); } return $node; } /** - * Enter description here... + * Move node * - * @param \Magento\Data\Tree\Node $node - * @param \Magento\Data\Tree\Node $parentNode - * @param \Magento\Data\Tree\Node $prevNode + * @param Node $node + * @param Node $parentNode + * @param Node $prevNode + * @return void */ public function moveNodeTo($node, $parentNode, $prevNode=null) { } /** - * Enter description here... + * Copy node * - * @param \Magento\Data\Tree\Node $node - * @param \Magento\Data\Tree\Node $parentNode - * @param \Magento\Data\Tree\Node $prevNode + * @param Node $node + * @param Node $parentNode + * @param Node $prevNode + * @return void */ public function copyNodeTo($node, $parentNode, $prevNode=null) { } /** - * Enter description here... + * Remove node * - * @param \Magento\Data\Tree\Node $node - * @return \Magento\Data\Tree + * @param Node $node + * @return $this */ public function removeNode($node) { @@ -158,28 +165,31 @@ class Tree } /** - * Enter description here... + * Create node * - * @param \Magento\Data\Tree\Node $parentNode - * @param \Magento\Data\Tree\Node $prevNode + * @param Node $parentNode + * @param Node $prevNode + * @return void */ public function createNode($parentNode, $prevNode=null) { } /** - * Enter description here... + * Get child * - * @param \Magento\Data\Tree\Node $node + * @param Node $node + * @return void */ public function getChild($node) { } /** - * Enter description here... + * Get children * - * @param \Magento\Data\Tree\Node $node + * @param Node $node + * @return void */ public function getChildren($node) { @@ -188,7 +198,7 @@ class Tree /** * Enter description here... * - * @return \Magento\Data\Tree\Node\Collection + * @return NodeCollection */ public function getNodes() { @@ -199,7 +209,7 @@ class Tree * Enter description here... * * @param unknown_type $nodeId - * @return \Magento\Data\Tree\Node + * @return Node */ public function getNodeById($nodeId) { @@ -207,16 +217,16 @@ class Tree } /** - * Enter description here... + * Get path * - * @param \Magento\Data\Tree\Node $node + * @param Node $node * @return array */ public function getPath($node) { - if ($node instanceof \Magento\Data\Tree\Node ) { + if ($node instanceof Node ) { - } elseif (is_numeric($node)){ + } elseif (is_numeric($node)) { if ($_node = $this->getNodeById($node)) { return $_node->getPath(); } diff --git a/lib/Magento/Data/Tree/Db.php b/lib/Magento/Data/Tree/Db.php index eb3fbd68d226fdfb3f43e37270f14e95677df7c2..100bbb39536a26b2243ac0d86705224bb758102f 100644 --- a/lib/Magento/Data/Tree/Db.php +++ b/lib/Magento/Data/Tree/Db.php @@ -65,13 +65,31 @@ class Db extends \Magento\Data\Tree protected $_select; /** - * Tree ctructure field names + * Tree structure field name: _idField * * @var string */ protected $_idField; + + /** + * Tree structure field name: _parentField + * + * @var string + */ protected $_parentField; + + /** + * Tree structure field name: _levelField + * + * @var string + */ protected $_levelField; + + /** + * Tree structure field name: _orderField + * + * @var string + */ protected $_orderField; /** @@ -87,6 +105,7 @@ class Db extends \Magento\Data\Tree * @param \Zend_Db_Adapter_Abstract $connection * @param string $table * @param array $fields + * @throws \Exception */ public function __construct($connection, $table, $fields) { @@ -116,11 +135,18 @@ class Db extends \Magento\Data\Tree $this->_select->from($this->_table, array_values($fields)); } + /** + * @return \Zend_Db_Select + */ public function getDbSelect() { return $this->_select; } + /** + * @param \Zend_Db_Select $select + * @return void + */ public function setDbSelect($select) { $this->_select = $select; @@ -129,9 +155,10 @@ class Db extends \Magento\Data\Tree /** * Load tree * - * @param int || \Magento\Data\Tree\Node $parentNode + * @param int|Node $parentNode * @param int $recursionLevel recursion level * @return this + * @throws \Exception */ public function load($parentNode=null, $recursionLevel=100) { @@ -139,7 +166,7 @@ class Db extends \Magento\Data\Tree $this->_loadFullTree(); return $this; } - elseif ($parentNode instanceof \Magento\Data\Tree\Node) { + elseif ($parentNode instanceof Node) { $parentId = $parentNode->getId(); } elseif (is_numeric($parentNode)) { @@ -156,7 +183,7 @@ class Db extends \Magento\Data\Tree $select->where($condition); $arrNodes = $this->_conn->fetchAll($select); foreach ($arrNodes as $nodeInfo) { - $node = new \Magento\Data\Tree\Node($nodeInfo, $this->_idField, $this, $parentNode); + $node = new Node($nodeInfo, $this->_idField, $this, $parentNode); $this->addNode($node, $parentNode); if ($recursionLevel) { @@ -166,16 +193,26 @@ class Db extends \Magento\Data\Tree return $this; } + /** + * @param mixed $nodeId + * @return Node + */ public function loadNode($nodeId) { $select = clone $this->_select; $condition = $this->_conn->quoteInto("$this->_table.$this->_idField=?", $nodeId); $select->where($condition); - $node = new \Magento\Data\Tree\Node($this->_conn->fetchRow($select), $this->_idField, $this); + $node = new Node($this->_conn->fetchRow($select), $this->_idField, $this); $this->addNode($node); return $node; } + /** + * @param Node $data + * @param Node $parentNode + * @param Node $prevNode + * @return Node + */ public function appendChild($data, $parentNode, $prevNode=null) { $orderSelect = $this->_conn->select(); @@ -196,9 +233,11 @@ class Db extends \Magento\Data\Tree /** * Move tree node * - * @param \Magento\Data\Tree\Node $node - * @param \Magento\Data\Tree\Node $parentNode - * @param \Magento\Data\Tree\Node $prevNode + * @param Node $node + * @param Node $parentNode + * @param Node $prevNode + * @return void + * @throws \Exception */ public function moveNodeTo($node, $parentNode, $prevNode=null) { @@ -245,6 +284,11 @@ class Db extends \Magento\Data\Tree } } + /** + * @param mixed $parentId + * @param int $parentLevel + * @return $this + */ protected function _updateChildLevels($parentId, $parentLevel) { $select = $this->_conn->select() @@ -263,6 +307,9 @@ class Db extends \Magento\Data\Tree return $this; } + /** + * @return $this + */ protected function _loadFullTree() { $select = clone $this->_select; @@ -272,7 +319,7 @@ class Db extends \Magento\Data\Tree $arrNodes = $this->_conn->fetchAll($select); foreach ($arrNodes as $nodeInfo) { - $node = new \Magento\Data\Tree\Node($nodeInfo, $this->_idField, $this); + $node = new Node($nodeInfo, $this->_idField, $this); $parentNode = $this->getNodeById($nodeInfo[$this->_parentField]); $this->addNode($node, $parentNode); } @@ -280,6 +327,11 @@ class Db extends \Magento\Data\Tree return $this; } + /** + * @param Node $node + * @return $this + * @throws \Exception + */ public function removeNode($node) { // For reorder old node branch diff --git a/lib/Magento/Data/Tree/Dbp.php b/lib/Magento/Data/Tree/Dbp.php index d94557e1b7627b079532a819c8a4b03e2784805e..11d26225d6a66db8d16d0c817aede697ad5ca096 100644 --- a/lib/Magento/Data/Tree/Dbp.php +++ b/lib/Magento/Data/Tree/Dbp.php @@ -37,6 +37,8 @@ */ namespace Magento\Data\Tree; +use Magento\DB\Select; + class Dbp extends \Magento\Data\Tree { @@ -59,6 +61,11 @@ class Dbp extends \Magento\Data\Tree */ protected $_table; + /** + * Indicates if loaded + * + * @var bool + */ protected $_loaded = false; /** @@ -69,13 +76,31 @@ class Dbp extends \Magento\Data\Tree protected $_select; /** - * Tree ctructure field names + * Tree structure field: id * * @var string */ protected $_idField; + + /** + * Tree structure field: path + * + * @var string + */ protected $_pathField; + + /** + * Tree structure field: order + * + * @var string + */ protected $_orderField; + + /** + * Tree structure field: level + * + * @var string + */ protected $_levelField; /** @@ -123,7 +148,7 @@ class Dbp extends \Magento\Data\Tree /** * Retrieve current select object * - * @return \Magento\DB\Select + * @return Select */ public function getDbSelect() { @@ -133,7 +158,8 @@ class Dbp extends \Magento\Data\Tree /** * Set Select object * - * @param \Magento\DB\Select $select + * @param Select $select + * @return void */ public function setDbSelect($select) { @@ -143,8 +169,9 @@ class Dbp extends \Magento\Data\Tree /** * Load tree * - * @param int|\Magento\Data\Tree\Node $parentNode - * @return \Magento\Data\Tree\Dbp + * @param int|Node $parentNode + * @param int $recursionLevel + * @return $this */ public function load($parentNode=null, $recursionLevel = 0) { @@ -152,7 +179,7 @@ class Dbp extends \Magento\Data\Tree $startLevel = 1; $parentPath = ''; - if ($parentNode instanceof \Magento\Data\Tree\Node) { + if ($parentNode instanceof Node) { $parentPath = $parentNode->getData($this->_pathField); $startLevel = $parentNode->getData($this->_levelField); } else if (is_numeric($parentNode)) { @@ -201,6 +228,15 @@ class Dbp extends \Magento\Data\Tree return $this; } + /** + * Add child nodes + * + * @param array $children + * @param string $path + * @param Node $parentNode + * @param int $level + * @return void + */ public function addChildNodes($children, $path, $parentNode, $level = 0) { if (isset($children[$path])) { @@ -209,7 +245,7 @@ class Dbp extends \Magento\Data\Tree if ($parentNode && $nodeId && $node = $parentNode->getChildren()->searchById($nodeId)) { $node->addData($child); } else { - $node = new \Magento\Data\Tree\Node($child, $this->_idField, $this, $parentNode); + $node = new Node($child, $this->_idField, $this, $parentNode); } //$node->setLevel(count(explode('/', $node->getData($this->_pathField)))-1); @@ -232,10 +268,10 @@ class Dbp extends \Magento\Data\Tree } /** - * Enter description here... + * Load node * * @param int|string $nodeId - * @return \Magento\Data\Tree\Node + * @return Node */ public function loadNode($nodeId) { @@ -248,11 +284,19 @@ class Dbp extends \Magento\Data\Tree $select->where("{$condField} = ?", $nodeId); - $node = new \Magento\Data\Tree\Node($this->_conn->fetchRow($select), $this->_idField, $this); + $node = new Node($this->_conn->fetchRow($select), $this->_idField, $this); $this->addNode($node); return $node; } + /** + * Get children + * + * @param Node $node + * @param bool $recursive + * @param array $result + * @return array + */ public function getChildren($node, $recursive = true, $result = array()) { if (is_numeric($node)) { $node = $this->getNodeById($node); @@ -276,9 +320,10 @@ class Dbp extends \Magento\Data\Tree * Move tree node * * @todo Use adapter for generate conditions - * @param \Magento\Data\Tree\Node $node - * @param \Magento\Data\Tree\Node $newParent - * @param \Magento\Data\Tree\Node $prevNode + * @param Node $node + * @param Node $newParent + * @param Node $prevNode + * @return void */ public function move($node, $newParent, $prevNode = null) { @@ -327,6 +372,13 @@ class Dbp extends \Magento\Data\Tree } } + /** + * Load ensured nodes + * + * @param object $category + * @param Node $rootNode + * @return void + */ public function loadEnsuredNodes($category, $rootNode) { $pathIds = $category->getPathIds(); @@ -361,6 +413,16 @@ class Dbp extends \Magento\Data\Tree } } + /** + * Add child nodes + * + * @param array $children + * @param string $path + * @param Node $parentNode + * @param bool $withChildren + * @param int $level + * @return void + */ protected function _addChildNodes($children, $path, $parentNode, $withChildren=false, $level = 0) { if (isset($children[$path])) { @@ -369,7 +431,7 @@ class Dbp extends \Magento\Data\Tree if ($parentNode && $nodeId && $node = $parentNode->getChildren()->searchById($nodeId)) { $node->addData($child); } else { - $node = new \Magento\Data\Tree\Node($child, $this->_idField, $this, $parentNode); + $node = new Node($child, $this->_idField, $this, $parentNode); $node->setLevel($node->getData($this->_levelField)); $node->setPathId($node->getData($this->_pathField)); $this->addNode($node, $parentNode); diff --git a/lib/Magento/Data/Tree/Node.php b/lib/Magento/Data/Tree/Node.php index 03c7a897c4a52e8c4561e232f6d0efd82e3a4d20..9e5f976b280f0de26b3cb9ea19d77343ad84fcca 100644 --- a/lib/Magento/Data/Tree/Node.php +++ b/lib/Magento/Data/Tree/Node.php @@ -33,26 +33,29 @@ */ namespace Magento\Data\Tree; +use Magento\Data\Tree; +use Magento\Data\Tree\Node\Collection; + class Node extends \Magento\Object { /** * Parent node * - * @var \Magento\Data\Tree\Node + * @var Node */ protected $_parent; /** * Main tree object * - * @var \Magento\Data\Tree + * @var Tree */ protected $_tree; /** * Child nodes * - * @var \Magento\Data\Tree\Node\Collection + * @var Collection */ protected $_childNodes; @@ -68,8 +71,8 @@ class Node extends \Magento\Object * * @param array $data * @param string $idFeild - * @param \Magento\Data\Tree $tree - * @param \Magento\Data\Tree\Node $parent + * @param Tree $tree + * @param Node $parent */ public function __construct($data, $idFeild, $tree, $parent = null) { @@ -77,7 +80,7 @@ class Node extends \Magento\Object $this->setParent($parent); $this->setIdField($idFeild); $this->setData($data); - $this->_childNodes = new \Magento\Data\Tree\Node\Collection($this); + $this->_childNodes = new Collection($this); } /** @@ -115,10 +118,10 @@ class Node extends \Magento\Object /** * Set node tree object * - * @param \Magento\Data\Tree $tree - * @return this + * @param Tree $tree + * @return $this */ - public function setTree(\Magento\Data\Tree $tree) + public function setTree(Tree $tree) { $this->_tree = $tree; return $this; @@ -127,7 +130,7 @@ class Node extends \Magento\Object /** * Retrieve node tree object * - * @return \Magento\Data\Tree + * @return Tree */ public function getTree() { @@ -137,8 +140,8 @@ class Node extends \Magento\Object /** * Set node parent * - * @param \Magento\Data\Tree\Node $parent - * @return \Magento\Data\Tree\Node + * @param Node $parent + * @return $this */ public function setParent($parent) { @@ -149,7 +152,7 @@ class Node extends \Magento\Object /** * Retrieve node parent * - * @return \Magento\Data\Tree + * @return Tree */ public function getParent() { @@ -166,18 +169,30 @@ class Node extends \Magento\Object return $this->_childNodes->count() > 0; } + /** + * @param mixed $level + * @return $this + */ public function setLevel($level) { $this->setData('level', $level); return $this; } + /** + * @param mixed $path + * @return $this + */ public function setPathId($path) { $this->setData('path_id', $path); return $this; } + /** + * @param Node $node + * @return void + */ public function isChildOf($node) { @@ -198,13 +213,17 @@ class Node extends \Magento\Object /** * Retrieve node children collection * - * @return \Magento\Data\Tree\Node\Collection + * @return Collection */ public function getChildren() { return $this->_childNodes; } + /** + * @param array $nodes + * @return array + */ public function getAllChildNodes(&$nodes = array()) { foreach ($this->_childNodes as $node) { @@ -214,6 +233,9 @@ class Node extends \Magento\Object return $nodes; } + /** + * @return mixed + */ public function getLastChild() { return $this->_childNodes->lastNode(); @@ -222,8 +244,8 @@ class Node extends \Magento\Object /** * Add child node * - * @param \Magento\Data\Tree\Node $node - * @return \Magento\Data\Tree\Node + * @param Node $node + * @return Node */ public function addChild($node) { @@ -231,30 +253,52 @@ class Node extends \Magento\Object return $this; } + /** + * @param Node $prevNode + * @return $this + */ public function appendChild($prevNode=null) { $this->_tree->appendChild($this, $prevNode); return $this; } + /** + * @param Node $parentNode + * @param Node $prevNode + * @return $this + */ public function moveTo($parentNode, $prevNode=null) { $this->_tree->moveNodeTo($this, $parentNode, $prevNode); return $this; } + /** + * @param Node $parentNode + * @param Node $prevNode + * @return $this + */ public function copyTo($parentNode, $prevNode=null) { $this->_tree->copyNodeTo($this, $parentNode, $prevNode); return $this; } + /** + * @param Node $childNode + * @return $this + */ public function removeChild($childNode) { $this->_childNodes->delete($childNode); return $this; } + /** + * @param array $prevNodes + * @return array + */ public function getPath(&$prevNodes = array()) { if ($this->_parent) { @@ -264,11 +308,17 @@ class Node extends \Magento\Object return $prevNodes; } + /** + * @return mixed + */ public function getIsActive() { return $this->_getData('is_active'); } + /** + * @return mixed + */ public function getName() { return $this->_getData('name'); diff --git a/lib/Magento/Data/Tree/Node/Collection.php b/lib/Magento/Data/Tree/Node/Collection.php index d2b42a950e720ad773b809fb392945cf46d7796a..a3d8d254c5b94e91ea6cce78040c1d8ae82ae2fd 100644 --- a/lib/Magento/Data/Tree/Node/Collection.php +++ b/lib/Magento/Data/Tree/Node/Collection.php @@ -33,71 +33,103 @@ */ namespace Magento\Data\Tree\Node; +use Magento\Data\Tree; +use Magento\Data\Tree\Node; + class Collection implements \ArrayAccess, \IteratorAggregate { + /** + * @var array + */ private $_nodes; + + /** + * @var Node + */ private $_container; - + + /** + * @param Node $container + */ public function __construct($container) { $this->_nodes = array(); $this->_container = $container; } - + + /** + * Get the nodes + * + * @return array + */ public function getNodes() { return $this->_nodes; } /** - * Implementation of \IteratorAggregate::getIterator() - */ + * Implementation of \IteratorAggregate::getIterator() + * + * @return \ArrayIterator + */ public function getIterator() { return new \ArrayIterator($this->_nodes); } /** - * Implementation of \ArrayAccess:offsetSet() - */ + * Implementation of \ArrayAccess:offsetSet() + * + * @param string $key + * @param mixed $value + * @return void + */ public function offsetSet($key, $value) { $this->_nodes[$key] = $value; } /** - * Implementation of \ArrayAccess:offsetGet() - */ + * Implementation of \ArrayAccess:offsetGet() + * @param string $key + * @return mixed + */ public function offsetGet($key) { return $this->_nodes[$key]; } /** - * Implementation of \ArrayAccess:offsetUnset() - */ + * Implementation of \ArrayAccess:offsetUnset() + * @param string $key + * @return void + */ public function offsetUnset($key) { unset($this->_nodes[$key]); } /** - * Implementation of \ArrayAccess:offsetExists() - */ + * Implementation of \ArrayAccess:offsetExists() + * @param string $key + * @return bool + */ public function offsetExists($key) { return isset($this->_nodes[$key]); } /** - * Adds a node to this node - */ - public function add(\Magento\Data\Tree\Node $node) + * Adds a node to this node + * @param Node $node + * @return Node + */ + public function add(Node $node) { $node->setParent($this->_container); // Set the Tree for the node - if ($this->_container->getTree() instanceof \Magento\Data\Tree) { + if ($this->_container->getTree() instanceof Tree) { $node->setTree($this->_container->getTree()); } @@ -105,7 +137,13 @@ class Collection implements \ArrayAccess, \IteratorAggregate return $node; } - + + /** + * Delete + * + * @param Node $node + * @return $this + */ public function delete($node) { if (isset($this->_nodes[$node->getId()])) { @@ -113,17 +151,33 @@ class Collection implements \ArrayAccess, \IteratorAggregate } return $this; } - + + /** + * Return count + * + * @return int + */ public function count() { return count($this->_nodes); } + /** + * Return the last node + * + * @return mixed + */ public function lastNode() { return !empty($this->_nodes) ? $this->_nodes[count($this->_nodes) - 1] : null; } + /** + * Search by Id + * + * @param string $nodeId + * @return null + */ public function searchById($nodeId) { if (isset($this->_nodes[$nodeId])) { diff --git a/lib/Magento/Encryption/Crypt.php b/lib/Magento/Encryption/Crypt.php index b2a9c1897ad0327dece58c5bb4ae3163c5b193d1..2ec6fef4714213c70cab6f96108be2651153dd6a 100644 --- a/lib/Magento/Encryption/Crypt.php +++ b/lib/Magento/Encryption/Crypt.php @@ -99,6 +99,8 @@ class Crypt /** * Destructor frees allocated resources + * + * @return void */ public function __destruct() { diff --git a/lib/Magento/Encryption/Encryptor.php b/lib/Magento/Encryption/Encryptor.php index 2943bf1883d2396bc004618857d0343697ef36b9..6ec40339e5c53552a00c06ffd8f243d80e71b55a 100644 --- a/lib/Magento/Encryption/Encryptor.php +++ b/lib/Magento/Encryption/Encryptor.php @@ -82,7 +82,7 @@ class Encryptor implements EncryptorInterface * string * * @param string $password - * @param mixed $salt + * @param bool|int|string $salt * @return string */ public function getHash($password, $salt = false) diff --git a/lib/Magento/Error/Handler.php b/lib/Magento/Error/Handler.php index 2853b58d59d23f9371b58afe6a999e1efeb9d87a..76bcb0fa983e6a3f0a84edb4e295f8a9b622f13c 100644 --- a/lib/Magento/Error/Handler.php +++ b/lib/Magento/Error/Handler.php @@ -56,7 +56,8 @@ class Handler implements HandlerInterface * Process exception * * @param \Exception $exception - * @param array $params + * @param string[] $params + * @return void */ public function processException(\Exception $exception, array $params = array()) { @@ -70,6 +71,7 @@ class Handler implements HandlerInterface * Show error as exception * * @param string $errorMessage + * @return void * @throws \Exception */ protected function _processError($errorMessage) diff --git a/lib/Magento/Error/HandlerInterface.php b/lib/Magento/Error/HandlerInterface.php index e9551cc9d2f35a83b9ac1f5e25d4460a518a48bb..45d030e54a13dc1734875a440a090a22c6eee5ac 100644 --- a/lib/Magento/Error/HandlerInterface.php +++ b/lib/Magento/Error/HandlerInterface.php @@ -44,7 +44,7 @@ interface HandlerInterface * Process exception * * @param \Exception $exception - * @param array $params + * @param string[] $params */ public function processException(\Exception $exception, array $params = array()); } diff --git a/lib/Magento/Escaper.php b/lib/Magento/Escaper.php index 2d6144bd03344720f4c7d93c98e5609bcb63f42a..6a9dd4b0f34da076844a68b8977c88840ed3a418 100644 --- a/lib/Magento/Escaper.php +++ b/lib/Magento/Escaper.php @@ -25,6 +25,7 @@ */ namespace Magento; + /** * Magento escape methods */ @@ -44,7 +45,7 @@ class Escaper foreach ($data as $item) { $result[] = $this->escapeHtml($item); } - } else if(strlen($data)) { + } elseif (strlen($data)) { if (is_array($allowedTags) and !empty($allowedTags)) { $allowed = implode('|', $allowedTags); $result = preg_replace('/<([\/\s\r\n]*)(' . $allowed . ')([\/\s\r\n]*)>/si', '##$1$2$3##', $data); diff --git a/lib/Magento/Event.php b/lib/Magento/Event.php index 8f215e26e3c4950639466a2749fcb00fc24ba98a..a6527eaa5e5705cf1520e4e1f8c94f2d0376f70e 100644 --- a/lib/Magento/Event.php +++ b/lib/Magento/Event.php @@ -70,7 +70,7 @@ class Event extends \Magento\Object * Register an observer for the event * * @param \Magento\Event\Observer $observer - * @return \Magento\Event + * @return $this */ public function addObserver(\Magento\Event\Observer $observer) { @@ -82,7 +82,7 @@ class Event extends \Magento\Object * Removes an observer by its name * * @param string $observerName - * @return \Magento\Event + * @return $this */ public function removeObserverByName($observerName) { @@ -93,7 +93,7 @@ class Event extends \Magento\Object /** * Dispatches the event to registered observers * - * @return \Magento\Event + * @return $this */ public function dispatch() { @@ -111,12 +111,19 @@ class Event extends \Magento\Object return isset($this->_data['name']) ? $this->_data['name'] : null; } + /** + * @param string $data + * @return $this + */ public function setName($data) { $this->_data['name'] = $data; return $this; } + /** + * @return mixed + */ public function getBlock() { return $this->_getData('block'); diff --git a/lib/Magento/Event/Collection.php b/lib/Magento/Event/Collection.php index 4618b83ed9b0725334514fa68f11545d0ce23aeb..59bd5d5ec9de728b5a97e48fb19a97feec6a99fd 100644 --- a/lib/Magento/Event/Collection.php +++ b/lib/Magento/Event/Collection.php @@ -34,6 +34,8 @@ */ namespace Magento\Event; +use \Magento\Event; + class Collection { /** @@ -48,7 +50,7 @@ class Collection * * For example regex observers will watch all events that * - * @var \Magento\Event\Observer\Collection + * @var Observer\Collection */ protected $_observers; @@ -59,7 +61,7 @@ class Collection public function __construct() { $this->_events = array(); - $this->_globalObservers = new \Magento\Event\Observer\Collection(); + $this->_globalObservers = new Observer\Collection(); } /** @@ -75,7 +77,7 @@ class Collection /** * Returns all registered global observers for the collection of events * - * @return \Magento\Event\Observer\Collection + * @return Observer\Collection */ public function getGlobalObservers() { @@ -88,12 +90,12 @@ class Collection * If event doesn't exist creates new one and returns it * * @param string $eventName - * @return \Magento\Event + * @return Event */ public function getEventByName($eventName) { if (!isset($this->_events[$eventName])) { - $this->addEvent(new \Magento\Event(array('name'=>$eventName))); + $this->addEvent(new Event(array('name'=>$eventName))); } return $this->_events[$eventName]; } @@ -101,10 +103,10 @@ class Collection /** * Register an event for this collection * - * @param \Magento\Event $event - * @return \Magento\Event\Collection + * @param Event $event + * @return $this */ - public function addEvent(\Magento\Event $event) + public function addEvent(Event $event) { $this->_events[$event->getName()] = $event; return $this; @@ -113,13 +115,13 @@ class Collection /** * Register an observer * - * If observer has event_name property it will be regitered for this specific event. + * If observer has event_name property it will be registered for this specific event. * If not it will be registered as global observer * - * @param \Magento\Event\Observer $observer - * @return \Magento\Event\Collection + * @param Observer $observer + * @return $this */ - public function addObserver(\Magento\Event\Observer $observer) + public function addObserver(Observer $observer) { $eventName = $observer->getEventName(); if ($eventName) { @@ -129,15 +131,15 @@ class Collection } return $this; } - + /** * Dispatch event name with optional data * * Will dispatch specific event and will try all global observers - * + * * @param string $eventName * @param array $data - * @return \Magento\Event\Collection + * @return $this */ public function dispatch($eventName, array $data=array()) { diff --git a/lib/Magento/Event/Config.php b/lib/Magento/Event/Config.php index 023513eacb8743c467339ea400db7bd1c1de3e52..75e4ac03c8fd81c2adfa760630216bd2e8c7a92b 100644 --- a/lib/Magento/Event/Config.php +++ b/lib/Magento/Event/Config.php @@ -25,19 +25,21 @@ */ namespace Magento\Event; -class Config implements \Magento\Event\ConfigInterface +use \Magento\Event\Config\Data; + +class Config implements ConfigInterface { /** * Modules configuration model * - * @var \Magento\Event\Config\Data + * @var Data */ protected $_dataContainer; /** - * @param \Magento\Event\Config\Data $dataContainer + * @param Data $dataContainer */ - public function __construct(Config\Data $dataContainer) + public function __construct(Data $dataContainer) { $this->_dataContainer = $dataContainer; } @@ -45,8 +47,8 @@ class Config implements \Magento\Event\ConfigInterface /** * Get observers by event name * - * @param $eventName - * @return array + * @param string $eventName + * @return null|array|mixed */ public function getObservers($eventName) { diff --git a/lib/Magento/Event/Config/Data.php b/lib/Magento/Event/Config/Data.php index 03978fe06b412b0c438358518c6571e805053a5c..fa4914d152652b28e0542d3424e9996e652fdc17 100644 --- a/lib/Magento/Event/Config/Data.php +++ b/lib/Magento/Event/Config/Data.php @@ -60,9 +60,9 @@ class Data extends \Magento\Config\Data\Scoped /** * Get config value by key * - * @param string $path - * @param mixed $default - * @return mixed + * @param null|string $path + * @param null|mixed $default + * @return null|mixed */ public function get($path = null, $default = null) { diff --git a/lib/Magento/Event/Invoker/InvokerDefault.php b/lib/Magento/Event/Invoker/InvokerDefault.php index e12a806ade05f8edf6fa7b8e31761fbc52cca1aa..83af2cb43bd8ad6c52a369c959e738744b0a1227 100644 --- a/lib/Magento/Event/Invoker/InvokerDefault.php +++ b/lib/Magento/Event/Invoker/InvokerDefault.php @@ -26,6 +26,7 @@ namespace Magento\Event\Invoker; use Zend\Stdlib\Exception\LogicException; +use \Magento\Event\Observer; class InvokerDefault implements \Magento\Event\InvokerInterface { @@ -57,9 +58,10 @@ class InvokerDefault implements \Magento\Event\InvokerInterface * Dispatch event * * @param array $configuration - * @param \Magento\Event\Observer $observer + * @param Observer $observer + * @return void */ - public function dispatch(array $configuration, \Magento\Event\Observer $observer) + public function dispatch(array $configuration, Observer $observer) { /** Check whether event observer is disabled */ if (isset($configuration['disabled']) && true === $configuration['disabled']) { @@ -79,8 +81,8 @@ class InvokerDefault implements \Magento\Event\InvokerInterface * * @param object $object * @param string $method - * @param \Magento\Event\Observer $observer - * @return \Magento\Event\InvokerInterface + * @param Observer $observer + * @return $this * @throws \LogicException */ protected function _callObserverMethod($object, $method, $observer) diff --git a/lib/Magento/Event/Manager.php b/lib/Magento/Event/Manager.php index 87a611793f411354a6dfdd4b554ea338996a2b54..d61f3583b2dd142765d019741b68cf64ed1c053a 100644 --- a/lib/Magento/Event/Manager.php +++ b/lib/Magento/Event/Manager.php @@ -69,6 +69,7 @@ class Manager implements ManagerInterface * * @param string $eventName * @param array $data + * @return void */ public function dispatch($eventName, array $data = array()) { diff --git a/lib/Magento/Event/Observer.php b/lib/Magento/Event/Observer.php index e4e1065248844d666e4261a01b63d4ef7972d801..3ac8075d71efb4b823c644fc3f597151a5628acb 100644 --- a/lib/Magento/Event/Observer.php +++ b/lib/Magento/Event/Observer.php @@ -26,15 +26,17 @@ namespace Magento\Event; +use \Magento\Event; + class Observer extends \Magento\Object { /** * Checks the observer's event_regex against event's name * - * @param \Magento\Event $event + * @param Event $event * @return boolean */ - public function isValidFor(\Magento\Event $event) + public function isValidFor(Event $event) { return $this->getEventName() === $event->getName(); } @@ -42,10 +44,10 @@ class Observer extends \Magento\Object /** * Dispatches an event to observer's callback * - * @param \Magento\Event $event - * @return \Magento\Event\Observer + * @param Event $event + * @return $this */ - public function dispatch(\Magento\Event $event) + public function dispatch(Event $event) { if (!$this->isValidFor($event)) { return $this; @@ -62,31 +64,52 @@ class Observer extends \Magento\Object return $this; } + /** + * @return string + */ public function getName() { return $this->getData('name'); } + /** + * @param string $data + * @return \Magento\Object + */ public function setName($data) { return $this->setData('name', $data); } + /** + * @return string + */ public function getEventName() { return $this->getData('event_name'); } + /** + * @param string $data + * @return \Magento\Object + */ public function setEventName($data) { return $this->setData('event_name', $data); } + /** + * @return string + */ public function getCallback() { return $this->getData('callback'); } + /** + * @param string $data + * @return \Magento\Object + */ public function setCallback($data) { return $this->setData('callback', $data); @@ -95,13 +118,17 @@ class Observer extends \Magento\Object /** * Get observer event object * - * @return \Magento\Event + * @return Event */ public function getEvent() { return $this->getData('event'); } + /** + * @param mixed $data + * @return \Magento\Object + */ public function setEvent($data) { return $this->setData('event', $data); diff --git a/lib/Magento/Event/Observer/Cron.php b/lib/Magento/Event/Observer/Cron.php index d28d885d65a684cf28a38c343a57107d75168ab5..0dfdf0e36dbfa41077febf9407b67d97e4fe7f12 100644 --- a/lib/Magento/Event/Observer/Cron.php +++ b/lib/Magento/Event/Observer/Cron.php @@ -37,7 +37,7 @@ namespace Magento\Event\Observer; class Cron extends \Magento\Event\Observer { /** - * Checkes the observer's cron string against event's name + * Checks the observer's cron string against event's name * * Supports $this->setCronExpr('* 0-5,10-59/5 2-10,15-25 january-june/2 mon-fri') * @@ -59,7 +59,10 @@ class Cron extends \Magento\Event\Observer && $this->matchCronExpression($e[3], $d['mon']) && $this->matchCronExpression($e[4], $d['wday']); } - + + /** + * @return int + */ public function getNow() { if (!$this->hasNow()) { @@ -67,7 +70,12 @@ class Cron extends \Magento\Event\Observer } return $this->getData('now'); } - + + /** + * @param string $expr + * @param int $num + * @return bool + */ public function matchCronExpression($expr, $num) { // handle ALL match @@ -118,7 +126,11 @@ class Cron extends \Magento\Event\Observer $value = $this->getNumeric($expr); return ($value!==false) && ($num==$value) && ($num%$mod===0); } - + + /** + * @param int|string $value + * @return bool|string + */ public function getNumeric($value) { static $data = array( diff --git a/lib/Magento/File/Csv.php b/lib/Magento/File/Csv.php index 9c98a8c01be710792131bd6b986522959e0e87c7..cf4e7a312dfc279786bbfbb30a83aab55fe42f26 100644 --- a/lib/Magento/File/Csv.php +++ b/lib/Magento/File/Csv.php @@ -33,8 +33,19 @@ namespace Magento\File; class Csv { + /** + * @var int + */ protected $_lineLength= 0; + + /** + * @var string + */ protected $_delimiter = ','; + + /** + * @var string + */ protected $_enclosure = '"'; public function __construct() @@ -124,7 +135,7 @@ class Csv * * @param string $file * @param array $data - * @return \Magento\File\Csv + * @return $this */ public function saveData($file, $data) { @@ -135,7 +146,16 @@ class Csv fclose($fh); return $this; } - + + /** + * Write to csv + * + * @param resource $handle + * @param string[] $fields + * @param string $delimiter + * @param string $enclosure + * @return int + */ public function fputcsv(&$handle, $fields = array(), $delimiter = ',', $enclosure = '"') { $str = ''; $escape_char = '\\'; diff --git a/lib/Magento/File/Transfer/Adapter/Http.php b/lib/Magento/File/Transfer/Adapter/Http.php index 8e9f359be0c8b57ea3f18d22c0e4cc559838f8e9..8eace14e12885236ba6d1a07991623575b10a971 100644 --- a/lib/Magento/File/Transfer/Adapter/Http.php +++ b/lib/Magento/File/Transfer/Adapter/Http.php @@ -33,6 +33,9 @@ namespace Magento\File\Transfer\Adapter; class Http { + /** + * @var array + */ protected $_mimeTypes = array( 'txt' => 'text/plain', 'htm' => 'text/html', diff --git a/lib/Magento/File/Uploader.php b/lib/Magento/File/Uploader.php index cc003bd6e46268ec4d5c5b5743c09f4d4057ed3a..e8ced82890c8e3527108f6930d246be5ab69429e 100644 --- a/lib/Magento/File/Uploader.php +++ b/lib/Magento/File/Uploader.php @@ -128,7 +128,7 @@ class Uploader protected $_fileExists = false; /** - * @var null|array + * @var null|string[] */ protected $_allowedExtensions = null; @@ -191,7 +191,7 @@ class Uploader * After save logic * * @param array $result - * @return \Magento\File\Uploader + * @return $this */ protected function _afterSave($result) { @@ -204,7 +204,7 @@ class Uploader * * @param string $destinationFolder * @param string $newFileName - * @return bool + * @return array * @throws \Exception */ public function save($destinationFolder, $newFileName = null) @@ -277,6 +277,7 @@ class Uploader /** * Validate file before save * + * @return void * @throws \Exception */ protected function _validateFile() @@ -388,7 +389,7 @@ class Uploader /** * Used to check if uploaded file mime type is valid or not * - * @param array $validTypes + * @param string[] $validTypes * @access public * @return bool */ @@ -416,9 +417,9 @@ class Uploader /** * Used to set {@link _allowCreateFolders} value * - * @param mixed $flag + * @param bool $flag * @access public - * @return \Magento\File\Uploader + * @return $this */ public function setAllowCreateFolders($flag) { @@ -429,9 +430,9 @@ class Uploader /** * Used to set {@link _allowRenameFiles} value * - * @param mixed $flag + * @param bool $flag * @access public - * @return \Magento\File\Uploader + * @return $this */ public function setAllowRenameFiles($flag) { @@ -442,9 +443,9 @@ class Uploader /** * Used to set {@link _enableFilesDispersion} value * - * @param mixed $flag + * @param bool $flag * @access public - * @return \Magento\File\Uploader + * @return $this */ public function setFilesDispersion($flag) { @@ -455,8 +456,8 @@ class Uploader /** * File names Case-sensitivity setter * - * @param mixed $flag - * @return \Magento\File\Uploader + * @param bool $flag + * @return $this */ public function setFilenamesCaseSensitivity($flag) { @@ -467,8 +468,8 @@ class Uploader /** * Set allowed extensions * - * @param array $extensions - * @return \Magento\File\Uploader + * @param string[] $extensions + * @return $this */ public function setAllowedExtensions($extensions = array()) { @@ -493,6 +494,11 @@ class Uploader return in_array(strtolower($extension), $this->_allowedExtensions); } + /** + * Return file mime type + * + * @return string + */ private function _getMimeType() { return $this->_file['type']; @@ -502,6 +508,7 @@ class Uploader * Set upload field id * * @param string $fileId + * @return void * @throws \Exception */ private function _setUploadFileId($fileId) diff --git a/lib/Magento/Filesystem.php b/lib/Magento/Filesystem.php index 7633443a2cc9f2d2afbb7969c543749b13bda5cb..79d58dc195eb00e80128e364f8cd89d9e98d5a56 100644 --- a/lib/Magento/Filesystem.php +++ b/lib/Magento/Filesystem.php @@ -26,6 +26,7 @@ namespace Magento; use Magento\Filesystem\FilesystemException; +use Magento\Filesystem\File\ReadInterface; class Filesystem { @@ -153,8 +154,8 @@ class Filesystem /** * @param string $path - * @param string $protocol - * @return mixed + * @param string|null $protocol + * @return ReadInterface */ public function getRemoteResource($path, $protocol = null) { diff --git a/lib/Magento/Filesystem/Directory/Read.php b/lib/Magento/Filesystem/Directory/Read.php index cab5a0265a22cca9b4da4f2f5aa1a477e34e7fb5..1ac6adbafe8693de360768d926b44fc717838ce7 100644 --- a/lib/Magento/Filesystem/Directory/Read.php +++ b/lib/Magento/Filesystem/Directory/Read.php @@ -63,8 +63,7 @@ class Read implements ReadInterface * @param \Magento\Filesystem\File\ReadFactory $fileFactory * @param \Magento\Filesystem\DriverInterface $driver */ - public function __construct - ( + public function __construct( array $config, \Magento\Filesystem\File\ReadFactory $fileFactory, \Magento\Filesystem\DriverInterface $driver @@ -119,7 +118,7 @@ class Read implements ReadInterface * Retrieve list of all entities in given path * * @param string|null $path - * @return array + * @return string[] */ public function read($path = null) { @@ -135,7 +134,7 @@ class Read implements ReadInterface * Read recursively * * @param null $path - * @return array + * @return string[] */ public function readRecursively($path = null) { @@ -148,12 +147,13 @@ class Read implements ReadInterface sort($result); return $result; } + /** * Search all entries for given regex pattern * * @param string $pattern * @param string $path [optional] - * @return array + * @return string[] */ public function search($pattern, $path = null) { diff --git a/lib/Magento/Filesystem/Directory/ReadInterface.php b/lib/Magento/Filesystem/Directory/ReadInterface.php index 0d7d024f9c03a22e31d9f8705d7478596ad39d0e..53fa33b7a5bc3881e45ad8b92fa383fe0a286114 100644 --- a/lib/Magento/Filesystem/Directory/ReadInterface.php +++ b/lib/Magento/Filesystem/Directory/ReadInterface.php @@ -29,7 +29,7 @@ interface ReadInterface * Get absolute path * * @param string $path [optional] - * @return string mixed + * @return string */ public function getAbsolutePath($path = null); diff --git a/lib/Magento/Filesystem/Directory/Write.php b/lib/Magento/Filesystem/Directory/Write.php index 7166c67d161ba4ce2cb925dd790b00f576b11a0f..04d66940be63114efca99b34d0c1a48fa121509a 100644 --- a/lib/Magento/Filesystem/Directory/Write.php +++ b/lib/Magento/Filesystem/Directory/Write.php @@ -51,8 +51,7 @@ class Write extends Read implements WriteInterface * @param \Magento\Filesystem\File\WriteFactory $fileFactory * @param \Magento\Filesystem\DriverInterface $driver */ - public function __construct - ( + public function __construct( array $config, \Magento\Filesystem\File\WriteFactory $fileFactory, \Magento\Filesystem\DriverInterface $driver @@ -82,6 +81,8 @@ class Write extends Read implements WriteInterface /** * Check if directory is writable * + * @param string $path + * @return void * @throws \Magento\Filesystem\FilesystemException */ protected function assertWritable($path) @@ -96,6 +97,7 @@ class Write extends Read implements WriteInterface * Check if given path is exists and is file * * @param string $path + * @return void * @throws \Magento\Filesystem\FilesystemException */ protected function assertIsFile($path) diff --git a/lib/Magento/Filesystem/Directory/WriteFactory.php b/lib/Magento/Filesystem/Directory/WriteFactory.php index 00e3c2b125f8bf4c4096243b3f4ad3016c09f8fe..6b5adceb1588c4e0c520027cc24e6a6488ff3721 100644 --- a/lib/Magento/Filesystem/Directory/WriteFactory.php +++ b/lib/Magento/Filesystem/Directory/WriteFactory.php @@ -33,7 +33,7 @@ class WriteFactory * * @param array $config * @param \Magento\Filesystem\DriverFactory $driverFactory - * @return \Magento\Filesystem\File\ReadInterface + * @return \Magento\Filesystem\File\WriteInterface */ public function create(array $config, \Magento\Filesystem\DriverFactory $driverFactory) { diff --git a/lib/Magento/Filesystem/DirectoryList.php b/lib/Magento/Filesystem/DirectoryList.php index 36475275bb49ba53f6d12b4108b6c544ca2baab6..4891bf0c759d1ae1587f473a1792acbd27d38d57 100644 --- a/lib/Magento/Filesystem/DirectoryList.php +++ b/lib/Magento/Filesystem/DirectoryList.php @@ -83,6 +83,7 @@ class DirectoryList * * @param string $code * @param array $directoryConfig + * @return void * @throws \Magento\Filesystem\FilesystemException */ public function addDirectory($code, array $directoryConfig) @@ -105,6 +106,7 @@ class DirectoryList * * @param string $wrapperCode * @param array $configuration + * @return void */ public function addProtocol($wrapperCode, array $configuration) { @@ -211,8 +213,9 @@ class DirectoryList * Path must be usable as a fragment of a URL path. * For interoperability and security purposes, no uppercase or "upper directory" paths like "." or ".." * - * @param $code - * @param $uri + * @param string $code + * @param string $uri + * @return void * @throws \InvalidArgumentException */ private function setUri($code, $uri) @@ -230,6 +233,7 @@ class DirectoryList * * @param string $code * @param string $path + * @return void */ private function setPath($code, $path) { diff --git a/lib/Magento/Filesystem/Driver/File.php b/lib/Magento/Filesystem/Driver/File.php index f9bcee09bfcd24ab16417c8f09de712a5a48dce1..89dee3569e6e338a584449cda021dc1797fec6dc 100644 --- a/lib/Magento/Filesystem/Driver/File.php +++ b/lib/Magento/Filesystem/Driver/File.php @@ -74,7 +74,7 @@ class File implements DriverInterface * * @param string $path * @return array - * @throws \Magento\Filesystem\FilesystemException + * @throws FilesystemException */ public function stat($path) { @@ -94,7 +94,7 @@ class File implements DriverInterface * * @param string $path * @return bool - * @throws \Magento\Filesystem\FilesystemException + * @throws FilesystemException */ public function isReadable($path) { @@ -114,7 +114,7 @@ class File implements DriverInterface * * @param string $path * @return bool - * @throws \Magento\Filesystem\FilesystemException + * @throws FilesystemException */ public function isFile($path) { @@ -134,7 +134,7 @@ class File implements DriverInterface * * @param string $path * @return bool - * @throws \Magento\Filesystem\FilesystemException + * @throws FilesystemException */ public function isDirectory($path) { @@ -177,7 +177,7 @@ class File implements DriverInterface * * @param string $path * @return bool - * @throws \Magento\Filesystem\FilesystemException + * @throws FilesystemException */ public function isWritable($path) { @@ -227,7 +227,7 @@ class File implements DriverInterface * Read directory * * @param string $path - * @return array + * @return string[] * @throws FilesystemException */ public function readDirectory($path) @@ -252,7 +252,7 @@ class File implements DriverInterface * * @param string $pattern * @param string $path - * @return array + * @return string[] * @throws FilesystemException */ public function search($pattern, $path) @@ -670,7 +670,7 @@ class File implements DriverInterface /** * Lock file in selected mode * - * @param $resource + * @param resource $resource * @param int $lockMode * @return bool * @throws FilesystemException @@ -690,7 +690,7 @@ class File implements DriverInterface /** * Unlock file * - * @param $resource + * @param resource $resource * @return bool * @throws FilesystemException */ @@ -761,9 +761,9 @@ class File implements DriverInterface /** * Read directory recursively * - * @param string|null $path - * @return array - * @throws \Magento\Filesystem\FilesystemException + * @param string $path + * @return string[] + * @throws FilesystemException */ public function readDirectoryRecursively($path = null) { diff --git a/lib/Magento/Filesystem/Driver/Http.php b/lib/Magento/Filesystem/Driver/Http.php index 956fa256d50083d4a20e221d1682d7063d5cf893..e44f7fa1a4b4c79e3920ec878665b95f35b6ab2c 100644 --- a/lib/Magento/Filesystem/Driver/Http.php +++ b/lib/Magento/Filesystem/Driver/Http.php @@ -40,7 +40,7 @@ class Http extends File protected $scheme = 'http'; /** - * @param $path + * @param string $path * @return bool * @throws FilesystemException */ @@ -64,7 +64,6 @@ class Http extends File * * @param string $path * @return array - * @throws \Magento\Filesystem\FilesystemException */ public function stat($path) { @@ -120,7 +119,7 @@ class Http extends File * @param string $path * @param string $content * @param string|null $mode - * @param string|null $context + * @param resource|null $context * @return int The number of bytes that were written * @throws FilesystemException */ diff --git a/lib/Magento/Filesystem/DriverFactory.php b/lib/Magento/Filesystem/DriverFactory.php index 30689df87c1441da42f8b99048334844a9684291..29b08bd686ae40e38700ef71dd7670763bb9a701 100644 --- a/lib/Magento/Filesystem/DriverFactory.php +++ b/lib/Magento/Filesystem/DriverFactory.php @@ -34,11 +34,14 @@ class DriverFactory protected $drivers = array(); /** - * @var \Magento\Filesystem\DirectoryList + * @var DirectoryList */ protected $directoryList; - public function __construct(\Magento\Filesystem\DirectoryList $directoryList) + /** + * @param DirectoryList $directoryList + */ + public function __construct(DirectoryList $directoryList) { $this->directoryList = $directoryList; } @@ -59,8 +62,8 @@ class DriverFactory } if (!isset($this->drivers[$driverClass])) { $this->drivers[$driverClass] = new $driverClass($driver); - if (!$this->drivers[$driverClass] instanceof \Magento\Filesystem\DriverInterface) { - throw new \Magento\Filesystem\FilesystemException("Invalid filesystem driver class: " . $driverClass); + if (!$this->drivers[$driverClass] instanceof DriverInterface) { + throw new FilesystemException("Invalid filesystem driver class: " . $driverClass); } } return $this->drivers[$driverClass]; diff --git a/lib/Magento/Filesystem/File/Read.php b/lib/Magento/Filesystem/File/Read.php index 01f122275222b08927709046782b63b063ab9fd1..eb1f6f34564f7d7ec9497946808eae4604873e4d 100644 --- a/lib/Magento/Filesystem/File/Read.php +++ b/lib/Magento/Filesystem/File/Read.php @@ -58,7 +58,7 @@ class Read implements ReadInterface /** * Constructor * - * @param $path + * @param string $path * @param DriverInterface $driver */ public function __construct($path, DriverInterface $driver) @@ -73,7 +73,6 @@ class Read implements ReadInterface /** * Open file * - * @throws FilesystemException * @return $this */ protected function open() @@ -190,6 +189,8 @@ class Read implements ReadInterface /** * {@inheritDoc} + * + * @return array */ public function stat() { diff --git a/lib/Magento/Filesystem/File/Write.php b/lib/Magento/Filesystem/File/Write.php index 96a1db0300ec5c8d70e0d0f55dda2c9a434f34ee..dfb589dec9c7fc916a5d0c431f48f5dc74a0d212 100644 --- a/lib/Magento/Filesystem/File/Write.php +++ b/lib/Magento/Filesystem/File/Write.php @@ -28,7 +28,6 @@ namespace Magento\Filesystem\File; use Magento\Filesystem\DriverInterface; use Magento\Filesystem\FilesystemException; -use Magento\Webapi\Exception; class Write extends Read implements WriteInterface { @@ -48,6 +47,7 @@ class Write extends Read implements WriteInterface /** * Assert file existence for proper mode * + * @return void * @throws \Magento\Filesystem\FilesystemException */ protected function assertValid() diff --git a/lib/Magento/Filesystem/File/WriteFactory.php b/lib/Magento/Filesystem/File/WriteFactory.php index 2b41e422f47ba3a3975a7917fb5a609d59e4c9de..cd1eef669367d4cbab00a86e30a3b28ba7b730bf 100644 --- a/lib/Magento/Filesystem/File/WriteFactory.php +++ b/lib/Magento/Filesystem/File/WriteFactory.php @@ -46,7 +46,7 @@ class WriteFactory /** * Create a readable file. * - * @param $path + * @param string $path * @param string|null $protocol * @param DriverInterface $directoryDriver [optional] * @param string $mode diff --git a/lib/Magento/Filesystem/WrapperFactory.php b/lib/Magento/Filesystem/WrapperFactory.php index 1a9191028970a2d8afc38e49dfa71036c7154864..d9bdea3cc98210d0dcc8d5a9be4381a680e36dd0 100644 --- a/lib/Magento/Filesystem/WrapperFactory.php +++ b/lib/Magento/Filesystem/WrapperFactory.php @@ -43,7 +43,10 @@ class WrapperFactory */ protected $directoryList; - public function __construct(\Magento\Filesystem\DirectoryList $directoryList) + /** + * @param DirectoryList $directoryList + */ + public function __construct(DirectoryList $directoryList) { $this->directoryList = $directoryList; } @@ -53,8 +56,9 @@ class WrapperFactory * * @param string $protocolCode * @param DriverInterface $driver + * @return WrapperInterface */ - public function get($protocolCode, \Magento\Filesystem\DriverInterface $driver) + public function get($protocolCode, DriverInterface $driver) { $wrapperClass = $this->directoryList->getProtocolConfig($protocolCode)['driver']; diff --git a/lib/Magento/Filter/Email.php b/lib/Magento/Filter/Email.php index 908894856822334651d5124afbb4b0b078a339ac..e7d3ac33239803abfcfb9dcda545ee5fe8d372e9 100644 --- a/lib/Magento/Filter/Email.php +++ b/lib/Magento/Filter/Email.php @@ -29,7 +29,7 @@ namespace Magento\Filter; class Email implements \Zend_Filter_Interface { /** - * @param mixed $value + * @param mixed $value * @return mixed */ public function filter($value) diff --git a/lib/Magento/Filter/FilterManager.php b/lib/Magento/Filter/FilterManager.php index a35c2ae126eeb6912c8252065833ae44a6d55117..7fa42430cf62d3107a3381b0a367165942b74b37 100644 --- a/lib/Magento/Filter/FilterManager.php +++ b/lib/Magento/Filter/FilterManager.php @@ -28,6 +28,21 @@ namespace Magento\Filter; /** * Magento Filter Manager + * + * @method string email(string $value) + * @method string money(string $value, $params = array()) + * @method string simple(string $value, $params = array()) + * @method string object(string $value, $params = array()) + * @method string sprintf(string $value, $params = array()) + * @method string template(string $value, $params = array()) + * @method string arrayFilter(string $value) + * @method string removeAccents(string $value, $params = array()) + * @method string splitWords(string $value, $params = array()) + * @method string removeTags(string $value, $params = array()) + * @method string stripTags(string $value, $params = array()) + * @method string truncate(string $value, $params = array()) + * @method string encrypt(string $value, $params = array()) + * @method string decrypt(string $value, $params = array()) */ class FilterManager { @@ -36,18 +51,13 @@ class FilterManager */ protected $objectManager; - /** - * @var array - */ - protected $filterInstances = array(); - /** * @var FilterManager\Config */ protected $config; /** - * @var array + * @var FactoryInterface[] */ protected $factoryInstances; @@ -128,7 +138,7 @@ class FilterManager * * @param string $filterAlias * @param array $arguments - * @return mixed + * @return \Zend_Filter_Interface */ public function __call($filterAlias, array $arguments = array()) { diff --git a/lib/Magento/Filter/FilterManager/Config.php b/lib/Magento/Filter/FilterManager/Config.php index a93ac2a60dbe4fc4c36f24adbf0542acdab1c5bc..545a1dcab3b5c2bdb14681d37409e1b7000beca8 100644 --- a/lib/Magento/Filter/FilterManager/Config.php +++ b/lib/Magento/Filter/FilterManager/Config.php @@ -32,7 +32,7 @@ namespace Magento\Filter\FilterManager; class Config implements ConfigInterface { /** - * @var array + * @var string[] */ protected $factories = array( 'Magento\Filter\Factory', @@ -40,7 +40,7 @@ class Config implements ConfigInterface ); /** - * @param array $factories + * @param string[] $factories */ public function __construct(array $factories = array()) { diff --git a/lib/Magento/Filter/Object.php b/lib/Magento/Filter/Object.php index 56a7381e39e7c4f8881f8073b0a0a201412b9bfa..e33a738ced4ec3462b5444466fd79ece4fdb0889 100644 --- a/lib/Magento/Filter/Object.php +++ b/lib/Magento/Filter/Object.php @@ -65,8 +65,8 @@ class Object extends \Zend_Filter } /** - * @param mixed $object - * @return mixed + * @param \Magento\Object $object + * @return \Magento\Object * @throws \Exception */ public function filter($object) diff --git a/lib/Magento/Filter/Object/Grid.php b/lib/Magento/Filter/Object/Grid.php index 2a219d4b1b79582fa463a2f73f472ee034d3c6da..b247f572e83ce8eeded61e1e996be69d83827339 100644 --- a/lib/Magento/Filter/Object/Grid.php +++ b/lib/Magento/Filter/Object/Grid.php @@ -27,11 +27,13 @@ namespace Magento\Filter\Object; +use Magento\Object; + class Grid extends \Magento\Filter\Object { /** - * @param array $grid - * @return array + * @param Object[] $grid + * @return Object[] */ public function filter($grid) { diff --git a/lib/Magento/Filter/RemoveAccents.php b/lib/Magento/Filter/RemoveAccents.php index 91f2389663d834893819b47ff7f7f69877074f40..7a2d80edd3414c1efede97f4cc2d53619b564b76 100644 --- a/lib/Magento/Filter/RemoveAccents.php +++ b/lib/Magento/Filter/RemoveAccents.php @@ -44,7 +44,7 @@ class RemoveAccents implements \Zend_Filter_Interface /** * @param string $string - * @return mixed|string + * @return string */ public function filter($string) { diff --git a/lib/Magento/Filter/RemoveTags.php b/lib/Magento/Filter/RemoveTags.php index 5d6548ea8e056f06c4aee065eb5823f8eaf2e26d..b519eacd93ea6ec483f10850a075b8f4e9d77f5c 100644 --- a/lib/Magento/Filter/RemoveTags.php +++ b/lib/Magento/Filter/RemoveTags.php @@ -32,7 +32,7 @@ class RemoveTags implements \Zend_Filter_Interface /** * Convert html entities * - * @param array $matches + * @param string[] $matches * @return string */ protected function _convertEntities($matches) diff --git a/lib/Magento/Filter/Sprintf.php b/lib/Magento/Filter/Sprintf.php index 11841350e6e3c1364b629d519e3f09b8133f8bd9..106a3a5953135ca427055643fb2450175ba7cc2f 100644 --- a/lib/Magento/Filter/Sprintf.php +++ b/lib/Magento/Filter/Sprintf.php @@ -31,22 +31,22 @@ class Sprintf implements \Zend_Filter_Interface /** * @var string */ - protected $_format; + protected $format; /** * @var int */ - protected $_decimals; + protected $decimals; /** * @var string */ - protected $_decPoint; + protected $decPoint; /** * @var string */ - protected $_thousandsSep; + protected $thousandsSep; /** * @param string $format @@ -54,24 +54,24 @@ class Sprintf implements \Zend_Filter_Interface * @param string $decPoint * @param string $thousandsSep */ - public function __construct($format, $decimals = 0, $decPoint = '.', $thousandsSep = ',') + public function __construct($format, $decimals = null, $decPoint = '.', $thousandsSep = ',') { - $this->_format = $format; - $this->_decimals = $decimals; - $this->_decPoint = $decPoint; - $this->_thousandsSep = $thousandsSep; + $this->format = $format; + $this->decimals = $decimals; + $this->decPoint = $decPoint; + $this->thousandsSep = $thousandsSep; } /** * @param string $value - * @return mixed|string + * @return string */ public function filter($value) { - if (!is_null($this->_decimals)) { - $value = number_format($value, $this->_decimals, $this->_decPoint, $this->_thousandsSep); + if (null !== $this->decimals) { + $value = number_format($value, $this->decimals, $this->decPoint, $this->thousandsSep); } - $value = sprintf($this->_format, $value); + $value = sprintf($this->format, $value); return $value; } } diff --git a/lib/Magento/Filter/Template.php b/lib/Magento/Filter/Template.php index 2388a57d8f7db38f6790369af9c78f06b00bd5a9..10143ae60afd0fb2dd115a98d7458f53d5a9da3a 100644 --- a/lib/Magento/Filter/Template.php +++ b/lib/Magento/Filter/Template.php @@ -53,7 +53,7 @@ class Template implements \Zend_Filter_Interface /** * Include processor * - * @var array|string|null + * @var callable|null */ protected $_includeProcessor = null; @@ -89,8 +89,8 @@ class Template implements \Zend_Filter_Interface /** * Sets the processor of includes. * - * @param array $callback it must return string - * @return \Magento\Filter\Template + * @param callable $callback it must return string + * @return $this */ public function setIncludeProcessor(array $callback) { @@ -101,7 +101,7 @@ class Template implements \Zend_Filter_Interface /** * Sets the processor of includes. * - * @return array|null + * @return callable|null */ public function getIncludeProcessor() { @@ -156,7 +156,7 @@ class Template implements \Zend_Filter_Interface } /** - * @param array $construction + * @param string[] $construction * @return string */ public function varDirective($construction) @@ -171,7 +171,7 @@ class Template implements \Zend_Filter_Interface } /** - * @param array $construction + * @param string[] $construction * @return mixed */ public function includeDirective($construction) @@ -192,7 +192,7 @@ class Template implements \Zend_Filter_Interface } /** - * @param array $construction + * @param string[] $construction * @return string */ public function dependDirective($construction) @@ -210,7 +210,7 @@ class Template implements \Zend_Filter_Interface } /** - * @param array $construction + * @param string[] $construction * @return string */ public function ifDirective($construction) diff --git a/lib/Magento/Filter/Template/Tokenizer/AbstractTokenizer.php b/lib/Magento/Filter/Template/Tokenizer/AbstractTokenizer.php index 23777b5efbb3cd13f01f45f12a3bacd7b2911524..9df52fd66447acef730bb45705028dcdfa6596bc 100644 --- a/lib/Magento/Filter/Template/Tokenizer/AbstractTokenizer.php +++ b/lib/Magento/Filter/Template/Tokenizer/AbstractTokenizer.php @@ -40,6 +40,8 @@ abstract class AbstractTokenizer /** * String for tokenize + * + * @var string */ protected $_string; @@ -90,6 +92,9 @@ abstract class AbstractTokenizer /** * Set string for tokenize + * + * @param string $value + * @return void */ public function setString($value) { @@ -99,6 +104,8 @@ abstract class AbstractTokenizer /** * Move char index to begin of string + * + * @return void */ public function reset() { @@ -114,6 +121,11 @@ abstract class AbstractTokenizer return trim($this->char()) != $this->char(); } + /** + * Tokenize string + * + * @return array + */ abstract public function tokenize(); } diff --git a/lib/Magento/Gdata/Gshopping/Content.php b/lib/Magento/Gdata/Gshopping/Content.php index b449a42fc6de024ed02f5ed8b4ab5526cc6cc08c..0154a06a12bae92829a0b8aac3ccb332f6bece80 100644 --- a/lib/Magento/Gdata/Gshopping/Content.php +++ b/lib/Magento/Gdata/Gshopping/Content.php @@ -41,6 +41,7 @@ class Content extends \Zend_Gdata /** * Google Merchant account ID + * * @var string */ protected $_accountId; @@ -82,6 +83,7 @@ class Content extends \Zend_Gdata * * @param \Zend_Http_Client $client (optional) The HTTP client to use when * when communicating with the Google Apps servers. + * @param string $accountId Google Merchant account ID * @param string $applicationId The identity of the app in the form of Company-AppName-Version */ public function __construct($client = null, $accountId = null, $applicationId = 'MyCompany-MyApp-1.0') @@ -95,7 +97,8 @@ class Content extends \Zend_Gdata * Retrieve entry object * * @param mixed $location The location for the feed, as a URL or Query - * @return \Magento\Gdata\Gshopping\Entry + * @return Entry + * @throws \Zend_Gdata_App_InvalidArgumentException */ public function getItem($location = null) { @@ -114,11 +117,11 @@ class Content extends \Zend_Gdata /** * Insert an entry * - * @param \Magento\Gdata\Gshopping\Entry $entry The Content entry to upload + * @param Entry $entry The Content entry to upload * @param boolean $dryRun Flag for the 'dry-run' parameter - * @return \Magento\Gdata\Gshopping\Entry + * @return Entry */ - public function insertItem(\Magento\Gdata\Gshopping\Entry $entry, $dryRun = false) + public function insertItem(Entry $entry, $dryRun = false) { $uri = $this->_getItemsUri(); if ($dryRun) { @@ -131,11 +134,11 @@ class Content extends \Zend_Gdata /** * Update an entry * - * @param \Magento\Gdata\Gshopping\Entry $entry The Content entry to be updated + * @param Entry $entry The Content entry to be updated * @param boolean $dryRun Flag for the 'dry-run' parameter - * @return \Magento\Gdata\Gshopping\Entry + * @return Entry */ - public function updateItem(\Magento\Gdata\Gshopping\Entry $entry, $dryRun = false) + public function updateItem(Entry $entry, $dryRun = false) { return $entry->save($dryRun); } @@ -143,11 +146,11 @@ class Content extends \Zend_Gdata /** * Delete an entry * - * @param \Magento\Gdata\Gshopping\Entry $entry The Content entry to remove + * @param Entry $entry The Content entry to remove * @param boolean $dryRun Flag for the 'dry-run' parameter - * @return \Magento\Gdata\Gshopping\Content Implements fluent interface + * @return $this Implements fluent interface */ - public function deleteItem(\Magento\Gdata\Gshopping\Entry $entry, $dryRun = false) + public function deleteItem(Entry $entry, $dryRun = false) { $entry->delete($dryRun); return $this; @@ -214,6 +217,7 @@ class Content extends \Zend_Gdata * @param int $remainingRedirects Number of redirects to follow if request * s results in one * @return \Zend_Http_Response The response object + * @throws HttpException */ public function performHttpRequest($method, $url, $headers = null, $body = null, $contentType = null, $remainingRedirects = null) { @@ -234,7 +238,7 @@ class Content extends \Zend_Gdata } catch (\Zend_Gdata_App_HttpException $e) { $debugData['response'] = $e->getResponse(); $this->debugData($debugData); - throw new \Magento\Gdata\Gshopping\HttpException($e); + throw new HttpException($e); } } @@ -242,7 +246,7 @@ class Content extends \Zend_Gdata * Log debug data * * @param mixed $debugData - * @return \Magento\Gdata\Gshopping\Content + * @return $this */ public function debugData($debugData) { @@ -257,7 +261,7 @@ class Content extends \Zend_Gdata * Set debug flag * * @param bool $flag - * @return \Magento\Gdata\Gshopping\Content + * @return $this */ public function setDebug($flag) { @@ -270,7 +274,7 @@ class Content extends \Zend_Gdata * * @param object $instance * @param string $method - * @return \Magento\Gdata\Gshopping\Content + * @return $this */ public function setLogAdapter($instance, $method) { diff --git a/lib/Magento/Gdata/Gshopping/Entry.php b/lib/Magento/Gdata/Gshopping/Entry.php index a078405989e37e60494846d81effa5a03e814741..d3709a190408ab4c02bce8d5a828e1b2802ed210 100644 --- a/lib/Magento/Gdata/Gshopping/Entry.php +++ b/lib/Magento/Gdata/Gshopping/Entry.php @@ -32,6 +32,8 @@ */ namespace Magento\Gdata\Gshopping; +use Magento\Gdata\Gshopping\Extension\Attribute; + class Entry extends \Zend_Gdata_Entry { @@ -45,7 +47,7 @@ class Entry extends \Zend_Gdata_Entry /** * Google Shopping attribute elements in the 'sc' and 'scp' namespaces * - * @var array + * @var string[] */ protected $_contentAttributes = array(); @@ -58,6 +60,7 @@ class Entry extends \Zend_Gdata_Entry /** * Constructs a new \Magento\Gdata\Gshopping\Entry object. + * * @param \DOMElement $element The \DOMElement on which to base this object. */ public function __construct($element = null) @@ -72,6 +75,8 @@ class Entry extends \Zend_Gdata_Entry * and eventually XML text for application storage/persistence. * * @param \DOMDocument $doc The \DOMDocument used to construct \DOMElements + * @param int $majorVersion + * @param int $minorVersion * @return \DOMElement The \DOMElement representing this element and all * child properties. */ @@ -96,6 +101,7 @@ class Entry extends \Zend_Gdata_Entry * stores them as members of this entry based upon DOM data. * * @param \DOMNode $child The \DOMNode to process + * @return void */ protected function takeChildFromDOM($child) { @@ -114,7 +120,7 @@ class Entry extends \Zend_Gdata_Entry case "$sc:expiration_date": case "$sc:adult": case "$sc:attribute": - $contentAttribute = new \Magento\Gdata\Gshopping\Extension\Attribute(); + $contentAttribute = new Attribute(); $contentAttribute->transferFromDOM($child); $this->_contentAttributes[] = $contentAttribute; break; @@ -144,23 +150,23 @@ class Entry extends \Zend_Gdata_Entry * </sc:attribute> * * @param string $name The name of the attribute - * @param string $value The text value of the attribute + * @param string $text The text value of the attribute * @param string $type (optional) The type of the attribute. * e.g.: 'text', 'number', 'float' * @param string $unit Currecnty for price - * @return \Magento\Gdata\Gshopping\Entry Provides a fluent interface + * @return $this Provides a fluent interface */ public function addContentAttribute($name, $text, $type = null, $unit = null) { - $this->_contentAttributes[] = new \Magento\Gdata\Gshopping\Extension\Attribute($name, $text, $type, $unit); + $this->_contentAttributes[] = new Attribute($name, $text, $type, $unit); return $this; } /** * Removes a Content attribute from the current list of Base attributes * - * @param \Zend_Gdata_Gbase_Extension_BaseAttribute $baseAttribute The attribute to be removed - * @return \Zend_Gdata_Gbase_Entry Provides a fluent interface + * @param string $name The attribute to be removed + * @return $this Provides a fluent interface */ public function removeContentAttribute($name) { @@ -185,7 +191,7 @@ class Entry extends \Zend_Gdata_Entry * @param array $extraHeaders Extra headers to add to the request, as an * array of string-based key/value pairs. * @return \Zend_Gdata_App_Entry The updated entry - * @throws \Zend_Gdata_App_Exception + * @throws \Zend_Gdata_App_InvalidArgumentException */ public function save($dryRun = false, $uri = null, $className = null, $extraHeaders = array()) { @@ -208,7 +214,7 @@ class Entry extends \Zend_Gdata_Entry * * @param boolean $dryRun Whether the transaction is dry run or not * @return void - * @throws \Zend_Gdata_App_Exception + * @throws \Zend_Gdata_App_InvalidArgumentException */ public function delete($dryRun = false) { @@ -229,7 +235,7 @@ class Entry extends \Zend_Gdata_Entry /** * Return all the Content attributes - * @return array + * @return string[] */ public function getContentAttributes() { @@ -240,7 +246,7 @@ class Entry extends \Zend_Gdata_Entry * Return an array of Content attributes that match the given attribute name * * @param string $name The name of the Content attribute to look for - * @return array $matches Array of \Magento\Gdata\Gshopping\Extension\Attribute + * @return string[] $matches Array of Attribute */ public function getContentAttributesByName($name) { @@ -259,7 +265,7 @@ class Entry extends \Zend_Gdata_Entry * return null otherwise * * @param string $name The name of the Content attribute to look for - * @return null|\Magento\Gdata\Gshopping\Extension\Attribute + * @return null|Attribute */ public function getContentAttributeByName($name) { @@ -278,7 +284,7 @@ class Entry extends \Zend_Gdata_Entry * @param array $modes Array with destination names and their statuses. * format: array(name => \Magento\Gdata\Gshopping\Extension\Control::DEST_MODE_*), * for instance: array('ProductSearch' => 2) - * @return \Magento\Gdata\Gshopping\Entry + * @return $this */ public function setDestinationsMode(array $modes) { @@ -304,6 +310,7 @@ class Entry extends \Zend_Gdata_Entry * * @param array $taxInfo Array with tax's information, * it may contains fields: tax_rate, tax_country, tax_region. + * @return $this */ public function addTax(array $taxInfo) { @@ -324,7 +331,7 @@ class Entry extends \Zend_Gdata_Entry /** * Clean taxes information. * - * @return \Magento\Gdata\Gshopping\Entry + * @return $this */ public function cleanTaxes() { diff --git a/lib/Magento/Gdata/Gshopping/Extension/Attribute.php b/lib/Magento/Gdata/Gshopping/Extension/Attribute.php index 222af2ee7f0e3fe1803d6cd8a2951a9cdf5cd21b..3d945a9717f12d5834f32d1d58939aaccb0822af 100644 --- a/lib/Magento/Gdata/Gshopping/Extension/Attribute.php +++ b/lib/Magento/Gdata/Gshopping/Extension/Attribute.php @@ -43,8 +43,8 @@ class Attribute extends \Zend_Gdata_App_Extension_Element * * @param string $name The name of the Content attribute * @param string $text The text value of the Content attribute - * @param string $text The type of the Content attribute - * @param string $unit Currennce for prices + * @param string $type The type of the Content attribute + * @param string $unit Currency for prices */ public function __construct($name = null, $text = null, $type = null, $unit = null) { @@ -79,7 +79,7 @@ class Attribute extends \Zend_Gdata_App_Extension_Element /** * Get the name of the attribute * - * @return attribute name The requested object. + * @return string|null name The requested object. */ public function getName() { @@ -90,9 +90,9 @@ class Attribute extends \Zend_Gdata_App_Extension_Element } /** - * Get the type of the attribute + * Get the currency for prices * - * @return attribute type The requested object. + * @return string|null attribute type The requested object. */ public function getUnit() { @@ -102,13 +102,19 @@ class Attribute extends \Zend_Gdata_App_Extension_Element /** * Get the type of the attribute * - * @return attribute type The requested object. + * @return string|null attribute type The requested object. */ public function getType() { return isset($this->_extensionAttributes['type']['value']) ? $this->_extensionAttributes['type']['value'] : null; } + /** + * Set the currency for prices + * + * @param string $value + * @return $this + */ public function setUnit($value) { $this->_extensionAttributes['unit'] = array( @@ -119,6 +125,12 @@ class Attribute extends \Zend_Gdata_App_Extension_Element return $this; } + /** + * Set the type of the attribute + * + * @param string $value + * @return $this + */ public function setType($value) { $this->_extensionAttributes['type'] = array( diff --git a/lib/Magento/Gdata/Gshopping/Extension/Control.php b/lib/Magento/Gdata/Gshopping/Extension/Control.php index 7bc9329e9c9409a961574a7c6d14f0465bf6d0b2..49ba6c5c31fa0de49bc1dbd9d957570c1f16ed4b 100644 --- a/lib/Magento/Gdata/Gshopping/Extension/Control.php +++ b/lib/Magento/Gdata/Gshopping/Extension/Control.php @@ -77,7 +77,9 @@ class Control extends \Zend_Gdata_App_Extension_Control * and eventually XML text for sending to the server upon updates, or * for application storage/persistence. * - * @param \DOMDocument $doc The \DOMDocument used to construct \DOMElements + * @param \DOMDocument|null $doc The \DOMDocument used to construct \DOMElements + * @param int $majorVersion + * @param null|int $minorVersion * @return \DOMElement The \DOMElement representing this element and all * child properties. */ @@ -110,6 +112,7 @@ class Control extends \Zend_Gdata_App_Extension_Control * objects are created and stored in an array. * * @param \DOMNode $child The \DOMNode needed to be handled + * @return void */ protected function takeChildFromDOM($child) { diff --git a/lib/Magento/Gdata/Gshopping/Extension/Shipping.php b/lib/Magento/Gdata/Gshopping/Extension/Shipping.php index 3f0b416df9133f798b95d9058df4e92e30a089cd..033a5bb4a7e1f426fffcd35bac1c649bfaf64a17 100644 --- a/lib/Magento/Gdata/Gshopping/Extension/Shipping.php +++ b/lib/Magento/Gdata/Gshopping/Extension/Shipping.php @@ -44,7 +44,8 @@ class Shipping extends \Zend_Gdata_App_Extension_Element /** * Key-value pair of shipping info - * @var unknown_type + * + * @var array */ protected $_shippingInfo; @@ -52,7 +53,7 @@ class Shipping extends \Zend_Gdata_App_Extension_Element * Creates instance of class * * @param array $shippingInfo as described in product requirements - * @see http://code.google.com/intl/ru/apis/shopping/content/getting-started/requirements-products.html#tax + * @see http://code.google.com/intl/ru/apis/shopping/content/getting-started/requirements-products.html#shipping */ public function __construct(array $shippingInfo = array()) { @@ -86,6 +87,7 @@ class Shipping extends \Zend_Gdata_App_Extension_Element * objects are created and stored in an array. * * @param \DOMNode $child The \DOMNode needed to be handled + * @return void */ protected function takeChildFromDOM($child) { diff --git a/lib/Magento/Gdata/Gshopping/Extension/Tax.php b/lib/Magento/Gdata/Gshopping/Extension/Tax.php index dce6594312c43fc467f248fa8f3033bd40d3d8fc..a74bfd72ae4d302da367bb76920c7d02d1515668 100644 --- a/lib/Magento/Gdata/Gshopping/Extension/Tax.php +++ b/lib/Magento/Gdata/Gshopping/Extension/Tax.php @@ -35,7 +35,9 @@ namespace Magento\Gdata\Gshopping\Extension; class Tax extends \Zend_Gdata_App_Extension_Element { /** - * @var string The XML namespace prefix + * The XML namespace prefix + * + * @var string */ protected $_rootNamespace = 'scp'; @@ -84,6 +86,7 @@ class Tax extends \Zend_Gdata_App_Extension_Element * objects are created and stored in an array. * * @param \DOMNode $child The \DOMNode needed to be handled + * @return void */ protected function takeChildFromDOM($child) { diff --git a/lib/Magento/Gdata/Gshopping/HttpException.php b/lib/Magento/Gdata/Gshopping/HttpException.php index 8b2b0a186fa68f6a4233cc97c009ba5bcac79104..db3f551ce6fe7ff8d078a7286a73c7b8c0312cad 100644 --- a/lib/Magento/Gdata/Gshopping/HttpException.php +++ b/lib/Magento/Gdata/Gshopping/HttpException.php @@ -81,7 +81,7 @@ class HttpException extends \Zend_Gdata_App_HttpException * Error codes. * One exception may have several codes. * - * @var array codes + * @var string[] codes */ protected $_codes = array(); @@ -89,10 +89,17 @@ class HttpException extends \Zend_Gdata_App_HttpException * Error messages. * One exception may have several codes with messages. * - * @var array messages + * @var string[] messages */ protected $_messages = array(); + /** + * Create object + * + * @param string|\Zend_Gdata_App_HttpException $message Optionally set a message + * @param \Zend_Http_Client_Exception $httpClientException Optionally in a Zend_Http_Client_Exception + * @param \Zend_Http_Response $response Optionally pass in a Zend_Http_Response + */ public function __construct($message = null, $httpClientException = null, $response = null) { if ($message instanceof \Zend_Gdata_App_HttpException) { @@ -107,6 +114,7 @@ class HttpException extends \Zend_Gdata_App_HttpException * Set the \Zend_Http_Response. * * @param \Zend_Http_Response $response + * @return $this */ public function setResponse($response) { @@ -117,7 +125,7 @@ class HttpException extends \Zend_Gdata_App_HttpException /** * Get array of error messages * - * @return array + * @return string[] */ public function getMessages() { @@ -127,7 +135,7 @@ class HttpException extends \Zend_Gdata_App_HttpException /** * Get array of error codes * - * @return array + * @return string[] */ public function getCodes() { @@ -138,7 +146,7 @@ class HttpException extends \Zend_Gdata_App_HttpException * Parse error response XML and fill arrays of codes and messages. * * @param \Zend_Http_Response $response - * @return \Magento\Gdata\Gshopping\HttpException + * @return $this */ protected function _parseResponse($response) { diff --git a/lib/Magento/Gdata/Gshopping/ItemQuery.php b/lib/Magento/Gdata/Gshopping/ItemQuery.php index 39d27a4901452ae08b325f040288247d7ba5b69c..d36d1492df3013b7813a0932f140602a9a8ce208 100644 --- a/lib/Magento/Gdata/Gshopping/ItemQuery.php +++ b/lib/Magento/Gdata/Gshopping/ItemQuery.php @@ -79,7 +79,7 @@ class ItemQuery extends \Zend_Gdata_Query * Set language code * * @param string $language code - * @return \Magento\Gdata\Gshopping\ItemQuery + * @return $this */ public function setLanguage($language) { @@ -101,7 +101,7 @@ class ItemQuery extends \Zend_Gdata_Query * Set target country code * * @param string $targetCountry code - * @return \Magento\Gdata\Gshopping\ItemQuery + * @return $this */ public function setTargetCountry($targetCountry) { @@ -123,7 +123,7 @@ class ItemQuery extends \Zend_Gdata_Query * Set default feed's URI * * @param string $uri URI - * @return \Magento\Gdata\Gshopping\ItemQuery + * @return $this */ public function setFeedUri($uri) { diff --git a/lib/Magento/HTTP/Adapter/Curl.php b/lib/Magento/HTTP/Adapter/Curl.php index d59754edd440831200334ce5abfc9f81dcc9ee44..151c31f6d260e7a08f76825367ee395ef5a657f4 100644 --- a/lib/Magento/HTTP/Adapter/Curl.php +++ b/lib/Magento/HTTP/Adapter/Curl.php @@ -103,7 +103,7 @@ class Curl implements \Zend_Http_Client_Adapter_Interface * Set array of additional cURL options * * @param array $options - * @return \Magento\HTTP\Adapter\Curl + * @return $this */ public function setOptions(array $options = array()) { @@ -116,7 +116,7 @@ class Curl implements \Zend_Http_Client_Adapter_Interface * * @param int $option the CURLOPT_* constants * @param mixed $value - * @return \Magento\HTTP\Adapter\Curl + * @return $this */ public function addOption($option, $value) { @@ -128,7 +128,7 @@ class Curl implements \Zend_Http_Client_Adapter_Interface * Set the configuration array for the adapter * * @param array $config - * @return \Magento\HTTP\Adapter\Curl + * @return $this */ public function setConfig($config = array()) { @@ -143,7 +143,7 @@ class Curl implements \Zend_Http_Client_Adapter_Interface * @param string $host * @param int $port * @param boolean $secure - * @return \Magento\HTTP\Adapter\Curl + * @return $this */ public function connect($host, $port = 80, $secure = false) { @@ -215,7 +215,7 @@ class Curl implements \Zend_Http_Client_Adapter_Interface /** * Close the connection to the server * - * @return \Magento\HTTP\Adapter\Curl + * @return $this */ public function close() { diff --git a/lib/Magento/HTTP/Authentication.php b/lib/Magento/HTTP/Authentication.php index 9e93caa154deaed319807e7641718940b051749c..b70c981f0973e6ca224a60e01f2b2f7cb16f2cc7 100644 --- a/lib/Magento/HTTP/Authentication.php +++ b/lib/Magento/HTTP/Authentication.php @@ -101,6 +101,7 @@ class Authentication * Set "auth failed" headers to the specified response object * * @param string $realm + * @return void */ public function setAuthenticationFailed($realm) { diff --git a/lib/Magento/HTTP/Client/Curl.php b/lib/Magento/HTTP/Client/Curl.php index 2632a7b8094ec09fefd53bfba316ce4005ceeeeb..a128521d377a205fd9edbc6448adb917b6ca92f2 100644 --- a/lib/Magento/HTTP/Client/Curl.php +++ b/lib/Magento/HTTP/Client/Curl.php @@ -60,7 +60,6 @@ implements \Magento\HTTP\IClient */ protected $_headers = array(); - /** * Fields for POST method - hash * @var array @@ -91,10 +90,9 @@ implements \Magento\HTTP\IClient */ protected $_responseStatus = 0; - /** * Request timeout - * @var intunknown_type + * @var int type */ protected $_timeout = 300; @@ -110,16 +108,14 @@ implements \Magento\HTTP\IClient */ protected $_ch; - /** - * User ovverides options hash + * User overrides options hash * Are applied before curl_exec * * @var array(); */ protected $_curlUserOptions = array(); - /** * Header count, used while parsing headers * in CURL callback function @@ -131,6 +127,7 @@ implements \Magento\HTTP\IClient * Set request timeout, msec * * @param int $value + * @return void */ public function setTimeout($value) { @@ -149,18 +146,19 @@ implements \Magento\HTTP\IClient * Set headers from hash * @param array $headers + * @return void */ public function setHeaders($headers) { $this->_headers = $headers; - } /** * Add header * - * @param $name name, ex. "Location" - * @param $value value ex. "http://google.com" + * @param string $name name, ex. "Location" + * @param string $value value ex. "http://google.com" + * @return void */ public function addHeader($name, $value) { @@ -171,11 +169,11 @@ implements \Magento\HTTP\IClient * Remove specified header * * @param string $name + * @return void */ public function removeHeader($name) { unset($this->_headers[$name]); - } /** @@ -184,6 +182,7 @@ implements \Magento\HTTP\IClient * * @param string $login username * @param string $pass password + * @return void */ public function setCredentials($login, $pass) { @@ -196,6 +195,7 @@ implements \Magento\HTTP\IClient * * @param string $name * @param string $value + * @return void */ public function addCookie($name, $value) { @@ -206,6 +206,7 @@ implements \Magento\HTTP\IClient * Remove cookie * * @param string $name + * @return void */ public function removeCookie($name) { @@ -216,6 +217,7 @@ implements \Magento\HTTP\IClient * Set cookies array * * @param array $cookies + * @return void */ public function setCookies($cookies) { @@ -224,17 +226,18 @@ implements \Magento\HTTP\IClient /** * Clear cookies + * @return void */ public function removeCookies() { $this->setCookies(array()); } - /** * Make GET request * * @param string $uri uri relative to host, ex. "/index.php" + * @return void */ public function get($uri) { @@ -244,13 +247,16 @@ implements \Magento\HTTP\IClient /** * Make POST request * @see lib/Magento/HTTP/\Magento\HTTP\Client#post($uri, $params) + * + * @param string $uri + * @param array $params + * @return void */ public function post($uri, $params) { $this->makeRequest("POST", $uri, $params); } - /** * Get response headers * @@ -261,7 +267,6 @@ implements \Magento\HTTP\IClient return $this->_responseHeaders; } - /** * Get response body * @@ -298,7 +303,6 @@ implements \Magento\HTTP\IClient return $out; } - /** * Get cookies array with details * (domain, expire time etc) @@ -337,6 +341,8 @@ implements \Magento\HTTP\IClient /** * Get response status code * @see lib/Magento/HTTP/\Magento\HTTP\Client#getStatus() + * + * @return int */ public function getStatus() { @@ -348,7 +354,7 @@ implements \Magento\HTTP\IClient * @param string $method * @param string $uri * @param array $params - * @return null + * @return void */ protected function makeRequest($method, $uri, $params = array()) { @@ -409,8 +415,9 @@ implements \Magento\HTTP\IClient } /** - * Throw error excpetion - * @param $string + * Throw error exception + * @param string $string + * @return void * @throws \Exception */ public function doError($string) @@ -418,7 +425,6 @@ implements \Magento\HTTP\IClient throw new \Exception($string); } - /** * Parse headers - CURL callback function * @@ -467,6 +473,7 @@ implements \Magento\HTTP\IClient * * @param string $name * @param string $value + * @return void */ protected function curlOption($name, $value) { @@ -475,15 +482,18 @@ implements \Magento\HTTP\IClient /** * Set curl options array directly - * @param array $array + * @param array $arr + * @return void */ - protected function curlOptions($array) + protected function curlOptions($arr) { curl_setopt_array($this->_ch, $arr); } /** - * Set CURL options ovverides array * + * Set CURL options overrides array + * @param array $arr + * @return void */ public function setOptions($arr) { @@ -492,6 +502,10 @@ implements \Magento\HTTP\IClient /** * Set curl option + * + * @param string $name + * @param string $value + * @return void */ public function setOption($name, $value) { diff --git a/lib/Magento/HTTP/Client/Socket.php b/lib/Magento/HTTP/Client/Socket.php index fdb50489652a890710821f0d23add24ca94ddc58..5c102d613dd581ea3d2433aac6002ffaa1a59ac6 100644 --- a/lib/Magento/HTTP/Client/Socket.php +++ b/lib/Magento/HTTP/Client/Socket.php @@ -59,8 +59,7 @@ class Socket * @var array */ private $_headers = array(); - - + /** * Fields for POST method - hash * @var array @@ -90,8 +89,7 @@ class Socket * @var int */ private $_responseStatus = 0; - - + /** * Request timeout * @var int @@ -104,11 +102,11 @@ class Socket */ private $_redirectCount = 0; - /** * Set request timeout, msec * - * @param int $value + * @param int $value + * @return void */ public function setTimeout($value) { @@ -116,8 +114,9 @@ class Socket } /** - * Constructor - * @param string $host + * Constructor + * + * @param string $host * @param int $port */ public function __construct($host = null, $port = 80) @@ -130,18 +129,20 @@ class Socket /** * Set connection params * - * @param string $host - * @param int $port + * @param string $host + * @param int $port + * @return void */ public function connect($host, $port = 80) { $this->_host = $host; $this->_port = (int) $port; - } /** * Disconnect + * + * @return void */ public function disconnect() { @@ -152,34 +153,34 @@ class Socket * Set headers from hash * @param array $headers + * @return void */ public function setHeaders($headers) { $this->_headers = $headers; - } /** * Add header * - * @param $name name, ex. "Location" - * @param $value value ex. "http://google.com" + * @param string $name name, ex. "Location" + * @param string $value value ex. "http://google.com" + * @return void */ public function addHeader($name, $value) { $this->_headers[$name] = $value; - } /** * Remove specified header * * @param string $name + * @return void */ public function removeHeader($name) { unset($this->_headers[$name]); - } /** @@ -188,6 +189,7 @@ class Socket * * @param string $login username * @param string $pass password + * @return void */ public function setCredentials($login, $pass) { @@ -199,7 +201,8 @@ class Socket * Add cookie * * @param string $name - * @param string $value + * @param string $value + * @return void */ public function addCookie($name, $value) { @@ -210,6 +213,7 @@ class Socket * Remove cookie * * @param string $name + * @return void */ public function removeCookie($name) { @@ -220,6 +224,7 @@ class Socket * Set cookies array * * @param array $cookies + * @return void */ public function setCookies($cookies) { @@ -228,17 +233,19 @@ class Socket /** * Clear cookies + * + * @return void */ public function removeCookies() { $this->setCookies(array()); } - /** * Make GET request * * @param string $uri full uri path + * @return void */ public function get($uri) { @@ -251,8 +258,9 @@ class Socket * * @param string $uri ex. http://google.com/index.php?a=b * @return string ex. /index.php?a=b + * @throws \InvalidArgumentException */ - protected function parseUrl($uri) + protected function parseUrl($uri) { $parts = parse_url($uri); if(!empty($parts['user']) && !empty($parts['pass'])) { @@ -282,13 +290,16 @@ class Socket /** * Make POST request + * + * @param string $uri + * @param array $params + * @return void */ - public function post($uri, $params) + public function post($uri, $params) { $this->makeRequest("POST", $this->parseUrl($uri), $params); } - /** * Get response headers * @@ -298,7 +309,6 @@ class Socket { return $this->_responseHeaders; } - /** * Get response body @@ -336,7 +346,6 @@ class Socket return $out; } - /** * Get cookies array with details * (domain, expire time etc) @@ -374,6 +383,8 @@ class Socket /** * Process response headers + * + * @return void */ protected function processResponseHeaders() { @@ -405,6 +416,8 @@ class Socket /** * Process response body + * + * @return void */ protected function processResponseBody() { @@ -416,9 +429,11 @@ class Socket } /** - * Process response + * Process response + * + * @return void */ - protected function processResponse() + protected function processResponse() { $response = ''; $responseLine = trim(fgets($this->_sock, 1024)); @@ -435,21 +450,23 @@ class Socket $this->processResponseBody(); } - /** * Process redirect + * + * @return void */ protected function processRedirect() { - // TODO: implement redircets support + // TODO: implement redirects support } - /** * Get response status code * @see lib/Magento/HTTP/\Magento\HTTP\Client#getStatus() + * + * @return int */ - public function getStatus() + public function getStatus() { return $this->_responseStatus; } @@ -459,9 +476,9 @@ class Socket * @param string $method * @param string $uri * @param array $params - * @return null + * @return void */ - protected function makeRequest($method, $uri, $params = array()) + protected function makeRequest($method, $uri, $params = array()) { $errno = $errstr = ''; $this->_sock = @fsockopen($this->_host, $this->_port, $errno, $errstr, $this->_timeout); @@ -492,8 +509,9 @@ class Socket } /** - * Throw error excpetion - * @param $string + * Throw error exception + * @param string $string + * @return void * @throws \Exception */ public function doError($string) @@ -503,8 +521,7 @@ class Socket /** * Convert headers hash to string - * @param $delimiter - * @param $append + * @param array $append * @return string */ protected function headersToString($append = array()) @@ -522,16 +539,23 @@ class Socket /** * TODO + * + * @param array $arr + * @return void */ - public function setOptions($arr) + public function setOptions($arr) { // Stub } /** * TODO + * + * @param string $name + * @param string $value + * @return void */ - public function setOption($name, $value) + public function setOption($name, $value) { // Stub } diff --git a/lib/Magento/HTTP/PhpEnvironment/ServerAddress.php b/lib/Magento/HTTP/PhpEnvironment/ServerAddress.php index e731d75d517cb1de9755744f62bcd5fd9ba775fc..9cb391fcb76a0ca90668ab96ff675967c010675e 100644 --- a/lib/Magento/HTTP/PhpEnvironment/ServerAddress.php +++ b/lib/Magento/HTTP/PhpEnvironment/ServerAddress.php @@ -26,6 +26,8 @@ namespace Magento\HTTP\PhpEnvironment; +use \Magento\App\RequestInterface; + /** * Library for working with server ip address */ @@ -34,12 +36,15 @@ class ServerAddress /** * Request object * - * @var \Magento\App\RequestInterface + * @var RequestInterface */ protected $request; + /** + * @param RequestInterface $httpRequest + */ public function __construct( - \Magento\App\RequestInterface $httpRequest + RequestInterface $httpRequest ) { $this->request = $httpRequest; } diff --git a/lib/Magento/HTTP/ZendClient.php b/lib/Magento/HTTP/ZendClient.php index 5d4fd8a65cc3ab5993318ff84b62741601d05dea..c6d00f71b6faaabdc29731e9f0789706ab7b8013 100644 --- a/lib/Magento/HTTP/ZendClient.php +++ b/lib/Magento/HTTP/ZendClient.php @@ -42,6 +42,10 @@ class ZendClient extends \Zend_Http_Client */ protected $_urlEncodeBody = true; + /** + * @param null|\Zend_Uri_Http|string $uri + * @param null|array $config + */ public function __construct($uri = null, $config = null) { $this->config['useragent'] = 'Magento\HTTP\ZendClient'; @@ -49,6 +53,9 @@ class ZendClient extends \Zend_Http_Client parent::__construct($uri, $config); } + /** + * @return $this + */ protected function _trySetCurlAdapter() { if (extension_loaded('curl')) { @@ -57,6 +64,10 @@ class ZendClient extends \Zend_Http_Client return $this; } + /** + * @param null|string $method + * @return \Zend_Http_Response + */ public function request($method = null) { $this->_trySetCurlAdapter(); diff --git a/lib/Magento/Image.php b/lib/Magento/Image.php index ba40c3a4a612be23c3887cdadff6cf03ed2ea958..53bd197821465a6355ec1d0737e6f0f5f9286547 100644 --- a/lib/Magento/Image.php +++ b/lib/Magento/Image.php @@ -141,26 +141,56 @@ class Image $this->_adapter->resize($width, $height); } + /** + * Get/set keepAspectRatio + * + * @param bool $value + * @return bool + */ public function keepAspectRatio($value) { return $this->_adapter->keepAspectRatio($value); } + /** + * Get/set keepFrame + * + * @param bool $value + * @return bool + */ public function keepFrame($value) { return $this->_adapter->keepFrame($value); } + /** + * Get/set keepTransparency + * + * @param bool $value + * @return bool + */ public function keepTransparency($value) { return $this->_adapter->keepTransparency($value); } + /** + * Get/set constrainOnly + * + * @param bool $value + * @return bool + */ public function constrainOnly($value) { return $this->_adapter->constrainOnly($value); } + /** + * Get/set backgroundColor + * + * @param null|array $value + * @return array|null + */ public function backgroundColor($value) { return $this->_adapter->backgroundColor($value); diff --git a/lib/Magento/Image/Adapter/AbstractAdapter.php b/lib/Magento/Image/Adapter/AbstractAdapter.php index e5cfc35ed483e2f5dc10aef784eaa3a140294fc6..06136409450e3d2133e227d4d06602c69bc69492 100644 --- a/lib/Magento/Image/Adapter/AbstractAdapter.php +++ b/lib/Magento/Image/Adapter/AbstractAdapter.php @@ -35,7 +35,7 @@ abstract class AbstractAdapter implements AdapterInterface { /** * Background color - * @var mixed + * @var int|string */ public $imageBackgroundColor = 0; @@ -55,26 +55,62 @@ abstract class AbstractAdapter implements AdapterInterface */ const DEFAULT_FONT_SIZE = 15; + /** @var int */ protected $_fileType; + + /** @var string */ protected $_fileName ; + + /** @var string */ protected $_fileMimeType; + + /** @var string */ protected $_fileSrcName; + + /** @var string */ protected $_fileSrcPath; + protected $_imageHandler; + + /** @var int */ protected $_imageSrcWidth; + + /** @var int */ protected $_imageSrcHeight; + protected $_requiredExtensions; + + /** @var string */ protected $_watermarkPosition; + + /** @var int */ protected $_watermarkWidth; - protected $_watermarkHeigth; + + /** @var int */ + protected $_watermarkHeight; + + /** @var int */ protected $_watermarkImageOpacity; + + /** @var int */ protected $_quality; + + /** @var int int */ protected $_fontSize = self::DEFAULT_FONT_SIZE; + /** @var bool */ protected $_keepAspectRatio; + + /** @var bool */ protected $_keepFrame; + + /** @var bool */ protected $_keepTransparency; + + /** @var array */ protected $_backgroundColor; + + /** @var bool */ protected $_constrainOnly; /** @@ -94,8 +130,23 @@ abstract class AbstractAdapter implements AdapterInterface */ protected $logger; + /** + * Open image for processing + * + * @param string $fileName + * @return void + */ abstract public function open($fileName); + /** + * Save image to specific path. + * If some folders of path does not exist they will be created + * + * @param null|string $destination + * @param null|string $newName + * @return void + * @throws \Exception if destination path is not writable + */ abstract public function save($destination = null, $newName = null); /** @@ -105,14 +156,52 @@ abstract class AbstractAdapter implements AdapterInterface */ abstract public function getImage(); + /** + * Change the image size + * + * @param null|int $width + * @param null|int $height + * @return void + */ abstract public function resize($width=null, $height=null); + /** + * Rotate image on specific angle + * + * @param int $angle + * @return void + */ abstract public function rotate($angle); + /** + * Crop image + * + * @param int $top + * @param int $left + * @param int $right + * @param int $bottom + * @return bool + */ abstract public function crop($top = 0, $left = 0, $right = 0, $bottom = 0); + /** + * Add watermark to image + * + * @param string $imagePath + * @param int $positionX + * @param int $positionY + * @param int $opacity + * @param bool $tile + * @return void + */ abstract public function watermark($imagePath, $positionX = 0, $positionY = 0, $opacity = 30, $tile = false); + /** + * Checks required dependencies + * + * @return void + * @throws \Exception if some of dependencies are missing + */ abstract public function checkDependencies(); /** @@ -120,12 +209,14 @@ abstract class AbstractAdapter implements AdapterInterface * * @param string $text * @param string $font Path to font file - * @return \Magento\Image\Adapter\AbstractAdapter + * @return AbstractAdapter */ abstract public function createPngFromString($text, $font = ''); /** * Reassign image dimensions + * + * @return void */ abstract public function refreshImageDimensions(); @@ -191,7 +282,8 @@ abstract class AbstractAdapter implements AdapterInterface /** * Set watermark position * - * @return \Magento\Image\Adapter\AbstractAdapter + * @param string $position + * @return $this */ public function setWatermarkPosition($position) { @@ -202,7 +294,7 @@ abstract class AbstractAdapter implements AdapterInterface /** * Get watermark position * - * @return \Magento\Image\Adapter\AbstractAdapter + * @return string */ public function getWatermarkPosition() { @@ -212,7 +304,8 @@ abstract class AbstractAdapter implements AdapterInterface /** * Set watermark opacity * - * @return \Magento\Image\Adapter\AbstractAdapter + * @param int $imageOpacity + * @return $this */ public function setWatermarkImageOpacity($imageOpacity) { @@ -233,7 +326,8 @@ abstract class AbstractAdapter implements AdapterInterface /** * Set watermark width * - * @return \Magento\Image\Adapter\AbstractAdapter + * @param int $width + * @return $this */ public function setWatermarkWidth($width) { @@ -254,11 +348,12 @@ abstract class AbstractAdapter implements AdapterInterface /** * Set watermark height * - * @return \Magento\Image\Adapter\AbstractAdapter + * @param int $height + * @return $this */ - public function setWatermarkHeight($heigth) + public function setWatermarkHeight($height) { - $this->_watermarkHeigth = $heigth; + $this->_watermarkHeight = $height; return $this; } @@ -269,10 +364,9 @@ abstract class AbstractAdapter implements AdapterInterface */ public function getWatermarkHeight() { - return $this->_watermarkHeigth; + return $this->_watermarkHeight; } - /** * Get/set keepAspectRatio * @@ -346,8 +440,8 @@ abstract class AbstractAdapter implements AdapterInterface /** * Get/set keepBackgroundColor * - * @param array $value - * @return array + * @param null|array $value + * @return array|null */ public function backgroundColor($value = null) { @@ -368,6 +462,7 @@ abstract class AbstractAdapter implements AdapterInterface /** * Assign file dirname and basename to object properties * + * @return void */ protected function _getFileAttributes() { @@ -380,10 +475,10 @@ abstract class AbstractAdapter implements AdapterInterface /** * Adapt resize values based on image configuration * - * @throws \Exception * @param int $frameWidth * @param int $frameHeight * @return array + * @throws \Exception */ protected function _adaptResizeValues($frameWidth, $frameHeight) { @@ -445,7 +540,7 @@ abstract class AbstractAdapter implements AdapterInterface * * @param int $frameWidth * @param int $frameHeight - * @return array + * @return int[] */ protected function _checkAspectRatio($frameWidth, $frameHeight) { @@ -474,6 +569,7 @@ abstract class AbstractAdapter implements AdapterInterface * * @param int $frameWidth * @param int $frameHeight + * @return void * @throws \Exception */ protected function _checkDimensions($frameWidth, $frameHeight) @@ -510,7 +606,7 @@ abstract class AbstractAdapter implements AdapterInterface /** * Return supported image formats * - * @return array + * @return string[] */ public function getSupportedFormats() { diff --git a/lib/Magento/Image/Adapter/AdapterInterface.php b/lib/Magento/Image/Adapter/AdapterInterface.php index f570938c2ba7f0ce4d78508cab121923573bbca2..7844a17748f284bfe95dc622c9dba987426f4a7c 100644 --- a/lib/Magento/Image/Adapter/AdapterInterface.php +++ b/lib/Magento/Image/Adapter/AdapterInterface.php @@ -54,6 +54,7 @@ interface AdapterInterface * @param int $positionY * @param int $opacity * @param bool $tile + * @return void */ public function watermark($imagePath, $positionX = 0, $positionY = 0, $opacity = 30, $tile = false); @@ -65,6 +66,7 @@ interface AdapterInterface /** * Checks required dependencies * + * @return void * @throws \Exception if some of dependencies are missing */ public function checkDependencies(); @@ -81,15 +83,17 @@ interface AdapterInterface /** * Open image for processing * - * @param string $filename + * @param $filename + * @return void */ public function open($filename); /** * Change the image size * - * @param int $frameWidth - * @param int $frameHeight + * @param null|int $frameWidth + * @param null|int $frameHeight + * @return void */ public function resize($frameWidth = null, $frameHeight = null); @@ -108,9 +112,10 @@ interface AdapterInterface * Save image to specific path. * If some folders of path does not exist they will be created * + * @param null|string $destination + * @param null|string $newName + * @return void * @throws \Exception if destination path is not writable - * @param string $destination - * @param string $newName */ public function save($destination = null, $newName = null); @@ -118,6 +123,7 @@ interface AdapterInterface * Rotate image on specific angle * * @param int $angle + * @return void */ public function rotate($angle); } \ No newline at end of file diff --git a/lib/Magento/Image/Adapter/Gd2.php b/lib/Magento/Image/Adapter/Gd2.php index 91d72e8b0c7b1d36843da28c4dd38e960d0122ad..460b26a94975aef4b0bfd45b77520d50f97e6a81 100644 --- a/lib/Magento/Image/Adapter/Gd2.php +++ b/lib/Magento/Image/Adapter/Gd2.php @@ -60,6 +60,7 @@ class Gd2 extends \Magento\Image\Adapter\AbstractAdapter * Open image for processing * * @param string $filename + * @return void * @throws \OverflowException */ public function open($filename) @@ -135,9 +136,10 @@ class Gd2 extends \Magento\Image\Adapter\AbstractAdapter * Save image to specific path. * If some folders of path does not exist they will be created * + * @param null|string $destination + * @param null|string $newName + * @return void * @throws \Exception if destination path is not writable - * @param string $destination - * @param string $newName */ public function save($destination = null, $newName = null) { @@ -202,7 +204,8 @@ class Gd2 extends \Magento\Image\Adapter\AbstractAdapter * Obtain function name, basing on image type and callback type * * @param string $callbackType - * @param int $fileType + * @param null|int $fileType + * @param string $unsupportedText * @return string * @throws \Exception */ @@ -331,8 +334,9 @@ class Gd2 extends \Magento\Image\Adapter\AbstractAdapter /** * Change the image size * - * @param int $frameWidth - * @param int $frameHeight + * @param null|int $frameWidth + * @param null|int $frameHeight + * @return void */ public function resize($frameWidth = null, $frameHeight = null) { @@ -371,6 +375,7 @@ class Gd2 extends \Magento\Image\Adapter\AbstractAdapter * Rotate image on specific angle * * @param int $angle + * @return void */ public function rotate($angle) { @@ -386,6 +391,7 @@ class Gd2 extends \Magento\Image\Adapter\AbstractAdapter * @param int $positionY * @param int $opacity * @param bool $tile + * @return void */ public function watermark($imagePath, $positionX = 0, $positionY = 0, $opacity = 30, $tile = false) { @@ -566,6 +572,7 @@ class Gd2 extends \Magento\Image\Adapter\AbstractAdapter /** * Checks required dependencies * + * @return void * @throws \Exception if some of dependencies are missing */ public function checkDependencies() diff --git a/lib/Magento/Image/Adapter/ImageMagick.php b/lib/Magento/Image/Adapter/ImageMagick.php index 62287567297cd38ef6bc3e74749322143fd899e5..24207dbde0f96e4809b99f8b3e6258bd8410b6c8 100644 --- a/lib/Magento/Image/Adapter/ImageMagick.php +++ b/lib/Magento/Image/Adapter/ImageMagick.php @@ -94,8 +94,9 @@ class ImageMagick extends \Magento\Image\Adapter\AbstractAdapter /** * Open image for processing * - * @throws \Exception * @param string $filename + * @return void + * @throws \Exception */ public function open($filename) { @@ -117,8 +118,10 @@ class ImageMagick extends \Magento\Image\Adapter\AbstractAdapter * Save image to specific path. * If some folders of path does not exist they will be created * - * @param string $destination - * @param string $newName + * @param null|string $destination + * @param null|string $newName + * @return void + * @throws \Exception if destination path is not writable */ public function save($destination = null, $newName = null) { @@ -163,9 +166,9 @@ class ImageMagick extends \Magento\Image\Adapter\AbstractAdapter /** * Change the image size * - * @param int $frameWidth - * @param int $frameHeight - * @throws \Exception + * @param null|int $frameWidth + * @param null|int $frameHeight + * @return void */ public function resize($frameWidth = null, $frameHeight = null) { @@ -214,7 +217,7 @@ class ImageMagick extends \Magento\Image\Adapter\AbstractAdapter * Rotate image on specific angle * * @param int $angle - * @throws \Exception + * @return void */ public function rotate($angle) { @@ -256,11 +259,13 @@ class ImageMagick extends \Magento\Image\Adapter\AbstractAdapter /** * Add watermark to image * - * @param $imagePath + * @param string $imagePath * @param int $positionX * @param int $positionY * @param int $opacity * @param bool $tile + * @return void + * @throws \LogicException * @throws \Exception */ public function watermark($imagePath, $positionX = 0, $positionY = 0, $opacity = 30, $tile = false) @@ -359,6 +364,7 @@ class ImageMagick extends \Magento\Image\Adapter\AbstractAdapter /** * Checks required dependencies * + * @return void * @throws \Exception if some of dependencies are missing */ public function checkDependencies() @@ -370,6 +376,8 @@ class ImageMagick extends \Magento\Image\Adapter\AbstractAdapter /** * Reassign image dimensions + * + * @return void */ public function refreshImageDimensions() { @@ -381,6 +389,7 @@ class ImageMagick extends \Magento\Image\Adapter\AbstractAdapter /** * Standard destructor. Destroy stored information about image * + * @return void */ public function __destruct() { @@ -427,7 +436,7 @@ class ImageMagick extends \Magento\Image\Adapter\AbstractAdapter * Check whether the adapter can work with the image * * @throws \LogicException - * @return bool + * @return true */ protected function _checkCanProcess() { diff --git a/lib/Magento/Interception/Definition.php b/lib/Magento/Interception/Definition.php index 430ee3e48c05102ab5e3b4910765781d6f038583..caf705a1acf3613697197a02a6c35991ea2a604a 100644 --- a/lib/Magento/Interception/Definition.php +++ b/lib/Magento/Interception/Definition.php @@ -31,7 +31,7 @@ interface Definition * Retrieve list of methods * * @param string $type - * @return array + * @return string[] */ public function getMethodList($type); } diff --git a/lib/Magento/Interception/Definition/Compiled.php b/lib/Magento/Interception/Definition/Compiled.php index 4f80a0c4f143cb0c131d164c93aff09ae84b0a27..e631f1cf8ae3f4785a73d8da684da3f765289c8d 100644 --- a/lib/Magento/Interception/Definition/Compiled.php +++ b/lib/Magento/Interception/Definition/Compiled.php @@ -25,7 +25,9 @@ */ namespace Magento\Interception\Definition; -class Compiled implements \Magento\Interception\Definition +use Magento\Interception\Definition; + +class Compiled implements Definition { /** * List of plugin definitions @@ -46,7 +48,7 @@ class Compiled implements \Magento\Interception\Definition * Retrieve list of methods * * @param string $type - * @return array + * @return string[] */ public function getMethodList($type) { diff --git a/lib/Magento/Interception/Definition/Runtime.php b/lib/Magento/Interception/Definition/Runtime.php index 7becde67302e3b520e1477c464ad786c2559aeb8..6f88846871d11f98c50867086b10deabd9432a16 100644 --- a/lib/Magento/Interception/Definition/Runtime.php +++ b/lib/Magento/Interception/Definition/Runtime.php @@ -26,13 +26,15 @@ */ namespace Magento\Interception\Definition; -class Runtime implements \Magento\Interception\Definition +use Magento\Interception\Definition; + +class Runtime implements Definition { /** * Retrieve list of methods * * @param string $type - * @return array + * @return string[] */ public function getMethodList($type) { diff --git a/lib/Magento/Interception/FactoryDecorator.php b/lib/Magento/Interception/FactoryDecorator.php index 6c61c18c2ecb1dbee6375ca58c0550a52dce6cb1..5b1a7cd5e636dccc2e750e2792b406645c63da94 100644 --- a/lib/Magento/Interception/FactoryDecorator.php +++ b/lib/Magento/Interception/FactoryDecorator.php @@ -25,47 +25,52 @@ */ namespace Magento\Interception; -class FactoryDecorator implements \Magento\ObjectManager\Factory +use Magento\ObjectManager; +use Magento\Interception\Config; +use Magento\Interception\PluginList; +use Magento\ObjectManager\Factory; + +class FactoryDecorator implements Factory { /** * Configurable factory * - * @var \Magento\ObjectManager\Factory + * @var Factory */ protected $_factory; /** * Object manager * - * @var \Magento\ObjectManager + * @var ObjectManager */ protected $_objectManager; /** * Object manager config * - * @var \Magento\Interception\Config + * @var Config */ protected $_config; /** * List of plugins configured for instance * - * @var \Magento\Interception\PluginList + * @var PluginList */ protected $_pluginList; /** - * @param \Magento\ObjectManager\Factory $factory - * @param \Magento\Interception\Config $config - * @param \Magento\Interception\PluginList $pluginList - * @param \Magento\ObjectManager $objectManager + * @param Factory $factory + * @param Config $config + * @param PluginList $pluginList + * @param ObjectManager $objectManager */ public function __construct( - \Magento\ObjectManager\Factory $factory, - \Magento\Interception\Config $config, - \Magento\Interception\PluginList $pluginList, - \Magento\ObjectManager $objectManager + Factory $factory, + Config $config, + PluginList $pluginList, + ObjectManager $objectManager ) { $this->_factory = $factory; $this->_pluginList = $pluginList; @@ -76,9 +81,10 @@ class FactoryDecorator implements \Magento\ObjectManager\Factory /** * Set object manager * - * @param \Magento\ObjectManager $objectManager + * @param ObjectManager $objectManager + * @return void */ - public function setObjectManager(\Magento\ObjectManager $objectManager) + public function setObjectManager(ObjectManager $objectManager) { $this->_objectManager = $objectManager; $this->_factory->setObjectManager($objectManager); @@ -88,6 +94,7 @@ class FactoryDecorator implements \Magento\ObjectManager\Factory * Set application arguments * * @param array $arguments + * @return void */ public function setArguments($arguments) { @@ -99,7 +106,7 @@ class FactoryDecorator implements \Magento\ObjectManager\Factory * * @param string $type * @param array $arguments - * @return mixed + * @return object */ public function create($type, array $arguments = array()) { diff --git a/lib/Magento/Interception/PluginList/PluginList.php b/lib/Magento/Interception/PluginList/PluginList.php index cfe6826128ad97156a8910ccf9a1ed609b8f530f..12daf60ac998ba75610ad1d7c916ea23b6cdfcee 100644 --- a/lib/Magento/Interception/PluginList/PluginList.php +++ b/lib/Magento/Interception/PluginList/PluginList.php @@ -25,68 +25,75 @@ */ namespace Magento\Interception\PluginList; +use Magento\Config\ReaderInterface; +use Magento\Config\ScopeInterface; +use Magento\Config\CacheInterface; +use Magento\Config\Data\Scoped; +use Magento\Interception\Definition; +use Magento\Interception\PluginList as InterceptionPluginList; +use Magento\ObjectManager\Config; +use Magento\ObjectManager\Relations; +use Magento\ObjectManager\Definition\Compiled; use Zend\Soap\Exception\InvalidArgumentException; -class PluginList - extends \Magento\Config\Data\Scoped - implements \Magento\Interception\PluginList +class PluginList extends Scoped implements InterceptionPluginList { /** * Type config * - * @var \Magento\ObjectManager\Config + * @var Config */ protected $_omConfig; /** * Class relations information provider * - * @var \Magento\ObjectManager\Relations + * @var Relations */ protected $_relations; /** * List of interception methods per plugin * - * @var \Magento\Interception\Definition + * @var Definition */ protected $_definitions; /** * List of interceptable application classes * - * @var \Magento\ObjectManager\Definition\Compiled + * @var Compiled */ protected $_classDefinitions; /** * Scope inheritance scheme * - * @var array + * @var string[] */ protected $_scopePriorityScheme = array('global'); /** - * @param \Magento\Config\ReaderInterface $reader - * @param \Magento\Config\ScopeInterface $configScope - * @param \Magento\Config\CacheInterface $cache - * @param \Magento\ObjectManager\Relations $relations - * @param \Magento\ObjectManager\Config $omConfig - * @param \Magento\Interception\Definition $definitions - * @param array $scopePriorityScheme + * @param ReaderInterface $reader + * @param ScopeInterface $configScope + * @param CacheInterface $cache + * @param Relations $relations + * @param Config $omConfig + * @param Definition $definitions + * @param string[] $scopePriorityScheme * @param string $cacheId - * @param \Magento\ObjectManager\Definition\Compiled $classDefinitions + * @param Compiled $classDefinitions */ public function __construct( - \Magento\Config\ReaderInterface $reader, - \Magento\Config\ScopeInterface $configScope, - \Magento\Config\CacheInterface $cache, - \Magento\ObjectManager\Relations $relations, - \Magento\ObjectManager\Config $omConfig, - \Magento\Interception\Definition $definitions, + ReaderInterface $reader, + ScopeInterface $configScope, + CacheInterface $cache, + Relations $relations, + Config $omConfig, + Definition $definitions, array $scopePriorityScheme, $cacheId = 'plugins', - \Magento\ObjectManager\Definition\Compiled $classDefinitions = null + Compiled $classDefinitions = null ) { parent::__construct($reader, $configScope, $cache, $cacheId); $this->_omConfig = $omConfig; @@ -101,7 +108,7 @@ class PluginList * * @param string $type * @return array - * @throws \Zend\Soap\Exception\InvalidArgumentException + * @throws InvalidArgumentException * @SuppressWarnings(PHPMD.CyclomaticComplexity) */ protected function _inheritPlugins($type) @@ -180,6 +187,11 @@ class PluginList /** * {@inheritdoc} + * + * @param string $type + * @param string $method + * @param string $scenario + * @return array * @SuppressWarnings(PHPMD.CyclomaticComplexity) */ public function getPlugins($type, $method, $scenario) @@ -198,6 +210,7 @@ class PluginList /** * Load configuration for current scope * + * @return void * @SuppressWarnings(PHPMD.CyclomaticComplexity) */ protected function _loadScopedData() diff --git a/lib/Magento/Io/AbstractIo.php b/lib/Magento/Io/AbstractIo.php index 4d4da3731be7f98e5299a8deeada96fd8d583d5a..f1740539e13eb7724f31b228140a0b83a042ed96 100644 --- a/lib/Magento/Io/AbstractIo.php +++ b/lib/Magento/Io/AbstractIo.php @@ -34,7 +34,7 @@ */ namespace Magento\Io; -abstract class AbstractIo implements \Magento\Io\IoInterface +abstract class AbstractIo implements IoInterface { /** * If this variable is set to true, our library will be able to automaticaly @@ -48,7 +48,7 @@ abstract class AbstractIo implements \Magento\Io\IoInterface * Allow automaticaly create non-existant directories * * @param bool $flag - * @return \Magento\Io\AbstractIo + * @return $this */ public function setAllowCreateFolders($flag) { @@ -59,19 +59,26 @@ abstract class AbstractIo implements \Magento\Io\IoInterface /** * Open a connection * - * @param array $config - * @return bool + * @param array $args + * @return false */ public function open(array $args = array()) { return false; } + /** + * @return string + */ public function dirsep() { return '/'; } + /** + * @param string $path + * @return string + */ public function getCleanPath($path) { if (empty($path)) { @@ -113,6 +120,11 @@ abstract class AbstractIo implements \Magento\Io\IoInterface return $pathTokR . implode('/', $realPathParts); } + /** + * @param string $haystackPath + * @param string $needlePath + * @return bool + */ public function allowedPath($haystackPath, $needlePath) { return strpos($this->getCleanPath($haystackPath), $this->getCleanPath($needlePath)) === 0; diff --git a/lib/Magento/Io/File.php b/lib/Magento/Io/File.php index 0de897007a21235f9130e4b59b11303e7ecc3f76..60ade58015eda43a550e40b5794dd23085508942 100644 --- a/lib/Magento/Io/File.php +++ b/lib/Magento/Io/File.php @@ -32,7 +32,7 @@ */ namespace Magento\Io; -class File extends \Magento\Io\AbstractIo +class File extends AbstractIo { /** * Save initial working directory @@ -101,6 +101,8 @@ class File extends \Magento\Io\AbstractIo /** * Destruct + * + * @return void */ public function __destruct() { @@ -116,7 +118,7 @@ class File extends \Magento\Io\AbstractIo * @param string $fileName * @param string $mode * @param int $chmod - * @return bool + * @return true * @throws \Exception */ public function streamOpen($fileName, $mode = 'w+', $chmod = 0666) @@ -176,7 +178,7 @@ class File extends \Magento\Io\AbstractIo * Binary-safe file read * * @param int $length - * @return string + * @return string|false */ public function streamRead($length = 1024) { @@ -194,7 +196,7 @@ class File extends \Magento\Io\AbstractIo * * @param string $delimiter * @param string $enclosure - * @return string + * @return string|false */ public function streamReadCsv($delimiter = ',', $enclosure = '"') { @@ -208,7 +210,7 @@ class File extends \Magento\Io\AbstractIo * Binary-safe file write * * @param string $str - * @return bool + * @return int|false */ public function streamWrite($str) { @@ -224,7 +226,7 @@ class File extends \Magento\Io\AbstractIo * @param array $row * @param string $delimiter * @param string $enclosure - * @return bool|int + * @return int|false The length of the written string or false */ public function streamWriteCsv(array $row, $delimiter = ',', $enclosure = '"') { @@ -290,7 +292,7 @@ class File extends \Magento\Io\AbstractIo * - path default current path * * @param array $args - * @return boolean + * @return true */ public function open(array $args = array()) { @@ -310,9 +312,9 @@ class File extends \Magento\Io\AbstractIo /** * Used to set {@link _allowCreateFolders} value * - * @param mixed $flag + * @param bool $flag * @access public - * @return \Magento\Io\File + * @return $this */ public function setAllowCreateFolders($flag) { @@ -323,7 +325,7 @@ class File extends \Magento\Io\AbstractIo /** * Close a connection * - * @return boolean + * @return true */ public function close() { @@ -335,8 +337,8 @@ class File extends \Magento\Io\AbstractIo * * @param string $dir * @param int $mode - * @param boolean $recursive - * @return boolean + * @param bool $recursive + * @return bool */ public function mkdir($dir, $mode = 0777, $recursive = true) { @@ -351,7 +353,7 @@ class File extends \Magento\Io\AbstractIo * * @param string $dir * @param bool $recursive - * @return boolean + * @return bool */ public function rmdir($dir, $recursive = false) { @@ -437,7 +439,7 @@ class File extends \Magento\Io\AbstractIo * Change current working directory * * @param string $dir - * @return boolean + * @return true * @throws \Exception */ public function cd($dir) @@ -459,7 +461,7 @@ class File extends \Magento\Io\AbstractIo * * @param string $filename * @param string|resource $dest - * @return boolean|string + * @return bool|string */ public function read($filename, $dest = null) { @@ -480,7 +482,7 @@ class File extends \Magento\Io\AbstractIo * @param string $filename * @param string|resource $src * @param int $mode - * @return int|boolean + * @return int|bool */ public function write($filename, $src, $mode = null) { @@ -568,7 +570,7 @@ class File extends \Magento\Io\AbstractIo * Create destination folder * * @param string $path - * @return \Magento\Io\File + * @return bool */ public function createDestinationDir($path) { @@ -583,7 +585,7 @@ class File extends \Magento\Io\AbstractIo * * @param string $folder * @param int $mode - * @return bool + * @return true * @throws \Exception */ public function checkAndCreateFolder($folder, $mode = 0777) @@ -615,7 +617,7 @@ class File extends \Magento\Io\AbstractIo * Delete a file * * @param string $filename - * @return boolean + * @return bool */ public function rm($filename) { @@ -630,7 +632,7 @@ class File extends \Magento\Io\AbstractIo * * @param string $src * @param string $destination - * @return boolean + * @return bool */ public function mv($src, $destination) { @@ -645,7 +647,7 @@ class File extends \Magento\Io\AbstractIo * * @param string $src * @param string $destination - * @return boolean + * @return bool */ public function cp($src, $destination) { @@ -660,8 +662,8 @@ class File extends \Magento\Io\AbstractIo * * @param string $filename * @param int $mode - * @param boolean $recursive - * @return boolean + * @param bool $recursive + * @return bool */ public function chmod($filename, $mode, $recursive = false) { @@ -698,7 +700,7 @@ class File extends \Magento\Io\AbstractIo * - LS_FILES = 2 * - LS_ALL = 3 * - * @param \Magento\Io\File const + * @param string|null $grep * @return array * @throws \Exception */ @@ -773,6 +775,8 @@ class File extends \Magento\Io\AbstractIo /** * Change directory to current working directory + * + * @return void */ protected function _cwd() { @@ -783,6 +787,8 @@ class File extends \Magento\Io\AbstractIo /** * Change directory to initial directory + * + * @return void */ protected function _iwd() { @@ -794,7 +800,7 @@ class File extends \Magento\Io\AbstractIo /** * Convert integer permissions format into human readable * - * @param integer $mode + * @param int $mode * @access protected * @return string */ diff --git a/lib/Magento/Io/Ftp.php b/lib/Magento/Io/Ftp.php index ead5c7b51fdcc05107190e2b6a01811d1fa1710c..a60ff98a1c2331917132bb4607be644fea6d367e 100644 --- a/lib/Magento/Io/Ftp.php +++ b/lib/Magento/Io/Ftp.php @@ -34,7 +34,7 @@ */ namespace Magento\Io; -class Ftp extends \Magento\Io\AbstractIo +class Ftp extends AbstractIo { const ERROR_EMPTY_HOST = 1; const ERROR_INVALID_CONNECTION = 2; @@ -82,13 +82,14 @@ class Ftp extends \Magento\Io\AbstractIo * - file_mode default FTP_BINARY * * @param array $args - * @return boolean + * @return true + * @throws IoException */ public function open(array $args=array()) { if (empty($args['host'])) { $this->_error = self::ERROR_EMPTY_HOST; - throw new \Magento\Io\IoException('Empty host specified'); + throw new IoException('Empty host specified'); } if (empty($args['port'])) { @@ -121,20 +122,20 @@ class Ftp extends \Magento\Io\AbstractIo } if (!$this->_conn) { $this->_error = self::ERROR_INVALID_CONNECTION; - throw new \Magento\Io\IoException('Could not establish FTP connection, invalid host or port'); + throw new IoException('Could not establish FTP connection, invalid host or port'); } if (!@ftp_login($this->_conn, $this->_config['user'], $this->_config['password'])) { $this->_error = self::ERROR_INVALID_LOGIN; $this->close(); - throw new \Magento\Io\IoException('Invalid user name or password'); + throw new IoException('Invalid user name or password'); } if (!empty($this->_config['path'])) { if (!@ftp_chdir($this->_conn, $this->_config['path'])) { $this->_error = self::ERROR_INVALID_PATH; $this->close(); - throw new \Magento\Io\IoException('Invalid path'); + throw new IoException('Invalid path'); } } @@ -142,7 +143,7 @@ class Ftp extends \Magento\Io\AbstractIo if (!@ftp_pasv($this->_conn, true)) { $this->_error = self::ERROR_INVALID_MODE; $this->close(); - throw new \Magento\Io\IoException('Invalid file transfer mode'); + throw new IoException('Invalid file transfer mode'); } } @@ -152,7 +153,7 @@ class Ftp extends \Magento\Io\AbstractIo /** * Close a connection * - * @return boolean + * @return bool */ public function close() { @@ -165,8 +166,8 @@ class Ftp extends \Magento\Io\AbstractIo * @todo implement $mode and $recursive * @param string $dir * @param int $mode - * @param boolean $recursive - * @return boolean + * @param bool $recursive + * @return bool */ public function mkdir($dir, $mode=0777, $recursive=true) { @@ -177,7 +178,8 @@ class Ftp extends \Magento\Io\AbstractIo * Delete a directory * * @param string $dir - * @return boolean + * @param bool $recursive + * @return bool */ public function rmdir($dir, $recursive=false) { @@ -198,7 +200,7 @@ class Ftp extends \Magento\Io\AbstractIo * Change current working directory * * @param string $dir - * @return boolean + * @return bool */ public function cd($dir) { @@ -210,7 +212,7 @@ class Ftp extends \Magento\Io\AbstractIo * * @param string $filename * @param string|resource|null $dest destination file name, stream, or if null will return file contents - * @return string + * @return false|string */ public function read($filename, $dest=null) { @@ -243,7 +245,8 @@ class Ftp extends \Magento\Io\AbstractIo * * @param string $filename * @param string|resource $src filename, string data or source stream - * @return int|boolean + * @param null $mode + * @return bool */ public function write($filename, $src, $mode=null) { @@ -273,7 +276,7 @@ class Ftp extends \Magento\Io\AbstractIo * Delete a file * * @param string $filename - * @return boolean + * @return bool */ public function rm($filename) { @@ -285,7 +288,7 @@ class Ftp extends \Magento\Io\AbstractIo * * @param string $src * @param string $dest - * @return boolean + * @return bool */ public function mv($src, $dest) { @@ -297,13 +300,17 @@ class Ftp extends \Magento\Io\AbstractIo * * @param string $filename * @param int $mode - * @return boolean + * @return bool */ public function chmod($filename, $mode) { return @ftp_chmod($this->_conn, $mode, $filename); } + /** + * @param null $grep ignored parameter + * @return array + */ public function ls($grep=null) { $ls = @ftp_nlist($this->_conn, '.'); @@ -319,6 +326,10 @@ class Ftp extends \Magento\Io\AbstractIo return $list; } + /** + * @param bool $new + * @return string + */ protected function _tmpFilename($new=false) { if ($new || !$this->_tmpFilename) { diff --git a/lib/Magento/Io/Sftp.php b/lib/Magento/Io/Sftp.php index 546f56dcb4275b7e538848b946297728e7c31f00..faef9b40b991ca5219b40025404ab7bc088f97ab 100644 --- a/lib/Magento/Io/Sftp.php +++ b/lib/Magento/Io/Sftp.php @@ -36,7 +36,7 @@ namespace Magento\Io; * @link http://www.php.net/manual/en/function.ssh2-connect.php */ require_once('phpseclib/Net/SFTP.php'); -class Sftp extends \Magento\Io\AbstractIo implements \Magento\Io\IoInterface +class Sftp extends AbstractIo implements IoInterface { const REMOTE_TIMEOUT = 10; const SSH2_PORT = 22; @@ -77,6 +77,8 @@ class Sftp extends \Magento\Io\AbstractIo implements \Magento\Io\IoInterface /** * Close a connection + * + * @return void */ public function close() { @@ -115,6 +117,11 @@ class Sftp extends \Magento\Io\AbstractIo implements \Magento\Io\IoInterface /** * Delete a directory + * + * @param string $dir + * @param bool $recursive + * @return bool + * @throws \Exception */ public function rmdir($dir, $recursive=false) { @@ -149,6 +156,8 @@ class Sftp extends \Magento\Io\AbstractIo implements \Magento\Io\IoInterface /** * Get current working directory + * + * @return mixed */ public function pwd() { @@ -158,6 +167,8 @@ class Sftp extends \Magento\Io\AbstractIo implements \Magento\Io\IoInterface /** * Change current working directory * + * @param string $dir + * @return bool */ public function cd($dir) { diff --git a/lib/Magento/Json/Decoder.php b/lib/Magento/Json/Decoder.php index a97e74930de407db9914c574fa7e54e462116758..cbab43b00a1fc515054ba14459942559e7a22b93 100644 --- a/lib/Magento/Json/Decoder.php +++ b/lib/Magento/Json/Decoder.php @@ -30,6 +30,8 @@ namespace Magento\Json; class Decoder implements DecoderInterface { /** + * Decodes the given $data string which is encoded in the JSON format. + * * @param string $data * @return mixed */ diff --git a/lib/Magento/Json/DecoderInterface.php b/lib/Magento/Json/DecoderInterface.php index 02e5c36b2260de7b93e437f448ff008cd929d212..4e8d0aefeddd6741df47f816c936868f4b4464f8 100644 --- a/lib/Magento/Json/DecoderInterface.php +++ b/lib/Magento/Json/DecoderInterface.php @@ -31,6 +31,8 @@ namespace Magento\Json; interface DecoderInterface { /** + * Decodes the given $data string which is encoded in the JSON format. + * * @param string $data * @return mixed */ diff --git a/lib/Magento/Json/Encoder.php b/lib/Magento/Json/Encoder.php index d7a3b700ba41a17ee582e20ad2741f1715a23431..6f0a9109212bea10a48c415c06bd5bc43f9af1fe 100644 --- a/lib/Magento/Json/Encoder.php +++ b/lib/Magento/Json/Encoder.php @@ -47,6 +47,8 @@ class Encoder implements EncoderInterface } /** + * Encode the mixed $data into the JSON format. + * * @param mixed $data * @return string */ diff --git a/lib/Magento/Json/EncoderInterface.php b/lib/Magento/Json/EncoderInterface.php index 349570790ed9e88d2110c7032a5933fc206e0bb1..c41afc32be14553d232ac34ec70a449e3abcd337 100644 --- a/lib/Magento/Json/EncoderInterface.php +++ b/lib/Magento/Json/EncoderInterface.php @@ -31,6 +31,8 @@ namespace Magento\Json; interface EncoderInterface { /** + * Encode the mixed $data into the JSON format. + * * @param mixed $data * @return string */ diff --git a/lib/Magento/LauncherInterface.php b/lib/Magento/LauncherInterface.php new file mode 100644 index 0000000000000000000000000000000000000000..4c2c10592f7b0d2fdf1edd356ddf52d8049c2999 --- /dev/null +++ b/lib/Magento/LauncherInterface.php @@ -0,0 +1,34 @@ +<?php +/** + * Application. Performs user requested actions. + * + * 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; + +interface LauncherInterface +{ + /** + * @return \Magento\App\ResponseInterface + */ + public function launch(); +} \ No newline at end of file diff --git a/lib/Magento/Less/File/FileList/Collator.php b/lib/Magento/Less/File/FileList/Collator.php new file mode 100644 index 0000000000000000000000000000000000000000..0671a866d9c60854b0466fab8f81b4a0705736ac --- /dev/null +++ b/lib/Magento/Less/File/FileList/Collator.php @@ -0,0 +1,54 @@ +<?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\Less\File\FileList; + +use Magento\View\Layout\File\FileList\CollateInterface; + +/** + * Less file list collator + */ +class Collator implements CollateInterface +{ + /** + * Collate less files + * + * @param \Magento\View\Layout\File[] $files + * @param \Magento\View\Layout\File[] $filesOrigin + * @return \Magento\View\Layout\File[] + */ + public function collate($files, $filesOrigin) + { + foreach ($files as $file) { + $fileId = substr($file->getFileIdentifier(), strpos($file->getFileIdentifier(), '|')); + foreach (array_keys($filesOrigin) as $identifier) { + if (false !== strpos($identifier, $fileId)) { + unset($filesOrigin[$identifier]); + } + } + $filesOrigin[$file->getFileIdentifier()] = $file; + } + return $filesOrigin; + } +} diff --git a/lib/Magento/Less/File/Source/Aggregated.php b/lib/Magento/Less/File/Source/Aggregated.php new file mode 100644 index 0000000000000000000000000000000000000000..3687fd1cf20186fe350af676215b35949f186a11 --- /dev/null +++ b/lib/Magento/Less/File/Source/Aggregated.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\Less\File\Source; + +use Magento\View\Layout\File\SourceInterface; +use Magento\View\Layout\File\FileList\Factory; +use Magento\View\Design\ThemeInterface; + +/** + * Source of layout files aggregated from a theme and its parents according to merging and overriding conventions + */ +class Aggregated implements SourceInterface +{ + /** + * @var Factory + */ + protected $fileListFactory; + + /** + * @var SourceInterface + */ + protected $libraryFiles; + + /** + * @var SourceInterface + */ + protected $baseFiles; + + /** + * @var SourceInterface + */ + protected $themeFiles; + + /** + * @param Factory $fileListFactory + * @param SourceInterface $libraryFiles + * @param SourceInterface $baseFiles + * @param SourceInterface $themeFiles + */ + public function __construct( + Factory $fileListFactory, + SourceInterface $libraryFiles, + SourceInterface $baseFiles, + SourceInterface $themeFiles + ) { + $this->fileListFactory = $fileListFactory; + $this->libraryFiles = $libraryFiles; + $this->baseFiles = $baseFiles; + $this->themeFiles = $themeFiles; + } + + /** + * Retrieve files + * + * Aggregate LESS files from modules and a theme and its ancestors + * + * @param \Magento\View\Design\ThemeInterface $theme + * @param string $filePath + * @return \Magento\View\Layout\File[] + * @throws \LogicException + */ + public function getFiles(ThemeInterface $theme, $filePath = '*') + { + $list = $this->fileListFactory->create('Magento\Less\File\FileList\Collator'); + $list->add($this->libraryFiles->getFiles($theme, $filePath)); + $list->add($this->baseFiles->getFiles($theme, $filePath)); + + foreach ($theme->getInheritedThemes() as $currentTheme) { + $files = $this->themeFiles->getFiles($currentTheme, $filePath); + $list->replace($files); + } + $result = $list->getAll(); + if (empty($result)) { + throw new \LogicException('magento_import returns empty result by path ' . $filePath); + } + return $result; + } +} diff --git a/lib/Magento/Less/File/Source/Base.php b/lib/Magento/Less/File/Source/Base.php new file mode 100644 index 0000000000000000000000000000000000000000..bca5e418aeb59798a9d89e8b5e17f62624ba0242 --- /dev/null +++ b/lib/Magento/Less/File/Source/Base.php @@ -0,0 +1,89 @@ +<?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\Less\File\Source; + +use Magento\View\Layout\File\SourceInterface; +use Magento\View\Design\ThemeInterface; +use Magento\App\Filesystem; +use Magento\Filesystem\Directory\ReadInterface; +use Magento\View\Layout\File\Factory; + +/** + * Source of base layout files introduced by modules + */ +class Base implements SourceInterface +{ + /** + * @var Factory + */ + protected $fileFactory; + + /** + * @var ReadInterface + */ + protected $modulesDirectory; + + /** + * @param Filesystem $filesystem + * @param Factory $fileFactory + */ + public function __construct( + Filesystem $filesystem, + Factory $fileFactory + ) { + $this->modulesDirectory = $filesystem->getDirectoryRead(Filesystem::MODULES_DIR); + $this->fileFactory = $fileFactory; + } + + /** + * Retrieve files + * + * @param ThemeInterface $theme + * @param string $filePath + * @return array|\Magento\View\Layout\File[] + */ + public function getFiles(ThemeInterface $theme, $filePath = '*') + { + //Import module base styles + + $filePath = pathinfo($filePath, PATHINFO_EXTENSION) ? $filePath : rtrim($filePath, '.') . '.less'; + + $namespace = $module = '*'; + $area = $theme->getArea(); + $files = $this->modulesDirectory->search("$namespace/$module/view/{$area}/{$filePath}"); + $result = array(); + $filePath = strtr(preg_quote($filePath), array('\*' => '[^/]+')); + $pattern = "#(?<namespace>[^/]+)/(?<module>[^/]+)/view/{$area}/" . $filePath . "$#i"; + foreach ($files as $file) { + $filename = $this->modulesDirectory->getAbsolutePath($file); + if (!preg_match($pattern, $filename, $matches)) { + continue; + } + $moduleFull = "{$matches['namespace']}_{$matches['module']}"; + $result[] = $this->fileFactory->create($filename, $moduleFull, $theme); + } + return $result; + } +} diff --git a/lib/Magento/Less/File/Source/Library.php b/lib/Magento/Less/File/Source/Library.php new file mode 100644 index 0000000000000000000000000000000000000000..24bea875357b424cc78194bb0c1d7d60d276f840 --- /dev/null +++ b/lib/Magento/Less/File/Source/Library.php @@ -0,0 +1,112 @@ +<?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\Less\File\Source; + +use Magento\View\Layout\File\SourceInterface; +use Magento\View\Design\ThemeInterface; +use Magento\App\Filesystem; +use Magento\Filesystem\Directory\ReadInterface; +use Magento\View\Layout\File\Factory; +use Magento\View\Layout\File\FileList\Factory as FileListFactory; + +/** + * Source of base layout files introduced by modules + */ +class Library implements SourceInterface +{ + /** + * @var Factory + */ + protected $fileFactory; + + /** + * @var ReadInterface + */ + protected $libraryDirectory; + + /** + * @var ReadInterface + */ + protected $themesDirectory; + + /** + * @var FileListFactory + */ + protected $fileListFactory; + + /** + * @param FileListFactory $fileListFactory + * @param Filesystem $filesystem + * @param Factory $fileFactory + */ + public function __construct( + FileListFactory $fileListFactory, + Filesystem $filesystem, + Factory $fileFactory + ) { + $this->fileListFactory = $fileListFactory; + $this->libraryDirectory = $filesystem->getDirectoryRead(Filesystem::PUB_LIB_DIR); + $this->themesDirectory = $filesystem->getDirectoryRead(Filesystem::THEMES_DIR); + $this->fileFactory = $fileFactory; + } + + /** + * Retrieve files + * + * @param ThemeInterface $theme + * @param string $filePath + * @return array|\Magento\View\Layout\File[] + */ + public function getFiles(ThemeInterface $theme, $filePath = '*') + { + $filePath = pathinfo($filePath, PATHINFO_EXTENSION) ? $filePath : rtrim($filePath, '.') . '.less'; + $list = $this->fileListFactory->create(); + $files = $this->libraryDirectory->search($filePath); + $list->add($this->createFiles($this->libraryDirectory, $theme, $files)); + + foreach ($theme->getInheritedThemes() as $currentTheme) { + $themeFullPath = $currentTheme->getFullPath(); + $files = $this->themesDirectory->search("{$themeFullPath}/{$filePath}"); + $list->replace($this->createFiles($this->themesDirectory, $theme, $files), false); + } + return $list->getAll(); + } + + /** + * @param ReadInterface $reader + * @param ThemeInterface $theme + * @param array $files + * @return array + */ + protected function createFiles(ReadInterface $reader, ThemeInterface $theme, $files) + { + $result = array(); + foreach ($files as $file) { + $filename = $reader->getAbsolutePath($file); + $result[] = $this->fileFactory->create($filename, 'lib', $theme); + } + return $result; + } +} diff --git a/lib/Magento/Less/File/Source/Theme.php b/lib/Magento/Less/File/Source/Theme.php new file mode 100644 index 0000000000000000000000000000000000000000..a5f3827590962ab976a4678d0c709e2090ed3e07 --- /dev/null +++ b/lib/Magento/Less/File/Source/Theme.php @@ -0,0 +1,86 @@ +<?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\Less\File\Source; + +use Magento\View\Layout\File\SourceInterface; +use Magento\View\Design\ThemeInterface; +use Magento\App\Filesystem; +use Magento\Filesystem\Directory\ReadInterface; +use Magento\View\Layout\File\Factory; + +/** + * Source of non-overriding layout files introduced by a theme + */ +class Theme implements SourceInterface +{ + /** + * @var Factory + */ + protected $fileFactory; + + /** + * @var ReadInterface + */ + protected $themesDirectory; + + /** + * @param Filesystem $filesystem + * @param Factory $fileFactory + */ + public function __construct( + Filesystem $filesystem, + Factory $fileFactory + ) { + $this->themesDirectory = $filesystem->getDirectoryRead(Filesystem::THEMES_DIR); + $this->fileFactory = $fileFactory; + } + + /** + * Retrieve files + * + * @param ThemeInterface $theme + * @param string $filePath + * @return array|\Magento\View\Layout\File[] + */ + public function getFiles(ThemeInterface $theme, $filePath = '*') + { + $filePath = pathinfo($filePath, PATHINFO_EXTENSION) ? $filePath : rtrim($filePath, '.') . '.less'; + + $namespace = $module = '*'; + $themePath = $theme->getFullPath(); + $files = $this->themesDirectory->search("{$themePath}/{$namespace}_{$module}/{$filePath}"); + $result = array(); + $pattern = "#/(?<moduleName>[^/]+)/" . strtr(preg_quote($filePath), array('\*' => '[^/]+')) . "#i"; + foreach ($files as $file) { + $filename = $this->themesDirectory->getAbsolutePath($file); + if (!preg_match($pattern, $filename, $matches)) { + continue; + } + $result[] = $this->fileFactory->create($filename, $matches['moduleName'], $theme); + } + + return $result; + } +} diff --git a/lib/Magento/Less/PreProcessor.php b/lib/Magento/Less/PreProcessor.php new file mode 100644 index 0000000000000000000000000000000000000000..7560df5cfb3f69a00ed4d88e66b92d8feca26b8e --- /dev/null +++ b/lib/Magento/Less/PreProcessor.php @@ -0,0 +1,161 @@ +<?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\Less; + +use Magento\Less\PreProcessor\InstructionFactory; + +/** + * LESS instruction preprocessor + */ +class PreProcessor +{ + /** + * Folder for publication preprocessed less files + */ + const PUBLICATION_PREFIX_PATH = 'less'; + + /** + * @var \Magento\View\FileSystem + */ + protected $viewFileSystem; + + /** + * @var \Magento\Filesystem + */ + protected $filesystem; + + /** + * @var InstructionFactory + */ + protected $instructionFactory; + + /** + * @var \Magento\Logger + */ + protected $logger; + + /** + * @var array + */ + protected $preProcessors; + + /** + * @param \Magento\View\FileSystem $viewFileSystem + * @param \Magento\Filesystem $filesystem + * @param InstructionFactory $instructionFactory + * @param \Magento\Logger $logger + * @param array $preProcessors + */ + public function __construct( + \Magento\View\FileSystem $viewFileSystem, + \Magento\Filesystem $filesystem, + InstructionFactory $instructionFactory, + \Magento\Logger $logger, + array $preProcessors = array() + ) { + $this->viewFileSystem = $viewFileSystem; + $this->filesystem = $filesystem; + $this->instructionFactory = $instructionFactory; + $this->logger = $logger; + $this->preProcessors = $preProcessors; + } + + /** + * Instantiate instruction less preprocessors + * + * @param array $params + * @return \Magento\Less\PreProcessorInterface[] + */ + protected function getLessPreProcessors(array $params) + { + $preProcessors = []; + foreach ($this->preProcessors as $preProcessorClass) { + $preProcessors[] = $this->instructionFactory->create($preProcessorClass['class'], $params); + } + return $preProcessors; + } + + /** + * Get base directory with source of less files + * + * @return \Magento\Filesystem\Directory\ReadInterface + */ + protected function getDirectoryRead() + { + return $this->filesystem->getDirectoryRead(\Magento\App\Filesystem::ROOT_DIR); + } + + /** + * Get directory for publication temporary less files + * + * @return \Magento\Filesystem\Directory\WriteInterface + */ + protected function getDirectoryWrite() + { + return $this->filesystem->getDirectoryWrite(\Magento\App\Filesystem::TMP_DIR); + } + + /** + * Generate new source path for less file into temporary folder + * + * @param string $lessFileSourcePath + * @return string + */ + protected function generateNewPath($lessFileSourcePath) + { + $sourcePathPrefix = $this->getDirectoryRead()->getAbsolutePath(); + $targetPathPrefix = $this->getDirectoryWrite()->getAbsolutePath() . self::PUBLICATION_PREFIX_PATH . '/'; + return str_replace($sourcePathPrefix, $targetPathPrefix, $lessFileSourcePath); + } + + /** + * Process less content throughout all existed instruction preprocessors + * + * @param string $lessFilePath + * @param array $params + * @return string of saved or original preprocessed less file + */ + public function processLessInstructions($lessFilePath, $params) + { + $lessFileSourcePath = $this->viewFileSystem->getViewFile($lessFilePath, $params); + $directoryRead = $this->getDirectoryRead(); + $lessContent = $lessSourceContent = $directoryRead->readFile( + $directoryRead->getRelativePath($lessFileSourcePath) + ); + + foreach ($this->getLessPreProcessors($params) as $processor) { + $lessContent = $processor->process($lessContent); + } + + $lessFileTargetPath = $this->generateNewPath($lessFileSourcePath); + if ($lessFileSourcePath != $lessFileTargetPath && $lessSourceContent != $lessContent) { + $directoryWrite = $this->getDirectoryWrite(); + $directoryWrite->writeFile($directoryWrite->getRelativePath($lessFileTargetPath), $lessContent); + return $lessFileTargetPath; + } + + return $lessFileSourcePath; + } +} diff --git a/lib/Magento/Less/PreProcessor/Instruction/Import.php b/lib/Magento/Less/PreProcessor/Instruction/Import.php new file mode 100644 index 0000000000000000000000000000000000000000..fac42869b7bf4a8867f1caec587cb26916ab934c --- /dev/null +++ b/lib/Magento/Less/PreProcessor/Instruction/Import.php @@ -0,0 +1,133 @@ +<?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\Less\PreProcessor\Instruction; + +use Magento\Less\PreProcessorInterface; + +/** + * Less @import instruction preprocessor + */ +class Import implements PreProcessorInterface +{ + /** + * Pattern of @import less instruction + */ + const REPLACE_PATTERN = + '#@import\s+(\((?P<type>\w+)\)\s+)?[\'\"](?P<path>(?![/\\\]|\w:[/\\\])[^\"\']+)[\'\"]\s*?(?P<media>.*?);#'; + + /** + * Import's path list where key is relative path and value is absolute path to the imported content + * + * @var array + */ + protected $importPaths = []; + + /** + * @var \Magento\Less\PreProcessor + */ + protected $preProcessor; + + /** + * @var \Magento\Logger + */ + protected $logger; + + /** + * @var array + */ + protected $viewParams; + + /** + * @param \Magento\Less\PreProcessor $preProcessor + * @param \Magento\Logger $logger + * @param array $viewParams + */ + public function __construct( + \Magento\Less\PreProcessor $preProcessor, + \Magento\Logger $logger, + array $viewParams = array() + ) { + $this->preProcessor = $preProcessor; + $this->logger = $logger; + $this->viewParams = $viewParams; + } + + /** + * Explode import paths + * + * @param array $importPaths + * @return $this + */ + protected function generatePaths($importPaths) + { + foreach ($importPaths as $path) { + $path = $this->preparePath($path); + try { + $this->importPaths[$path] = $this->preProcessor->processLessInstructions($path, $this->viewParams); + } catch (\Magento\Filesystem\FilesystemException $e) { + $this->logger->logException($e); + } + } + return $this; + } + + /** + * Prepare relative path to less compatible state + * + * @param string $lessSourcePath + * @return string + */ + protected function preparePath($lessSourcePath) + { + return pathinfo($lessSourcePath, PATHINFO_EXTENSION) ? $lessSourcePath : $lessSourcePath . '.less'; + } + + /** + * {@inheritdoc} + */ + public function process($lessContent) + { + $matches = []; + preg_match_all(self::REPLACE_PATTERN, $lessContent, $matches); + $this->generatePaths($matches['path']); + return preg_replace_callback(self::REPLACE_PATTERN, array($this, 'replace'), $lessContent); + } + + /** + * Replace import path to file + * + * @param array $matchContent + * @return string + */ + protected function replace($matchContent) + { + $path = $this->preparePath($matchContent['path']); + if (empty($this->importPaths[$path])) { + return ''; + } + $typeString = empty($matchContent['type']) ? '' : '(' . $matchContent['type'] . ') '; + return "@import {$typeString}'{$this->importPaths[$path]}';"; + } +} diff --git a/lib/Magento/Less/PreProcessor/Instruction/MagentoImport.php b/lib/Magento/Less/PreProcessor/Instruction/MagentoImport.php new file mode 100644 index 0000000000000000000000000000000000000000..c842e2ab9cb37349a4798c5a97f21fba2226c667 --- /dev/null +++ b/lib/Magento/Less/PreProcessor/Instruction/MagentoImport.php @@ -0,0 +1,102 @@ +<?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\Less\PreProcessor\Instruction; + +use Magento\Less\PreProcessorInterface; + +/** + * Less @magento_import instruction preprocessor + */ +class MagentoImport implements PreProcessorInterface +{ + /** + * Pattern of @import less instruction + */ + const REPLACE_PATTERN = '#//@magento_import\s+[\'\"](?P<path>(?![/\\\]|\w:[/\\\])[^\"\']+)[\'\"]\s*?;#'; + + /** + * @var \Magento\View\Layout\File\SourceInterface + */ + protected $fileSource; + + /** + * @var \Magento\Logger + */ + protected $logger; + + /** + * @var array + */ + protected $viewParams; + + /** + * @param \Magento\View\Layout\File\SourceInterface $fileSource + * @param \Magento\View\Service $viewService + * @param \Magento\Less\PreProcessor $preProcessor + * @param \Magento\Logger $logger + * @param array $viewParams + */ + public function __construct( + \Magento\View\Layout\File\SourceInterface $fileSource, + \Magento\View\Service $viewService, + \Magento\Less\PreProcessor $preProcessor, + \Magento\Logger $logger, + array $viewParams = array() + ) { + $this->fileSource = $fileSource; + $viewService->updateDesignParams($viewParams); + $this->logger = $logger; + $this->viewParams = $viewParams; + } + + /** + * {@inheritdoc} + */ + public function process($lessContent) + { + return preg_replace_callback(self::REPLACE_PATTERN, array($this, 'replace'), $lessContent); + } + + /** + * Replace @magento_import to @import less instructions + * + * @param array $matchContent + * @return string + */ + protected function replace($matchContent) + { + $importsContent = ''; + try { + $importFiles = $this->fileSource->getFiles($this->viewParams['themeModel'], $matchContent['path']); + /** @var $importFile \Magento\View\Layout\File */ + foreach ($importFiles as $importFile) { + $importsContent .= "@import '{$importFile->getFilename()}';\n"; + } + } catch(\LogicException $e) { + $this->logger->logException($e); + } + return $importsContent; + } +} diff --git a/lib/Magento/Less/PreProcessor/InstructionFactory.php b/lib/Magento/Less/PreProcessor/InstructionFactory.php new file mode 100644 index 0000000000000000000000000000000000000000..56aad9b1df9c1cc4b9ff46cfaf9ebc7191ea1ae8 --- /dev/null +++ b/lib/Magento/Less/PreProcessor/InstructionFactory.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\Less\PreProcessor; + +/** + * Factory class for \Magento\Less\PreProcessorInterface + */ +class InstructionFactory +{ + /** + * Object Manager instance + * + * @var \Magento\ObjectManager + */ + protected $_objectManager; + + /** + * Factory constructor + * + * @param \Magento\ObjectManager $objectManager + */ + public function __construct(\Magento\ObjectManager $objectManager) + { + $this->_objectManager = $objectManager; + } + + /** + * Create class instance with specified parameters + * + * @param string $className + * @param array $viewParams + * @return \Magento\Less\PreProcessorInterface + * @throws \InvalidArgumentException + */ + public function create($className, array $viewParams = array()) + { + $preProcessor = $this->_objectManager->create($className, array('viewParams' => $viewParams)); + if (!$preProcessor instanceof \Magento\Less\PreProcessorInterface) { + throw new \InvalidArgumentException( + "{$className} aren't instance of \\Magento\\Less\\PreProcessorInterface" + ); + } + return $preProcessor; + } +} diff --git a/lib/Magento/Less/PreProcessorInterface.php b/lib/Magento/Less/PreProcessorInterface.php new file mode 100644 index 0000000000000000000000000000000000000000..08fd5dc7a550a568fb916372fed3f0522c648289 --- /dev/null +++ b/lib/Magento/Less/PreProcessorInterface.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\Less; + +/** + * Interface for pre-processing less instruction + */ +interface PreProcessorInterface +{ + /** + * Process less content to adapt magento view system + * + * @param string $lessContent + * @return string of processed content + */ + public function process($lessContent); +} diff --git a/lib/Magento/Message/AbstractMessage.php b/lib/Magento/Message/AbstractMessage.php index 42563fb362cf8e00d8de19032c18118950f1deda..3aa1576641aab1f9010069d43c75b80adfe8b7c8 100644 --- a/lib/Magento/Message/AbstractMessage.php +++ b/lib/Magento/Message/AbstractMessage.php @@ -35,7 +35,7 @@ abstract class AbstractMessage implements MessageInterface protected $text; /** - * @var mixed + * @var string */ protected $identifier; diff --git a/lib/Magento/Message/Collection.php b/lib/Magento/Message/Collection.php index a50b5da9ee5b630ad242eee2816153abafa541ef..2656123ef2d00657aa474e359d9064e3edc4d3df 100644 --- a/lib/Magento/Message/Collection.php +++ b/lib/Magento/Message/Collection.php @@ -45,7 +45,7 @@ class Collection * Adding new message to collection * * @param MessageInterface $message - * @return Collection + * @return $this */ public function addMessage(MessageInterface $message) { @@ -60,7 +60,7 @@ class Collection /** * Clear all messages except sticky * - * @return Collection + * @return $this */ public function clear() { @@ -113,6 +113,7 @@ class Collection * Delete message by id * * @param string $identifier + * @return void */ public function deleteMessageByIdentifier($identifier) { diff --git a/lib/Magento/Message/CollectionFactory.php b/lib/Magento/Message/CollectionFactory.php index 409b285a44a10589cb27071a61a3ecdafac30311..0bb523ad921e1c6a75d62106a3e2bde3d8c955a1 100644 --- a/lib/Magento/Message/CollectionFactory.php +++ b/lib/Magento/Message/CollectionFactory.php @@ -24,6 +24,8 @@ namespace Magento\Message; +use Magento\ObjectManager; + /** * Message collection factory */ @@ -32,14 +34,14 @@ class CollectionFactory /** * Object Manager instance * - * @var \Magento\ObjectManager + * @var ObjectManager */ protected $objectManager; /** - * @param \Magento\ObjectManager $objectManager + * @param ObjectManager $objectManager */ - public function __construct(\Magento\ObjectManager $objectManager) + public function __construct(ObjectManager $objectManager) { $this->objectManager = $objectManager; } diff --git a/lib/Magento/Message/Factory.php b/lib/Magento/Message/Factory.php index a78932dd252810b0654cebef3ed0f14c54fc150b..43829742e755f354b00ecdfbc65e534296073741 100644 --- a/lib/Magento/Message/Factory.php +++ b/lib/Magento/Message/Factory.php @@ -24,6 +24,8 @@ namespace Magento\Message; +use Magento\ObjectManager; + /** * Message model factory */ @@ -32,7 +34,7 @@ class Factory /** * Allowed message types * - * @var array + * @var string[] */ protected $types = array( MessageInterface::TYPE_ERROR, @@ -44,16 +46,16 @@ class Factory /** * Object Manager instance * - * @var \Magento\ObjectManager + * @var ObjectManager */ protected $objectManager; /** * Factory constructor * - * @param \Magento\ObjectManager $objectManager + * @param ObjectManager $objectManager */ - public function __construct(\Magento\ObjectManager $objectManager) + public function __construct(ObjectManager $objectManager) { $this->objectManager = $objectManager; } diff --git a/lib/Magento/Message/Manager.php b/lib/Magento/Message/Manager.php index 21136dc23c434d306d010160704f7784fe185cac..fe20d10c68cdba62ecf659d7c6cdb6ab6c329394 100644 --- a/lib/Magento/Message/Manager.php +++ b/lib/Magento/Message/Manager.php @@ -24,6 +24,9 @@ namespace Magento\Message; +use Magento\Logger; +use Magento\Event\ManagerInterface as EventManagerInterface; + /** * Message manager model */ @@ -45,12 +48,12 @@ class Manager implements ManagerInterface protected $messagesFactory; /** - * @var \Magento\Event\ManagerInterface + * @var EventManagerInterface */ protected $eventManager; /** - * @var \Magento\Logger + * @var Logger */ protected $logger; @@ -63,16 +66,16 @@ class Manager implements ManagerInterface * @param Session $session * @param Factory $messageFactory * @param CollectionFactory $messagesFactory - * @param \Magento\Event\ManagerInterface $eventManager - * @param \Magento\Logger $logger + * @param EventManagerInterface $eventManager + * @param Logger $logger * @param string $defaultGroup */ public function __construct( Session $session, Factory $messageFactory, CollectionFactory $messagesFactory, - \Magento\Event\ManagerInterface $eventManager, - \Magento\Logger $logger, + EventManagerInterface $eventManager, + Logger $logger, $defaultGroup = self::DEFAULT_GROUP ) { $this->session = $session; @@ -144,7 +147,7 @@ class Manager implements ManagerInterface /** * Adding messages array to message collection * - * @param array $messages + * @param MessageInterface[] $messages * @param string|null $group * @return $this */ @@ -211,7 +214,7 @@ class Manager implements ManagerInterface /** * Adds messages array to message collection, but doesn't add duplicates to it * - * @param array|MessageInterface $messages + * @param MessageInterface[]|MessageInterface $messages * @param string|null $group * @return $this */ @@ -268,7 +271,7 @@ class Manager implements ManagerInterface $exception->getTraceAsString() ); - $this->logger->logFile($message, \Zend_Log::DEBUG, \Magento\Logger::LOGGER_EXCEPTION); + $this->logger->logFile($message, \Zend_Log::DEBUG, Logger::LOGGER_EXCEPTION); $this->addMessage($this->messageFactory->create(MessageInterface::TYPE_ERROR, $alternativeText), $group); return $this; } diff --git a/lib/Magento/Module/Declaration/FileIterator.php b/lib/Magento/Module/Declaration/FileIterator.php index 73143c246f07e743ff1bff7109d85285e3bd34d4..802c37d4abbf89369950aa995ef7aeb32fe18cbe 100644 --- a/lib/Magento/Module/Declaration/FileIterator.php +++ b/lib/Magento/Module/Declaration/FileIterator.php @@ -23,14 +23,22 @@ */ namespace Magento\Module\Declaration; +use Magento\App\Filesystem; + class FileIterator extends \Magento\Config\FileIterator { + /** + * Constructor. + * + * @param Filesystem $filesystem + * @param string[] $paths + */ public function __construct( - \Magento\App\Filesystem $filesystem, + Filesystem $filesystem, array $paths ) { - parent::__construct($filesystem->getDirectoryRead(\Magento\App\Filesystem::APP_DIR), $paths); + parent::__construct($filesystem->getDirectoryRead(Filesystem::APP_DIR), $paths); } } diff --git a/lib/Magento/Module/Declaration/FileIteratorFactory.php b/lib/Magento/Module/Declaration/FileIteratorFactory.php index 47d9ffd37101e222e9345e21d8228c7753521299..c04dded51bd724f67cd10a55a14c92de637b4f54 100644 --- a/lib/Magento/Module/Declaration/FileIteratorFactory.php +++ b/lib/Magento/Module/Declaration/FileIteratorFactory.php @@ -25,10 +25,19 @@ */ namespace Magento\Module\Declaration; +use Magento\Filesystem; + class FileIteratorFactory { + /** + * Creates a FileIterator. + * + * @param Filesystem $filesystem + * @param string[] paths + * @return FileIterator + */ public function create($filesystem, $paths) { - return new \Magento\Module\Declaration\FileIterator($filesystem, $paths); + return new FileIterator($filesystem, $paths); } } diff --git a/lib/Magento/Module/Declaration/FileResolver.php b/lib/Magento/Module/Declaration/FileResolver.php index 9edb5e9470861d1e35766d005ae3b5a250b59f64..3d3949e8bf91d9eb70cf7564f9ebf8aa9ccc508a 100644 --- a/lib/Magento/Module/Declaration/FileResolver.php +++ b/lib/Magento/Module/Declaration/FileResolver.php @@ -25,48 +25,51 @@ */ namespace Magento\Module\Declaration; +use Magento\App\Filesystem; +use Magento\Filesystem\Directory\ReadInterface; + class FileResolver implements \Magento\Config\FileResolverInterface { /** * Modules directory with read access * - * @var \Magento\Filesystem\Directory\ReadInterface + * @var ReadInterface */ protected $modulesDirectory; /** * Config directory with read access * - * @var \Magento\Filesystem\Directory\ReadInterface + * @var ReadInterface */ protected $configDirectory; /** * Root directory with read access * - * @var \Magento\Filesystem\Directory\ReadInterface + * @var ReadInterface */ protected $rootDirectory; /** * File iterator factory * - * @var FileIteratorFactory + * @var \Magento\Config\FileIteratorFactory */ protected $iteratorFactory; /** - * @param \Magento\App\Filesystem $filesystem + * @param Filesystem $filesystem * @param \Magento\Config\FileIteratorFactory $iteratorFactory */ public function __construct( - \Magento\App\Filesystem $filesystem, + Filesystem $filesystem, \Magento\Config\FileIteratorFactory $iteratorFactory ) { - $this->iteratorFactory = $iteratorFactory; - $this->modulesDirectory = $filesystem->getDirectoryRead(\Magento\App\Filesystem::MODULES_DIR); - $this->configDirectory = $filesystem->getDirectoryRead(\Magento\App\Filesystem::CONFIG_DIR); - $this->rootDirectory = $filesystem->getDirectoryRead(\Magento\App\Filesystem::ROOT_DIR); + $this->iteratorFactory = $iteratorFactory; + $this->modulesDirectory = $filesystem->getDirectoryRead(Filesystem::MODULES_DIR); + $this->configDirectory = $filesystem->getDirectoryRead(Filesystem::CONFIG_DIR); + $this->rootDirectory = $filesystem->getDirectoryRead(Filesystem::ROOT_DIR); } /** @@ -76,7 +79,7 @@ class FileResolver implements \Magento\Config\FileResolverInterface public function get($filename, $scope) { $moduleDir = $this->modulesDirectory->getAbsolutePath(); - $configDir = $this->configDirectory->getAbsolutePath(); + $configDir = $this->configDirectory->getAbsolutePath(); $mageScopePath = $moduleDir . '/Magento'; $output = array( diff --git a/lib/Magento/Module/Declaration/Reader/Filesystem.php b/lib/Magento/Module/Declaration/Reader/Filesystem.php index 438e3f6248c54fcbc0eff5400feb4d793fd59f20..04efefb19997dfaaf2703eca0bda8e12f687a8a8 100644 --- a/lib/Magento/Module/Declaration/Reader/Filesystem.php +++ b/lib/Magento/Module/Declaration/Reader/Filesystem.php @@ -25,6 +25,11 @@ */ namespace Magento\Module\Declaration\Reader; +use Magento\Module\Declaration\FileResolver; +use Magento\Module\Declaration\Converter\Dom; +use Magento\Module\Declaration\SchemaLocator; +use Magento\Config\ValidationStateInterface; + class Filesystem extends \Magento\Config\Reader\Filesystem { /** @@ -45,10 +50,10 @@ class Filesystem extends \Magento\Config\Reader\Filesystem ); /** - * @param \Magento\Module\Declaration\FileResolver $fileResolver - * @param \Magento\Module\Declaration\Converter\Dom $converter - * @param \Magento\Module\Declaration\SchemaLocator $schemaLocator - * @param \Magento\Config\ValidationStateInterface $validationState + * @param FileResolver $fileResolver + * @param Dom $converter + * @param SchemaLocator $schemaLocator + * @param ValidationStateInterface $validationState * @param string $fileName * @param array $idAttributes * @param string $domDocumentClass @@ -56,10 +61,10 @@ class Filesystem extends \Magento\Config\Reader\Filesystem * @param array $allowedModules */ public function __construct( - \Magento\Module\Declaration\FileResolver $fileResolver, - \Magento\Module\Declaration\Converter\Dom $converter, - \Magento\Module\Declaration\SchemaLocator $schemaLocator, - \Magento\Config\ValidationStateInterface $validationState, + FileResolver $fileResolver, + Dom $converter, + SchemaLocator $schemaLocator, + ValidationStateInterface $validationState, $fileName = 'module.xml', $idAttributes = array(), $domDocumentClass = 'Magento\Config\Dom', @@ -115,6 +120,7 @@ class Filesystem extends \Magento\Config\Reader\Filesystem * * @param array $moduleConfig * @param array $activeModules + * @return void * @throws \Exception */ protected function _checkModuleDependencies(array $moduleConfig, array $activeModules) @@ -147,6 +153,7 @@ class Filesystem extends \Magento\Config\Reader\Filesystem * * @param string $moduleName * @param array $altExtensions + * @return void * @throws \Exception */ protected function _checkAlternativeExtensions($moduleName, array $altExtensions) diff --git a/lib/Magento/Module/Dir.php b/lib/Magento/Module/Dir.php index a19bfc0b7a0659e6d675398abf99a51ab061912c..3345338caf6cab6c74a8a71e84e4ddff58e383ef 100644 --- a/lib/Magento/Module/Dir.php +++ b/lib/Magento/Module/Dir.php @@ -26,13 +26,14 @@ namespace Magento\Module; use Magento\App\Filesystem; +use Magento\Filesystem\Directory\ReadInterface; class Dir { /** * Modules root directory * - * @var \Magento\Filesystem\Directory\ReadInterface + * @var ReadInterface */ protected $_modulesDirectory; @@ -42,7 +43,7 @@ class Dir protected $_string; /** - * @param \Magento\App\Filesystem $filesystem + * @param Filesystem $filesystem * @param \Magento\Stdlib\String $string */ public function __construct(Filesystem $filesystem, \Magento\Stdlib\String $string) diff --git a/lib/Magento/Module/Dir/Reader.php b/lib/Magento/Module/Dir/Reader.php index 3f19fe390e53326530e34f9a73bfbe4aeeaaa36a..bb37775635c58dc6be946d651ed528cef1326b0f 100644 --- a/lib/Magento/Module/Dir/Reader.php +++ b/lib/Magento/Module/Dir/Reader.php @@ -25,8 +25,12 @@ */ namespace Magento\Module\Dir; -use Magento\Filesystem\Directory\Read; use Magento\App\Filesystem; +use Magento\Config\FileIterator; +use Magento\Config\FileIteratorFactory; +use Magento\Filesystem\Directory\Read; +use Magento\Module\ModuleListInterface; +use Magento\Module\Dir; class Reader { @@ -40,14 +44,14 @@ class Reader /** * Directory registry * - * @var \Magento\Module\Dir + * @var Dir */ protected $moduleDirs; /** * Modules configuration provider * - * @var \Magento\Module\ModuleListInterface + * @var ModuleListInterface */ protected $modulesList; @@ -56,19 +60,22 @@ class Reader */ protected $modulesDirectory; + /** + * @var FileIteratorFactory + */ protected $fileIteratorFactory; /** - * @param \Magento\Module\Dir $moduleDirs - * @param \Magento\Module\ModuleListInterface $moduleList + * @param Dir $moduleDirs + * @param ModuleListInterface $moduleList * @param Filesystem $filesystem - * @param \Magento\Config\FileIteratorFactory $fileIteratorFactory + * @param FileIteratorFactory $fileIteratorFactory */ public function __construct( - \Magento\Module\Dir $moduleDirs, - \Magento\Module\ModuleListInterface $moduleList, - \Magento\App\Filesystem $filesystem, - \Magento\Config\FileIteratorFactory $fileIteratorFactory + Dir $moduleDirs, + ModuleListInterface $moduleList, + Filesystem $filesystem, + FileIteratorFactory $fileIteratorFactory ) { $this->moduleDirs = $moduleDirs; $this->modulesList = $moduleList; @@ -79,8 +86,8 @@ class Reader /** * Go through all modules and find configuration files of active modules * - * @param $filename - * @return \Magento\Config\FileIterator + * @param string $filename + * @return FileIterator */ public function getConfigurationFiles($filename) { @@ -116,6 +123,7 @@ class Reader * @param string $moduleName * @param string $type directory type (etc, controllers, locale etc) * @param string $path + * @return void */ public function setModuleDir($moduleName, $type, $path) { diff --git a/lib/Magento/Module/Dir/ReverseResolver.php b/lib/Magento/Module/Dir/ReverseResolver.php index 459bb5e328f956fcb2ca88205665459eade37b34..ab9cde759773a51c82af5e9c64a9c2d827b95656 100644 --- a/lib/Magento/Module/Dir/ReverseResolver.php +++ b/lib/Magento/Module/Dir/ReverseResolver.php @@ -25,25 +25,28 @@ */ namespace Magento\Module\Dir; +use Magento\Module\ModuleListInterface; +use Magento\Module\Dir as ModuleDir; + class ReverseResolver { /** - * @var \Magento\Module\ModuleListInterface + * @var ModuleListInterface */ protected $_moduleList; /** - * @var \Magento\Module\Dir + * @var ModuleDir */ protected $_moduleDirs; /** - * @param \Magento\Module\ModuleListInterface $moduleList - * @param \Magento\Module\Dir $moduleDirs + * @param ModuleListInterface $moduleList + * @param ModuleDir $moduleDirs */ public function __construct( - \Magento\Module\ModuleListInterface $moduleList, - \Magento\Module\Dir $moduleDirs + ModuleListInterface $moduleList, + ModuleDir $moduleDirs ) { $this->_moduleList = $moduleList; $this->_moduleDirs = $moduleDirs; diff --git a/lib/Magento/Module/FrontController/Plugin/Install.php b/lib/Magento/Module/FrontController/Plugin/Install.php index b8a30c1166f4b8a4ef38479e8c9eb06aa51c9e1d..afdee09c7d4f30d8464fe2185b362e5e7b908abe 100644 --- a/lib/Magento/Module/FrontController/Plugin/Install.php +++ b/lib/Magento/Module/FrontController/Plugin/Install.php @@ -25,6 +25,11 @@ */ namespace Magento\Module\FrontController\Plugin; +use Magento\Cache\FrontendInterface; +use Magento\Module\UpdaterInterface; +use Magento\App\State; +use Magento\Code\Plugin\InvocationChain; + class Install { /** @@ -33,24 +38,24 @@ class Install protected $_appState; /** - * @var \Magento\Cache\FrontendInterface + * @var FrontendInterface */ protected $_cache; /** - * @var \Magento\Module\UpdaterInterface + * @var UpdaterInterface */ protected $_updater; /** - * @param \Magento\App\State $appState - * @param \Magento\Cache\FrontendInterface $cache - * @param \Magento\Module\UpdaterInterface $dbUpdater + * @param State $appState + * @param FrontendInterface $cache + * @param UpdaterInterface $dbUpdater */ public function __construct( - \Magento\App\State $appState, - \Magento\Cache\FrontendInterface $cache, - \Magento\Module\UpdaterInterface $dbUpdater + State $appState, + FrontendInterface $cache, + UpdaterInterface $dbUpdater ) { $this->_appState = $appState; $this->_cache = $cache; @@ -59,10 +64,10 @@ class Install /** * @param array $arguments - * @param \Magento\Code\Plugin\InvocationChain $invocationChain + * @param InvocationChain $invocationChain * @return mixed */ - public function aroundDispatch($arguments, \Magento\Code\Plugin\InvocationChain $invocationChain) + public function aroundDispatch($arguments, InvocationChain $invocationChain) { if ($this->_appState->isInstalled() && !$this->_cache->load('data_upgrade')) { $this->_dbUpdater->updateScheme(); @@ -71,4 +76,4 @@ class Install } return $invocationChain->proceed($arguments); } -} \ No newline at end of file +} diff --git a/lib/Magento/Module/Manager.php b/lib/Magento/Module/Manager.php index 86df866d9bdb45d22410855c31280cf4cdbd21f0..2b2483fa60ae705c985c2441a615e610f7a9c415 100644 --- a/lib/Magento/Module/Manager.php +++ b/lib/Magento/Module/Manager.php @@ -30,12 +30,12 @@ namespace Magento\Module; class Manager { /** - * @var \Magento\Module\Output\ConfigInterface + * @var ConfigInterface */ private $_outputConfig; /** - * @var \Magento\Module\ModuleListInterface + * @var ModuleListInterface */ private $_moduleList; @@ -50,8 +50,8 @@ class Manager * @param array $outputConfigPaths */ public function __construct( - \Magento\Module\Output\ConfigInterface $outputConfig, - \Magento\Module\ModuleListInterface $moduleList, + Output\ConfigInterface $outputConfig, + ModuleListInterface $moduleList, array $outputConfigPaths = array() ) { $this->_outputConfig = $outputConfig; @@ -103,7 +103,7 @@ class Manager if (defined($configPath)) { $configPath = constant($configPath); } - return $this->_outputConfig->getFlag($configPath); + return $this->_outputConfig->isSetFlag($configPath); } return true; } diff --git a/lib/Magento/Module/ModuleList.php b/lib/Magento/Module/ModuleList.php index b4facdd28ed55b60982b9c17e26ba85e99db6188..95dccad5926d980ef4355622e92125e4412b3e43 100644 --- a/lib/Magento/Module/ModuleList.php +++ b/lib/Magento/Module/ModuleList.php @@ -25,6 +25,9 @@ */ namespace Magento\Module; +use Magento\Config\CacheInterface; +use Magento\Module\Declaration\Reader\Filesystem; + class ModuleList implements \Magento\Module\ModuleListInterface { /** @@ -42,13 +45,13 @@ class ModuleList implements \Magento\Module\ModuleListInterface protected $_scope = 'global'; /** - * @param \Magento\Module\Declaration\Reader\Filesystem $reader - * @param \Magento\Config\CacheInterface $cache + * @param Filesystem $reader + * @param CacheInterface $cache * @param string $cacheId */ public function __construct( - Declaration\Reader\Filesystem $reader, - \Magento\Config\CacheInterface $cache, + Filesystem $reader, + CacheInterface $cache, $cacheId = 'modules_declaration_cache' ) { $data = $cache->load($this->_scope . '::' . $cacheId); diff --git a/lib/Magento/Module/Output/ConfigInterface.php b/lib/Magento/Module/Output/ConfigInterface.php index c1958cf218ece8926473b042cb6054c53fb34976..0ed89404979086072242746f59eb1f78d6616048 100644 --- a/lib/Magento/Module/Output/ConfigInterface.php +++ b/lib/Magento/Module/Output/ConfigInterface.php @@ -40,5 +40,5 @@ interface ConfigInterface * @param string $path Fully-qualified config path * @return boolean */ - public function getFlag($path); + public function isSetFlag($path); } diff --git a/lib/Magento/Module/ResourceResolver.php b/lib/Magento/Module/ResourceResolver.php index fc8732db47c5896dd44bb59becbb090a368f8752..d3abeb69734fc94e62b055ec56d0cf6731505a33 100644 --- a/lib/Magento/Module/ResourceResolver.php +++ b/lib/Magento/Module/ResourceResolver.php @@ -25,10 +25,12 @@ */ namespace Magento\Module; +use Magento\Module\Dir\Reader; + class ResourceResolver implements \Magento\Module\ResourceResolverInterface { /** - * @var \Magento\Module\Dir\Reader + * @var Reader */ protected $_moduleReader; @@ -40,9 +42,9 @@ class ResourceResolver implements \Magento\Module\ResourceResolverInterface protected $_moduleResources = array(); /** - * @param \Magento\Module\Dir\Reader $moduleReader + * @param Reader $moduleReader */ - public function __construct(Dir\Reader $moduleReader) + public function __construct(Reader $moduleReader) { $this->_moduleReader = $moduleReader; } @@ -51,7 +53,7 @@ class ResourceResolver implements \Magento\Module\ResourceResolverInterface * Retrieve the list of resources declared by the given module * * @param string $moduleName - * @return array + * @return string[] */ public function getResourceList($moduleName) { diff --git a/lib/Magento/Module/Updater.php b/lib/Magento/Module/Updater.php index 0d80160b40487e92a51f76a4fc7995a3707639d8..401fdc41aaefcf811057e699cb4001d0dfb063f8 100644 --- a/lib/Magento/Module/Updater.php +++ b/lib/Magento/Module/Updater.php @@ -27,13 +27,16 @@ namespace Magento\Module; use Magento\App\State; +use Magento\Module\Updater\SetupFactory; +use Magento\Module\ModuleListInterface; +use Magento\Module\ResourceResolverInterface; class Updater implements \Magento\Module\UpdaterInterface { /** * Setup model factory * - * @var \Magento\Module\Updater\SetupFactory + * @var SetupFactory */ protected $_factory; @@ -66,12 +69,12 @@ class Updater implements \Magento\Module\UpdaterInterface protected $_resourceList; /** - * @var \Magento\Module\ModuleListInterface + * @var ModuleListInterface */ protected $_moduleList; /** - * @var \Magento\Module\ResourceResolverInterface + * @var ResourceResolverInterface */ protected $_resourceResolver; @@ -83,15 +86,15 @@ class Updater implements \Magento\Module\UpdaterInterface /** * @param Updater\SetupFactory $setupFactory * @param State $appState - * @param \Magento\Module\ModuleListInterface $moduleList - * @param \Magento\Module\ResourceResolverInterface $resourceResolver + * @param ModuleListInterface $moduleList + * @param ResourceResolverInterface $resourceResolver * @param bool $skipModuleUpdate */ public function __construct( - \Magento\Module\Updater\SetupFactory $setupFactory, - \Magento\App\State $appState, - \Magento\Module\ModuleListInterface $moduleList, - \Magento\Module\ResourceResolverInterface $resourceResolver, + Updater\SetupFactory $setupFactory, + State $appState, + ModuleListInterface $moduleList, + ResourceResolverInterface $resourceResolver, $skipModuleUpdate = false ) { $this->_appState = $appState; @@ -117,6 +120,8 @@ class Updater implements \Magento\Module\UpdaterInterface /** * Apply database scheme updates whenever needed + * + * @return void */ public function updateScheme() { @@ -151,6 +156,8 @@ class Updater implements \Magento\Module\UpdaterInterface /** * Apply database data updates whenever needed + * + * @return void */ public function updateData() { diff --git a/lib/Magento/Mview/ActionFactory.php b/lib/Magento/Mview/ActionFactory.php new file mode 100644 index 0000000000000000000000000000000000000000..a4c5df083d68603371d2eda541b0b634019719c7 --- /dev/null +++ b/lib/Magento/Mview/ActionFactory.php @@ -0,0 +1,58 @@ +<?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\Mview; + +class ActionFactory +{ + /** + * @var \Magento\ObjectManager + */ + protected $objectManager; + + /** + * @param \Magento\ObjectManager $objectManager + */ + public function __construct(\Magento\ObjectManager $objectManager) + { + $this->objectManager = $objectManager; + } + + /** + * Get action class instance by class name + * + * @param string $className + * @throws \InvalidArgumentException + * @return ActionInterface + */ + public function get($className) + { + $action = $this->objectManager->get($className); + if (!($action instanceof ActionInterface)) { + throw new \InvalidArgumentException($className . ' doesn\'t implement \Magento\Mview\ActionInterface'); + } + + return $action; + } +} diff --git a/lib/Magento/Mview/ActionInterface.php b/lib/Magento/Mview/ActionInterface.php new file mode 100644 index 0000000000000000000000000000000000000000..6a1a9a10aac94f5da79d1cc2ea0514b52ea988b3 --- /dev/null +++ b/lib/Magento/Mview/ActionInterface.php @@ -0,0 +1,35 @@ +<?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\Mview; + +interface ActionInterface +{ + /** + * Execute materialization on ids entities + * + * @param int[] $ids + */ + public function execute($ids); +} diff --git a/lib/Magento/Mview/Config.php b/lib/Magento/Mview/Config.php new file mode 100644 index 0000000000000000000000000000000000000000..74f56b75fd8de39a5fe0af2a330665e66bd44750 --- /dev/null +++ b/lib/Magento/Mview/Config.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\Mview; + +class Config extends \Magento\Config\Data implements ConfigInterface +{ + /** + * @param \Magento\Mview\Config\Reader $reader + * @param \Magento\Config\CacheInterface $cache + * @param string $cacheId + */ + public function __construct( + \Magento\Mview\Config\Reader $reader, + \Magento\Config\CacheInterface $cache, + $cacheId = 'mview_config' + ) { + parent::__construct($reader, $cache, $cacheId); + } + + /** + * Get views configuration + * + * @return mixed + */ + public function getAll() + { + return $this->get(); + } +} diff --git a/lib/Magento/Mview/Config/Converter.php b/lib/Magento/Mview/Config/Converter.php new file mode 100644 index 0000000000000000000000000000000000000000..fd4d4e699c208a44d3b2dc5d05c063cc8326acad --- /dev/null +++ b/lib/Magento/Mview/Config/Converter.php @@ -0,0 +1,103 @@ +<?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\Mview\Config; + +class Converter implements \Magento\Config\ConverterInterface +{ + /** + * Convert dom node tree to array + * + * @param \DOMDocument $source + * @return array + * @throws \InvalidArgumentException + */ + public function convert($source) + { + $output = array(); + $xpath = new \DOMXPath($source); + $views = $xpath->evaluate('/config/view'); + /** @var $viewNode \DOMNode */ + foreach ($views as $viewNode) { + $data = array(); + $viewId = $this->getAttributeValue($viewNode, 'id'); + $data['view_id'] = $viewId; + $data['action_class'] = $this->getAttributeValue($viewNode, 'class'); + $data['group'] = $this->getAttributeValue($viewNode, 'group'); + $data['subscriptions'] = array(); + + /** @var $childNode \DOMNode */ + foreach ($viewNode->childNodes as $childNode) { + if ($childNode->nodeType != XML_ELEMENT_NODE) { + continue; + } + + $data = $this->convertChild($childNode, $data); + } + $output[$viewId] = $data; + } + return $output; + } + + /** + * Get attribute value + * + * @param \DOMNode $input + * @param string $attributeName + * @param mixed $default + * @return null|string + */ + protected function getAttributeValue(\DOMNode $input, $attributeName, $default = null) + { + $node = $input->attributes->getNamedItem($attributeName); + return $node ? $node->nodeValue : $default; + } + + /** + * Convert child from dom to array + * + * @param \DOMNode $childNode + * @param array $data + * @return array + */ + protected function convertChild(\DOMNode $childNode, $data) + { + switch ($childNode->nodeName) { + case 'subscriptions': + /** @var $subscription \DOMNode */ + foreach ($childNode->childNodes as $subscription) { + if ($subscription->nodeType != XML_ELEMENT_NODE || $subscription->nodeName != 'table') { + continue; + } + $name = $this->getAttributeValue($subscription, 'name'); + $column = $this->getAttributeValue($subscription, 'entity_column'); + $data['subscriptions'][$name] = array( + 'name' => $name, + 'column' => $column, + ); + } + break; + } + return $data; + } +} diff --git a/lib/Magento/Mview/Config/Reader.php b/lib/Magento/Mview/Config/Reader.php new file mode 100644 index 0000000000000000000000000000000000000000..613c00583c622e2a21d093270798f1cfd38c924c --- /dev/null +++ b/lib/Magento/Mview/Config/Reader.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\Mview\Config; + +class Reader extends \Magento\Config\Reader\Filesystem +{ + /** + * List of id attributes for merge + * + * @var array + */ + protected $_idAttributes = array( + '/config/view' => 'id', + '/config/view/subscriptions/table' => 'name', + ); + + /** + * @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\Mview\Config\Converter $converter, + \Magento\Mview\Config\SchemaLocator $schemaLocator, + \Magento\Config\ValidationStateInterface $validationState, + $fileName = 'mview.xml', + $idAttributes = array(), + $domDocumentClass = 'Magento\Config\Dom', + $defaultScope = 'global' + ) { + parent::__construct( + $fileResolver, + $converter, + $schemaLocator, + $validationState, + $fileName, + $idAttributes, + $domDocumentClass, + $defaultScope + ); + } +} diff --git a/lib/Magento/Mview/Config/SchemaLocator.php b/lib/Magento/Mview/Config/SchemaLocator.php new file mode 100644 index 0000000000000000000000000000000000000000..68266b582eedc554b8b20a7755bde8e751b94946 --- /dev/null +++ b/lib/Magento/Mview/Config/SchemaLocator.php @@ -0,0 +1,72 @@ +<?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\Mview\Config; + +class SchemaLocator implements \Magento\Config\SchemaLocatorInterface +{ + /** + * Path to corresponding XSD file with validation rules for merged config + * + * @var string + */ + protected $_schema = null; + + /** + * Path to corresponding XSD file with validation rules for separate config files + * + * @var string + */ + protected $_perFileSchema = null; + + /** + * @param \Magento\Filesystem\DirectoryList $directoryList + */ + public function __construct(\Magento\Filesystem\DirectoryList $directoryList) + { + $etcDir = $directoryList->getDir(\Magento\App\Filesystem::LIB_DIR) . '/Magento/Mview/etc'; + $this->_schema = $etcDir . '/mview.xsd'; + $this->_perFileSchema = $etcDir . '/mview.xsd'; + } + + /** + * Get path to merged config schema + * + * @return string|null + */ + public function getSchema() + { + return $this->_schema; + } + + /** + * Get path to pre file validation schema + * + * @return string|null + */ + public function getPerFileSchema() + { + return $this->_perFileSchema; + } +} diff --git a/lib/Magento/Mview/ConfigInterface.php b/lib/Magento/Mview/ConfigInterface.php new file mode 100644 index 0000000000000000000000000000000000000000..9667aeffc1c6153c5481d699cab20e929ed3abf7 --- /dev/null +++ b/lib/Magento/Mview/ConfigInterface.php @@ -0,0 +1,44 @@ +<?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\Mview; + +interface ConfigInterface +{ + /** + * Get indexer's config + * + * @return array + */ + public function getAll(); + + /** + * Get config value by key + * + * @param string $path + * @param mixed $default + * @return mixed + */ + public function get($path = null, $default = null); +} diff --git a/lib/Magento/Mview/Processor.php b/lib/Magento/Mview/Processor.php new file mode 100644 index 0000000000000000000000000000000000000000..fd3f92ac4c6a87f25613338a362ffba92ce6886d --- /dev/null +++ b/lib/Magento/Mview/Processor.php @@ -0,0 +1,78 @@ +<?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\Mview; + +class Processor implements ProcessorInterface +{ + /** + * @var View\CollectionFactory + */ + protected $viewsFactory; + + /** + * @param View\CollectionFactory $viewsFactory + */ + public function __construct( + View\CollectionFactory $viewsFactory + ) { + $this->viewsFactory = $viewsFactory; + } + + /** + * Return list of views by group + * + * @param string $group + * @return ViewInterface[] + */ + protected function getViewsByGroup($group = '') + { + $collection = $this->viewsFactory->create(); + return $group ? $collection->getItemsByColumnValue('group', $group) : $collection->getItems(); + } + + /** + * Materialize all views by group (all views if empty) + * + * @param string $group + */ + public function update($group = '') + { + foreach ($this->getViewsByGroup($group) as $view) { + $view->update(); + } + } + + /** + * Clear all views' changelogs by group (all views if empty) + * + * @param string $group + */ + public function clearChangelog($group = '') + { + foreach ($this->getViewsByGroup($group) as $view) { + $view->clearChangelog(); + } + } +} diff --git a/lib/Magento/Mview/ProcessorInterface.php b/lib/Magento/Mview/ProcessorInterface.php new file mode 100644 index 0000000000000000000000000000000000000000..2abe5f760a79e0aa5f201dc7ac6e5e929d967187 --- /dev/null +++ b/lib/Magento/Mview/ProcessorInterface.php @@ -0,0 +1,42 @@ +<?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\Mview; + +interface ProcessorInterface +{ + /** + * Materialize all views by group (all views if empty) + * + * @param string $group + */ + public function update($group = ''); + + /** + * Clear all views' changelogs by group (all views if empty) + * + * @param string $group + */ + public function clearChangelog($group = ''); +} diff --git a/lib/Magento/Mview/View.php b/lib/Magento/Mview/View.php new file mode 100644 index 0000000000000000000000000000000000000000..ef4f30a19089368276a5820124d701f5283081cc --- /dev/null +++ b/lib/Magento/Mview/View.php @@ -0,0 +1,289 @@ +<?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\Mview; + +/** + * @method string getActionClass() + * @method string getGroup() + * @method array getSubscriptions() + */ +class View extends \Magento\Object implements ViewInterface +{ + /** + * @var string + */ + protected $_idFieldName = 'view_id'; + + /** + * @var ConfigInterface + */ + protected $config; + + /** + * @var ActionFactory + */ + protected $actionFactory; + + /** + * @var View\ChangelogInterface + */ + protected $changelog; + + /** + * @var View\SubscriptionFactory + */ + protected $subscriptionFactory; + + /** + * @var \Magento\Mview\View\StateInterface + */ + protected $state; + + /** + * @param ConfigInterface $config + * @param ActionFactory $actionFactory + * @param View\StateInterface $state + * @param View\ChangelogInterface $changelog + * @param View\SubscriptionFactory $subscriptionFactory + * @param array $data + */ + public function __construct( + ConfigInterface $config, + ActionFactory $actionFactory, + View\StateInterface $state, + View\ChangelogInterface $changelog, + View\SubscriptionFactory $subscriptionFactory, + array $data = array() + ) { + $this->config = $config; + $this->actionFactory = $actionFactory; + $this->state = $state; + $this->changelog = $changelog; + $this->subscriptionFactory = $subscriptionFactory; + parent::__construct($data); + } + + /** + * Fill view data from config + * + * @param string $viewId + * @return ViewInterface + * @throws \InvalidArgumentException + */ + public function load($viewId) + { + $view = $this->config->get($viewId); + if (empty($view) || empty($view['view_id']) || $view['view_id'] != $viewId) { + throw new \InvalidArgumentException("{$viewId} view does not exist."); + } + + $this->setId($viewId); + $this->setData($view); + + return $this; + } + + /** + * Create subscriptions + * + * @throws \Exception + * @return ViewInterface + */ + public function subscribe() + { + if ($this->getState()->getMode() != View\StateInterface::MODE_ENABLED) { + try { + // Create changelog table + $this->getChangelog()->create(); + + // Create subscriptions + foreach ($this->getSubscriptions() as $subscription) { + /** @var \Magento\Mview\View\SubscriptionInterface $subscription */ + $subscription = $this->subscriptionFactory->create(array( + 'view' => $this, + 'tableName' => $subscription['name'], + 'columnName' => $subscription['column'], + )); + $subscription->create(); + } + + // Update view state + $this->getState() + ->setMode(View\StateInterface::MODE_ENABLED) + ->save(); + } catch (\Exception $e) { + throw $e; + } + } + + return $this; + } + + /** + * Remove subscriptions + * + * @throws \Exception + * @return ViewInterface + */ + public function unsubscribe() + { + if ($this->getState()->getMode() != View\StateInterface::MODE_DISABLED) { + try { + // Remove subscriptions + foreach ($this->getSubscriptions() as $subscription) { + /** @var \Magento\Mview\View\SubscriptionInterface $subscription */ + $subscription = $this->subscriptionFactory->create(array( + 'view' => $this, + 'tableName' => $subscription['name'], + 'columnName' => $subscription['column'], + )); + $subscription->remove(); + } + + // Drop changelog table + $this->getChangelog()->drop(); + + // Update view state + $this->getState() + ->setMode(View\StateInterface::MODE_DISABLED) + ->save(); + } catch (\Exception $e) { + throw $e; + } + } + + return $this; + } + + /** + * Materialize view by IDs in changelog + * + * @throws \Exception + */ + public function update() + { + if ($this->getState()->getMode() == View\StateInterface::MODE_ENABLED + && $this->getState()->getStatus() != View\StateInterface::STATUS_WORKING + ) { + $currentVersionId = $this->getChangelog()->getVersion(); + $lastVersionId = $this->getState()->getVersionId(); + $ids = $this->getChangelog()->getList($lastVersionId, $currentVersionId); + if ($ids) { + $action = $this->actionFactory->get($this->getActionClass()); + $this->getState() + ->setStatus(View\StateInterface::STATUS_WORKING) + ->save(); + try { + $action->execute($ids); + $this->getState() + ->setVersionId($currentVersionId) + ->setStatus(View\StateInterface::STATUS_IDLE) + ->save(); + } catch (\Exception $exception) { + $this->getState() + ->setStatus(View\StateInterface::STATUS_IDLE) + ->save(); + throw $exception; + } + } + } + } + + /** + * Clear precessed changelog entries + */ + public function clearChangelog() + { + $this->getChangelog()->clear($this->getState()->getVersionId()); + } + + /** + * Return related state object + * + * @return View\StateInterface + */ + public function getState() + { + if (!$this->state->getViewId()) { + $this->state->loadByView($this->getId()); + } + return $this->state; + } + + /** + * Set view state object + * + * @param View\StateInterface $state + * @return ViewInterface + */ + public function setState(View\StateInterface $state) + { + $this->state = $state; + return $this; + } + + /** + * Return view mode + * + * @return string + */ + public function getMode() + { + return $this->getState()->getMode(); + } + + /** + * Return view status + * + * @return string + */ + public function getStatus() + { + return $this->getState()->getStatus(); + } + + /** + * Return view updated datetime + * + * @return string + */ + public function getUpdated() + { + return $this->getState()->getUpdated(); + } + + /** + * Retrieve linked changelog + * + * @return View\ChangelogInterface + */ + public function getChangelog() + { + if (!$this->changelog->getViewId()) { + $this->changelog->setViewId($this->getId()); + } + return $this->changelog; + } +} diff --git a/lib/Magento/Mview/View/Changelog.php b/lib/Magento/Mview/View/Changelog.php new file mode 100644 index 0000000000000000000000000000000000000000..90752202d2d197f875a826150cdbdb0441cd9516 --- /dev/null +++ b/lib/Magento/Mview/View/Changelog.php @@ -0,0 +1,222 @@ +<?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\Mview\View; + +class Changelog implements ChangelogInterface +{ + /** + * Suffix for changelog table + */ + const NAME_SUFFIX = 'cl'; + + /** + * Column name of changelog entity + */ + const COLUMN_NAME = 'entity_id'; + + /** + * Database write connection + * + * @var \Magento\DB\Adapter\AdapterInterface + */ + protected $write; + + /** + * View Id identifier + * + * @var string + */ + protected $viewId; + + /** + * @param \Magento\App\Resource $resource + */ + public function __construct(\Magento\App\Resource $resource) + { + $this->write = $resource->getConnection('core_write'); + $this->checkConnection(); + } + + /** + * Check DB connection + * + * @throws \Exception + */ + protected function checkConnection() + { + if (!$this->write) { + throw new \Exception('Write DB connection is not available'); + } + } + + /** + * Create changelog table + * + * @throws \Exception + */ + public function create() + { + $changelogTableName = $this->write->getTableName($this->getName()); + if ($this->write->isTableExists($changelogTableName)) { + throw new \Exception("Table {$changelogTableName} already exist"); + } + + $table = $this->write->newTable($changelogTableName) + ->addColumn('version_id', \Magento\DB\Ddl\Table::TYPE_INTEGER, null, array( + 'identity' => true, + 'unsigned' => true, + 'nullable' => false, + 'primary' => true, + ), 'Version ID') + ->addColumn($this->getColumnName(), \Magento\DB\Ddl\Table::TYPE_INTEGER, null, array( + 'unsigned' => true, + 'nullable' => false, + 'default' => '0', + ), 'Entity ID'); + + $this->write->createTable($table); + } + + /** + * Drop changelog table + * + * @throws \Exception + */ + public function drop() + { + $changelogTableName = $this->write->getTableName($this->getName()); + if (!$this->write->isTableExists($changelogTableName)) { + throw new \Exception("Table {$changelogTableName} does not exist"); + } + + $this->write->dropTable($changelogTableName); + } + + /** + * Clear changelog table by version_id + * + * @param integer $versionId + * @return boolean + * @throws \Exception + */ + public function clear($versionId) + { + $changelogTableName = $this->write->getTableName($this->getName()); + if (!$this->write->isTableExists($changelogTableName)) { + throw new \Exception("Table {$changelogTableName} does not exist"); + } + + $this->write->delete($changelogTableName, array('version_id <= ?' => (int)$versionId)); + + return true; + } + + /** + * Retrieve entity ids by range [$fromVersionId..$toVersionId] + * + * @param int $fromVersionId + * @param int $toVersionId + * @return int[] + * @throws \Exception + */ + public function getList($fromVersionId, $toVersionId) + { + $changelogTableName = $this->write->getTableName($this->getName()); + if (!$this->write->isTableExists($changelogTableName)) { + throw new \Exception("Table {$changelogTableName} does not exist"); + } + + $select = $this->write->select() + ->distinct(true) + ->from($changelogTableName, array($this->getColumnName())) + ->where('version_id > ?', (int)$fromVersionId) + ->where('version_id <= ?', (int)$toVersionId); + + return $this->write->fetchCol($select); + } + + /** + * Get maximum version_id from changelog + * + * @return int + * @throws \Exception + */ + public function getVersion() + { + $changelogTableName = $this->write->getTableName($this->getName()); + if (!$this->write->isTableExists($changelogTableName)) { + throw new \Exception("Table {$changelogTableName} does not exist"); + } + + $select = $this->write->select() + ->from($changelogTableName, new \Zend_Db_Expr('MAX(`version_id`)')); + + return (int)$this->write->fetchOne($select); + } + + /** + * Get changlog name + * + * Build a changelog name by concatenating view identifier and changelog name suffix. + * + * @throws \Exception + * @return string + */ + public function getName() + { + if (strlen($this->viewId) == 0) { + throw new \Exception("View's identifier is not set"); + } + return $this->viewId . '_' . self::NAME_SUFFIX; + } + + /** + * Get changlog entity column name + * + * @return string + */ + public function getColumnName() + { + return self::COLUMN_NAME; + } + + /** + * Set view's identifier + * + * @param string $viewId + */ + public function setViewId($viewId) + { + $this->viewId = $viewId; + } + + /** + * @return string + */ + public function getViewId() + { + return $this->viewId; + } +} diff --git a/lib/Magento/Mview/View/ChangelogInterface.php b/lib/Magento/Mview/View/ChangelogInterface.php new file mode 100644 index 0000000000000000000000000000000000000000..11c803e574d416443f866e3da6e9949a71bd55f8 --- /dev/null +++ b/lib/Magento/Mview/View/ChangelogInterface.php @@ -0,0 +1,94 @@ +<?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\Mview\View; + +interface ChangelogInterface +{ + /** + * Create changelog table + * + * @return boolean + */ + public function create(); + + /** + * Drop changelog table + * + * @return boolean + */ + public function drop(); + + /** + * Clear changelog by version_id + * + * @param $versionId + * @return boolean + */ + public function clear($versionId); + + /** + * Retrieve entity ids by range [$fromVersionId..$toVersionId] + * + * @param integer $fromVersionId + * @param integer $toVersionId + * @return int[] + */ + public function getList($fromVersionId, $toVersionId); + + /** + * Get maximum version_id from changelog + * + * @return int + */ + public function getVersion(); + + /** + * Get changlog name + * + * @return string + */ + public function getName(); + + /** + * Get changlog entity column name + * + * @return string + */ + public function getColumnName(); + + /** + * Set view's identifier + * + * @param string $viewId + */ + public function setViewId($viewId); + + /** + * Get view's identifier + * + * @return string + */ + public function getViewId(); +} diff --git a/lib/Magento/Mview/View/Collection.php b/lib/Magento/Mview/View/Collection.php new file mode 100644 index 0000000000000000000000000000000000000000..d3ccd8b7b1089e6667e8f039a8b75cab358a8d0d --- /dev/null +++ b/lib/Magento/Mview/View/Collection.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\Mview\View; + +class Collection extends \Magento\Data\Collection implements CollectionInterface +{ + /** + * Item object class name + * + * @var string + */ + protected $_itemObjectClass = 'Magento\Mview\ViewInterface'; + + /** + * @var \Magento\Indexer\Model\ConfigInterface + */ + protected $config; + + /** + * @var \Magento\Mview\View\State\CollectionFactory + */ + protected $statesFactory; + + /** + * @param \Magento\Data\Collection\EntityFactoryInterface $entityFactory + * @param \Magento\Mview\ConfigInterface $config + * @param State\CollectionFactory $statesFactory + */ + public function __construct( + \Magento\Data\Collection\EntityFactoryInterface $entityFactory, + \Magento\Mview\ConfigInterface $config, + \Magento\Mview\View\State\CollectionFactory $statesFactory + ) { + $this->config = $config; + $this->statesFactory = $statesFactory; + parent::__construct($entityFactory); + } + + /** + * Load data + * + * @param bool $printQuery + * @param bool $logQuery + * @return \Magento\Mview\View\CollectionInterface + * + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + */ + public function loadData($printQuery = false, $logQuery = false) + { + if (!$this->isLoaded()) { + $states = $this->statesFactory->create(); + foreach (array_keys($this->config->getAll()) as $viewId) { + /** @var \Magento\Mview\ViewInterface $view */ + $view = $this->getNewEmptyItem(); + $view->load($viewId); + foreach ($states->getItems() as $state) { + /** @var \Magento\Mview\View\StateInterface $state */ + if ($state->getViewId() == $viewId) { + $view->setState($state); + break; + } + } + $this->_addItem($view); + } + $this->_setIsLoaded(true); + } + return $this; + } + + /** + * Return views by given state mode + * + * @param string $mode + * @return \Magento\Mview\ViewInterface[] + */ + public function getViewsByStateMode($mode) + { + $this->load(); + + $result = array(); + foreach ($this as $view) { + /** @var \Magento\Mview\ViewInterface $view */ + if ($view->getState()->getMode() == $mode) { + $result[] = $view; + } + } + return $result; + } + + /** + * Return views by given state status + * + * @param string $status + * @return \Magento\Mview\ViewInterface[] + */ + public function getViewsByStateStatus($status) + { + $this->load(); + + $result = array(); + foreach ($this as $view) { + /** @var \Magento\Mview\ViewInterface $view */ + if ($view->getState()->getStatus() == $status) { + $result[] = $view; + } + } + return $result; + } +} diff --git a/lib/Magento/Mview/View/CollectionFactory.php b/lib/Magento/Mview/View/CollectionFactory.php new file mode 100644 index 0000000000000000000000000000000000000000..1f3c3faed3083dce7f61ee27e8a5f933deadf078 --- /dev/null +++ b/lib/Magento/Mview/View/CollectionFactory.php @@ -0,0 +1,52 @@ +<?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\Mview\View; + +class CollectionFactory +{ + /** + * @var \Magento\ObjectManager + */ + protected $objectManager; + + /** + * @param \Magento\ObjectManager $objectManager + */ + public function __construct(\Magento\ObjectManager $objectManager) + { + $this->objectManager = $objectManager; + } + + /** + * Create class instance with specified parameters + * + * @param array $data + * @return CollectionInterface + */ + public function create(array $data = array()) + { + return $this->objectManager->create('Magento\Mview\View\CollectionInterface', $data); + } +} diff --git a/lib/Magento/Mview/View/CollectionInterface.php b/lib/Magento/Mview/View/CollectionInterface.php new file mode 100644 index 0000000000000000000000000000000000000000..4193f94a451075905d7b051ec831c2daef76ddf8 --- /dev/null +++ b/lib/Magento/Mview/View/CollectionInterface.php @@ -0,0 +1,60 @@ +<?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\Mview\View; + +interface CollectionInterface +{ + /** + * Return views by given state mode + * + * @param string $mode + * @return \Magento\Mview\ViewInterface[] + */ + public function getViewsByStateMode($mode); + + /** + * Return views by given state status + * + * @param string $status + * @return \Magento\Mview\ViewInterface[] + */ + public function getViewsByStateStatus($status); + + /** + * Search all views by field value + * + * @param string $column + * @param mixed $value + * @return \Magento\Mview\ViewInterface[] + */ + public function getItemsByColumnValue($column, $value); + + /** + * Retrieve collection views + * + * @return \Magento\Mview\ViewInterface[] + */ + public function getItems(); +} diff --git a/lib/Magento/Mview/View/State/CollectionFactory.php b/lib/Magento/Mview/View/State/CollectionFactory.php new file mode 100644 index 0000000000000000000000000000000000000000..bf55fc39c98f76fc3a522986bb369b67541a88e8 --- /dev/null +++ b/lib/Magento/Mview/View/State/CollectionFactory.php @@ -0,0 +1,52 @@ +<?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\Mview\View\State; + +class CollectionFactory +{ + /** + * @var \Magento\ObjectManager + */ + protected $objectManager; + + /** + * @param \Magento\ObjectManager $objectManager + */ + public function __construct(\Magento\ObjectManager $objectManager) + { + $this->objectManager = $objectManager; + } + + /** + * Create class instance with specified parameters + * + * @param array $data + * @return CollectionInterface + */ + public function create(array $data = array()) + { + return $this->objectManager->create('Magento\Mview\View\State\CollectionInterface', $data); + } +} diff --git a/lib/Magento/Mview/View/State/CollectionInterface.php b/lib/Magento/Mview/View/State/CollectionInterface.php new file mode 100644 index 0000000000000000000000000000000000000000..d8b08c767a9c09d7a0a2bdb769096994354da7db --- /dev/null +++ b/lib/Magento/Mview/View/State/CollectionInterface.php @@ -0,0 +1,35 @@ +<?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\Mview\View\State; + +interface CollectionInterface +{ + /** + * Retrieve loaded states + * + * @return array + */ + public function getItems(); +} diff --git a/lib/Magento/Mview/View/StateInterface.php b/lib/Magento/Mview/View/StateInterface.php new file mode 100644 index 0000000000000000000000000000000000000000..90ac1d146df3cf3b4d44119a26d584f92cc51aaf --- /dev/null +++ b/lib/Magento/Mview/View/StateInterface.php @@ -0,0 +1,133 @@ +<?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\Mview\View; + +interface StateInterface +{ + /**#@+ + * View modes + */ + const MODE_ENABLED = 'enabled'; + const MODE_DISABLED = 'disabled'; + /**#@-*/ + + /**#@+ + * View statuses + */ + const STATUS_IDLE = 'idle'; + const STATUS_WORKING = 'working'; + /**#@-*/ + + /** + * Fill object with state data by view ID + * + * @param string $viewId + * @return \Magento\Mview\View\StateInterface + */ + public function loadByView($viewId); + + /** + * Save state object + * + * @return \Magento\Mview\View\StateInterface + * @throws \Exception + */ + public function save(); + + /** + * Delete state object + * + * @return \Magento\Mview\View\StateInterface + * @throws \Exception + */ + public function delete(); + + /** + * Get state view ID + * + * @return string + */ + public function getViewId(); + + /** + * Get state mode + * + * @return string + */ + public function getMode(); + + /** + * Set state mode + * + * @param string $mode + * @return \Magento\Mview\View\StateInterface + */ + public function setMode($mode); + + /** + * Get state status + * + * @return string + */ + public function getStatus(); + + /** + * Set state status + * + * @param string $status + * @return \Magento\Mview\View\StateInterface + */ + public function setStatus($status); + + /** + * Get state version ID + * + * @return string + */ + public function getVersionId(); + + /** + * Set state version ID + * + * @param int $versionId + * @return \Magento\Mview\View\StateInterface + */ + public function setVersionId($versionId); + + /** + * Get state updated time + * + * @return string + */ + public function getUpdated(); + + /** + * Set state updated time + * + * @param string|int|\Zend_Date $updated + * @return \Magento\Mview\View\StateInterface + */ + public function setUpdated($updated); +} diff --git a/lib/Magento/Mview/View/Subscription.php b/lib/Magento/Mview/View/Subscription.php new file mode 100644 index 0000000000000000000000000000000000000000..b0d5ec9e3a8d7dd5b668df0d66b4f7163755f492 --- /dev/null +++ b/lib/Magento/Mview/View/Subscription.php @@ -0,0 +1,286 @@ +<?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\Mview\View; + +class Subscription implements SubscriptionInterface +{ + /** + * Trigger name qualifier + */ + const TRIGGER_NAME_QUALIFIER = 'trg'; + + /** + * Database write connection + * + * @var \Magento\DB\Adapter\AdapterInterface + */ + protected $write; + + /** + * @var \Magento\DB\Ddl\Trigger + */ + protected $triggerFactory; + + /** + * @var \Magento\Mview\View\CollectionInterface + */ + protected $viewCollection; + + /** + * @var string + */ + protected $view; + + /** + * @var string + */ + protected $tableName; + + /** + * @var string + */ + protected $columnName; + + /** + * List of views linked to the same entity as the current view + * + * @var array + */ + protected $linkedViews = array(); + + /** + * @param \Magento\App\Resource $resource + * @param \Magento\DB\Ddl\TriggerFactory $triggerFactory + * @param \Magento\Mview\View\CollectionInterface $viewCollection + * @param \Magento\Mview\ViewInterface $view + * @param string $tableName + * @param string $columnName + */ + public function __construct( + \Magento\App\Resource $resource, + \Magento\DB\Ddl\TriggerFactory $triggerFactory, + \Magento\Mview\View\CollectionInterface $viewCollection, + $view, + $tableName, + $columnName + ) { + $this->write = $resource->getConnection('core_write'); + $this->triggerFactory = $triggerFactory; + $this->viewCollection = $viewCollection; + $this->view = $view; + $this->tableName = $tableName; + $this->columnName = $columnName; + + // Force collection clear + $this->viewCollection->clear(); + } + + /** + * Create subsciption + * + * @return \Magento\Mview\View\SubscriptionInterface + */ + public function create() + { + foreach (\Magento\DB\Ddl\Trigger::getListOfEvents() as $event) { + $triggerName = $this->getTriggerName( + $this->getTableName(), + \Magento\DB\Ddl\Trigger::TIME_AFTER, + $event + ); + + /** @var \Magento\DB\Ddl\Trigger $trigger */ + $trigger = $this->triggerFactory->create() + ->setName($triggerName) + ->setTime(\Magento\DB\Ddl\Trigger::TIME_AFTER) + ->setEvent($event) + ->setTable($this->getTableName()); + + $trigger->addStatement( + $this->buildStatement($event, $this->getView()->getChangelog()) + ); + + // Add statements for linked views + foreach ($this->getLinkedViews() as $view) { + /** @var \Magento\Mview\ViewInterface $view */ + $trigger->addStatement( + $this->buildStatement($event, $view->getChangelog()) + ); + } + + $this->write->dropTrigger($trigger->getName()); + $this->write->createTrigger($trigger); + } + + return $this; + } + + /** + * Remove subscription + * + * @return \Magento\Mview\View\SubscriptionInterface + */ + public function remove() + { + foreach (\Magento\DB\Ddl\Trigger::getListOfEvents() as $event) { + $triggerName = $this->getTriggerName( + $this->getTableName(), + \Magento\DB\Ddl\Trigger::TIME_AFTER, + $event + ); + + /** @var \Magento\DB\Ddl\Trigger $trigger */ + $trigger = $this->triggerFactory->create() + ->setName($triggerName) + ->setTime(\Magento\DB\Ddl\Trigger::TIME_AFTER) + ->setEvent($event) + ->setTable($this->getTableName()); + + // Add statements for linked views + foreach ($this->getLinkedViews() as $view) { + /** @var \Magento\Mview\ViewInterface $view */ + $trigger->addStatement( + $this->buildStatement($event, $view->getChangelog()) + ); + } + + $this->write->dropTrigger($trigger->getName()); + + // Re-create trigger if trigger used by linked views + if ($trigger->getStatements()) { + $this->write->createTrigger($trigger); + } + } + + return $this; + } + + /** + * Retrieve list of linked views + * + * @return array + */ + protected function getLinkedViews() + { + if (!$this->linkedViews) { + $viewList = $this->viewCollection + ->getViewsByStateMode(\Magento\Mview\View\StateInterface::MODE_ENABLED); + + foreach ($viewList as $view) { + /** @var \Magento\Mview\ViewInterface $view */ + // Skip the current view + if ($view->getId() == $this->getView()->getId()) { + continue; + } + // Search in view subscriptions + foreach ($view->getSubscriptions() as $subscription) { + if ($subscription['name'] != $this->getTableName()) { + continue; + } + $this->linkedViews[] = $view; + } + } + } + return $this->linkedViews; + } + + /** + * Build trigger statement for INSER, UPDATE, DELETE events + * + * @param string $event + * @param \Magento\Mview\View\ChangelogInterface $changelog + * @return string + */ + protected function buildStatement($event, $changelog) + { + switch ($event) { + case \Magento\DB\Ddl\Trigger::EVENT_INSERT: + case \Magento\DB\Ddl\Trigger::EVENT_UPDATE: + return sprintf("INSERT IGNORE INTO %s (%s) VALUES (NEW.%s);", + $this->write->quoteIdentifier($changelog->getName()), + $this->write->quoteIdentifier($changelog->getColumnName()), + $this->write->quoteIdentifier($this->getColumnName()) + ); + + case \Magento\DB\Ddl\Trigger::EVENT_DELETE: + return sprintf("INSERT IGNORE INTO %s (%s) VALUES (OLD.%s);", + $this->write->quoteIdentifier($changelog->getName()), + $this->write->quoteIdentifier($changelog->getColumnName()), + $this->write->quoteIdentifier($this->getColumnName()) + ); + + default: + return ''; + } + } + + /** + * Retrieve trigger name + * + * Build a trigger name by concatenating trigger name prefix, table name, + * trigger time and trigger event. + * + * @param string $tableName + * @param string $time + * @param string $event + * @return string + */ + protected function getTriggerName($tableName, $time, $event) + { + return self::TRIGGER_NAME_QUALIFIER . '_' . $tableName + . '_' . $time + . '_' . $event; + } + + /** + * Retrieve View related to subscription + * + * @return \Magento\Mview\ViewInterface + */ + public function getView() + { + return $this->view; + } + + /** + * Retrieve table name + * + * @return string + */ + public function getTableName() + { + return $this->tableName; + } + + /** + * Retrieve table column name + * + * @return string + */ + public function getColumnName() + { + return $this->columnName; + } +} diff --git a/lib/Magento/Mview/View/SubscriptionFactory.php b/lib/Magento/Mview/View/SubscriptionFactory.php new file mode 100644 index 0000000000000000000000000000000000000000..ac870d93c20d38ae6111dbb5c2895f65196aa6e6 --- /dev/null +++ b/lib/Magento/Mview/View/SubscriptionFactory.php @@ -0,0 +1,52 @@ +<?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\Mview\View; + +class SubscriptionFactory +{ + /** + * @var \Magento\ObjectManager + */ + protected $objectManager; + + /** + * @param \Magento\ObjectManager $objectManager + */ + public function __construct(\Magento\ObjectManager $objectManager) + { + $this->objectManager = $objectManager; + } + + /** + * Create class instance with specified parameters + * + * @param array $data + * @return StateInterface + */ + public function create(array $data = array()) + { + return $this->objectManager->create('Magento\Mview\View\SubscriptionInterface', $data); + } +} diff --git a/lib/Magento/Mview/View/SubscriptionInterface.php b/lib/Magento/Mview/View/SubscriptionInterface.php new file mode 100644 index 0000000000000000000000000000000000000000..ab56056d2e3da4ff9cd703b75ac2aa9034b4c98c --- /dev/null +++ b/lib/Magento/Mview/View/SubscriptionInterface.php @@ -0,0 +1,63 @@ +<?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\Mview\View; + +interface SubscriptionInterface +{ + /** + * Create subsciption + * + * @return \Magento\Mview\View\SubscriptionInterface + */ + public function create(); + + /** + * Remove subscription + * + * @return \Magento\Mview\View\SubscriptionInterface + */ + public function remove(); + + /** + * Retrieve View related to subscription + * + * @return \Magento\Mview\ViewInterface + */ + public function getView(); + + /** + * Retrieve table name + * + * @return string + */ + public function getTableName(); + + /** + * Retrieve table column name + * + * @return string + */ + public function getColumnName(); +} diff --git a/lib/Magento/Mview/ViewInterface.php b/lib/Magento/Mview/ViewInterface.php new file mode 100644 index 0000000000000000000000000000000000000000..847da63dc9530540bf3874c8377ea1179d0389d4 --- /dev/null +++ b/lib/Magento/Mview/ViewInterface.php @@ -0,0 +1,99 @@ +<?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\Mview; + +interface ViewInterface +{ + /** + * Fill view data from config + * + * @param string $viewId + * @return ViewInterface + * @throws \InvalidArgumentException + */ + public function load($viewId); + + /** + * Create subscriptions + * + * @throws \Exception + * @return ViewInterface + */ + public function subscribe(); + + /** + * Remove subscriptions + * + * @throws \Exception + * @return ViewInterface + */ + public function unsubscribe(); + + /** + * @return mixed + */ + public function update(); + + /** + * Clear precessed changelog entries + */ + public function clearChangelog(); + + /** + * Return related state object + * + * @return View\StateInterface + */ + public function getState(); + + /** + * Set view state object + * + * @param View\StateInterface $state + * @return ViewInterface + */ + public function setState(View\StateInterface $state); + + /** + * Return view mode + * + * @return string + */ + public function getMode(); + + /** + * Return view status + * + * @return string + */ + public function getStatus(); + + /** + * Retrieve linked changelog + * + * @return View\ChangelogInterface + */ + public function getChangelog(); +} diff --git a/lib/Magento/Mview/etc/mview.xsd b/lib/Magento/Mview/etc/mview.xsd new file mode 100644 index 0000000000000000000000000000000000000000..c8b87a8f260343aaa93260a7b8dcdc8b0efe19e6 --- /dev/null +++ b/lib/Magento/Mview/etc/mview.xsd @@ -0,0 +1,122 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- +/** + * 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) + */ +--> +<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> + <xs:element name="config"> + <xs:complexType> + <xs:sequence> + <xs:element name="view" type="viewType" minOccurs="1" maxOccurs="unbounded" /> + </xs:sequence> + </xs:complexType> + <xs:unique name="uniqueViewId"> + <xs:annotation> + <xs:documentation> + View Id must be unique. + </xs:documentation> + </xs:annotation> + <xs:selector xpath="view" /> + <xs:field xpath="@id" /> + </xs:unique> + </xs:element> + + <xs:complexType name="viewType"> + <xs:annotation> + <xs:documentation> + View declaration. + </xs:documentation> + </xs:annotation> + <xs:sequence> + <xs:element name="subscriptions" type="subscriptionsType"> + <xs:unique name="uniqueSubscriptionsTable"> + <xs:annotation> + <xs:documentation> + Table must be unique. + </xs:documentation> + </xs:annotation> + <xs:selector xpath=".//table" /> + <xs:field xpath="@name" /> + <xs:field xpath="@entity_column" /> + </xs:unique> + </xs:element> + </xs:sequence> + <xs:attribute name="id" type="xs:string" use="required" /> + <xs:attribute name="class" type="classType" use="required" /> + <xs:attribute name="group" type="xs:string" use="required" /> + </xs:complexType> + + <xs:simpleType name="classType"> + <xs:annotation> + <xs:documentation> + Class name can contain only [a-zA-Z\]. + </xs:documentation> + </xs:annotation> + <xs:restriction base="xs:string"> + <xs:pattern value="[a-zA-Z\\]+" /> + </xs:restriction> + </xs:simpleType> + + <xs:complexType name="subscriptionsType"> + <xs:annotation> + <xs:documentation> + Subscriptions declaration. + </xs:documentation> + </xs:annotation> + <xs:sequence> + <xs:element name="table" type="subscriptionsTableType" minOccurs="1" maxOccurs="unbounded" /> + </xs:sequence> + </xs:complexType> + + <xs:complexType name="subscriptionsTableType"> + <xs:annotation> + <xs:documentation> + Table declaration. + </xs:documentation> + </xs:annotation> + <xs:attribute name="name" type="tableNameType" use="required" /> + <xs:attribute name="entity_column" type="entityColumnType" use="required" /> + </xs:complexType> + + <xs:simpleType name="entityColumnType"> + <xs:annotation> + <xs:documentation> + Entity column can contain only [a-z_]. + </xs:documentation> + </xs:annotation> + <xs:restriction base="xs:string"> + <xs:pattern value="[a-z_]+" /> + </xs:restriction> + </xs:simpleType> + + <xs:simpleType name="tableNameType"> + <xs:annotation> + <xs:documentation> + Table name can contain only [a-z_]. + </xs:documentation> + </xs:annotation> + <xs:restriction base="xs:string"> + <xs:pattern value="[a-z_]+" /> + </xs:restriction> + </xs:simpleType> +</xs:schema> diff --git a/lib/Magento/Oauth/Helper/Request.php b/lib/Magento/Oauth/Helper/Request.php index 86bb41f6749a7713a4ccd27c11c03f9ee80816bd..9a311445ba12103604f7c1eccdc9093e6f67d7f6 100644 --- a/lib/Magento/Oauth/Helper/Request.php +++ b/lib/Magento/Oauth/Helper/Request.php @@ -91,20 +91,17 @@ class Request * Process HTTP request object and prepare for token validation * * @param \Zend_Controller_Request_Http $httpRequest - * @param string $requestUrl The request Url - * @param array $bodyParams array of key value body parameters * @return array */ - public function prepareRequest($httpRequest, $requestUrl, $bodyParams = array()) + public function prepareRequest($httpRequest) { - $oauthParams = $this->_processRequest($httpRequest->getHeader('Authorization'), + $oauthParams = $this->_processRequest( + $httpRequest->getHeader('Authorization'), $httpRequest->getHeader(\Zend_Http_Client::CONTENT_TYPE), $httpRequest->getRawBody(), - $requestUrl); - // Use body parameters only for POST and PUT - $bodyParams = is_array($bodyParams) && ($httpRequest->getMethod() == 'POST' || - $httpRequest->getMethod() == 'PUT') ? $bodyParams : array(); - return array_merge($oauthParams, $bodyParams); + $this->getRequestUrl($httpRequest) + ); + return $oauthParams; } /** @@ -123,10 +120,10 @@ class Request /** * Process oauth related protocol information and return as an array * - * @param $authHeaderValue - * @param $contentTypeHeader - * @param $requestBodyString - * @param $requestUrl + * @param string $authHeaderValue + * @param string $contentTypeHeader + * @param string $requestBodyString + * @param string $requestUrl * @return array * merged array of oauth protocols and request parameters. eg : * <pre> @@ -175,8 +172,9 @@ class Request /** * Retrieve protocol parameters from query string * - * @param $protocolParams - * @param $queryString + * @param array $protocolParams + * @param array $queryString + * @return void */ protected function _fetchProtocolParamsFromQuery(&$protocolParams, $queryString) { @@ -201,8 +199,9 @@ class Request /** * Process header parameters for Oauth * - * @param $authHeaderValue - * @param $protocolParams + * @param string $authHeaderValue + * @param array $protocolParams + * @return void */ protected function _processHeader($authHeaderValue, &$protocolParams) { @@ -225,8 +224,9 @@ class Request /** * Process query string for Oauth * - * @param $protocolParams - * @param $queryString + * @param array $protocolParams + * @param string $queryString + * @return void */ protected function _extractQueryStringParams(&$protocolParams, $queryString) { @@ -246,7 +246,7 @@ class Request * * @param \Exception $exception * @param \Zend_Controller_Response_Http $response OPTIONAL If NULL - will use internal getter - * @return string + * @return array */ public function prepareErrorResponse( \Exception $exception, diff --git a/lib/Magento/Oauth/Oauth.php b/lib/Magento/Oauth/Oauth.php index 57982e750e750bacb24d6e822216a33377596338..900e9a61373056f02b08780b088f4fc6d9a76b14 100644 --- a/lib/Magento/Oauth/Oauth.php +++ b/lib/Magento/Oauth/Oauth.php @@ -59,7 +59,7 @@ class Oauth implements OauthInterface /** * Retrieve array of supported signature methods. * - * @return array - Supported HMAC-SHA1 and HMAC-SHA256 signature methods. + * @return string[] - Supported HMAC-SHA1 and HMAC-SHA256 signature methods. */ public static function getSupportedSignatureMethods() { @@ -196,7 +196,8 @@ class Oauth implements OauthInterface * @param string $httpMethod * @param string $requestUrl * @param string $tokenSecret - * @throws \Magento\Oauth\Exception + * @return void + * @throws Exception */ protected function _validateSignature($params, $consumerSecret, $httpMethod, $requestUrl, $tokenSecret = null) { @@ -228,7 +229,8 @@ class Oauth implements OauthInterface * Validate oauth version. * * @param string $version - * @throws \Magento\Oauth\Exception + * @return void + * @throws Exception */ protected function _validateVersionParam($version) { @@ -243,7 +245,8 @@ class Oauth implements OauthInterface * * @param array $protocolParams * @param array $requiredParams - * @throws \Magento\Oauth\Exception + * @return void + * @throws Exception */ protected function _validateProtocolParams($protocolParams, $requiredParams) { @@ -289,7 +292,8 @@ class Oauth implements OauthInterface * * @param array $protocolParams * @param array $requiredParams - * @throws \Magento\Oauth\Exception + * @return void + * @throws Exception */ protected function _checkRequiredParams($protocolParams, $requiredParams) { diff --git a/lib/Magento/Object.php b/lib/Magento/Object.php index 9487a97087956ae19fb4a06a5d48c81d7a290d4f..27daf11f41b630bb4ea34fe3ab771c893141f945 100644 --- a/lib/Magento/Object.php +++ b/lib/Magento/Object.php @@ -123,7 +123,7 @@ class Object implements \ArrayAccess * Id field name setter * * @param string $name - * @return \Magento\Object + * @return $this */ public function setIdFieldName($name) { @@ -154,8 +154,8 @@ class Object implements \ArrayAccess /** * Identifier setter * - * @param mixed $value - * @return \Magento\Object + * @param mixed $value + * @return $this */ public function setId($value) { @@ -169,7 +169,7 @@ class Object implements \ArrayAccess * Retains previous data in the object. * * @param array $arr - * @return \Magento\Object + * @return $this */ public function addData(array $arr) { @@ -189,7 +189,7 @@ class Object implements \ArrayAccess * * @param string|array $key * @param mixed $value - * @return \Magento\Object + * @return $this */ public function setData($key, $value = null) { @@ -211,7 +211,7 @@ class Object implements \ArrayAccess * Unset data from the object. * * @param null|string|array $key - * @return \Magento\Object + * @return $this */ public function unsetData($key = null) { @@ -325,7 +325,7 @@ class Object implements \ArrayAccess * * @param string $key * @param mixed $args - * @return \Magento\Object + * @return $this */ public function setDataUsingMethod($key, $args = array()) { @@ -510,6 +510,7 @@ class Object implements \ArrayAccess * @param string $method * @param array $args * @return mixed + * @throws \Magento\Exception */ public function __call($method, $args) { @@ -600,7 +601,7 @@ class Object implements \ArrayAccess * * @param string $key * @param mixed $data - * @return \Magento\Object + * @return $this */ public function setOrigData($key = null, $data = null) { @@ -643,7 +644,7 @@ class Object implements \ArrayAccess * Clears data changes status * * @param boolean $value - * @return \Magento\Object + * @return $this */ public function setDataChanges($value) { @@ -687,6 +688,7 @@ class Object implements \ArrayAccess * @link http://www.php.net/manual/en/arrayaccess.offsetset.php * @param string $offset * @param mixed $value + * @return void */ public function offsetSet($offset, $value) { @@ -710,6 +712,7 @@ class Object implements \ArrayAccess * * @link http://www.php.net/manual/en/arrayaccess.offsetunset.php * @param string $offset + * @return void */ public function offsetUnset($offset) { diff --git a/lib/Magento/Object/Cache.php b/lib/Magento/Object/Cache.php index 755695fae4e188d36c93ab02a703fc44866e4897..67066df1d034a1fda19438c4bc8aab97ae5aadc4 100644 --- a/lib/Magento/Object/Cache.php +++ b/lib/Magento/Object/Cache.php @@ -265,6 +265,7 @@ class Cache * Cleanup by class name for objects of subclasses too * * @param string $class + * @return void */ public function deleteByClass($class) { @@ -279,6 +280,7 @@ class Cache * Cleanup objects by tags * * @param array|string $tags + * @return true */ public function deleteByTags($tags) { @@ -320,6 +322,12 @@ class Cache return false; } + /** + * Find objects by ids + * + * @param string[] $ids + * @return array + */ public function findByIds($ids) { $objects = array(); @@ -331,6 +339,12 @@ class Cache return $objects; } + /** + * Find object by hash + * + * @param string $hash + * @return object + */ public function findByHash($hash) { return isset($this->_hashes[$hash]) ? $this->_objects[$this->_hashes[$hash]] : null; @@ -363,6 +377,7 @@ class Cache * Find by class name for objects of subclasses too * * @param string $class + * @return array */ public function findByClass($class) { @@ -375,6 +390,13 @@ class Cache return $objects; } + /** + * Debug + * + * @param string $idx + * @param object|null $object + * @return void + */ public function debug($idx, $object=null) { $bt = debug_backtrace(); @@ -392,7 +414,7 @@ class Cache /** * Return debug information by ids * - * @param array|integer $ids + * @param array|string $ids * @return array */ public function debugByIds($ids) diff --git a/lib/Magento/ObjectManager/Config.php b/lib/Magento/ObjectManager/Config.php index 93f8d67f315cad8dce0cfc3b0d041c3937c1dffa..ed7fe64a9080783bd64931a8f68d0b199c8172a2 100644 --- a/lib/Magento/ObjectManager/Config.php +++ b/lib/Magento/ObjectManager/Config.php @@ -28,14 +28,14 @@ interface Config /** * Set class relations * - * @param \Magento\ObjectManager\Relations $relations + * @param Relations $relations */ public function setRelations(Relations $relations); /** * Set configuration cache instance * - * @param \Magento\ObjectManager\ConfigCache $cache + * @param ConfigCache $cache */ public function setCache(ConfigCache $cache); diff --git a/lib/Magento/ObjectManager/Config/Config.php b/lib/Magento/ObjectManager/Config/Config.php index f282d3557f7319e21e1ed165039b28b96436e7fd..58001c0be9f441796ddd8482089a50780c5abaf7 100644 --- a/lib/Magento/ObjectManager/Config/Config.php +++ b/lib/Magento/ObjectManager/Config/Config.php @@ -23,12 +23,16 @@ */ namespace Magento\ObjectManager\Config; +use \Magento\ObjectManager\ConfigCache; +use \Magento\ObjectManager\Definition; +use \Magento\ObjectManager\Relations; + class Config implements \Magento\ObjectManager\Config { /** * Config cache * - * @var \Magento\ObjectManager\ConfigCache + * @var ConfigCache */ protected $_cache; @@ -91,7 +95,7 @@ class Config implements \Magento\ObjectManager\Config /** * List of relations * - * @var \Magento\ObjectManager\Relations + * @var Relations */ protected $_relations; @@ -103,12 +107,12 @@ class Config implements \Magento\ObjectManager\Config protected $_mergedArguments; /** - * @param \Magento\ObjectManager\Relations $relations - * @param \Magento\ObjectManager\Definition $definitions + * @param Relations $relations + * @param Definition $definitions */ public function __construct( - \Magento\ObjectManager\Relations $relations = null, - \Magento\ObjectManager\Definition $definitions = null + Relations $relations = null, + Definition $definitions = null ) { $this->_relations = $relations ?: new \Magento\ObjectManager\Relations\Runtime(); $this->_definitions = $definitions ?: new \Magento\ObjectManager\Definition\Runtime(); @@ -117,9 +121,10 @@ class Config implements \Magento\ObjectManager\Config /** * Set class relations * - * @param \Magento\ObjectManager\Relations $relations + * @param Relations $relations + * @return void */ - public function setRelations(\Magento\ObjectManager\Relations $relations) + public function setRelations(Relations $relations) { $this->_relations = $relations; } @@ -127,9 +132,10 @@ class Config implements \Magento\ObjectManager\Config /** * Set cache instance * - * @param \Magento\ObjectManager\ConfigCache $cache + * @param ConfigCache $cache + * @return void */ - public function setCache(\Magento\ObjectManager\ConfigCache $cache) + public function setCache(ConfigCache $cache) { $this->_cache = $cache; } diff --git a/lib/Magento/ObjectManager/Config/Mapper/Dom.php b/lib/Magento/ObjectManager/Config/Mapper/Dom.php index f085a1658a892a4efa687f1fe2c0ca20ea988a5d..22c92336623776f61fad92ff62dc726863ef8f94 100644 --- a/lib/Magento/ObjectManager/Config/Mapper/Dom.php +++ b/lib/Magento/ObjectManager/Config/Mapper/Dom.php @@ -30,7 +30,7 @@ class Dom implements \Magento\Config\ConverterInterface /** * Convert configuration in DOM format to assoc array that can be used by object manager * - * @param mixed $config + * @param \DOMDocument $config * @return array * @throws \Exception * @todo this method has high cyclomatic complexity in order to avoid performance issues @@ -98,6 +98,9 @@ class Dom implements \Magento\Config\ConverterInterface case 'value': $paramData = $this->_processValueNode($paramChildNode); break; + case 'array': + $paramData = $this->_processArrayNode($paramChildNode); + break; default: throw new \Exception( "Invalid application config. Unknown node: {$paramChildNode->nodeName}." @@ -144,6 +147,58 @@ class Dom implements \Magento\Config\ConverterInterface return $output; } + /** + * Get value of array node + * + * Expected structure: + * <array> + * <item key="key1"><value>...</value></value> + * <item key="key2"> + * <array>...</array> + * </item> + * </array> + * + * Which will convert to: array('key1' => ..., 'key2' => array(...)) + * + * @param \DOMNode $valueNode + * @return array + * @throws \Exception + */ + protected function _processArrayNode(\DOMNode $valueNode) + { + $result = array(); + foreach ($valueNode->childNodes as $item) { + if ($item->nodeType != XML_ELEMENT_NODE) { + continue; + } + if ($item->nodeName != 'item') { + throw new \Exception("Unexpected node {$item->nodeName} under 'array' node."); + } + $count = 0; + $key = (string)$item->attributes->getNamedItem('key')->nodeValue; + foreach ($item->childNodes as $subItem) { + if ($subItem->nodeType != XML_ELEMENT_NODE) { + continue; + } + $count++; + if ($count > 1) { + throw new \Exception("The 'item' node expects one and only one child node."); + } + switch ($subItem->nodeName) { + case 'value': + $result[$key] = $this->_processValueNode($subItem); + break; + case 'array': + $result[$key] = $this->_processArrayNode($subItem); + break; + default: + throw new \Exception("Unexpected node {$subItem->nodeName} under 'item' node."); + } + } + } + return $result; + } + /** * Retrieve value of the given node * Treat all child nodes as an assoc array @@ -168,8 +223,6 @@ class Dom implements \Magento\Config\ConverterInterface $nodeType = $node->attributes->getNamedItem('type'); if ($nodeType && 'null' == $nodeType->nodeValue) { $output[$node->nodeName] = null; - } else { - $output[$node->nodeName] = $this->_processValueNode($node); } } elseif (($node->nodeType == XML_TEXT_NODE || $node->nodeType == XML_CDATA_SECTION_NODE) && $childNodesCount == 1 diff --git a/lib/Magento/ObjectManager/Config/Reader/Dom.php b/lib/Magento/ObjectManager/Config/Reader/Dom.php index b998b911a9412a6a13db528ece050bd026698c57..a5f88c46f7378f7ed3a4542cc335898f92a4b915 100644 --- a/lib/Magento/ObjectManager/Config/Reader/Dom.php +++ b/lib/Magento/ObjectManager/Config/Reader/Dom.php @@ -33,13 +33,14 @@ class Dom extends \Magento\Config\Reader\Filesystem * @var array */ protected $_idAttributes = array( - '/config/preference' => 'for', - '/config/type' => 'name', - '/config/type/param' => 'name', - '/config/type/plugin' => 'name', - '/config/virtualType' => 'name', - '/config/virtualType/param' => 'name', - '/config/virtualType/plugin' => 'name', + '/config/preference' => 'for', + '/config/type' => 'name', + '/config/type/param' => 'name', + '/config/type/plugin' => 'name', + '/config/virtualType' => 'name', + '/config/virtualType/param' => 'name', + '/config/virtualType/plugin' => 'name', + '/config/(type|virtualType)/param(/array/item)+' => 'key', ); /** diff --git a/lib/Magento/ObjectManager/DefinitionFactory.php b/lib/Magento/ObjectManager/DefinitionFactory.php index 8f989910291c6edbf85f902e774a79b47b7d5a48..87f172ce17327084eea62c2857bb27fa1df96327 100644 --- a/lib/Magento/ObjectManager/DefinitionFactory.php +++ b/lib/Magento/ObjectManager/DefinitionFactory.php @@ -26,13 +26,17 @@ */ namespace Magento\ObjectManager; +use \Magento\Filesystem\DriverInterface; +use \Magento\ObjectManager\Definition\Runtime; +use \Magento\ObjectManager\Relations; + /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class DefinitionFactory { /** - * Directory containig compiled class metadata + * Directory containing compiled class metadata * * @var string */ @@ -55,12 +59,12 @@ class DefinitionFactory /** * Filesystem Driver * - * @var \Magento\Filesystem\DriverInterface + * @var DriverInterface */ protected $_filesystemDriver; /** - * List of defintion models + * List of definition models * * @var array */ @@ -70,13 +74,13 @@ class DefinitionFactory ); /** - * @param \Magento\Filesystem\DriverInterface $filesystemDriver + * @param DriverInterface $filesystemDriver * @param string $definitionDir * @param string $generationDir * @param string $definitionFormat */ public function __construct( - \Magento\Filesystem\DriverInterface $filesystemDriver, + DriverInterface $filesystemDriver, $definitionDir, $generationDir, $definitionFormat @@ -88,8 +92,10 @@ class DefinitionFactory } /** - * @param $definitions - * @return \Magento\ObjectManager\Definition\Runtime + * Create class definition based + * + * @param mixed $definitions + * @return Runtime */ public function createClassDefinition($definitions) { @@ -116,7 +122,7 @@ class DefinitionFactory $autoloader = new \Magento\Code\Generator\Autoloader($generator); spl_autoload_register(array($autoloader, 'load')); - $result = new \Magento\ObjectManager\Definition\Runtime(); + $result = new Runtime(); } return $result; } @@ -139,7 +145,9 @@ class DefinitionFactory } /** - * @return \Magento\ObjectManager\Relations + * Create relations + * + * @return Relations */ public function createRelations() { @@ -154,7 +162,7 @@ class DefinitionFactory } /** - * Uncompress definitions + * Un-compress definitions * * @param string $definitions * @return mixed diff --git a/lib/Magento/ObjectManager/Factory/Factory.php b/lib/Magento/ObjectManager/Factory/Factory.php index 539ad7ecaaa5152a2e6b8a668c4c6324cef42498..27240971bd4e640f9d61174f1e1ec3138b2728e9 100644 --- a/lib/Magento/ObjectManager/Factory/Factory.php +++ b/lib/Magento/ObjectManager/Factory/Factory.php @@ -82,6 +82,7 @@ class Factory implements \Magento\ObjectManager\Factory * @param array $arguments * @return array * @throws \LogicException + * @throws \InvalidArgumentException * @throws \BadMethodCallException * * @SuppressWarnings(PHPMD.CyclomaticComplexity) @@ -145,6 +146,7 @@ class Factory implements \Magento\ObjectManager\Factory * Set object manager * * @param \Magento\ObjectManager $objectManager + * @return void */ public function setObjectManager(\Magento\ObjectManager $objectManager) { diff --git a/lib/Magento/ObjectManager/ObjectManager.php b/lib/Magento/ObjectManager/ObjectManager.php index d78ffe94f017534119b73b1b0fd4f7a428b2febe..a786b1398ec0f109bf7475a8c1128d1b78f76319 100644 --- a/lib/Magento/ObjectManager/ObjectManager.php +++ b/lib/Magento/ObjectManager/ObjectManager.php @@ -67,6 +67,7 @@ class ObjectManager implements \Magento\ObjectManager * Set creation factory * * @param Factory $factory + * @return void */ public function setFactory(Factory $factory) { diff --git a/lib/Magento/ObjectManager/Relations/Compiled.php b/lib/Magento/ObjectManager/Relations/Compiled.php index e7168bdd50c499d033ccd553d335b03c1b899c22..d2b31e84f8481cc145eac742543dc3f595816c47 100644 --- a/lib/Magento/ObjectManager/Relations/Compiled.php +++ b/lib/Magento/ObjectManager/Relations/Compiled.php @@ -49,6 +49,12 @@ class Compiled implements \Magento\ObjectManager\Relations $this->_relations = $relations; } + /** + * Check whether requested type is available for read + * + * @param string $type + * @return bool + */ public function has($type) { return isset($this->_relations[$type]); diff --git a/lib/Magento/ObjectManager/etc/config.xsd b/lib/Magento/ObjectManager/etc/config.xsd index f6648384797fecaded651267624747bc2acbaa27..b5e317127219d9c5ade6c01158bee7bb5482a9e8 100644 --- a/lib/Magento/ObjectManager/etc/config.xsd +++ b/lib/Magento/ObjectManager/etc/config.xsd @@ -121,12 +121,49 @@ </xs:complexContent> </xs:complexType> - <xs:complexType name="paramType"> + <xs:complexType name="paramTypeBase"> + <xs:annotation> + <xs:documentation> + Base type to be used for both param and array's item nodes + </xs:documentation> + </xs:annotation> <xs:choice> - <xs:element name="instance" minOccurs="0" maxOccurs="1" type="instanceType" /> - <xs:element name="value" minOccurs="0" maxOccurs="1" type="valueType" /> + <xs:element name="instance" type="instanceType" /> + <xs:element name="value" type="valueType" /> + <xs:element name="array" type="arrayType"> + <xs:unique name="uniqueArrayIndex"> + <xs:annotation> + <xs:documentation> + Array index should be unique for single array + </xs:documentation> + </xs:annotation> + <xs:selector xpath="item" /> + <xs:field xpath="@key" /> + </xs:unique> + </xs:element> + </xs:choice> + </xs:complexType> + + <xs:complexType name="paramType"> + <xs:complexContent> + <xs:extension base="paramTypeBase"> + <xs:attribute name="name" type="xs:string" use="required" /> + </xs:extension> + </xs:complexContent> + </xs:complexType> + + <xs:complexType name="arrayType"> + <xs:choice maxOccurs="unbounded"> + <xs:element name="item" type="arrayItemType" /> </xs:choice> - <xs:attribute name="name" type="xs:string" use="required" /> + </xs:complexType> + + <xs:complexType name="arrayItemType"> + <xs:complexContent> + <xs:extension base="paramTypeBase"> + <xs:attribute name="key" type="xs:string" use="required" /> + </xs:extension> + </xs:complexContent> </xs:complexType> <xs:complexType name="instanceType"> @@ -134,13 +171,14 @@ <xs:attribute name="shared" type="xs:boolean" use="optional" /> </xs:complexType> - <xs:complexType name="valueType" mixed="true"> - <xs:choice> - <xs:any processContents="lax" minOccurs="0" maxOccurs="unbounded" /> - </xs:choice> - <xs:attribute name="translate" type="xs:string" use="optional" /> - <xs:attribute name="module" type="xs:string" use="optional" /> - <xs:attribute name="type" type="xs:string" use="optional" /> + <xs:complexType name="valueType"> + <xs:simpleContent> + <xs:extension base="xs:string"> + <xs:attribute name="translate" type="xs:string" use="optional" /> + <xs:attribute name="module" type="xs:string" use="optional" /> + <xs:attribute name="type" type="xs:string" use="optional" /> + </xs:extension> + </xs:simpleContent> </xs:complexType> <xs:complexType name="pluginType"> diff --git a/lib/Magento/Outbound/Authentication/Factory.php b/lib/Magento/Outbound/Authentication/Factory.php index 5ea07467051856859df6441b50a552b05f2ba21e..496108ff3cd9a210fcdc8e01d1364424f8677b6d 100644 --- a/lib/Magento/Outbound/Authentication/Factory.php +++ b/lib/Magento/Outbound/Authentication/Factory.php @@ -26,9 +26,14 @@ */ namespace Magento\Outbound\Authentication; +use Magento\ObjectManager; +use Magento\Outbound\AuthenticationInterface; + class Factory { - /** @var \Magento\App\ObjectManager */ + /** + * @var ObjectManager + */ private $_objectManager; /** @@ -38,11 +43,11 @@ class Factory /** * @param array $authenticationMap - * @param \Magento\ObjectManager $objectManager + * @param ObjectManager $objectManager */ public function __construct( array $authenticationMap, - \Magento\ObjectManager $objectManager + ObjectManager $objectManager ) { $this->_authenticationMap = $authenticationMap; $this->_objectManager = $objectManager; @@ -52,8 +57,8 @@ class Factory * Returns an Authentication that matches the type specified within Endpoint * * @param string $authenticationType + * @return AuthenticationInterface * @throws \LogicException - * @return \Magento\Outbound\AuthenticationInterface */ public function getAuthentication($authenticationType) { @@ -62,7 +67,7 @@ class Factory } $authentication = $this->_objectManager->get($this->_authenticationMap[$authenticationType]); - if (!$authentication instanceof \Magento\Outbound\AuthenticationInterface) { + if (!$authentication instanceof AuthenticationInterface) { throw new \LogicException( "Authentication class for {$authenticationType} does not implement authentication interface" ); diff --git a/lib/Magento/Outbound/Authentication/Hmac.php b/lib/Magento/Outbound/Authentication/Hmac.php index 2c9cd30b3f290654f8839c3e039716545111e8b2..318ff90975e71cfb02a89a8a4ff0a59ff5185b5b 100644 --- a/lib/Magento/Outbound/Authentication/Hmac.php +++ b/lib/Magento/Outbound/Authentication/Hmac.php @@ -27,7 +27,12 @@ */ namespace Magento\Outbound\Authentication; -class Hmac implements \Magento\Outbound\AuthenticationInterface +use Magento\Core\Model\StoreManagerInterface; +use Magento\Outbound\AuthenticationInterface; +use Magento\Outbound\UserInterface; +use Magento\UrlInterface; + +class Hmac implements AuthenticationInterface { /** * The name of the header which stores the HMAC signature for client verification @@ -44,13 +49,15 @@ class Hmac implements \Magento\Outbound\AuthenticationInterface */ const SHA256_ALGORITHM = 'sha256'; - /** @var \Magento\Core\Model\StoreManagerInterface */ + /** + * @var StoreManagerInterface + */ private $_storeManager; /** - * @param \Magento\Core\Model\StoreManagerInterface $storeManager + * @param StoreManagerInterface $storeManager */ - public function __construct(\Magento\Core\Model\StoreManagerInterface $storeManager) + public function __construct(StoreManagerInterface $storeManager) { $this->_storeManager = $storeManager; } @@ -58,13 +65,12 @@ class Hmac implements \Magento\Outbound\AuthenticationInterface /** * Get authentication signature to add to the headers * - * @param string $body - * @param \Magento\Outbound\UserInterface $user - * - * @throws \LogicException + * @param string $body + * @param UserInterface $user * @return array Headers to add to message + * @throws \LogicException */ - public function getSignatureHeaders($body, \Magento\Outbound\UserInterface $user) + public function getSignatureHeaders($body, UserInterface $user) { $secret = $user->getSharedSecret(); if ('' === $secret || is_null($secret)) { @@ -79,11 +85,11 @@ class Hmac implements \Magento\Outbound\AuthenticationInterface /** * An overridable method to get the domain name * - * @return mixed + * @return array|bool */ protected function _getDomain() { return parse_url($this->_storeManager->getSafeStore() - ->getBaseUrl(\Magento\Core\Model\Store::URL_TYPE_WEB), PHP_URL_HOST); + ->getBaseUrl(UrlInterface::URL_TYPE_WEB), PHP_URL_HOST); } } diff --git a/lib/Magento/Outbound/Formatter/Factory.php b/lib/Magento/Outbound/Formatter/Factory.php index d311de61b1f79d10fa3323d980e7f786b67e00c7..0edc3c190f8eadbb5f14222941fcc64487262171 100644 --- a/lib/Magento/Outbound/Formatter/Factory.php +++ b/lib/Magento/Outbound/Formatter/Factory.php @@ -27,10 +27,13 @@ */ namespace Magento\Outbound\Formatter; +use Magento\ObjectManager; +use Magento\Outbound\FormatterInterface; + class Factory { /** - * @var \Magento\ObjectManager + * @var ObjectManager */ protected $_objectManager; @@ -41,11 +44,11 @@ class Factory /** * @param array $formatterMap - * @param \Magento\ObjectManager $objectManager + * @param ObjectManager $objectManager */ public function __construct( array $formatterMap, - \Magento\ObjectManager $objectManager + ObjectManager $objectManager ) { $this->_formatterMap = $formatterMap; $this->_objectManager = $objectManager; @@ -55,7 +58,7 @@ class Factory * Get formatter for specified format * * @param string $format - * @return \Magento\Outbound\FormatterInterface + * @return FormatterInterface * @throws \LogicException */ public function getFormatter($format) @@ -66,7 +69,7 @@ class Factory $formatterClassName = $this->_formatterMap[$format]; $formatter = $this->_objectManager->get($formatterClassName); - if (!$formatter instanceof \Magento\Outbound\FormatterInterface) { + if (!$formatter instanceof FormatterInterface) { throw new \LogicException("Formatter class for {$format} does not implement FormatterInterface."); } return $formatter; diff --git a/lib/Magento/Outbound/Message.php b/lib/Magento/Outbound/Message.php index 365ea664ca12f4151c281b8fbf823dd5e6518965..7d9ac6f1ebe28caef149fff6f38d46d61ca59cc5 100644 --- a/lib/Magento/Outbound/Message.php +++ b/lib/Magento/Outbound/Message.php @@ -27,7 +27,7 @@ */ namespace Magento\Outbound; -class Message implements \Magento\Outbound\MessageInterface +class Message implements MessageInterface { /** default timeout value in seconds */ const DEFAULT_TIMEOUT = 20; @@ -47,14 +47,16 @@ class Message implements \Magento\Outbound\MessageInterface */ protected $_timeout; - /** @var string */ + /** + * @var string + */ protected $_endpointUrl; /** * @param string $endpointUrl * @param array $headers - * @param null $body + * @param string|null $body * @param int $timeout in seconds */ public function __construct($endpointUrl, $headers = array(), $body = null, $timeout = self::DEFAULT_TIMEOUT) diff --git a/lib/Magento/Outbound/Message/Factory.php b/lib/Magento/Outbound/Message/Factory.php index b6485e43f742fd5af16f68ce56e1b740a7497183..88172912cdca4290dc668e50c561bed59cafb88c 100644 --- a/lib/Magento/Outbound/Message/Factory.php +++ b/lib/Magento/Outbound/Message/Factory.php @@ -27,34 +27,41 @@ */ namespace Magento\Outbound\Message; -class Factory implements \Magento\Outbound\Message\FactoryInterface +use Magento\ObjectManager; +use Magento\Outbound\EndpointInterface; +use Magento\Outbound\FormatterInterface; +use Magento\Outbound\Message; +use Magento\Outbound\Authentication\Factory as AuthenticationFactory; +use Magento\Outbound\Formatter\Factory as FormatterFactory; + +class Factory implements FactoryInterface { /** - * @var \Magento\ObjectManager + * @var ObjectManager */ protected $_objectManager; /** - * @var \Magento\Outbound\Formatter\Factory + * @var FormatterFactory */ private $_formatterFactory; /** - * @var \Magento\Outbound\Authentication\Factory + * @var AuthenticationFactory */ private $_authFactory; /** * initialize the class * - * @param \Magento\ObjectManager $objectManager - * @param \Magento\Outbound\Formatter\Factory $formatterFactory - * @param \Magento\Outbound\Authentication\Factory $authFactory + * @param ObjectManager $objectManager + * @param FormatterFactory $formatterFactory + * @param AuthenticationFactory $authFactory */ public function __construct( - \Magento\ObjectManager $objectManager, - \Magento\Outbound\Formatter\Factory $formatterFactory, - \Magento\Outbound\Authentication\Factory $authFactory + ObjectManager $objectManager, + FormatterFactory $formatterFactory, + AuthenticationFactory $authFactory ) { $this->_objectManager = $objectManager; $this->_formatterFactory = $formatterFactory; @@ -64,19 +71,18 @@ class Factory implements \Magento\Outbound\Message\FactoryInterface /** * Create a message for a given endpoint, topic and message data * - * @param \Magento\Outbound\EndpointInterface $endpoint - * @param string $topic topic of the message - * @param array $bodyData body of the message - * - * @return \Magento\Outbound\Message + * @param EndpointInterface $endpoint + * @param string $topic topic of the message + * @param array $bodyData body of the message + * @return Message */ - public function create(\Magento\Outbound\EndpointInterface $endpoint, $topic, array $bodyData) + public function create(EndpointInterface $endpoint, $topic, array $bodyData) { // Format first since that should turn the body from an array into a string $formatter = $this->_formatterFactory->getFormatter($endpoint->getFormat()); $headers = array( - \Magento\Outbound\Message\FactoryInterface::TOPIC_HEADER => $topic, - \Magento\Outbound\FormatterInterface::CONTENT_TYPE_HEADER => $formatter->getContentType(), + FactoryInterface::TOPIC_HEADER => $topic, + FormatterInterface::CONTENT_TYPE_HEADER => $formatter->getContentType(), ); $formattedBody = $formatter->format($bodyData); diff --git a/lib/Magento/Outbound/Transport/Http.php b/lib/Magento/Outbound/Transport/Http.php index 4d54b47e166a7719982da206508e42bd22be63f8..8587ec3f866a13027b29ddfb958098e2ab936485 100644 --- a/lib/Magento/Outbound/Transport/Http.php +++ b/lib/Magento/Outbound/Transport/Http.php @@ -27,7 +27,13 @@ */ namespace Magento\Outbound\Transport; -class Http implements \Magento\Outbound\TransportInterface +use Magento\HTTP\Adapter\Curl; +use Magento\Outbound\Message; +use Magento\Outbound\MessageInterface; +use Magento\Outbound\TransportInterface; +use Magento\Outbound\Transport\Http\Response; + +class Http implements TransportInterface { /** * Http version used by Magento @@ -35,14 +41,14 @@ class Http implements \Magento\Outbound\TransportInterface const HTTP_VERSION = '1.1'; /** - * @var \Magento\HTTP\Adapter\Curl + * @var Curl */ protected $_curl; /** - * @param \Magento\HTTP\Adapter\Curl $curl + * @param Curl $curl */ - public function __construct(\Magento\HTTP\Adapter\Curl $curl) + public function __construct(Curl $curl) { $this->_curl = $curl; } @@ -50,10 +56,10 @@ class Http implements \Magento\Outbound\TransportInterface /** * Dispatch message and return response * - * @param \Magento\Outbound\MessageInterface $message - * @return \Magento\Outbound\Transport\Http\Response + * @param MessageInterface $message + * @return Response */ - public function dispatch(\Magento\Outbound\MessageInterface $message) + public function dispatch(MessageInterface $message) { $config = array( 'verifypeer' => TRUE, @@ -64,7 +70,7 @@ class Http implements \Magento\Outbound\TransportInterface if (!is_null($timeout) && $timeout > 0) { $config['timeout'] = $timeout; } else { - $config['timeout'] = \Magento\Outbound\Message::DEFAULT_TIMEOUT; + $config['timeout'] = Message::DEFAULT_TIMEOUT; } $this->_curl->setConfig($config); @@ -75,14 +81,14 @@ class Http implements \Magento\Outbound\TransportInterface $message->getBody() ); - return new \Magento\Outbound\Transport\Http\Response($this->_curl->read()); + return new Response($this->_curl->read()); } /** * Prepare headers for dispatch * * @param string[] $headers - * @return array + * @return string[] */ protected function _prepareHeaders($headers) { diff --git a/lib/Magento/Outbound/Transport/Http/Response.php b/lib/Magento/Outbound/Transport/Http/Response.php index 9d8c5053267d7667b21b19e9d43064d28176e544..e212c84a20de2220e9b203c6162163e9492fe4e6 100644 --- a/lib/Magento/Outbound/Transport/Http/Response.php +++ b/lib/Magento/Outbound/Transport/Http/Response.php @@ -35,7 +35,7 @@ class Response protected $_response; /** - * @param $string response string from an http request + * @param string $string response from an http request */ public function __construct($string) { diff --git a/lib/Magento/Pear.php b/lib/Magento/Pear.php index 115a955695bea5cbfca30bee002b88b0fe0b443d..fc36991d412a88d09dda40c6d4062a766c7719f8 100644 --- a/lib/Magento/Pear.php +++ b/lib/Magento/Pear.php @@ -33,6 +33,10 @@ */ namespace Magento; +use Magento\Exception; +use Magento\Pear\Frontend; +use Magento\Pear\Registry; + // Looks like PEAR is being developed without E_NOTICE (1.7.0RC1) error_reporting(E_ALL & ~E_NOTICE); @@ -67,23 +71,45 @@ require_once __DIR__ . "/Pear/Package.php"; require_once dirname(__FILE__) . "/Pear/Package.php"; class Pear { + /** + * @var array + */ protected $_config; + /** + * @var Registry + */ protected $_registry; + /** + * @var Frontend + */ protected $_frontend; + /** + * @var array + */ protected $_cmdCache = array(); + /** + * @var Pear + */ static protected $_instance; + /** + * @var bool + */ static public $reloadOnRegistryUpdate = true; + public function __construct() { $this->getConfig(); } + /** + * @return Pear + */ public function getInstance() { if (!self::$_instance) { @@ -92,21 +118,34 @@ class Pear return self::$_instance; } + /** + * @param string $pkg + * @return bool + */ public function isSystemPackage($pkg) { return in_array($pkg, array('Archive_Tar', 'Console_Getopt', 'PEAR', 'Structures_Graph')); } + /** + * @return string + */ public function getBaseDir() { return dirname(dirname(__DIR__)); } + /** + * @return string + */ public function getPearDir() { return $this->getBaseDir() . '/downloader/pearlib'; } + /** + * @return array + */ public function getConfig() { if (!$this->_config) { @@ -151,15 +190,22 @@ class Pear return $this->_config; } + /** + * @return string[] + */ public function getMagentoChannels() { return array('connect.magentocommerce.com/core', 'connect.magentocommerce.com/community'); } + /** + * @param bool $redirectOnChange + * @return Registry + */ public function getRegistry($redirectOnChange=true) { if (!$this->_registry) { - $this->_registry = new \Magento\Pear\Registry($this->getPearDir() . '/php'); + $this->_registry = new Registry($this->getPearDir() . '/php'); $changed = false; foreach ($this->getMagentoChannels() as $channel) { @@ -183,24 +229,39 @@ class Pear return $this->_registry; } + /** + * @return Frontend + */ public function getFrontend() { if (!$this->_frontend) { - $this->_frontend = new \Magento\Pear\Frontend; + $this->_frontend = new Frontend; } return $this->_frontend; } + /** + * @return string[] + */ public function getLog() { return $this->getFrontend()->getLog(); } + /** + * @return array + */ public function getOutput() { return $this->getFrontend()->getOutput(); } + /** + * @param string $command + * @param array $options + * @param array $params + * @return mixed + */ public function run($command, $options=array(), $params=array()) { @set_time_limit(0); @@ -220,6 +281,10 @@ class Pear return $result; } + /** + * @param string $uri + * @return $this + */ public function setRemoteConfig($uri) #$host, $user, $password, $path='', $port=null) { #$uri = 'ftp://' . $user . ':' . $password . '@' . $host . (is_numeric($port) ? ':' . $port : '') . '/' . trim($path, '/') . '/'; @@ -232,6 +297,8 @@ class Pear * * @param array|\Magento\Object $runParams command, options, params, * comment, success_callback, failure_callback + * @return mixed + * @throws Exception */ public function runHtmlConsole($runParams) { @@ -241,14 +308,14 @@ class Pear $oldLogStream = $fe->getLogStream(); $fe->setLogStream('stdout'); - if ($runParams instanceof \Magento\Object) { + if ($runParams instanceof Object) { $run = $runParams; } elseif (is_array($runParams)) { - $run = new \Magento\Object($runParams); + $run = new Object($runParams); } elseif (is_string($runParams)) { - $run = new \Magento\Object(array('title'=>$runParams)); + $run = new Object(array('title'=>$runParams)); } else { - throw \Magento\Exception("Invalid run parameters"); + throw Exception("Invalid run parameters"); } ?> <html><head><style type="text/css"> diff --git a/lib/Magento/Pear/Frontend.php b/lib/Magento/Pear/Frontend.php index 3ead9f1e8b5e781d6dbda5232ca0817469051c61..7d7663a12ec66d71970b4704beb0804c9fdc90db 100644 --- a/lib/Magento/Pear/Frontend.php +++ b/lib/Magento/Pear/Frontend.php @@ -36,15 +36,31 @@ namespace Magento\Pear; class Frontend { + /** + * @var string|resource + */ protected $_logStream = null; + + /** + * @var null + */ protected $_outStream = null; + + /** + * @var string[] + */ protected $_log = array(); + + /** + * @var array + */ protected $_out = array(); /** * Enter description here... * * @param string|resource $stream 'stdout' or open php stream + * @return $this */ public function setLogStream($stream) { @@ -52,11 +68,19 @@ class Frontend return $this; } + /** + * @return string|resource + */ public function getLogStream() { return $this->_logStream; } + /** + * @param string $msg + * @param bool $append_crlf + * @return void + */ public function log($msg, $append_crlf = true) { if (is_null($msg) || false===$msg or ''===$msg) { @@ -80,6 +104,11 @@ class Frontend } } + /** + * @param string|array $data + * @param string $command + * @return void + */ public function outputData($data, $command = '_default') { $this->_out[] = array('output'=>$data, 'command'=>$command); @@ -97,22 +126,34 @@ class Frontend } } + /** + * @return void + */ public function userConfirm() { } + /** + * @return void + */ public function clear() { $this->_log = array(); $this->_out = array(); } + /** + * @return string[] + */ public function getLog() { return $this->_log; } + /** + * @return string + */ public function getLogText() { $text = ''; @@ -122,6 +163,9 @@ class Frontend return $text; } + /** + * @return array + */ public function getOutput() { return $this->_out; diff --git a/lib/Magento/Pear/Package.php b/lib/Magento/Pear/Package.php index 9e7dcdfa6f785d082d30887c856b46c50da54cc0..2d45e94d4b92dc688f6ee05b4c314db62968414b 100644 --- a/lib/Magento/Pear/Package.php +++ b/lib/Magento/Pear/Package.php @@ -54,8 +54,13 @@ require_once "PEAR/PackageFile/Generator/v2.php";*/ namespace Magento\Pear; +use Magento\Pear; + class Package { + /** + * @var array + */ protected $_data = array( 'options' => array( 'baseinstalldir'=>'', @@ -67,24 +72,46 @@ class Package 'release' => array(), ); + /** + * @var Pear + */ protected $_pear; + + /** + * @var PEAR_PackageFileManager2 + */ protected $_pfm; + /** + * Constructor + */ public function __construct() { - $this->_pear = \Magento\Pear::getInstance(); + $this->_pear = Pear::getInstance(); } + /** + * @return Pear + */ public function getPear() { return $this->_pear; } + /** + * @param string $key + * @return mixed + */ public function getPearConfig($key) { return $this->getPear()->getConfig()->get($key); } + /** + * @param string $key + * @param array $data + * @return $this + */ public function set($key, $data) { if (''===$key) { @@ -108,6 +135,10 @@ class Package return $this; } + /** + * @param string $key + * @return array|null + */ public function get($key) { if (''===$key) { @@ -133,6 +164,10 @@ class Package return $data; } + /** + * @param PEAR_PackageFileManager2 $pfm + * @return $this + */ public function setPfm($pfm) { $this->_pfm = $pfm; @@ -142,8 +177,9 @@ class Package /** * Get PackageFileManager2 instance * - * @param string|PEAR_PackageFile_v1 $package - * @return PEAR_PackageFileManager2|PEAR_Error + * @param string|null $package + * @return PEAR_PackageFileManager2 + * @throws PEAR_Exception */ public function getPfm($package=null) { @@ -165,6 +201,9 @@ class Package return $this->_pfm; } + /** + * @return $this + */ public function clearPackage() { $pfm = $this->getPfm(); @@ -175,6 +214,10 @@ class Package return $this; } + /** + * @param bool $make + * @return $this + */ public function generatePackage($make=false) { PEAR::setErrorHandling(PEAR_ERROR_DIE); @@ -205,6 +248,9 @@ class Package return $this; } + /** + * @return $this + */ public function defineData() { $this->set('options/outputdirectory', $this->getPear()->getPearDir() . '/output'); @@ -214,11 +260,17 @@ class Package return $this; } + /** + * @return $this + */ public function definePackage() { return $this; } + /** + * @return $this + */ public function defineRelease() { return $this; diff --git a/lib/Magento/Phrase.php b/lib/Magento/Phrase.php index 0f26c27756c090358ad5d39a0dba8267951fb5c7..7ca78c4f21bec189117509f9b45d4d3a34540ae2 100644 --- a/lib/Magento/Phrase.php +++ b/lib/Magento/Phrase.php @@ -25,12 +25,14 @@ */ namespace Magento; +use \Magento\Phrase\RendererInterface; + class Phrase { /** * Default phrase renderer. Allows stacking renderers that "don't know about each other" * - * @var \Magento\Phrase\RendererInterface + * @var RendererInterface */ private static $_renderer; @@ -51,9 +53,10 @@ class Phrase /** * Set default Phrase renderer * - * @param \Magento\Phrase\RendererInterface $renderer + * @param RendererInterface $renderer + * @return void */ - public static function setRenderer(\Magento\Phrase\RendererInterface $renderer) + public static function setRenderer(RendererInterface $renderer) { self::$_renderer = $renderer; } diff --git a/lib/Magento/Phrase/Renderer/Composite.php b/lib/Magento/Phrase/Renderer/Composite.php index 3266f8e719188a708776b1f0cfade44c1cb25de3..7affc8eadd1eac9d2d43c5754c3ed41eaf5966f6 100644 --- a/lib/Magento/Phrase/Renderer/Composite.php +++ b/lib/Magento/Phrase/Renderer/Composite.php @@ -30,7 +30,7 @@ class Composite implements \Magento\Phrase\RendererInterface /** * Renderer factory * - * @var \Magento\Phrase\Renderer\Factory + * @var Factory */ protected $_rendererFactory; @@ -44,11 +44,11 @@ class Composite implements \Magento\Phrase\RendererInterface /** * Renderer construct * - * @param \Magento\Phrase\Renderer\Factory $rendererFactory + * @param Factory $rendererFactory * @param array $renderers */ public function __construct( - \Magento\Phrase\Renderer\Factory $rendererFactory, + Factory $rendererFactory, array $renderers = array() ) { $this->_rendererFactory = $rendererFactory; @@ -62,6 +62,7 @@ class Composite implements \Magento\Phrase\RendererInterface * Add renderer to the end of the chain * * @param string $render + * @return void */ protected function _append($render) { @@ -69,7 +70,11 @@ class Composite implements \Magento\Phrase\RendererInterface } /** - * {@inheritdoc} + * Render result text + * + * @param string $text + * @param array $arguments + * @return string */ public function render($text, array $arguments = array()) { diff --git a/lib/Magento/Phrase/Renderer/Placeholder.php b/lib/Magento/Phrase/Renderer/Placeholder.php index 4e07a722e45f09e6ef661bd739157d7112e4a658..3a5b4f45a6333cd1da7862a9e54b2b9f1925aa68 100644 --- a/lib/Magento/Phrase/Renderer/Placeholder.php +++ b/lib/Magento/Phrase/Renderer/Placeholder.php @@ -29,6 +29,10 @@ class Placeholder implements \Magento\Phrase\RendererInterface { /** * {@inheritdoc} + * + * @param string $text + * @param array $arguments + * @return string */ public function render($text, array $arguments) { diff --git a/lib/Magento/Phrase/Renderer/Translate.php b/lib/Magento/Phrase/Renderer/Translate.php index f87258b1460b8c0c6ad1a05636c7a02adf3eecc7..97d6027c7a5db41c64a913b19fbea42d3ec542b2 100644 --- a/lib/Magento/Phrase/Renderer/Translate.php +++ b/lib/Magento/Phrase/Renderer/Translate.php @@ -46,6 +46,10 @@ class Translate implements \Magento\Phrase\RendererInterface /** * {@inheritdoc} + * + * @param string $text + * @param array $arguments + * @return string */ public function render($text, array $arguments) { diff --git a/lib/Magento/Profiler.php b/lib/Magento/Profiler.php index f4e3f8bc20bee7947434d40bf3dafb62085e21cd..5bed0ce60cdbe7d8eb321f21d3aec78887f7881c 100644 --- a/lib/Magento/Profiler.php +++ b/lib/Magento/Profiler.php @@ -25,6 +25,9 @@ */ namespace Magento; +use Magento\Profiler\DriverInterface; +use Magento\Profiler\Driver\Factory; + class Profiler { /** @@ -42,7 +45,7 @@ class Profiler /** * Nesting path that represents namespace to resolve timer names * - * @var array + * @var string[] */ static private $_currentPath = array(); @@ -63,7 +66,7 @@ class Profiler /** * Collection for profiler drivers. * - * @var array + * @var DriverInterface[] */ static private $_drivers = array(); @@ -82,7 +85,7 @@ class Profiler static private $_tagFilters = array(); /** - * Has tag filters flag to faster checks of filters availability. + * Has tag filters flag for faster checks of filters availability. * * @var bool */ @@ -92,6 +95,7 @@ class Profiler * Set default tags * * @param array $tags + * @return void */ public static function setDefaultTags(array $tags) { @@ -103,6 +107,7 @@ class Profiler * * @param string $tagName * @param string $tagValue + * @return void */ public static function addTagFilter($tagName, $tagValue) { @@ -140,9 +145,10 @@ class Profiler /** * Add profiler driver. * - * @param \Magento\Profiler\DriverInterface $driver + * @param DriverInterface $driver + * @return void */ - public static function add(\Magento\Profiler\DriverInterface $driver) + public static function add(DriverInterface $driver) { self::$_drivers[] = $driver; self::enable(); @@ -184,6 +190,8 @@ class Profiler * Enable profiling. * * Any call to profiler does nothing until profiler is enabled. + * + * @return void */ public static function enable() { @@ -194,6 +202,8 @@ class Profiler * Disable profiling. * * Any call to profiler is silently ignored while profiler is disabled. + * + * @return void */ public static function disable() { @@ -214,6 +224,7 @@ class Profiler * Clear collected statistics for specified timer or for whole profiler if timer id is omitted * * @param string|null $timerName + * @return void * @throws \InvalidArgumentException */ public static function clear($timerName = null) @@ -222,7 +233,7 @@ class Profiler throw new \InvalidArgumentException('Timer name must not contain a nesting separator.'); } $timerId = self::_getTimerId($timerName); - /** @var \Magento\Profiler\DriverInterface $driver */ + /** @var DriverInterface $driver */ foreach (self::$_drivers as $driver) { $driver->clear($timerId); } @@ -230,6 +241,8 @@ class Profiler /** * Reset profiler to initial state + * + * @return void */ public static function reset() { @@ -249,6 +262,7 @@ class Profiler * * @param string $timerName * @param array|null $tags + * @return void * @throws \InvalidArgumentException */ public static function start($timerName, array $tags = null) @@ -267,7 +281,7 @@ class Profiler } $timerId = self::_getTimerId($timerName); - /** @var \Magento\Profiler\DriverInterface $driver */ + /** @var DriverInterface $driver */ foreach (self::$_drivers as $driver) { $driver->start($timerId, $tags); } @@ -284,6 +298,7 @@ class Profiler * Only the latest started timer can be stopped. * * @param string|null $timerName + * @return void * @throws \InvalidArgumentException */ public static function stop($timerName = null) @@ -310,7 +325,7 @@ class Profiler for ($i = 0; $i < $timersToStop; $i++) { $timerId = self::_getTimerId(); - /** @var \Magento\Profiler\DriverInterface $driver */ + /** @var DriverInterface $driver */ foreach (self::$_drivers as $driver) { $driver->stop($timerId); } @@ -325,7 +340,8 @@ class Profiler * * @param array|string $config * @param string $baseDir - * @param boolean $isAjax + * @param bool $isAjax + * @return void */ public static function applyConfig($config, $baseDir, $isAjax = false) { @@ -345,7 +361,7 @@ class Profiler * * @param array|string $profilerConfig * @param string $baseDir - * @param boolean $isAjax + * @param bool $isAjax * @return array * @SuppressWarnings(PHPMD.NPathComplexity) */ @@ -369,7 +385,7 @@ class Profiler $driverConfigs = (array) (isset($config['drivers']) ? $config['drivers'] : array()); $driverFactory = isset($config['driverFactory']) ? $config['driverFactory'] - : new \Magento\Profiler\Driver\Factory(); + : new Factory(); $tagFilters = (array) (isset($config['tagFilters']) ? $config['tagFilters'] : array()); $result = array( @@ -411,7 +427,7 @@ class Profiler * Parses driver config * * @param mixed $driverConfig - * @return array|bool + * @return array|false */ protected static function _parseDriverConfig($driverConfig) { diff --git a/lib/Magento/Profiler/Driver/Factory.php b/lib/Magento/Profiler/Driver/Factory.php index 325c943fb7a5980652f415bd0f7881eb64924912..9ea221b1d8f70c9018dfe706da5ca44fe8af6557 100644 --- a/lib/Magento/Profiler/Driver/Factory.php +++ b/lib/Magento/Profiler/Driver/Factory.php @@ -25,6 +25,8 @@ */ namespace Magento\Profiler\Driver; +use Magento\Profiler\DriverInterface; + class Factory { /** @@ -57,7 +59,7 @@ class Factory * Create instance of profiler driver * * @param array $config|null - * @return \Magento\Profiler\DriverInterface + * @return DriverInterface * @throws \InvalidArgumentException */ public function create(array $config = null) @@ -74,7 +76,7 @@ class Factory } } $driver = new $class($config); - if (!$driver instanceof \Magento\Profiler\DriverInterface) { + if (!$driver instanceof DriverInterface) { throw new \InvalidArgumentException(sprintf( "Driver class \"%s\" must implement \Magento\Profiler\DriverInterface.", get_class($driver) )); diff --git a/lib/Magento/Profiler/Driver/Standard.php b/lib/Magento/Profiler/Driver/Standard.php index 1e57669ee3589631ab85ee06332fd4c85ed65393..42907fc8cf2af855d384225c3f5c1210f3da4b02 100644 --- a/lib/Magento/Profiler/Driver/Standard.php +++ b/lib/Magento/Profiler/Driver/Standard.php @@ -25,19 +25,24 @@ */ namespace Magento\Profiler\Driver; -class Standard implements \Magento\Profiler\DriverInterface +use Magento\Profiler\Driver\Standard\Output\Factory as OutputFactory; +use Magento\Profiler\Driver\Standard\OutputInterface; +use Magento\Profiler\Driver\Standard\Stat; +use Magento\Profiler\DriverInterface; + +class Standard implements DriverInterface { /** * Storage for timers statistics * - * @var \Magento\Profiler\Driver\Standard\Stat + * @var Stat */ protected $_stat; /** * List of profiler driver outputs * - * @var \Magento\Profiler\Driver\Standard\OutputInterface[] + * @var OutputInterface[] */ protected $_outputs = array(); @@ -57,6 +62,7 @@ class Standard implements \Magento\Profiler\DriverInterface * Init outputs by configuration * * @param array|null $config + * @return void */ protected function _initOutputs(array $config = null) { @@ -124,16 +130,16 @@ class Standard implements \Magento\Profiler\DriverInterface * Gets output factory from configuration or create new one * * @param array|null $config - * @return \Magento\Profiler\Driver\Standard\Output\Factory + * @return OutputFactory */ protected function _getOutputFactory(array $config = null) { if (isset($config['outputFactory']) - && $config['outputFactory'] instanceof \Magento\Profiler\Driver\Standard\Output\Factory + && $config['outputFactory'] instanceof OutputFactory ) { $result = $config['outputFactory']; } else { - $result = new \Magento\Profiler\Driver\Standard\Output\Factory(); + $result = new OutputFactory(); } return $result; } @@ -142,15 +148,16 @@ class Standard implements \Magento\Profiler\DriverInterface * Init timers statistics object from configuration or create new one * * @param array $config|null + * @return void */ protected function _initStat(array $config = null) { if (isset($config['stat']) - && $config['stat'] instanceof \Magento\Profiler\Driver\Standard\Stat + && $config['stat'] instanceof Stat ) { $this->_stat = $config['stat']; } else { - $this->_stat = new \Magento\Profiler\Driver\Standard\Stat(); + $this->_stat = new Stat(); } } @@ -158,6 +165,7 @@ class Standard implements \Magento\Profiler\DriverInterface * Clear collected statistics for specified timer or for whole profiler if timer id is omitted * * @param string|null $timerId + * @return void */ public function clear($timerId = null) { @@ -169,6 +177,7 @@ class Standard implements \Magento\Profiler\DriverInterface * * @param string $timerId * @param array|null $tags + * @return void * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ public function start($timerId, array $tags = null) @@ -180,6 +189,7 @@ class Standard implements \Magento\Profiler\DriverInterface * Stop recording statistics for specified timer. * * @param string $timerId + * @return void */ public function stop($timerId) { @@ -189,15 +199,18 @@ class Standard implements \Magento\Profiler\DriverInterface /** * Register profiler output instance to display profiling result at the end of execution * - * @param \Magento\Profiler\Driver\Standard\OutputInterface $output + * @param OutputInterface $output + * @return void */ - public function registerOutput(\Magento\Profiler\Driver\Standard\OutputInterface $output) + public function registerOutput(OutputInterface $output) { $this->_outputs[] = $output; } /** * Display collected statistics with registered outputs + * + * @return void */ public function display() { diff --git a/lib/Magento/Profiler/Driver/Standard/AbstractOutput.php b/lib/Magento/Profiler/Driver/Standard/AbstractOutput.php index 0994e8a032da7eef812ad09e12dbd5a0d41441a7..baac18889efbb9ed8b5f446f34b543b44454c511 100644 --- a/lib/Magento/Profiler/Driver/Standard/AbstractOutput.php +++ b/lib/Magento/Profiler/Driver/Standard/AbstractOutput.php @@ -25,8 +25,7 @@ */ namespace Magento\Profiler\Driver\Standard; -abstract class AbstractOutput - implements \Magento\Profiler\Driver\Standard\OutputInterface +abstract class AbstractOutput implements OutputInterface { /** * PCRE Regular Expression for filter timer by id @@ -40,11 +39,7 @@ abstract class AbstractOutput * * @var array */ - protected $_thresholds = array( - \Magento\Profiler\Driver\Standard\Stat::TIME => 0.001, - \Magento\Profiler\Driver\Standard\Stat::COUNT => 10, - \Magento\Profiler\Driver\Standard\Stat::EMALLOC => 10000, - ); + protected $_thresholds = array(Stat::TIME => 0.001, Stat::COUNT => 10, Stat::EMALLOC => 10000); /** * List of columns to output @@ -52,12 +47,12 @@ abstract class AbstractOutput * @var array */ protected $_columns = array( - 'Timer Id' => \Magento\Profiler\Driver\Standard\Stat::ID, - 'Time' => \Magento\Profiler\Driver\Standard\Stat::TIME, - 'Avg' => \Magento\Profiler\Driver\Standard\Stat::AVG, - 'Cnt' => \Magento\Profiler\Driver\Standard\Stat::COUNT, - 'Emalloc' => \Magento\Profiler\Driver\Standard\Stat::EMALLOC, - 'RealMem' => \Magento\Profiler\Driver\Standard\Stat::REALMEM, + 'Timer Id' => Stat::ID, + 'Time' => Stat::TIME, + 'Avg' => Stat::AVG, + 'Cnt' => Stat::COUNT, + 'Emalloc' => Stat::EMALLOC, + 'RealMem' => Stat::REALMEM ); /** @@ -81,6 +76,7 @@ abstract class AbstractOutput * Set profiler output with timer identifiers filter. * * @param string $filterPattern PCRE pattern to filter timers by their identifiers + * @return void */ public function setFilterPattern($filterPattern) { @@ -104,6 +100,7 @@ abstract class AbstractOutput * * @param string $fetchKey * @param int|float|null $minAllowedValue + * @return void */ public function setThreshold($fetchKey, $minAllowedValue) { @@ -127,18 +124,18 @@ abstract class AbstractOutput /** * Render statistics column value for specified timer * - * @param mixed $value + * @param string|float $value * @param string $columnKey * @return string */ protected function _renderColumnValue($value, $columnKey) { switch ($columnKey) { - case \Magento\Profiler\Driver\Standard\Stat::ID: + case Stat::ID: $result = $this->_renderTimerId($value); break; - case \Magento\Profiler\Driver\Standard\Stat::TIME: - case \Magento\Profiler\Driver\Standard\Stat::AVG: + case Stat::TIME: + case Stat::AVG: $result = number_format($value, 6); break; default: @@ -177,10 +174,10 @@ abstract class AbstractOutput * * Timer ids will be ordered and filtered by thresholds and filter pattern. * - * @param \Magento\Profiler\Driver\Standard\Stat $stat - * @return array + * @param Stat $stat + * @return string[] */ - protected function _getTimerIds(\Magento\Profiler\Driver\Standard\Stat $stat) + protected function _getTimerIds(Stat $stat) { return $stat->getFilteredTimerIds($this->_thresholds, $this->_filterPattern); } diff --git a/lib/Magento/Profiler/Driver/Standard/Output/Csvfile.php b/lib/Magento/Profiler/Driver/Standard/Output/Csvfile.php index d9a4d0ac9f96496c693b48e8029c7b580831decb..6244c165a3422a5f93c002586a21f5d244471767 100644 --- a/lib/Magento/Profiler/Driver/Standard/Output/Csvfile.php +++ b/lib/Magento/Profiler/Driver/Standard/Output/Csvfile.php @@ -25,7 +25,10 @@ */ namespace Magento\Profiler\Driver\Standard\Output; -class Csvfile extends \Magento\Profiler\Driver\Standard\AbstractOutput +use Magento\Profiler\Driver\Standard\AbstractOutput; +use Magento\Profiler\Driver\Standard\Stat; + +class Csvfile extends AbstractOutput { const DEFAULT_FILEPATH = '/var/log/profiler.csv'; @@ -76,10 +79,11 @@ class Csvfile extends \Magento\Profiler\Driver\Standard\AbstractOutput /** * Write profiling results to CSV-file * - * @param \Magento\Profiler\Driver\Standard\Stat $stat + * @param Stat $stat + * @return void * @throws \RuntimeException if output file cannot be opened */ - public function display(\Magento\Profiler\Driver\Standard\Stat $stat) + public function display(Stat $stat) { $fileHandle = fopen($this->_filePath, 'w'); if (!$fileHandle) { @@ -102,9 +106,10 @@ class Csvfile extends \Magento\Profiler\Driver\Standard\AbstractOutput * Write content into an opened file handle * * @param resource $fileHandle - * @param \Magento\Profiler\Driver\Standard\Stat $stat + * @param Stat $stat + * @return void */ - protected function _writeFileContent($fileHandle, \Magento\Profiler\Driver\Standard\Stat $stat) + protected function _writeFileContent($fileHandle, Stat $stat) { foreach ($this->_getTimerIds($stat) as $timerName) { $row = array(); diff --git a/lib/Magento/Profiler/Driver/Standard/Output/Factory.php b/lib/Magento/Profiler/Driver/Standard/Output/Factory.php index 155fa5f42c2c7fac5aac0378090291111d2f7b7d..652bb6f1d636bff2ca758c4d8ab88bae2d4e5b17 100644 --- a/lib/Magento/Profiler/Driver/Standard/Output/Factory.php +++ b/lib/Magento/Profiler/Driver/Standard/Output/Factory.php @@ -25,6 +25,8 @@ */ namespace Magento\Profiler\Driver\Standard\Output; +use Magento\Profiler\Driver\Standard\OutputInterface; + class Factory { /** @@ -59,7 +61,7 @@ class Factory * Create instance of standard profiler driver output * * @param array $config - * @return \Magento\Profiler\Driver\Standard\OutputInterface + * @return OutputInterface * @throws \InvalidArgumentException If driver cannot be created */ public function create(array $config) @@ -76,7 +78,7 @@ class Factory } } $output = new $class($config); - if (!$output instanceof \Magento\Profiler\Driver\Standard\OutputInterface) { + if (!$output instanceof OutputInterface) { throw new \InvalidArgumentException(sprintf( "Output class \"%s\" must implement \Magento\Profiler\Driver\Standard\OutputInterface.", get_class($output) diff --git a/lib/Magento/Profiler/Driver/Standard/Output/Firebug.php b/lib/Magento/Profiler/Driver/Standard/Output/Firebug.php index 358774e81cdb23e956eb47679d2623f8083a1b12..031e441962c2095fdbfccacc3c3421bd57e1b478 100644 --- a/lib/Magento/Profiler/Driver/Standard/Output/Firebug.php +++ b/lib/Magento/Profiler/Driver/Standard/Output/Firebug.php @@ -25,7 +25,11 @@ */ namespace Magento\Profiler\Driver\Standard\Output; -class Firebug extends \Magento\Profiler\Driver\Standard\AbstractOutput +use Magento\Profiler; +use Magento\Profiler\Driver\Standard\AbstractOutput; +use Magento\Profiler\Driver\Standard\Stat; + +class Firebug extends AbstractOutput { /** * @var \Zend_Controller_Request_Abstract @@ -51,9 +55,10 @@ class Firebug extends \Magento\Profiler\Driver\Standard\AbstractOutput /** * Display profiling results and flush output buffer * - * @param \Magento\Profiler\Driver\Standard\Stat $stat + * @param Stat $stat + * @return void */ - public function display(\Magento\Profiler\Driver\Standard\Stat $stat) + public function display(Stat $stat) { $firebugMessage = new \Zend_Wildfire_Plugin_FirePhp_TableMessage($this->_renderCaption()); $firebugMessage->setHeader(array_keys($this->_columns)); @@ -90,7 +95,7 @@ class Firebug extends \Magento\Profiler\Driver\Standard\AbstractOutput */ protected function _renderTimerId($timerId) { - $nestingSep = preg_quote(\Magento\Profiler::NESTING_SEPARATOR, '/'); + $nestingSep = preg_quote(Profiler::NESTING_SEPARATOR, '/'); return preg_replace('/.+?' . $nestingSep . '/', '. ', $timerId); } @@ -98,6 +103,7 @@ class Firebug extends \Magento\Profiler\Driver\Standard\AbstractOutput * Request setter * * @param \Zend_Controller_Request_Abstract $request + * @return void */ public function setRequest(\Zend_Controller_Request_Abstract $request) { @@ -121,6 +127,7 @@ class Firebug extends \Magento\Profiler\Driver\Standard\AbstractOutput * Response setter * * @param \Zend_Controller_Response_Abstract $response + * @return void */ public function setResponse(\Zend_Controller_Response_Abstract $response) { diff --git a/lib/Magento/Profiler/Driver/Standard/Output/Html.php b/lib/Magento/Profiler/Driver/Standard/Output/Html.php index c1935d0fc78aed406fc69e3a78b04898b6f6ed7d..4edc2285537ddc2651e41ac7a2bb4940b349fd5f 100644 --- a/lib/Magento/Profiler/Driver/Standard/Output/Html.php +++ b/lib/Magento/Profiler/Driver/Standard/Output/Html.php @@ -25,14 +25,19 @@ */ namespace Magento\Profiler\Driver\Standard\Output; -class Html extends \Magento\Profiler\Driver\Standard\AbstractOutput +use Magento\Profiler; +use Magento\Profiler\Driver\Standard\AbstractOutput; +use Magento\Profiler\Driver\Standard\Stat; + +class Html extends AbstractOutput { /** * Display profiling results * - * @param \Magento\Profiler\Driver\Standard\Stat $stat + * @param Stat $stat + * @return void */ - public function display(\Magento\Profiler\Driver\Standard\Stat $stat) + public function display(Stat $stat) { $out = array(); $out[] = '<table border="1" cellspacing="0" cellpadding="2">'; @@ -65,7 +70,7 @@ class Html extends \Magento\Profiler\Driver\Standard\AbstractOutput */ protected function _renderTimerId($timerId) { - $nestingSep = preg_quote(\Magento\Profiler::NESTING_SEPARATOR, '/'); + $nestingSep = preg_quote(Profiler::NESTING_SEPARATOR, '/'); return preg_replace('/.+?' . $nestingSep . '/', '· ', $timerId); } } diff --git a/lib/Magento/Profiler/Driver/Standard/OutputInterface.php b/lib/Magento/Profiler/Driver/Standard/OutputInterface.php index 31757521d4e3b0973dcd6ed80674df90462789b3..282471c130b843def3e1ec574502d07ffeee29b7 100644 --- a/lib/Magento/Profiler/Driver/Standard/OutputInterface.php +++ b/lib/Magento/Profiler/Driver/Standard/OutputInterface.php @@ -30,7 +30,7 @@ interface OutputInterface /** * Display profiling results in appropriate format * - * @param \Magento\Profiler\Driver\Standard\Stat $stat + * @param Stat $stat */ - public function display(\Magento\Profiler\Driver\Standard\Stat $stat); + public function display(Stat $stat); } diff --git a/lib/Magento/Profiler/Driver/Standard/Stat.php b/lib/Magento/Profiler/Driver/Standard/Stat.php index 8c35a4948433beb802fba2c9f84d706651525ce7..b69bc441479072fac3cd83aa0eaaedb50c7ab96e 100644 --- a/lib/Magento/Profiler/Driver/Standard/Stat.php +++ b/lib/Magento/Profiler/Driver/Standard/Stat.php @@ -25,6 +25,8 @@ */ namespace Magento\Profiler\Driver\Standard; +use Magento\Profiler; + class Stat { /** @@ -55,6 +57,7 @@ class Stat * @param int $time * @param int $realMemory Real size of memory allocated from system * @param int $emallocMemory Memory used by emalloc() + * @return void */ public function start($timerId, $time, $realMemory, $emallocMemory) { @@ -81,6 +84,7 @@ class Stat * @param int $time * @param int $realMemory Real size of memory allocated from system * @param int $emallocMemory Memory used by emalloc() + * @return void * @throws \InvalidArgumentException if timer doesn't exist */ public function stop($timerId, $time, $realMemory, $emallocMemory) @@ -115,9 +119,9 @@ class Stat /** * Retrieve statistics on specified timer * - * @param $timerId + * @param string $timerId * @param string $key Information to return - * @return int|float + * @return string|bool|int|float * @throws \InvalidArgumentException */ public function fetch($timerId, $key) @@ -153,6 +157,7 @@ class Stat * Clear collected statistics for specified timer or for all timers if timer id is omitted * * @param string|null $timerId + * @return void */ public function clear($timerId = null) { @@ -212,7 +217,7 @@ class Stat } /* Prepare PCRE once to use it inside the loop body */ - $nestingSep = preg_quote(\Magento\Profiler::NESTING_SEPARATOR, '/'); + $nestingSep = preg_quote(Profiler::NESTING_SEPARATOR, '/'); $patternLastTimerId = '/' . $nestingSep . '(?:.(?!' . $nestingSep . '))+$/'; $prevTimerId = $timerIds[0]; @@ -224,10 +229,10 @@ class Stat continue; } /* Loop over all timers that need to be closed under previous timer */ - while (strpos($timerId, $prevTimerId . \Magento\Profiler::NESTING_SEPARATOR) !== 0) { + while (strpos($timerId, $prevTimerId . Profiler::NESTING_SEPARATOR) !== 0) { /* Add to result all timers nested in the previous timer */ for ($j = $i + 1; $j < count($timerIds); $j++) { - if (strpos($timerIds[$j], $prevTimerId . \Magento\Profiler::NESTING_SEPARATOR) === 0) { + if (strpos($timerIds[$j], $prevTimerId . Profiler::NESTING_SEPARATOR) === 0) { $result[] = $timerIds[$j]; /* Mark timer as already added */ $timerIds[$j] = null; diff --git a/lib/Magento/PubSub/Event.php b/lib/Magento/PubSub/Event.php index 7c610ba3a5bef0a5c7368d08aea31e61f0cd0e96..fd1a7cc44c345d682105d2277c9ce2fe10affdb0 100644 --- a/lib/Magento/PubSub/Event.php +++ b/lib/Magento/PubSub/Event.php @@ -27,23 +27,31 @@ */ namespace Magento\PubSub; -class Event implements \Magento\PubSub\EventInterface +class Event implements EventInterface { - /** @var int */ - protected $_status = \Magento\PubSub\EventInterface::STATUS_READY_TO_SEND; + /** + * @var int + */ + protected $_status = EventInterface::STATUS_READY_TO_SEND; - /** @var array */ + /** + * @var array + */ protected $_bodyData; - /** @var array */ + /** + * @var array + */ protected $_headers = array(); - /** @var string */ + /** + * @var string + */ protected $_topic; /** - * @param $topic - * @param $bodyData + * @param string $topic + * @param array $bodyData */ public function __construct($topic, $bodyData) { @@ -95,22 +103,22 @@ class Event implements \Magento\PubSub\EventInterface /** * Mark event as processed * - * @return \Magento\PubSub\Event + * @return $this */ public function complete() { - $this->_status = \Magento\PubSub\EventInterface::STATUS_PROCESSED; + $this->_status = EventInterface::STATUS_PROCESSED; return $this; } /** * Mark event as processed * - * @return \Magento\PubSub\Event + * @return $this */ public function markAsInProgress() { - $this->_status = \Magento\PubSub\EventInterface::STATUS_IN_PROGRESS; + $this->_status = EventInterface::STATUS_IN_PROGRESS; return $this; } } diff --git a/lib/Magento/PubSub/Event/QueueHandler.php b/lib/Magento/PubSub/Event/QueueHandler.php index b2398adf25b06988f297166a566b07cd0c24bfe0..ecdd3555637b1f69dbbcfad12004f9e14a2487fb 100644 --- a/lib/Magento/PubSub/Event/QueueHandler.php +++ b/lib/Magento/PubSub/Event/QueueHandler.php @@ -27,40 +27,44 @@ */ namespace Magento\PubSub\Event; +use Magento\PubSub\Job\FactoryInterface as JobFactoryInterface; +use Magento\PubSub\Job\QueueWriterInterface as JobQueueWriterInterface; +use Magento\PubSub\Subscription\CollectionInterface; + class QueueHandler { /** - * @var \Magento\PubSub\Event\QueueReaderInterface + * @var QueueReaderInterface */ protected $_eventQueue; /** - * @var \Magento\PubSub\Job\QueueWriterInterface + * @var JobQueueWriterInterface */ protected $_jobQueue; /** - * @var \Magento\PubSub\Job\FactoryInterface + * @var JobFactoryInterface */ protected $_jobFactory; /** - * @var \Magento\PubSub\Subscription\CollectionInterface + * @var CollectionInterface */ protected $_subscriptionSet; /** * Initialize the class * - * @param \Magento\PubSub\Event\QueueReaderInterface $eventQueue - * @param \Magento\PubSub\Job\QueueWriterInterface $jobQueue - * @param \Magento\PubSub\Job\FactoryInterface $jobFactory - * @param \Magento\PubSub\Subscription\CollectionInterface $subscriptionSet + * @param QueueReaderInterface $eventQueue + * @param JobQueueWriterInterface $jobQueue + * @param JobFactoryInterface $jobFactory + * @param CollectionInterface $subscriptionSet */ - public function __construct(\Magento\PubSub\Event\QueueReaderInterface $eventQueue, - \Magento\PubSub\Job\QueueWriterInterface $jobQueue, - \Magento\PubSub\Job\FactoryInterface $jobFactory, - \Magento\PubSub\Subscription\CollectionInterface $subscriptionSet + public function __construct(QueueReaderInterface $eventQueue, + JobQueueWriterInterface $jobQueue, + JobFactoryInterface $jobFactory, + CollectionInterface $subscriptionSet ) { $this->_eventQueue = $eventQueue; $this->_jobQueue = $jobQueue; @@ -70,6 +74,8 @@ class QueueHandler /** * Build job queue from event queue + * + * @return void */ public function handle() { diff --git a/lib/Magento/PubSub/Message/DispatcherAsync.php b/lib/Magento/PubSub/Message/DispatcherAsync.php index bdc5fe6ba91092dcc4e21a5d9d6535d1e82c6f14..950a67544fc757848aa5fb8487db031387c9bd0d 100644 --- a/lib/Magento/PubSub/Message/DispatcherAsync.php +++ b/lib/Magento/PubSub/Message/DispatcherAsync.php @@ -27,21 +27,24 @@ */ namespace Magento\PubSub\Message; -class DispatcherAsync implements \Magento\PubSub\Message\DispatcherAsyncInterface +use Magento\PubSub\Event\FactoryInterface; +use Magento\PubSub\Event\QueueWriterInterface; + +class DispatcherAsync implements DispatcherAsyncInterface { - /** @var \Magento\PubSub\Event\FactoryInterface */ + /** @var FactoryInterface */ protected $_eventFactory; - /** @var \Magento\PubSub\Event\QueueWriterInterface */ + /** @var QueueWriterInterface */ protected $_eventQueue; /** - * @param \Magento\PubSub\Event\FactoryInterface $eventFactory - * @param \Magento\PubSub\Event\QueueWriterInterface $eventQueue + * @param FactoryInterface $eventFactory + * @param QueueWriterInterface $eventQueue */ public function __construct( - \Magento\PubSub\Event\FactoryInterface $eventFactory, - \Magento\PubSub\Event\QueueWriterInterface $eventQueue + FactoryInterface $eventFactory, + QueueWriterInterface $eventQueue ) { $this->_eventFactory = $eventFactory; $this->_eventQueue = $eventQueue; @@ -52,6 +55,7 @@ class DispatcherAsync implements \Magento\PubSub\Message\DispatcherAsyncInterfac * * @param string $topic * @param array $data should only contain primitives, no objects. + * @return void */ public function dispatch($topic, $data) { diff --git a/lib/Magento/Service/Entity/AbstractDto.php b/lib/Magento/Service/Entity/AbstractDto.php index 27e19a2fba85a44bfb5a92f2dcaffce146d23d32..de1638f778c12a30ed439c449636ce8dc252e458 100644 --- a/lib/Magento/Service/Entity/AbstractDto.php +++ b/lib/Magento/Service/Entity/AbstractDto.php @@ -48,16 +48,30 @@ abstract class AbstractDto */ protected function _get($key) { - return isset($this->_data[$key]) ? $this->_data[$key]: null; + return isset($this->_data[$key]) ? $this->_data[$key] : null; } /** * Return DTO data in array format. * - * @return \ArrayAccess + * This only handles use cases of nested DTOs and array of DTOs + * + * @return array */ public function __toArray() { - return $this->_data; + $data = $this->_data; + foreach ($data as $key => $value) { + if (method_exists($value, '__toArray')) { + $data[$key] = $value->__toArray(); + } else if (is_array($value)) { + foreach ($value as $nestedArrayKey => $nestedArrayValue) { + if (method_exists($nestedArrayValue, '__toArray')) { + $data[$nestedArrayKey] = $nestedArrayValue->__toArray(); + } + } + } + } + return $data; } } diff --git a/lib/Magento/Service/Entity/AbstractDtoBuilder.php b/lib/Magento/Service/Entity/AbstractDtoBuilder.php index 4116091276708a999da66616817c8075ca178300..52e5164101212e934a005f3e5679fe932c37618a 100644 --- a/lib/Magento/Service/Entity/AbstractDtoBuilder.php +++ b/lib/Magento/Service/Entity/AbstractDtoBuilder.php @@ -42,7 +42,7 @@ abstract class AbstractDtoBuilder * Populates the fields with an existing entity. * * @param \Magento\Service\Entity\AbstractDto $prototype the prototype to base on - * @return $this + * @return AbstractDtoBuilder */ public function populate(\Magento\Service\Entity\AbstractDto $prototype) { @@ -75,6 +75,7 @@ abstract class AbstractDtoBuilder * Populates the fields with data from the array. * * @param array $data + * @return self */ public function populateWithArray(array $data) { @@ -100,7 +101,7 @@ abstract class AbstractDtoBuilder * @param string $key * @param mixed $value * - * @return AbstractDto + * @return self */ protected function _set($key, $value) { diff --git a/lib/Magento/Session/SidResolverInterface.php b/lib/Magento/Session/SidResolverInterface.php index 97ebdaefd0dafc8797a51d21697257fcd271ac73..5ab13fa9d4cf0fca76fa9c0ab9192bda4473c41d 100644 --- a/lib/Magento/Session/SidResolverInterface.php +++ b/lib/Magento/Session/SidResolverInterface.php @@ -48,4 +48,34 @@ interface SidResolverInterface * @return string */ public function getSessionIdQueryParam(\Magento\Session\SessionManagerInterface $session); + + /** + * Set use session var instead of SID for URL + * + * @param bool $var + * @return \Magento\Session\SidResolverInterface + */ + public function setUseSessionVar($var); + + /** + * Retrieve use flag session var instead of SID for URL + * + * @return bool + */ + public function getUseSessionVar(); + + /** + * Set Use session in URL flag + * + * @param bool $flag + * @return \Magento\Session\SidResolverInterface + */ + public function setUseSessionInUrl($flag = true); + + /** + * Retrieve use session in URL flag + * + * @return bool + */ + public function getUseSessionInUrl(); } diff --git a/lib/Magento/Simplexml/Config.php b/lib/Magento/Simplexml/Config.php index cd49ffc83cdac098901728721f96acf572b9d0c5..9d473010ec9e3d8280d822c7516d326f8f76f0c8 100644 --- a/lib/Magento/Simplexml/Config.php +++ b/lib/Magento/Simplexml/Config.php @@ -128,7 +128,7 @@ class Config * Sets xml for this configuration * * @param \Magento\Simplexml\Element $sourceData - * @return \Magento\Simplexml\Config + * @return $this */ public function setXml(\Magento\Simplexml\Element $node) { @@ -141,7 +141,7 @@ class Config * * @see \Magento\Simplexml\Element::descend * @param string $path - * @return \Magento\Simplexml\Element + * @return \Magento\Simplexml\Element|bool */ public function getNode($path=null) { @@ -158,7 +158,7 @@ class Config * Returns nodes found by xpath expression * * @param string $xpath - * @return array + * @return \SimpleXMLElement[]|bool */ public function getXpath($xpath) { @@ -177,7 +177,7 @@ class Config * Enter description here... * * @param \Magento\Simplexml\Config\Cache\AbstractCache $cache - * @return \Magento\Simplexml\Config + * @return $this */ public function setCache($cache) { @@ -199,7 +199,7 @@ class Config * Enter description here... * * @param boolean $flag - * @return \Magento\Simplexml\Config + * @return $this */ public function setCacheSaved($flag) { @@ -221,7 +221,7 @@ class Config * Enter description here... * * @param string $id - * @return \Magento\Simplexml\Config + * @return $this */ public function setCacheId($id) { @@ -243,7 +243,7 @@ class Config * Enter description here... * * @param array $tags - * @return \Magento\Simplexml\Config + * @return $this */ public function setCacheTags($tags) { @@ -265,7 +265,7 @@ class Config * Enter description here... * * @param int $lifetime - * @return \Magento\Simplexml\Config + * @return $this */ public function setCacheLifetime($lifetime) { @@ -287,7 +287,7 @@ class Config * Enter description here... * * @param string $data - * @return \Magento\Simplexml\Config + * @return $this */ public function setCacheChecksum($data) { @@ -305,7 +305,7 @@ class Config * Enter description here... * * @param string $data - * @return \Magento\Simplexml\Config + * @return $this */ public function updateCacheChecksum($data) { @@ -394,7 +394,7 @@ class Config * Enter description here... * * @param array $tags - * @return \Magento\Simplexml\Config + * @return $this */ public function saveCache($tags=null) { @@ -434,7 +434,7 @@ class Config /** * Enter description here... * - * @return \Magento\Simplexml\Config + * @return $this */ public function removeCache() { @@ -520,7 +520,7 @@ class Config * Imports DOM node * * @param \DOMNode $dom - * @return \Magento\Simplexml\Element + * @return bool */ public function loadDom($dom) { @@ -540,7 +540,7 @@ class Config * @param string $path separated by slashes * @param string $value * @param boolean $overwrite - * @return \Magento\Simplexml\Config + * @return $this */ public function setNode($path, $value, $overwrite=true) { @@ -551,7 +551,7 @@ class Config /** * Process configuration xml * - * @return \Magento\Simplexml\Config + * @return $this */ public function applyExtends() { @@ -590,7 +590,7 @@ class Config * * @param \Magento\Simplexml\Config $config * @param boolean $overwrite - * @return \Magento\Simplexml\Config + * @return $this */ public function extend(\Magento\Simplexml\Config $config, $overwrite=true) { @@ -603,6 +603,8 @@ class Config * * Destructor should be called explicitly in order to work around the PHP bug * https://bugs.php.net/bug.php?id=62468 + * + * @return void */ public function __destruct() { diff --git a/lib/Magento/Simplexml/Config/Cache/AbstractCache.php b/lib/Magento/Simplexml/Config/Cache/AbstractCache.php index a6763fcacc15038a471207d6e44541bba3f7695f..620f910f73bb78c4663ff923ab15b09479c58678 100644 --- a/lib/Magento/Simplexml/Config/Cache/AbstractCache.php +++ b/lib/Magento/Simplexml/Config/Cache/AbstractCache.php @@ -55,7 +55,7 @@ abstract class AbstractCache extends \Magento\Object * Add configuration component to stats * * @param string $component Filename of the configuration component file - * @return \Magento\Simplexml\Config\Cache\AbstractCache + * @return $this */ public function addComponent($component) { @@ -88,6 +88,9 @@ abstract class AbstractCache extends \Magento\Object return true; } + /** + * @return string + */ public function getComponentsHash() { $sum = ''; diff --git a/lib/Magento/Simplexml/Element.php b/lib/Magento/Simplexml/Element.php index 4ea15c9ee68b09b6e066dc046d06436842772a0b..43b2a2d897ac77efa4ce90f0212f5a61bd14436c 100644 --- a/lib/Magento/Simplexml/Element.php +++ b/lib/Magento/Simplexml/Element.php @@ -52,6 +52,7 @@ class Element extends \SimpleXMLElement * For future use * * @param \Magento\Simplexml\Element $element + * @return void */ public function setParent($element) { @@ -303,7 +304,7 @@ class Element extends \SimpleXMLElement /** * Converts meaningful xml characters to xml entities * - * @param string + * @param string $value * @return string */ public function xmlentities($value = null) @@ -326,7 +327,7 @@ class Element extends \SimpleXMLElement * Appends $source to current node * * @param \Magento\Simplexml\Element $source - * @return \Magento\Simplexml\Element + * @return $this */ public function appendChild($source) { @@ -356,7 +357,7 @@ class Element extends \SimpleXMLElement * * @param \Magento\Simplexml\Element $source * @param boolean $overwrite - * @return \Magento\Simplexml\Element + * @return $this */ public function extend($source, $overwrite=false) { @@ -376,7 +377,7 @@ class Element extends \SimpleXMLElement * * @param \Magento\Simplexml\Element $source * @param boolean $overwrite - * @return \Magento\Simplexml\Element + * @return $this */ public function extendChild($source, $overwrite=false) { @@ -432,6 +433,14 @@ class Element extends \SimpleXMLElement return $this; } + /** + * Set node + * + * @param string $path + * @param string $value + * @param bool $overwrite + * @return $this + */ public function setNode($path, $value, $overwrite=true) { $arr1 = explode('/', $path); @@ -462,6 +471,7 @@ class Element extends \SimpleXMLElement * Unset self from the XML-node tree * * Note: trying to refer this object as a variable after "unsetting" like this will result in E_WARNING + * @return void */ public function unsetSelf() { diff --git a/lib/Magento/Stdlib/ArrayUtils.php b/lib/Magento/Stdlib/ArrayUtils.php index 00a7c61c04f79b11703a35488633f815a243c608..a1252e67fb22e0c3bc31965c36fd4c55781e30e3 100644 --- a/lib/Magento/Stdlib/ArrayUtils.php +++ b/lib/Magento/Stdlib/ArrayUtils.php @@ -74,10 +74,10 @@ class ArrayUtils * $forceSetAll true will cause to set all possible values for all elements. * When false (default), only non-empty values will be set. * - * @param mixed $array + * @param array $array * @param string $prefix * @param bool $forceSetAll - * @return mixed + * @return array */ public function decorateArray($array, $prefix = 'decorated_', $forceSetAll = false) { @@ -127,7 +127,7 @@ class ArrayUtils * * @param \Magento\Object $element * @param string $key - * @param mixed $value + * @param bool $value * @param bool $isSkipped */ private function _decorateArrayObject($element, $key, $value, $isSkipped) diff --git a/lib/Magento/Stdlib/Cookie.php b/lib/Magento/Stdlib/Cookie.php index da0e34db5f323dfec39e9b7ce4c50ee4e8772a93..f938f233eefb003e1d0ad57a8eb315c9be6c22df 100644 --- a/lib/Magento/Stdlib/Cookie.php +++ b/lib/Magento/Stdlib/Cookie.php @@ -55,7 +55,7 @@ class Cookie * @param string $domain * @param bool|int|string $secure * @param bool|string $httponly - * @return \Magento\Stdlib\Cookie + * @return $this */ public function set($name, $value, $period = null, $path = null, $domain = null, $secure = null, $httponly = null) { @@ -90,7 +90,7 @@ class Cookie * @param string $domain * @param bool|int|string $secure * @param string|bool $httponly - * @return \Magento\Stdlib\Cookie + * @return $this */ public function renew($name, $period = null, $path = null, $domain = null, $secure = null, $httponly = null) { diff --git a/lib/Magento/Stdlib/DateTime/Timezone/Validator.php b/lib/Magento/Stdlib/DateTime/Timezone/Validator.php index 4e6d135adfedfa038d71828a97e467b65e73d2c8..145ff26a3af636ee40dfda67921fd0d76784cb78 100644 --- a/lib/Magento/Stdlib/DateTime/Timezone/Validator.php +++ b/lib/Magento/Stdlib/DateTime/Timezone/Validator.php @@ -56,6 +56,7 @@ class Validator * * @param int|string $timestamp * @param int|string $toDate + * @return void * @throws ValidationException */ public function validate($timestamp, $toDate) diff --git a/lib/Magento/Stdlib/String.php b/lib/Magento/Stdlib/String.php index c0f05ee9b79f35c6078ffc7dd835c467968fb09a..df392699af326f62f56b747df1e72000bd15efdc 100644 --- a/lib/Magento/Stdlib/String.php +++ b/lib/Magento/Stdlib/String.php @@ -86,7 +86,7 @@ class String * @param bool $keepWords * @param bool $trim * @param string $wordSeparatorRegex - * @return array + * @return string[] */ public function split($value, $length = 1, $keepWords = false, $trim = false, $wordSeparatorRegex = '\s') { diff --git a/lib/Magento/System/Args.php b/lib/Magento/System/Args.php index b108de896481e5eb882e80656d3b9490f1fe0cd8..90e1e1a14eae9b25a651224ee36eaaed12fc528f 100644 --- a/lib/Magento/System/Args.php +++ b/lib/Magento/System/Args.php @@ -31,7 +31,14 @@ namespace Magento\System; class Args { + /** + * @var array + */ public $flags; + + /** + * @var array + */ public $filtered; /** @@ -54,8 +61,9 @@ class Args /** * Constructor - * @param array $argv, if false $GLOBALS['argv'] is taken - * @return void + * Note: the array $argv, if false $GLOBALS['argv'] is taken + * + * @param bool $source */ public function __construct($source = false) { diff --git a/lib/Magento/System/Dirs.php b/lib/Magento/System/Dirs.php index 8caec6f6f9cec794d9d778d482fcb63d884dde63..7d9a079d299f0398425ca203e8a775398f5c4e42 100644 --- a/lib/Magento/System/Dirs.php +++ b/lib/Magento/System/Dirs.php @@ -29,7 +29,10 @@ namespace Magento\System; class Dirs { - + /** + * @param string[]|string $dirname + * @return bool + */ public static function rm($dirname) { if(is_array($dirname)) { @@ -78,9 +81,17 @@ class Dirs @closedir($dh); } return true; - } - - + } + + /** + * Attempts to create the directory + * + * @param string $path + * @param bool $recursive + * @param int $mode + * @return true + * @throws \Exception + */ public static function mkdirStrict($path, $recursive = true, $mode = 0777) { $exists = file_exists($path); @@ -96,7 +107,13 @@ class Dirs } return true; } - + + /** + * @param string $source + * @param string $dest + * @return void + * @throws \Exception + */ public static function copyFileStrict($source, $dest) { $exists = file_exists($source); diff --git a/lib/Magento/System/Ftp.php b/lib/Magento/System/Ftp.php index 9b729111d15c075450998ab2ec9c239ea9e851fb..2bbd7278ad5e39c01d978cac8525bda59bb804a0 100644 --- a/lib/Magento/System/Ftp.php +++ b/lib/Magento/System/Ftp.php @@ -59,8 +59,8 @@ class Ftp /** * ftp_mkdir wrapper * - * @param stin$name - * @return unknown_type + * @param string $name + * @return string the newly created directory name on success or <b>FALSE</b> on error. */ public function mdkir($name) { @@ -101,8 +101,8 @@ class Ftp * * @param string $login * @param string $password - * @throws \Exception on invalid login credentials * @return bool + * @throws \Exception on invalid login credentials */ public function login($login = "anonymous", $password = "test@gmail.com") { @@ -140,6 +140,8 @@ class Ftp * * @param string $string * @param int $timeout + * @return void + * @throws \Exception */ public function connect($string, $timeout = 900) { @@ -196,7 +198,7 @@ class Ftp /** * Get current working directory * - * @return mixed + * @return false|string */ public function getcwd() { @@ -217,9 +219,9 @@ class Ftp /** * ftp_raw wrapper - * + * * @param string $cmd - * @return mixed + * @return array The server's response as an array of strings. */ public function raw($cmd) { @@ -233,11 +235,12 @@ class Ftp * Can be used for relative and absoulte remote paths * Relative: use chdir before calling this * - * @param srting $remote + * @param string $remote * @param string $local * @param int $dirMode * @param int $ftpMode - * @return unknown_type + * @return bool + * @throws \Exception */ public function upload($remote, $local, $dirMode = 0777, $ftpMode = FTP_BINARY) { @@ -314,9 +317,9 @@ class Ftp /** * ftp_chmod wrapper * - * @param $mode - * @param $remoteFile - * @return bool + * @param int $mode + * @param string $remoteFile + * @return int The new file permissions on success or <b>FALSE</b> on error. */ public function chmod($mode, $remoteFile) { @@ -381,7 +384,7 @@ class Ftp * * @param string $dir * @param bool $recursive - * @return mixed + * @return array an array where each element corresponds to one line of text. */ public function rawlist( $dir = "/", $recursive = false ) { diff --git a/lib/Magento/Translate/AbstractAdapter.php b/lib/Magento/Translate/AbstractAdapter.php index adfe22013721dfa7f9ffa6fab212dd97ec7fd2b1..df06e19e49c40d530dcaf92ab6c6598017c62da1 100644 --- a/lib/Magento/Translate/AbstractAdapter.php +++ b/lib/Magento/Translate/AbstractAdapter.php @@ -31,7 +31,7 @@ namespace Magento\Translate; abstract class AbstractAdapter extends \Zend_Translate_Adapter - implements \Magento\Translate\AdapterInterface + implements AdapterInterface { /** * Load translation data @@ -54,9 +54,9 @@ abstract class AbstractAdapter extends \Zend_Translate_Adapter * * @SuppressWarnings(PHPMD.UnusedFormalParameter) * @param string $messageId - * @param boolean $original + * @param bool $original * @param null $locale - * @return boolean + * @return false */ public function isTranslated($messageId, $original = false, $locale = null) { @@ -68,7 +68,7 @@ abstract class AbstractAdapter extends \Zend_Translate_Adapter * * @SuppressWarnings(PHPMD.UnusedFormalParameter) * @param string|\Zend_Locale $locale - * @return \Zend_Translate_Adapter + * @return $this */ public function setLocale($locale) { diff --git a/lib/Magento/Translate/Adapter.php b/lib/Magento/Translate/Adapter.php index 8b9d81129a3c2fd79f41267c1a7e87b0f64484b0..17b3e6d7102193ff90a0c50a88dbaf01efbad339 100644 --- a/lib/Magento/Translate/Adapter.php +++ b/lib/Magento/Translate/Adapter.php @@ -30,7 +30,7 @@ */ namespace Magento\Translate; -class Adapter extends \Magento\Translate\AbstractAdapter +class Adapter extends AbstractAdapter { /** * Translate message string. diff --git a/app/code/Magento/Core/Model/Url.php b/lib/Magento/Url.php similarity index 60% rename from app/code/Magento/Core/Model/Url.php rename to lib/Magento/Url.php index 5130788181ad92036cd265618809ee5d65e1dcfb..94d5eb5662b6ea31f8b208ab4951d1779e4381c0 100644 --- a/app/code/Magento/Core/Model/Url.php +++ b/lib/Magento/Url.php @@ -33,7 +33,7 @@ * * - relative_url: true, false * - type: 'link', 'skin', 'js', 'media' - * - store: instanceof \Magento\Core\Model\Store + * - scope: instanceof \Magento\Url\ScopeInterface * - secure: true, false * * - scheme: 'http', 'https' @@ -44,7 +44,7 @@ * - base_path: '/dev/magento/' * - base_script: 'index.php' * - * - storeview_path: 'storeview/' + * - scopeview_path: 'scopeview/' * - route_path: 'module/controller/action/param1/value1/param2/value2' * - route_name: 'module' * - controller_name: 'controller' @@ -57,7 +57,7 @@ * * URL structure: * - * https://user:password@host:443/base_path/[base_script][storeview_path]route_name/controller_name/action_name/param1/value1?query_param=query_value#fragment + * https://user:password@host:443/base_path/[base_script][scopeview_path]route_name/controller_name/action_name/param1/value1?query_param=query_value#fragment * \__________A___________/\____________________________________B_____________________________________/ * \__________________C___________________/ \__________________D_________________/ \_____E_____/ * \_____________F______________/ \___________________________G______________________/ @@ -74,14 +74,9 @@ * * @category Magento * @package Magento_Core - * @author Magento Core Team <core@magentocommerce.com> + * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\Core\Model; - -use Magento\Core\Model\App; -use Magento\Core\Model\Session; -use Magento\Core\Model\Store; -use Magento\Core\Model\StoreManager; +namespace Magento; class Url extends \Magento\Object implements \Magento\UrlInterface { @@ -105,9 +100,9 @@ class Url extends \Magento\Object implements \Magento\UrlInterface * @var array */ protected $_reservedRouteParams = array( - '_store', '_type', '_secure', '_forced_secure', '_use_rewrite', '_nosid', + '_scope', '_type', '_secure', '_forced_secure', '_use_rewrite', '_nosid', '_absolute', '_current', '_direct', '_fragment', '_escape', '_query', - '_store_to_url' + '_scope_to_url' ); /** @@ -127,25 +122,10 @@ class Url extends \Magento\Object implements \Magento\UrlInterface /** * Url security info list * - * @var \Magento\Core\Model\Url\SecurityInfoInterface + * @var \Magento\Url\SecurityInfoInterface */ protected $_urlSecurityInfo; - /** - * @var \Magento\Core\Model\Store\Config - */ - protected $_coreStoreConfig; - - /** - * @var \Magento\Core\Model\App - */ - protected $_app; - - /** - * @var \Magento\Core\Model\StoreManagerInterface - */ - protected $_storeManager; - /** * @var \Magento\Core\Model\Session */ @@ -164,54 +144,53 @@ class Url extends \Magento\Object implements \Magento\UrlInterface protected $_routeConfig; /** - * @var string + * @var \Magento\Url\RouteParamsResolverInterface + */ + protected $_routeParamsResolver; + + /** + * @var \Magento\Url\ScopeResolverInterface + */ + protected $_scopeResolver; + + /** + * @var \Magento\Url\QueryParamsResolverInterface */ - protected $_areaCode; + protected $_queryParamsResolver; /** * @param \Magento\App\Route\ConfigInterface $routeConfig * @param \Magento\App\RequestInterface $request - * @param Url\SecurityInfoInterface $urlSecurityInfo - * @param Store\Config $coreStoreConfig - * @param App $app - * @param StoreManager $storeManager - * @param Session $session + * @param \Magento\Url\SecurityInfoInterface $urlSecurityInfo + * @param \Magento\Url\ScopeResolverInterface $scopeResolver + * @param \Magento\Session\Generic $session * @param \Magento\Session\SidResolverInterface $sidResolver - * @param null $areaCode + * @param \Magento\Url\RouteParamsResolverFactory $routeParamsResolver + * @param \Magento\Url\QueryParamsResolverInterface $queryParamsResolver * @param array $data */ public function __construct( \Magento\App\Route\ConfigInterface $routeConfig, \Magento\App\RequestInterface $request, - Url\SecurityInfoInterface $urlSecurityInfo, - \Magento\Core\Model\Store\Config $coreStoreConfig, - \Magento\Core\Model\App $app, - \Magento\Core\Model\StoreManagerInterface $storeManager, - \Magento\Core\Model\Session $session, + \Magento\Url\SecurityInfoInterface $urlSecurityInfo, + \Magento\Url\ScopeResolverInterface $scopeResolver, + \Magento\Session\Generic $session, \Magento\Session\SidResolverInterface $sidResolver, - $areaCode = null, + \Magento\Url\RouteParamsResolverFactory $routeParamsResolver, + \Magento\Url\QueryParamsResolverInterface $queryParamsResolver, array $data = array() ) { $this->_request = $request; $this->_routeConfig = $routeConfig; $this->_urlSecurityInfo = $urlSecurityInfo; - $this->_coreStoreConfig = $coreStoreConfig; - $this->_app = $app; - $this->_storeManager = $storeManager; + $this->_scopeResolver = $scopeResolver; $this->_session = $session; $this->_sidResolver = $sidResolver; - $this->_areaCode = $areaCode; + $this->_routeParamsResolver = $routeParamsResolver->create(); + $this->_queryParamsResolver = $queryParamsResolver; parent::__construct($data); } - /** - * Initialize object - */ - protected function _construct() - { - $this->setStore(null); - } - /** * Get default url type * @@ -219,16 +198,16 @@ class Url extends \Magento\Object implements \Magento\UrlInterface */ protected function _getDefaultUrlType() { - return \Magento\Core\Model\Store::URL_TYPE_LINK; + return \Magento\UrlInterface::URL_TYPE_LINK; } /** * Initialize object data from retrieved url * * @param string $url - * @return \Magento\Core\Model\Url + * @return \Magento\UrlInterface */ - public function parseUrl($url) + protected function _parseUrl($url) { $data = parse_url($url); $parts = array( @@ -254,28 +233,16 @@ class Url extends \Magento\Object implements \Magento\UrlInterface * * @return string */ - public function getDefaultControllerName() + protected function _getDefaultControllerName() { return self::DEFAULT_CONTROLLER_NAME; } - /** - * Set use_url_cache flag - * - * @param boolean $flag - * @return \Magento\Core\Model\Url - */ - public function setUseUrlCache($flag) - { - $this->setData('use_url_cache', $flag); - return $this; - } - /** * Set use session rule * * @param bool $useSession - * @return \Magento\Core\Model\Url + * @return \Magento\UrlInterface */ public function setUseSession($useSession) { @@ -287,9 +254,9 @@ class Url extends \Magento\Object implements \Magento\UrlInterface * Set route front name * * @param string $name - * @return \Magento\Core\Model\Url + * @return \Magento\UrlInterface */ - public function setRouteFrontName($name) + protected function _setRouteFrontName($name) { $this->setData('route_front_name', $name); return $this; @@ -303,7 +270,7 @@ class Url extends \Magento\Object implements \Magento\UrlInterface public function getUseSession() { if (is_null($this->_useSession)) { - $this->_useSession = $this->_app->getUseSessionInUrl(); + $this->_useSession = $this->_sidResolver->getUseSessionInUrl(); } return $this->_useSession; } @@ -313,7 +280,7 @@ class Url extends \Magento\Object implements \Magento\UrlInterface * * @return string */ - public function getDefaultActionName() + protected function _getDefaultActionName() { return self::DEFAULT_ACTION_NAME; } @@ -328,7 +295,7 @@ class Url extends \Magento\Object implements \Magento\UrlInterface public function getConfigData($key, $prefix = null) { if (is_null($prefix)) { - $prefix = 'web/' . ($this->isSecure() ? 'secure' : 'unsecure').'/'; + $prefix = 'web/' . ($this->_isSecure() ? 'secure' : 'unsecure').'/'; } $path = $prefix . $key; @@ -349,7 +316,7 @@ class Url extends \Magento\Object implements \Magento\UrlInterface */ protected function _getConfigCacheId($path) { - return $this->getStore()->getCode() . '/' . $path; + return $this->_getScope()->getCode() . '/' . $path; } /** @@ -360,14 +327,14 @@ class Url extends \Magento\Object implements \Magento\UrlInterface */ protected function _getConfig($path) { - return $this->getStore()->getConfig($path); + return $this->_getScope()->getConfig($path); } /** * Set request * * @param \Magento\App\RequestInterface $request - * @return \Magento\Core\Model\Url + * @return \Magento\UrlInterface */ public function setRequest(\Magento\App\RequestInterface $request) { @@ -380,7 +347,7 @@ class Url extends \Magento\Object implements \Magento\UrlInterface * * @return \Magento\App\RequestInterface */ - public function getRequest() + protected function _getRequest() { return $this->_request; } @@ -390,12 +357,22 @@ class Url extends \Magento\Object implements \Magento\UrlInterface * * @return string */ - public function getType() + protected function _getType() { - if (!$this->hasData('type')) { - $this->setData('type', $this->_getDefaultUrlType()); + if (!$this->_routeParamsResolver->hasData('type')) { + $this->_routeParamsResolver->setData('type', $this->_getDefaultUrlType()); } - return $this->_getData('type'); + return $this->_routeParamsResolver->getType(); + } + + /** + * @param string $type + * @return mixed + */ + public function setType($type) + { + $this->_routeParamsResolver->setType($type); + return $this; } /** @@ -403,51 +380,52 @@ class Url extends \Magento\Object implements \Magento\UrlInterface * * @return bool */ - public function isSecure() + protected function _isSecure() { - if ($this->hasData('secure_is_forced')) { - return (bool)$this->getData('secure'); + if ($this->_routeParamsResolver->hasData('secure_is_forced')) { + return (bool)$this->_routeParamsResolver->getData('secure'); } - if (!$this->getStore()->isUrlSecure()) { + if (!$this->_getScope()->isUrlSecure()) { return false; } - if (!$this->hasData('secure')) { - if ($this->getType() == \Magento\Core\Model\Store::URL_TYPE_LINK) { - $pathSecure = $this->_urlSecurityInfo->isSecure('/' . $this->getActionPath()); - $this->setData('secure', $pathSecure); + if (!$this->_routeParamsResolver->hasData('secure')) { + if ($this->_getType() == \Magento\UrlInterface::URL_TYPE_LINK) { + $pathSecure = $this->_urlSecurityInfo->isSecure('/' . $this->_getActionPath()); + $this->_routeParamsResolver->setData('secure', $pathSecure); } else { - $this->setData('secure', true); + $this->_routeParamsResolver->setData('secure', true); } } - return $this->getData('secure'); + return $this->_routeParamsResolver->getData('secure'); } /** - * Set store entity + * Set scope entity * * @param mixed $params - * @return \Magento\Core\Model\Url + * @return \Magento\UrlInterface */ - public function setStore($params) + public function setScope($params) { - $this->setData('store', $this->_storeManager->getStore($params)); + $this->setData('scope', $this->_scopeResolver->getScope($params)); + $this->_routeParamsResolver->setScope($this->_scopeResolver->getScope($params)); return $this; } /** - * Get current store for the url instance + * Get current scope for the url instance * - * @return \Magento\Core\Model\Store + * @return \Magento\Url\ScopeInterface */ - public function getStore() + protected function _getScope() { - if (!$this->hasData('store')) { - $this->setStore(null); + if (!$this->hasData('scope')) { + $this->setScope(null); } - return $this->_getData('store'); + return $this->_getData('scope'); } /** @@ -458,27 +436,27 @@ class Url extends \Magento\Object implements \Magento\UrlInterface */ public function getBaseUrl($params = array()) { - if (isset($params['_store'])) { - $this->setStore($params['_store']); + if (isset($params['_scope'])) { + $this->setScope($params['_scope']); } if (isset($params['_type'])) { - $this->setType($params['_type']); + $this->_routeParamsResolver->setType($params['_type']); } if (isset($params['_secure'])) { - $this->setSecure($params['_secure']); + $this->_routeParamsResolver->setSecure($params['_secure']); } /** - * Add availability support urls without store code + * Add availability support urls without scope code */ - if ($this->getType() == \Magento\Core\Model\Store::URL_TYPE_LINK - && $this->getRequest()->isDirectAccessFrontendName($this->getRouteFrontName())) { - $this->setType(\Magento\Core\Model\Store::URL_TYPE_DIRECT_LINK); + if ($this->_getType() == \Magento\UrlInterface::URL_TYPE_LINK + && $this->_getRequest()->isDirectAccessFrontendName($this->_getRouteFrontName())) { + $this->_routeParamsResolver->setType(\Magento\UrlInterface::URL_TYPE_DIRECT_LINK); } - $result = $this->getStore()->getBaseUrl($this->getType(), $this->isSecure()); - $this->setType($this->_getDefaultUrlType()); + $result = $this->_getScope()->getBaseUrl($this->_getType(), $this->_isSecure()); + $this->_routeParamsResolver->setType($this->_getDefaultUrlType()); return $result; } @@ -486,9 +464,9 @@ class Url extends \Magento\Object implements \Magento\UrlInterface * Set Route Parameters * * @param string $data - * @return \Magento\Core\Model\Url + * @return \Magento\UrlInterface */ - public function setRoutePath($data) + protected function _setRoutePath($data) { if ($this->_getData('route_path') == $data) { return $this; @@ -499,34 +477,34 @@ class Url extends \Magento\Object implements \Magento\UrlInterface $route = array_shift($routePieces); if ('*' === $route) { - $route = $this->getRequest()->getRequestedRouteName(); + $route = $this->_getRequest()->getRequestedRouteName(); } - $this->setRouteName($route); + $this->_setRouteName($route); $controller = ''; if (!empty($routePieces)) { $controller = array_shift($routePieces); if ('*' === $controller) { - $controller = $this->getRequest()->getRequestedControllerName(); + $controller = $this->_getRequest()->getRequestedControllerName(); } } - $this->setControllerName($controller); + $this->_setControllerName($controller); $action = ''; if (!empty($routePieces)) { $action = array_shift($routePieces); if ('*' === $action) { - $action = $this->getRequest()->getRequestedActionName(); + $action = $this->_getRequest()->getRequestedActionName(); } } - $this->setActionName($action); + $this->_setActionName($action); if (!empty($routePieces)) { while (!empty($routePieces)) { $key = array_shift($routePieces); if (!empty($routePieces)) { $value = array_shift($routePieces); - $this->setRouteParam($key, $value); + $this->_routeParamsResolver->setRouteParam($key, $value); } } } @@ -539,24 +517,24 @@ class Url extends \Magento\Object implements \Magento\UrlInterface * * @return string */ - public function getActionPath() + protected function _getActionPath() { - if (!$this->getRouteName()) { + if (!$this->_getRouteName()) { return ''; } - $hasParams = (bool) $this->getRouteParams(); - $path = $this->getRouteFrontName() . '/'; + $hasParams = (bool) $this->_getRouteParams(); + $path = $this->_getRouteFrontName() . '/'; - if ($this->getControllerName()) { - $path .= $this->getControllerName() . '/'; + if ($this->_getControllerName()) { + $path .= $this->_getControllerName() . '/'; } elseif ($hasParams) { - $path .= $this->getDefaultControllerName() . '/'; + $path .= $this->_getDefaultControllerName() . '/'; } - if ($this->getActionName()) { - $path .= $this->getActionName() . '/'; + if ($this->_getActionName()) { + $path .= $this->_getActionName() . '/'; } elseif ($hasParams) { - $path .= $this->getDefaultActionName() . '/'; + $path .= $this->_getDefaultActionName() . '/'; } return $path; @@ -568,17 +546,17 @@ class Url extends \Magento\Object implements \Magento\UrlInterface * @param array $routeParams * @return string */ - public function getRoutePath($routeParams = array()) + protected function _getRoutePath($routeParams = array()) { if (!$this->hasData('route_path')) { - $routePath = $this->getRequest()->getAlias(Url\Rewrite::REWRITE_REQUEST_PATH_ALIAS); + $routePath = $this->_getRequest()->getAlias(self::REWRITE_REQUEST_PATH_ALIAS); if (!empty($routeParams['_use_rewrite']) && ($routePath !== null)) { $this->setData('route_path', $routePath); return $routePath; } - $routePath = $this->getActionPath(); - if ($this->getRouteParams()) { - foreach ($this->getRouteParams() as $key=>$value) { + $routePath = $this->_getActionPath(); + if ($this->_getRouteParams()) { + foreach ($this->_getRouteParams() as $key=>$value) { if (is_null($value) || false === $value || '' === $value || !is_scalar($value)) { continue; } @@ -597,9 +575,9 @@ class Url extends \Magento\Object implements \Magento\UrlInterface * Set route name * * @param string $data - * @return \Magento\Core\Model\Url + * @return \Magento\UrlInterface */ - public function setRouteName($data) + protected function _setRouteName($data) { if ($this->_getData('route_name') == $data) { return $this; @@ -617,11 +595,14 @@ class Url extends \Magento\Object implements \Magento\UrlInterface * * @return string */ - public function getRouteFrontName() + protected function _getRouteFrontName() { if (!$this->hasData('route_front_name')) { - $frontName = $this->_routeConfig->getRouteFrontName($this->getRouteName(), $this->_areaCode); - $this->setRouteFrontName($frontName); + $frontName = $this->_routeConfig->getRouteFrontName( + $this->_getRouteName(), + $this->_scopeResolver->getAreaCode() + ); + $this->_setRouteFrontName($frontName); } return $this->_getData('route_front_name'); @@ -633,7 +614,7 @@ class Url extends \Magento\Object implements \Magento\UrlInterface * @param mixed $default * @return string|null */ - public function getRouteName($default = null) + protected function _getRouteName($default = null) { return $this->_getData('route_name') ? $this->_getData('route_name') : $default; } @@ -644,9 +625,9 @@ class Url extends \Magento\Object implements \Magento\UrlInterface * Reset action name and route path if has change * * @param string $data - * @return \Magento\Core\Model\Url + * @return \Magento\UrlInterface */ - public function setControllerName($data) + protected function _setControllerName($data) { if ($this->_getData('controller_name') == $data) { return $this; @@ -658,10 +639,9 @@ class Url extends \Magento\Object implements \Magento\UrlInterface /** * Retrieve controller name * - * @param mixed $default * @return string|null */ - public function getControllerName($default = null) + protected function _getControllerName() { return $this->_getData('controller_name') ? $this->_getData('controller_name') : null; } @@ -671,9 +651,9 @@ class Url extends \Magento\Object implements \Magento\UrlInterface * Reseted route path if action name has change * * @param string $data - * @return \Magento\Core\Model\Url + * @return \Magento\UrlInterface */ - public function setActionName($data) + protected function _setActionName($data) { if ($this->_getData('action_name') == $data) { return $this; @@ -688,7 +668,7 @@ class Url extends \Magento\Object implements \Magento\UrlInterface * @param mixed $default * @return string|null */ - public function getActionName($default = null) + protected function _getActionName($default = null) { return $this->_getData('action_name') ? $this->_getData('action_name') : $default; } @@ -698,78 +678,11 @@ class Url extends \Magento\Object implements \Magento\UrlInterface * * @param array $data * @param boolean $unsetOldParams - * @return \Magento\Core\Model\Url + * @return \Magento\UrlInterface */ - public function setRouteParams(array $data, $unsetOldParams = true) + protected function _setRouteParams(array $data, $unsetOldParams = true) { - if (isset($data['_type'])) { - $this->setType($data['_type']); - unset($data['_type']); - } - - if (isset($data['_store'])) { - $this->setStore($data['_store']); - unset($data['_store']); - } - - if (isset($data['_forced_secure'])) { - $this->setSecure((bool)$data['_forced_secure']); - $this->setSecureIsForced(true); - unset($data['_forced_secure']); - } elseif (isset($data['_secure'])) { - $this->setSecure((bool)$data['_secure']); - unset($data['_secure']); - } - - if (isset($data['_absolute'])) { - unset($data['_absolute']); - } - - if ($unsetOldParams) { - $this->unsetData('route_params'); - } - - $this->setUseUrlCache(true); - if (isset($data['_current'])) { - if (is_array($data['_current'])) { - foreach ($data['_current'] as $key) { - if (array_key_exists($key, $data) || !$this->getRequest()->getUserParam($key)) { - continue; - } - $data[$key] = $this->getRequest()->getUserParam($key); - } - } elseif ($data['_current']) { - foreach ($this->getRequest()->getUserParams() as $key => $value) { - if (array_key_exists($key, $data) || $this->getRouteParam($key)) { - continue; - } - $data[$key] = $value; - } - foreach ($this->getRequest()->getQuery() as $key => $value) { - $this->setQueryParam($key, $value); - } - $this->setUseUrlCache(false); - } - unset($data['_current']); - } - - if (isset($data['_use_rewrite'])) { - unset($data['_use_rewrite']); - } - - if (isset($data['_store_to_url']) && (bool)$data['_store_to_url'] === true) { - if (!$this->_coreStoreConfig->getConfig(\Magento\Core\Model\Store::XML_PATH_STORE_IN_URL, $this->getStore()) - && !$this->_storeManager->hasSingleStore() - ) { - $this->setQueryParam('___store', $this->getStore()->getCode()); - } - } - unset($data['_store_to_url']); - - foreach ($data as $k => $v) { - $this->setRouteParam($k, $v); - } - + $this->_routeParamsResolver->setRouteParams($data, $unsetOldParams); return $this; } @@ -778,38 +691,9 @@ class Url extends \Magento\Object implements \Magento\UrlInterface * * @return array */ - public function getRouteParams() + protected function _getRouteParams() { - return $this->_getData('route_params'); - } - - /** - * Set route param - * - * @param string $key - * @param mixed $data - * @return \Magento\Core\Model\Url - */ - public function setRouteParam($key, $data) - { - $params = $this->_getData('route_params'); - if (isset($params[$key]) && $params[$key] == $data) { - return $this; - } - $params[$key] = $data; - $this->unsetData('route_path'); - return $this->setData('route_params', $params); - } - - /** - * Retrieve route params - * - * @param string $key - * @return mixed - */ - public function getRouteParam($key) - { - return $this->getData('route_params', $key); + return $this->_routeParamsResolver->getRouteParams(); } /** @@ -825,50 +709,27 @@ class Url extends \Magento\Object implements \Magento\UrlInterface return $routePath; } - $this->unsetData('route_params'); + $this->_routeParamsResolver->unsetData('route_params'); if (isset($routeParams['_direct'])) { if (is_array($routeParams)) { - $this->setRouteParams($routeParams, false); + $this->_setRouteParams($routeParams, false); } return $this->getBaseUrl() . $routeParams['_direct']; } - $this->setRoutePath($routePath); + $this->_setRoutePath($routePath); if (is_array($routeParams)) { - $this->setRouteParams($routeParams, false); + $this->_setRouteParams($routeParams, false); } - $url = $this->getBaseUrl() . $this->getRoutePath($routeParams); - return $url; - } - - /** - * If the host was switched but session cookie won't recognize it - add session id to query - * - * @return \Magento\Core\Model\Url - */ - public function checkCookieDomains() - { - $hostArr = explode(':', $this->getRequest()->getServer('HTTP_HOST')); - if ($hostArr[0] !== $this->getHost()) { - if (!$this->_session->isValidForHost($this->getHost())) { - if (!self::$_encryptedSessionId) { - self::$_encryptedSessionId = $this->_session->getSessionId(); - } - $this->setQueryParam( - $this->_sidResolver->getSessionIdQueryParam($this->_session), - self::$_encryptedSessionId - ); - } - } - return $this; + return $this->getBaseUrl() . $this->_getRoutePath($routeParams); } /** * Add session param * - * @return \Magento\Core\Model\Url + * @return \Magento\UrlInterface */ public function addSessionParam() { @@ -883,15 +744,11 @@ class Url extends \Magento\Object implements \Magento\UrlInterface * Set URL query param(s) * * @param mixed $data - * @return \Magento\Core\Model\Url + * @return \Magento\UrlInterface */ - public function setQuery($data) + protected function _setQuery($data) { - if ($this->_getData('query') == $data) { - return $this; - } - $this->unsetData('query_params'); - return $this->setData('query', $data); + return $this->_queryParamsResolver->setQuery($data); } /** @@ -900,55 +757,31 @@ class Url extends \Magento\Object implements \Magento\UrlInterface * @param bool $escape "&" escape flag * @return string */ - public function getQuery($escape = false) + protected function _getQuery($escape = false) { - if (!$this->hasData('query')) { - $query = ''; - $params = $this->getQueryParams(); - if (is_array($params)) { - ksort($params); - $query = http_build_query($params, '', $escape ? '&' : '&'); - } - $this->setData('query', $query); - } - return $this->_getData('query'); + return $this->_queryParamsResolver->getQuery($escape); } /** * Set query Params as array * * @param array $data - * @return \Magento\Core\Model\Url + * @return \Magento\UrlInterface */ public function setQueryParams(array $data) { - $this->unsetData('query'); - - if ($this->_getData('query_params') == $data) { - return $this; - } - - $params = $this->_getData('query_params'); - if (!is_array($params)) { - $params = array(); - } - foreach ($data as $param => $value) { - $params[$param] = $value; - } - $this->setData('query_params', $params); - + $this->_queryParamsResolver->setQueryParams($data); return $this; } /** * Purge Query params array * - * @return \Magento\Core\Model\Url + * @return \Magento\UrlInterface */ public function purgeQueryParams() { - $this->setData('query_params', array()); - return $this; + return $this->_queryParamsResolver->purgeQueryParams(); } /** @@ -956,19 +789,9 @@ class Url extends \Magento\Object implements \Magento\UrlInterface * * @return array */ - public function getQueryParams() + protected function _getQueryParams() { - if (!$this->hasData('query_params')) { - $params = array(); - if ($this->_getData('query')) { - foreach (explode('&', $this->_getData('query')) as $param) { - $paramArr = explode('=', $param); - $params[$paramArr[0]] = urldecode($paramArr[1]); - } - } - $this->setData('query_params', $params); - } - return $this->_getData('query_params'); + return $this->_queryParamsResolver->getQueryParams(); } /** @@ -976,42 +799,11 @@ class Url extends \Magento\Object implements \Magento\UrlInterface * * @param string $key * @param mixed $data - * @return \Magento\Core\Model\Url + * @return \Magento\UrlInterface */ public function setQueryParam($key, $data) { - $params = $this->getQueryParams(); - if (isset($params[$key]) && $params[$key] == $data) { - return $this; - } - $params[$key] = $data; - $this->unsetData('query'); - return $this->setData('query_params', $params); - } - - /** - * Retrieve query param - * - * @param string $key - * @return mixed - */ - public function getQueryParam($key) - { - if (!$this->hasData('query_params')) { - $this->getQueryParams(); - } - return $this->getData('query_params', $key); - } - - /** - * Set fragment to URL - * - * @param string $data - * @return \Magento\Core\Model\Url - */ - public function setFragment($data) - { - return $this->setData('fragment', $data); + return $this->_queryParamsResolver->setQueryParam($key, $data); } /** @@ -1019,7 +811,7 @@ class Url extends \Magento\Object implements \Magento\UrlInterface * * @return string|null */ - public function getFragment() + protected function _getFragment() { return $this->_getData('fragment'); } @@ -1073,7 +865,7 @@ class Url extends \Magento\Object implements \Magento\UrlInterface */ if ($query !== null) { if (is_string($query)) { - $this->setQuery($query); + $this->_setQuery($query); } elseif (is_array($query)) { $this->setQueryParams($query, !empty($routeParams['_current'])); } @@ -1086,12 +878,12 @@ class Url extends \Magento\Object implements \Magento\UrlInterface $this->_prepareSessionUrl($url); } - $query = $this->getQuery($escapeQuery); + $query = $this->_getQuery($escapeQuery); if ($query) { $mark = (strpos($url, '?') === false) ? '?' : ($escapeQuery ? '&' : '&'); $url .= $mark . $query; - $this->unsetData('query'); - $this->unsetData('query_params'); + $this->_queryParamsResolver->unsetData('query'); + $this->_queryParamsResolver->unsetData('query_params'); } if (!is_null($fragment)) { @@ -1106,7 +898,7 @@ class Url extends \Magento\Object implements \Magento\UrlInterface * * @param string $url * - * @return \Magento\Core\Model\Url + * @return \Magento\UrlInterface */ protected function _prepareSessionUrl($url) { @@ -1119,7 +911,7 @@ class Url extends \Magento\Object implements \Magento\UrlInterface * @param string $url * @param array $params * - * @return \Magento\Core\Model\Url + * @return \Magento\UrlInterface */ protected function _prepareSessionUrlWithParams($url, array $params) { @@ -1127,8 +919,8 @@ class Url extends \Magento\Object implements \Magento\UrlInterface return $this; } $sessionId = $this->_session->getSessionIdForHost($url); - if ($this->_app->getUseSessionVar() && !$sessionId) { - $this->setQueryParam('___SID', $this->isSecure() ? 'S' : 'U'); // Secure/Unsecure + if ($this->_sidResolver->getUseSessionVar() && !$sessionId) { + $this->setQueryParam('___SID', $this->_isSecure() ? 'S' : 'U'); // Secure/Unsecure } else if ($sessionId) { $this->setQueryParam($this->_sidResolver->getSessionIdQueryParam($this->_session), $sessionId); } @@ -1143,7 +935,7 @@ class Url extends \Magento\Object implements \Magento\UrlInterface */ public function getRebuiltUrl($url) { - $this->parseUrl($url); + $this->_parseUrl($url); $port = $this->getPort(); if ($port) { $port = ':' . $port; @@ -1154,12 +946,12 @@ class Url extends \Magento\Object implements \Magento\UrlInterface $this->_prepareSessionUrl($url); - $query = $this->getQuery(); + $query = $this->_getQuery(); if ($query) { $url .= '?' . $query; } - $fragment = $this->getFragment(); + $fragment = $this->_getFragment(); if ($fragment) { $url .= '#' . $fragment; } @@ -1204,7 +996,7 @@ class Url extends \Magento\Object implements \Magento\UrlInterface public function sessionUrlVar($html) { return preg_replace_callback('#(\?|&|&)___SID=([SU])(&|&)?#', - array($this, "sessionVarCallback"), $html); + array($this, "_sessionVarCallback"), $html); } /** @@ -1218,7 +1010,7 @@ class Url extends \Magento\Object implements \Magento\UrlInterface $key = 'use_session_id_for_url_' . (int) $secure; if (is_null($this->getData($key))) { $httpHost = $this->_request->getHttpHost(); - $urlHost = parse_url($this->getStore()->getBaseUrl(\Magento\Core\Model\Store::URL_TYPE_LINK, $secure), + $urlHost = parse_url($this->_getScope()->getBaseUrl(\Magento\UrlInterface::URL_TYPE_LINK, $secure), PHP_URL_HOST); if ($httpHost != $urlHost) { @@ -1236,7 +1028,7 @@ class Url extends \Magento\Object implements \Magento\UrlInterface * @param array $match * @return string */ - public function sessionVarCallback($match) + protected function _sessionVarCallback($match) { if ($this->useSessionIdForUrl($match[2] == 'S' ? true : false)) { return $match[1] @@ -1258,22 +1050,22 @@ class Url extends \Magento\Object implements \Magento\UrlInterface } /** - * Check if users originated URL is one of the domain URLs assigned to stores + * Check if users originated URL is one of the domain URLs assigned to scopes * * @return boolean */ public function isOwnOriginUrl() { - $storeDomains = array(); - $referer = parse_url($this->_app->getRequest()->getServer('HTTP_REFERER'), PHP_URL_HOST); - foreach ($this->_storeManager->getStores() as $store) { - $storeDomains[] = parse_url($store->getBaseUrl(), PHP_URL_HOST); - $storeDomains[] = parse_url($store->getBaseUrl( - \Magento\Core\Model\Store::URL_TYPE_LINK, true), PHP_URL_HOST + $scopeDomains = array(); + $referer = parse_url($this->_request->getServer('HTTP_REFERER'), PHP_URL_HOST); + foreach ($this->_scopeResolver->getScopes() as $scope) { + $scopeDomains[] = parse_url($scope->getBaseUrl(), PHP_URL_HOST); + $scopeDomains[] = parse_url($scope->getBaseUrl( + \Magento\UrlInterface::URL_TYPE_LINK, true), PHP_URL_HOST ); } - $storeDomains = array_unique($storeDomains); - if (empty($referer) || in_array($referer, $storeDomains)) { + $scopeDomains = array_unique($scopeDomains); + if (empty($referer) || in_array($referer, $scopeDomains)) { return true; } return false; @@ -1289,10 +1081,10 @@ class Url extends \Magento\Object implements \Magento\UrlInterface public function getRedirectUrl($url) { $this->_prepareSessionUrlWithParams($url, array( - 'name' => \Magento\Core\App\Action\Plugin\LastUrl::SESSION_NAMESPACE + 'name' => self::SESSION_NAMESPACE )); - $query = $this->getQuery(false); + $query = $this->_getQuery(false); if ($query) { $url .= (strpos($url, '?') === false ? '?' : '&') . $query; } @@ -1317,7 +1109,7 @@ class Url extends \Magento\Object implements \Magento\UrlInterface } $requestUri = $this->_request->getServer('REQUEST_URI'); $url = $this->_request->getScheme() . '://' . $this->_request->getHttpHost() - . $port . $requestUri; + . $port . $requestUri; return $url; } } diff --git a/lib/Magento/Url/QueryParamsResolver.php b/lib/Magento/Url/QueryParamsResolver.php new file mode 100644 index 0000000000000000000000000000000000000000..237bd9e4ea882ed66c38b85a1acf1cacfe79e794 --- /dev/null +++ b/lib/Magento/Url/QueryParamsResolver.php @@ -0,0 +1,124 @@ +<?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\Url; + +class QueryParamsResolver extends \Magento\Object implements QueryParamsResolverInterface +{ + /** + * {@inheritdoc} + */ + public function getQuery($escape = false) + { + if (!$this->hasData('query')) { + $query = ''; + $params = $this->getQueryParams(); + if (is_array($params)) { + ksort($params); + $query = http_build_query($params, '', $escape ? '&' : '&'); + } + $this->setData('query', $query); + } + return $this->_getData('query'); + } + + /** + * {@inheritdoc} + */ + public function setQuery($data) + { + if ($this->_getData('query') == $data) { + return $this; + } + $this->unsetData('query_params'); + $this->setData('query', $data); + return $this; + } + + + /** + * {@inheritdoc} + */ + public function setQueryParam($key, $data) + { + $params = $this->getQueryParams(); + if (isset($params[$key]) && $params[$key] == $data) { + return $this; + } + $params[$key] = $data; + $this->unsetData('query'); + $this->setData('query_params', $params); + return $this; + } + + /** + * {@inheritdoc} + */ + public function getQueryParams() + { + if (!$this->hasData('query_params')) { + $params = array(); + if ($this->_getData('query')) { + foreach (explode('&', $this->_getData('query')) as $param) { + $paramArr = explode('=', $param); + $params[$paramArr[0]] = urldecode($paramArr[1]); + } + } + $this->setData('query_params', $params); + } + return $this->_getData('query_params'); + } + + /** + * {@inheritdoc} + */ + public function purgeQueryParams() + { + $this->setData('query_params', array()); + return $this; + } + + /** + * {@inheritdoc} + */ + public function setQueryParams(array $data) + { + $this->unsetData('query'); + + if ($this->_getData('query_params') == $data) { + return $this; + } + + $params = $this->_getData('query_params'); + if (!is_array($params)) { + $params = array(); + } + foreach ($data as $param => $value) { + $params[$param] = $value; + } + $this->setData('query_params', $params); + + return $this; + } +} diff --git a/lib/Magento/Url/QueryParamsResolverInterface.php b/lib/Magento/Url/QueryParamsResolverInterface.php new file mode 100644 index 0000000000000000000000000000000000000000..5e7af7c4bb6939702cb5fef0b471d1c1fe724ab6 --- /dev/null +++ b/lib/Magento/Url/QueryParamsResolverInterface.php @@ -0,0 +1,83 @@ +<?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\Url; + +interface QueryParamsResolverInterface +{ + /** + * Get query params part of url + * + * @param bool $escape "&" escape flag + * @return string + */ + public function getQuery($escape = false); + + /** + * Set URL query param(s) + * + * @param mixed $data + * @return \Magento\Url\QueryParamsResolverInterface + */ + public function setQuery($data); + + /** + * Set query param + * + * @param string $key + * @param mixed $data + * @return \Magento\Url\QueryParamsResolverInterface + */ + public function setQueryParam($key, $data); + + /** + * Return Query Params + * + * @return array + */ + public function getQueryParams(); + + /** + * Purge Query params array + * + * @return \Magento\Url\QueryParamsResolverInterface + */ + public function purgeQueryParams(); + + /** + * Set query Params as array + * + * @param array $data + * @return \Magento\Url\QueryParamsResolverInterface + */ + public function setQueryParams(array $data); + + /** + * Unset data from the object. + * + * @param null|string|array $key + * @return \Magento\Object + */ + public function unsetData($key = null); +} diff --git a/lib/Magento/Url/RouteParamsResolverFactory.php b/lib/Magento/Url/RouteParamsResolverFactory.php new file mode 100644 index 0000000000000000000000000000000000000000..02ecc71fcdde536d2a2b418262f060edfa2f3239 --- /dev/null +++ b/lib/Magento/Url/RouteParamsResolverFactory.php @@ -0,0 +1,61 @@ +<?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\Url; + +class RouteParamsResolverFactory +{ + /** + * @var \Magento\ObjectManager + */ + protected $_objectManager; + + /** + * @var string + */ + protected $_instanceName; + + /** + * @param \Magento\ObjectManager $objectManager + * @param string $instanceName + */ + public function __construct( + \Magento\ObjectManager $objectManager, + $instanceName = 'Magento\Url\RouteParamsResolverInterface' + ) { + $this->_objectManager = $objectManager; + $this->_instanceName = $instanceName; + } + + /** + * Create RouteParamsResolverInterface instance + * + * @param array $data + * @return \Magento\Url\RouteParamsResolverInterface + */ + public function create(array $data = array()) + { + return $this->_objectManager->create($this->_instanceName, $data); + } +} diff --git a/lib/Magento/Url/RouteParamsResolverInterface.php b/lib/Magento/Url/RouteParamsResolverInterface.php new file mode 100644 index 0000000000000000000000000000000000000000..bedcbe0ffee508739ef4d53145cf32f5416eaee1 --- /dev/null +++ b/lib/Magento/Url/RouteParamsResolverInterface.php @@ -0,0 +1,61 @@ +<?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\Url; + +interface RouteParamsResolverInterface +{ + /** + * Set route params + * + * @param array $data + * @param boolean $unsetOldParams + * @return RouteParamsResolverInterface + */ + public function setRouteParams(array $data, $unsetOldParams = true); + + /** + * Set route param + * + * @param string $key + * @param mixed $data + * @return RouteParamsResolverInterface + */ + public function setRouteParam($key, $data); + + /** + * Retrieve route params + * + * @return array + */ + public function getRouteParams(); + + /** + * Retrieve route param + * + * @param string $key + * @return mixed + */ + public function getRouteParam($key); +} diff --git a/lib/Magento/Url/ScopeInterface.php b/lib/Magento/Url/ScopeInterface.php new file mode 100644 index 0000000000000000000000000000000000000000..db23cf136dd1adba89ec6053a5d223bb74e2688c --- /dev/null +++ b/lib/Magento/Url/ScopeInterface.php @@ -0,0 +1,59 @@ +<?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\Url; + +interface ScopeInterface +{ + /** + * Retrieve base URL + * + * @param string $type + * @param boolean|null $secure + * @return string + */ + public function getBaseUrl($type = '', $secure = null); + + /** + * Retrieve scope code + * + * @return string + */ + public function getCode(); + + /** + * Retrieve scope configuration data + * + * @param string $path + * @return string|null + */ + public function getConfig($path); + + /** + * Check is URL should be secure + * + * @return boolean + */ + public function isUrlSecure(); +} diff --git a/lib/Magento/Url/ScopeResolverInterface.php b/lib/Magento/Url/ScopeResolverInterface.php new file mode 100644 index 0000000000000000000000000000000000000000..7bce54e3139f9c9b0cccb7c03746d820e9c3ffb5 --- /dev/null +++ b/lib/Magento/Url/ScopeResolverInterface.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\Url; + +interface ScopeResolverInterface +{ + + /** + * Retrieve application scope object + * + * @param null|int $scopeId + * @return \Magento\Url\ScopeInterface + */ + public function getScope($scopeId = null); + + /** + * Retrieve scopes array + * + * @return \Magento\Url\ScopeInterface[] + */ + public function getScopes(); + + /** + * Retrieve area code + * + * @return \Magento\Url\ScopeInterface[] + */ + public function getAreaCode(); +} diff --git a/app/code/Magento/Core/Model/Url/SecurityInfoInterface.php b/lib/Magento/Url/SecurityInfoInterface.php similarity index 97% rename from app/code/Magento/Core/Model/Url/SecurityInfoInterface.php rename to lib/Magento/Url/SecurityInfoInterface.php index aee94bff02538c4d7f688185e3b65dc09189b3c2..049a01afce8dda9f095c6bc7fc2928be1cefec90 100644 --- a/app/code/Magento/Core/Model/Url/SecurityInfoInterface.php +++ b/lib/Magento/Url/SecurityInfoInterface.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\Url; +namespace Magento\Url; interface SecurityInfoInterface { diff --git a/lib/Magento/UrlFactory.php b/lib/Magento/UrlFactory.php new file mode 100644 index 0000000000000000000000000000000000000000..f32d51ebb79f1a8ec0adad08e68bcddcd227817d --- /dev/null +++ b/lib/Magento/UrlFactory.php @@ -0,0 +1,59 @@ +<?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; + +class UrlFactory +{ + /** + * @var \Magento\ObjectManager + */ + protected $_objectManager = null; + + /** + * @var string + */ + protected $_instanceName = null; + + /** + * @param \Magento\ObjectManager $objectManager + * @param string $instanceName + */ + public function __construct(\Magento\ObjectManager $objectManager, $instanceName = 'Magento\UrlInterface') + { + $this->_objectManager = $objectManager; + $this->_instanceName = $instanceName; + } + + /** + * Create Url instance with specified parameters + * + * @param array $data + * @return \Magento\UrlInterface + */ + public function create(array $data = array()) + { + return $this->_objectManager->create($this->_instanceName, $data); + } +} diff --git a/lib/Magento/UrlInterface.php b/lib/Magento/UrlInterface.php index ee4a6d0fdcc7bccbeb6cba9538161d9ef7de4a02..7d096a94c900c7129c622cf6e8927f3f9099f09b 100644 --- a/lib/Magento/UrlInterface.php +++ b/lib/Magento/UrlInterface.php @@ -25,6 +25,18 @@ namespace Magento; interface UrlInterface { + /** + * Possible URL types + */ + const URL_TYPE_LINK = 'link'; + const URL_TYPE_DIRECT_LINK = 'direct_link'; + const URL_TYPE_WEB = 'web'; + const URL_TYPE_LIB = 'lib'; + const URL_TYPE_MEDIA = 'media'; + const URL_TYPE_STATIC = 'static'; + const URL_TYPE_CACHE = 'cache'; + const URL_TYPE_JS = 'js'; + /** * Default controller name */ @@ -36,51 +48,14 @@ interface UrlInterface const DEFAULT_ACTION_NAME = 'index'; /** - * Configuration paths - */ - const XML_PATH_UNSECURE_URL = 'web/unsecure/base_url'; - const XML_PATH_SECURE_URL = 'web/secure/base_url'; - const XML_PATH_SECURE_IN_ADMIN = 'web/secure/use_in_adminhtml'; - const XML_PATH_SECURE_IN_FRONT = 'web/secure/use_in_frontend'; - - /** - * Initialize object data from retrieved url - * - * @param string $url - * @return \Magento\UrlInterface - */ - public function parseUrl($url); - - /** - * Retrieve default controller name - * - * @return string - */ - public function getDefaultControllerName(); - - /** - * Set use_url_cache flag - * - * @param boolean $flag - * @return \Magento\UrlInterface - */ - public function setUseUrlCache($flag); - - /** - * Set use session rule - * - * @param bool $useSession - * @return \Magento\UrlInterface + * Rewrite request path alias */ - public function setUseSession($useSession); + const REWRITE_REQUEST_PATH_ALIAS = 'rewrite_request_path'; /** - * Set route front name - * - * @param string $name - * @return \Magento\UrlInterface + * Session namespace to refer in other places */ - public function setRouteFrontName($name); + const SESSION_NAMESPACE = 'frontend'; /** * Retrieve use session rule @@ -89,51 +64,6 @@ interface UrlInterface */ public function getUseSession(); - /** - * Retrieve default action name - * - * @return string - */ - public function getDefaultActionName(); - - /** - * Retrieve configuration data - * - * @param string $key - * @param string|null $prefix - * @return string - */ - public function getConfigData($key, $prefix = null); - - /** - * Set request - * - * @param \Magento\App\RequestInterface $request - * @return \Magento\UrlInterface - */ - public function setRequest(\Magento\App\RequestInterface $request); - - /** - * Zend request object - * - * @return \Magento\App\RequestInterface - */ - public function getRequest(); - - /** - * Retrieve URL type - * - * @return string - */ - public function getType(); - - /** - * Retrieve is secure mode URL - * - * @return bool - */ - public function isSecure(); - /** * Retrieve Base URL * @@ -149,120 +79,6 @@ interface UrlInterface */ public function getCurrentUrl(); - /** - * Set Route Parameters - * - * @param array $data - * @return \Magento\UrlInterface - */ - public function setRoutePath($data); - - /** - * Retrieve action path - * - * @return string - */ - public function getActionPath(); - - /** - * Retrieve route path - * - * @param array $routeParams - * @return string - */ - public function getRoutePath($routeParams = array()); - - /** - * Set route name - * - * @param string $data - * @return \Magento\UrlInterface - */ - public function setRouteName($data); - - /** - * Retrieve route front name - * - * @return string - */ - public function getRouteFrontName(); - - /** - * Retrieve route name - * - * @param mixed $default - * @return string|null - */ - public function getRouteName($default = null); - - /** - * Set Controller Name - * - * Reset action name and route path if has change - * - * @param string $data - * @return \Magento\UrlInterface - */ - public function setControllerName($data); - - /** - * Retrieve controller name - * - * @param mixed $default - * @return string|null - */ - public function getControllerName($default = null); - - /** - * Set Action name - * Reseted route path if action name has change - * - * @param string $data - * @return \Magento\UrlInterface - */ - public function setActionName($data); - - /** - * Retrieve action name - * - * @param mixed $default - * @return string|null - */ - public function getActionName($default = null); - - /** - * Set route params - * - * @param array $data - * @param boolean $unsetOldParams - * @return \Magento\UrlInterface - */ - public function setRouteParams(array $data, $unsetOldParams = true); - - /** - * Retrieve route params - * - * @return array - */ - public function getRouteParams(); - - /** - * Set route param - * - * @param string $key - * @param mixed $data - * @return \Magento\UrlInterface - */ - public function setRouteParam($key, $data); - - /** - * Retrieve route params - * - * @param string $key - * @return mixed - */ - public function getRouteParam($key); - /** * Retrieve route URL * @@ -272,13 +88,6 @@ interface UrlInterface */ public function getRouteUrl($routePath = null, $routeParams = null); - /** - * If the host was switched but session cookie won't recognize it - add session id to query - * - * @return \Magento\UrlInterface - */ - public function checkCookieDomains(); - /** * Add session param * @@ -286,22 +95,6 @@ interface UrlInterface */ public function addSessionParam(); - /** - * Set URL query param(s) - * - * @param mixed $data - * @return \Magento\UrlInterface - */ - public function setQuery($data); - - /** - * Get query params part of url - * - * @param bool $escape "&" escape flag - * @return string - */ - public function getQuery($escape = false); - /** * Set query Params as array * @@ -310,20 +103,6 @@ interface UrlInterface */ public function setQueryParams(array $data); - /** - * Purge Query params array - * - * @return \Magento\UrlInterface - */ - public function purgeQueryParams(); - - /** - * Return Query Params - * - * @return array - */ - public function getQueryParams(); - /** * Set query param * @@ -333,29 +112,6 @@ interface UrlInterface */ public function setQueryParam($key, $data); - /** - * Retrieve query param - * - * @param string $key - * @return mixed - */ - public function getQueryParam($key); - - /** - * Set fragment to URL - * - * @param string $data - * @return \Magento\UrlInterface - */ - public function setFragment($data); - - /** - * Retrieve URL fragment - * - * @return string|null - */ - public function getFragment(); - /** * Build url by requested path and parameters * @@ -365,14 +121,6 @@ interface UrlInterface */ public function getUrl($routePath = null, $routeParams = null); - /** - * Rebuild URL to handle the case when session ID was changed - * - * @param string $url - * @return string - */ - public function getRebuiltUrl($url); - /** * Escape (enclosure) URL string * @@ -398,22 +146,6 @@ interface UrlInterface */ public function sessionUrlVar($html); - /** - * Check and return use SID for URL - * - * @param bool $secure - * @return bool - */ - public function useSessionIdForUrl($secure = false); - - /** - * Callback function for session replace - * - * @param array $match - * @return string - */ - public function sessionVarCallback($match); - /** * Check if users originated URL is one of the domain URLs assigned to stores * @@ -429,4 +161,12 @@ interface UrlInterface * @return string */ public function getRedirectUrl($url); + + /** + * Set scope entity + * + * @param mixed $params + * @return \Magento\UrlInterface + */ + public function setScope($params); } diff --git a/lib/Magento/Validator/AbstractValidator.php b/lib/Magento/Validator/AbstractValidator.php index 303153079b1a31d8fb315ec7b5fc882156547a4d..15fbabc5dbb019738b4c5a8095f541e66ea0a362 100644 --- a/lib/Magento/Validator/AbstractValidator.php +++ b/lib/Magento/Validator/AbstractValidator.php @@ -48,6 +48,7 @@ abstract class AbstractValidator implements \Magento\Validator\ValidatorInterfac * Set default translator instance * * @param \Magento\Translate\AdapterInterface|null $translator + * @return void */ public static function setDefaultTranslator(\Magento\Translate\AdapterInterface $translator = null) { @@ -111,6 +112,8 @@ abstract class AbstractValidator implements \Magento\Validator\ValidatorInterfac /** * Clear messages + * + * @return void */ protected function _clearMessages() { @@ -121,6 +124,7 @@ abstract class AbstractValidator implements \Magento\Validator\ValidatorInterfac * Add messages * * @param array $messages + * @return void */ protected function _addMessages(array $messages) { diff --git a/lib/Magento/Validator/Builder.php b/lib/Magento/Validator/Builder.php index 1e1350f9ee703e4bba6dd48df8647638c850bc85..2d9c76969aa8619d34cb7e2cf6aba73c2fde09a8 100644 --- a/lib/Magento/Validator/Builder.php +++ b/lib/Magento/Validator/Builder.php @@ -25,6 +25,8 @@ */ namespace Magento\Validator; +use Magento\Validator\Constraint\OptionInterface; + class Builder { /** @@ -76,6 +78,7 @@ class Builder * * @param array $configuration * @param bool $argumentsIsArray + * @return void * @throws \InvalidArgumentException */ protected function _checkConfigurationArguments(array $configuration, $argumentsIsArray) @@ -106,6 +109,7 @@ class Builder * Check configuration method arguments * * @param array $configuration + * @return void * @throws \InvalidArgumentException */ protected function _checkMethodArguments(array $configuration) @@ -123,6 +127,7 @@ class Builder * * @param array $configuration * @param bool $callbackIsArray + * @return void * @throws \InvalidArgumentException */ protected function _checkConfigurationCallback(array $configuration, $callbackIsArray) @@ -174,8 +179,8 @@ class Builder * * @param string $alias * @param array $configuration + * @return $this * @throws \InvalidArgumentException - * @return \Magento\Validator\Builder */ public function addConfiguration($alias, array $configuration) { @@ -238,7 +243,7 @@ class Builder * Add constraints configuration * * @param array $configurations - * @return \Magento\Validator\Builder + * @return $this */ public function addConfigurations(array $configurations) { @@ -277,8 +282,8 @@ class Builder * Create constraint validator instance * * @param array $data - * @throws \InvalidArgumentException * @return \Magento\Validator\ValidatorInterface + * @throws \InvalidArgumentException */ protected function _createConstraintValidator(array $data) { @@ -305,6 +310,7 @@ class Builder * * @param \Magento\Validator\ValidatorInterface $validator * @param array $options + * @return void */ protected function _configureConstraintValidator(\Magento\Validator\ValidatorInterface $validator, array $options) { @@ -336,13 +342,13 @@ class Builder /** * Apply all argument callback * - * @param \Magento\Validator\Constraint\OptionInterface[] $arguments - * @return array + * @param OptionInterface[] $arguments + * @return OptionInterface[] */ protected function _applyArgumentsCallback(array $arguments) { foreach ($arguments as &$argument) { - if ($argument instanceof \Magento\Validator\Constraint\OptionInterface) { + if ($argument instanceof OptionInterface) { $argument = $argument->getValue(); } } diff --git a/lib/Magento/Validator/Config.php b/lib/Magento/Validator/Config.php index 0076bab3f237a914fdda5d176c6a83ab56e086ea..c7c51b06c4e28dca4994b47d4051c9d65a50a8c1 100644 --- a/lib/Magento/Validator/Config.php +++ b/lib/Magento/Validator/Config.php @@ -25,6 +25,10 @@ */ namespace Magento\Validator; +use Magento\Validator\Constraint\Option; +use Magento\Validator\Constraint\OptionInterface; +use Magento\Validator\Constraint\Option\Callback; + class Config extends \Magento\Config\AbstractXml { /**#@+ @@ -296,7 +300,7 @@ class Config extends \Magento\Config\AbstractXml * Get arguments. * * @param array $children - * @return array|null + * @return OptionInterface[]|null */ protected function _readArguments($children) { @@ -313,7 +317,7 @@ class Config extends \Magento\Config\AbstractXml $arguments[] = $options; } else { $argument = $node->textContent; - $arguments[] = new \Magento\Validator\Constraint\Option(trim($argument)); + $arguments[] = new Option(trim($argument)); } } @@ -326,7 +330,7 @@ class Config extends \Magento\Config\AbstractXml * Get callback rules. * * @param array $children - * @return array|null + * @return Callback[]|null */ protected function _readCallback($children) { @@ -334,7 +338,7 @@ class Config extends \Magento\Config\AbstractXml $callbacks = array(); /** @var $callbackData \DOMElement */ foreach ($children['callback'] as $callbackData) { - $callbacks[] = new \Magento\Validator\Constraint\Option\Callback(array( + $callbacks[] = new Callback(array( trim($callbackData->getAttribute('class')), trim($callbackData->getAttribute('method')) ), null, true); @@ -348,7 +352,7 @@ class Config extends \Magento\Config\AbstractXml * Get options array. * * @param array $children - * @return array|null + * @return Option|null */ protected function _readOptions($children) { @@ -363,7 +367,7 @@ class Config extends \Magento\Config\AbstractXml $data[] = $value; } } - return new \Magento\Validator\Constraint\Option($data); + return new Option($data); } return null; } diff --git a/lib/Magento/Validator/Constraint/Option.php b/lib/Magento/Validator/Constraint/Option.php index a094062d0dd3186fe47177a188a7004c103e7256..d7ae29bc13815cdb8efec4d73e1a391ed65261aa 100644 --- a/lib/Magento/Validator/Constraint/Option.php +++ b/lib/Magento/Validator/Constraint/Option.php @@ -28,14 +28,14 @@ namespace Magento\Validator\Constraint; class Option implements \Magento\Validator\Constraint\OptionInterface { /** - * @var mixed + * @var int|string|array */ protected $_value; /** * Set value * - * @param mixed $value + * @param int|string|array $value */ public function __construct($value) { @@ -45,7 +45,7 @@ class Option implements \Magento\Validator\Constraint\OptionInterface /** * Get value * - * @return mixed + * @return int|string|array */ public function getValue() { diff --git a/lib/Magento/Validator/Entity/Properties.php b/lib/Magento/Validator/Entity/Properties.php index a35dc7f39aabf3330555bdb2c65c94ba8cdb3d61..50623df96a09e65ec298a3c12465650dd197a4f4 100644 --- a/lib/Magento/Validator/Entity/Properties.php +++ b/lib/Magento/Validator/Entity/Properties.php @@ -25,17 +25,20 @@ */ namespace Magento\Validator\Entity; +use Magento\Object; + class Properties extends \Magento\Validator\AbstractValidator { /** - * @var array + * @var string[] */ protected $_readOnlyProperties = array(); /** * Set read-only properties. * - * @param array $readOnlyProperties + * @param string[] $readOnlyProperties + * @return void */ public function setReadOnlyProperties(array $readOnlyProperties) { @@ -47,14 +50,14 @@ class Properties extends \Magento\Validator\AbstractValidator * * If read-only properties are set than $value mustn't have changes in them. * - * @param \Magento\Object|mixed $value + * @param Object $value * @return bool * @throws \InvalidArgumentException when $value is not instanceof \Magento\Object */ public function isValid($value) { $this->_clearMessages(); - if (!($value instanceof \Magento\Object)) { + if (!($value instanceof Object)) { throw new \InvalidArgumentException('Instance of \Magento\Object is expected.'); } if ($this->_readOnlyProperties) { diff --git a/lib/Magento/View/Asset/GroupedCollection.php b/lib/Magento/View/Asset/GroupedCollection.php index 1425e78c2f44900d390f31d1f5cda616778c0a20..9122d53b2ff0cb4d7ed261ac7aeae421db06a033 100644 --- a/lib/Magento/View/Asset/GroupedCollection.php +++ b/lib/Magento/View/Asset/GroupedCollection.php @@ -64,6 +64,7 @@ class GroupedCollection extends Collection public function add($identifier, AssetInterface $asset, array $properties = array()) { parent::add($identifier, $asset); + $properties = array_filter($properties); $properties[self::PROPERTY_CONTENT_TYPE] = $asset->getContentType(); $properties[self::PROPERTY_CAN_MERGE] = $asset instanceof MergeableInterface; $this->getGroupFor($properties)->add($identifier, $asset); diff --git a/lib/Magento/View/Asset/MergeStrategy/Checksum.php b/lib/Magento/View/Asset/MergeStrategy/Checksum.php index a7eca9114033c0e3839021fd3da925da48b54174..ebfe570e10ad1f9eec9c37597aa131c1f4a76766 100644 --- a/lib/Magento/View/Asset/MergeStrategy/Checksum.php +++ b/lib/Magento/View/Asset/MergeStrategy/Checksum.php @@ -57,13 +57,13 @@ class Checksum implements \Magento\View\Asset\MergeStrategyInterface */ public function mergeFiles(array $publicFiles, $destinationFile, $contentType) { - $mergedMTimeFile = $destinationFile . '.dat'; + $directory = $this->filesystem->getDirectoryWrite(\Magento\App\Filesystem::PUB_DIR); + $mergedMTimeFile = $directory->getRelativePath($destinationFile . '.dat'); // Check whether we have already merged these files $filesMTimeData = ''; - $directory = $this->filesystem->getDirectoryWrite(\Magento\App\Filesystem::ROOT_DIR); foreach ($publicFiles as $file) { - $filesMTimeData .= $directory->stat($file)['mtime']; + $filesMTimeData .= $directory->stat($directory->getRelativePath($file))['mtime']; } if (!($directory->isExist($destinationFile) && $directory->isExist($mergedMTimeFile) && (strcmp($filesMTimeData, $directory->readFile($mergedMTimeFile)) == 0)) diff --git a/lib/Magento/View/Asset/MergeStrategy/FileExists.php b/lib/Magento/View/Asset/MergeStrategy/FileExists.php index abb45162ee575e44358c0521d5d3d33aa85f4e30..69f50c32e80b30a2e71974ca134f62ae3aa24bfa 100644 --- a/lib/Magento/View/Asset/MergeStrategy/FileExists.php +++ b/lib/Magento/View/Asset/MergeStrategy/FileExists.php @@ -56,7 +56,8 @@ class FileExists implements \Magento\View\Asset\MergeStrategyInterface */ public function mergeFiles(array $publicFiles, $destinationFile, $contentType) { - if (!$this->filesystem->getDirectoryRead(\Magento\App\Filesystem::ROOT_DIR)->isExist($destinationFile)) { + $directory = $this->filesystem->getDirectoryRead(\Magento\App\Filesystem::PUB_DIR); + if (!$directory->isExist($directory->getRelativePath($destinationFile))) { $this->strategy->mergeFiles($publicFiles, $destinationFile, $contentType); } } diff --git a/lib/Magento/View/Asset/PreProcessor/PreProcessorInterface.php b/lib/Magento/View/Asset/PreProcessor/PreProcessorInterface.php new file mode 100644 index 0000000000000000000000000000000000000000..f4fd4072a460d4cff0f4c1c8372968e108ff1b5a --- /dev/null +++ b/lib/Magento/View/Asset/PreProcessor/PreProcessorInterface.php @@ -0,0 +1,41 @@ +<?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\View\Asset\PreProcessor; + +/** + * The pre-processors which implement this interface are supposed to publish processed content to the $targetDirectory + * and return the path to the published file (as $sourcePath). + */ +interface PreProcessorInterface +{ + /** + * @param string $filePath + * @param array $params + * @param \Magento\Filesystem\Directory\WriteInterface $targetDirectory + * @param string|null $sourcePath + * @return string + */ + public function process($filePath, $params, $targetDirectory, $sourcePath = null); +} diff --git a/lib/Magento/View/Design/ThemeInterface.php b/lib/Magento/View/Design/ThemeInterface.php index 2fd4cde2fe2fe9a660391da1670c277d116206a7..629a5b2661d6977f34d208c6559e7ecf2d0c78cc 100644 --- a/lib/Magento/View/Design/ThemeInterface.php +++ b/lib/Magento/View/Design/ThemeInterface.php @@ -95,4 +95,11 @@ interface ThemeInterface * @return bool */ public function isPhysical(); + + /** + * Return the full theme inheritance sequence, from the root theme till a specified one + * + * @return ThemeInterface[] Format: array([<root_theme>, ..., <parent_theme>,] <current_theme>) + */ + public function getInheritedThemes(); } diff --git a/lib/Magento/View/Element/AbstractBlock.php b/lib/Magento/View/Element/AbstractBlock.php index 5ba9c9bfd29e5a3d761641c42df0779d0536c52d..214d5c6ab34b519a0cc36bec5c931543b4400b8e 100644 --- a/lib/Magento/View/Element/AbstractBlock.php +++ b/lib/Magento/View/Element/AbstractBlock.php @@ -699,7 +699,6 @@ abstract class AbstractBlock extends \Magento\Object implements BlockInterface $params = array_merge(['_secure' => $this->getRequest()->isSecure()], $params); return $this->_viewUrl->getViewFileUrl($file, $params); } catch (\Magento\Exception $e) { - $this->_logger->logException($e); return $this->_getNotFoundUrl(); } diff --git a/lib/Magento/View/Element/RendererList.php b/lib/Magento/View/Element/RendererList.php new file mode 100644 index 0000000000000000000000000000000000000000..740a9aa89c7b4ec5411bcbb318e2116258931d1a --- /dev/null +++ b/lib/Magento/View/Element/RendererList.php @@ -0,0 +1,65 @@ +<?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\View\Element; + +class RendererList extends AbstractBlock +{ + /** + * Renderer templates cache + * + * @var array + */ + protected $rendererTemplates = array(); + + /** + * Retrieve renderer by code + * + * @param string $type + * @param string $defalut + * @param string $rendererTemplate + * @return bool|AbstractBlock + * @throws \RuntimeException + */ + public function getRenderer($type, $defalut = null, $rendererTemplate = null) + { + /** @var \Magento\View\Element\Template $renderer */ + $renderer = $this->getChildBlock($type) ?: $this->getChildBlock($defalut); + if (!$renderer instanceof BlockInterface) { + throw new \RuntimeException('Renderer for type "' . $type . '" does not exist.'); + } + $renderer->setRenderedBlock($this); + + if (!isset($this->rendererTemplates[$type])) { + $this->rendererTemplates[$type] = $renderer->getTemplate(); + } else { + $renderer->setTemplate($this->rendererTemplates[$type]); + } + + if ($rendererTemplate) { + $renderer->setTemplate($rendererTemplate); + } + return $renderer; + } +} diff --git a/lib/Magento/View/Element/Template.php b/lib/Magento/View/Element/Template.php index 4101ed5e6556f3e8775f76b935de4e36fcb14a75..de5cc66732ac260307b0ef3c30fb110356e597c4 100644 --- a/lib/Magento/View/Element/Template.php +++ b/lib/Magento/View/Element/Template.php @@ -214,11 +214,11 @@ class Template extends AbstractBlock * @param mixed $value * @return \Magento\View\Element\Template */ - public function assign($key, $value=null) + public function assign($key, $value = null) { if (is_array($key)) { - foreach ($key as $k=>$v) { - $this->assign($k, $v); + foreach ($key as $subKey => $subValue) { + $this->assign($subKey, $subValue); } } else { $this->_viewVars[$key] = $value; @@ -236,7 +236,8 @@ class Template extends AbstractBlock { $relativeFilePath = $this->getRootDirectory()->getRelativePath($fileName); \Magento\Profiler::start( - 'TEMPLATE:' . $fileName, array('group' => 'TEMPLATE', 'file_name' => $relativeFilePath) + 'TEMPLATE:' . $fileName, + array('group' => 'TEMPLATE', 'file_name' => $relativeFilePath) ); if ($this->isTemplateFileValid($fileName)) { diff --git a/lib/Magento/View/FileSystem.php b/lib/Magento/View/FileSystem.php index 6b9aa1e110db7867b83441651ea1ab0127a47e08..31509e178e0447ccbcc9c8c41b0840d1d8cbad0b 100644 --- a/lib/Magento/View/FileSystem.php +++ b/lib/Magento/View/FileSystem.php @@ -37,17 +37,17 @@ class FileSystem protected $_resolutionPool; /** - * @var \Magento\View\Service + * @var Service */ protected $_viewService; /** * @param \Magento\View\Design\FileResolution\StrategyPool $resolutionPool - * @param \Magento\View\Service $viewService + * @param Service $viewService */ public function __construct( \Magento\View\Design\FileResolution\StrategyPool $resolutionPool, - \Magento\View\Service $viewService + Service $viewService ) { $this->_resolutionPool = $resolutionPool; $this->_viewService = $viewService; @@ -141,7 +141,7 @@ class FileSystem } else { array_pop($result); } - } else if ('.' !== $part) { + } elseif ('.' !== $part) { $result[] = $part; } } diff --git a/lib/Magento/View/Layout/File.php b/lib/Magento/View/Layout/File.php index acdc47f7291d78f171fb2e6b2ae9f6b8ca446979..bf871b0af35625be15c7abb2ec9b02612b799d27 100644 --- a/lib/Magento/View/Layout/File.php +++ b/lib/Magento/View/Layout/File.php @@ -34,17 +34,22 @@ class File /** * @var string */ - private $filename; + protected $filename; /** * @var string */ - private $module; + protected $module; /** * @var ThemeInterface */ - private $theme; + protected $theme; + + /** + * @var string + */ + protected $identifier; /** * @param string $filename @@ -107,4 +112,18 @@ class File { return is_null($this->theme); } + + /** + * Calculate unique identifier for a layout file + * + * @return string + */ + public function getFileIdentifier() + { + if (null === $this->identifier) { + $theme = ($this->getTheme() ? 'theme:' . $this->theme->getFullPath() : 'base'); + $this->identifier = $theme . '|module:' . $this->getModule() . '|file:' . $this->getName(); + } + return $this->identifier; + } } diff --git a/lib/Magento/View/Layout/File/FileList.php b/lib/Magento/View/Layout/File/FileList.php index 20bdd1cdd2fd97a2128e8c75ecfc0a7172fe4ba6..e1ade158ed0a42b4a8c90e6c942f377db95b27ee 100644 --- a/lib/Magento/View/Layout/File/FileList.php +++ b/lib/Magento/View/Layout/File/FileList.php @@ -25,6 +25,7 @@ namespace Magento\View\Layout\File; use Magento\View\Layout\File; +use Magento\View\Layout\File\FileList\CollateInterface; /** * Unordered list of layout file instances with awareness of layout file identity @@ -34,7 +35,20 @@ class FileList /** * @var File[] */ - private $files = array(); + protected $files = array(); + + /** + * @var CollateInterface + */ + protected $collator; + + /** + * @param CollateInterface $collator + */ + public function __construct(CollateInterface $collator) + { + $this->collator = $collator; + } /** * Retrieve all layout file instances @@ -55,7 +69,7 @@ class FileList public function add(array $files) { foreach ($files as $file) { - $identifier = $this->getFileIdentifier($file); + $identifier = $file->getFileIdentifier(); if (array_key_exists($identifier, $this->files)) { $filename = $this->files[$identifier]->getFilename(); throw new \LogicException( @@ -70,30 +84,9 @@ class FileList * Replace already added layout files with specified ones, checking for identity match * * @param File[] $files - * @throws \LogicException */ public function replace(array $files) { - foreach ($files as $file) { - $identifier = $this->getFileIdentifier($file); - if (!array_key_exists($identifier, $this->files)) { - throw new \LogicException( - "Overriding layout file '{$file->getFilename()}' does not match to any of the files." - ); - } - $this->files[$identifier] = $file; - } - } - - /** - * Calculate unique identifier for a layout file - * - * @param File $file - * @return string - */ - protected function getFileIdentifier(File $file) - { - $theme = ($file->getTheme() ? 'theme:' . $file->getTheme()->getFullPath() : 'base'); - return $theme . '|module:' . $file->getModule() . '|file:' . $file->getName(); + $this->files = $this->collator->collate($files, $this->files); } } diff --git a/lib/Magento/View/Layout/File/FileList/CollateInterface.php b/lib/Magento/View/Layout/File/FileList/CollateInterface.php new file mode 100644 index 0000000000000000000000000000000000000000..79cc7e4e4a23034c67723d51ec1c84a3706caf2e --- /dev/null +++ b/lib/Magento/View/Layout/File/FileList/CollateInterface.php @@ -0,0 +1,40 @@ +<?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\View\Layout\File\FileList; + +/** + * Layout file list collate interface + */ +interface CollateInterface +{ + /** + * Collate layout files + * + * @param \Magento\View\Layout\File[] $files + * @param \Magento\View\Layout\File[] $filesOrigin + * @return \Magento\View\Layout\File[] + */ + public function collate($files, $filesOrigin); +} diff --git a/lib/Magento/View/Layout/File/FileList/Collator.php b/lib/Magento/View/Layout/File/FileList/Collator.php new file mode 100644 index 0000000000000000000000000000000000000000..8e50f97b74f11141c6fb44df4dd8dd8b2dbca282 --- /dev/null +++ b/lib/Magento/View/Layout/File/FileList/Collator.php @@ -0,0 +1,53 @@ +<?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\View\Layout\File\FileList; + +/** + * Layout file list collator + */ +class Collator implements CollateInterface +{ + /** + * Collate layout files + * + * @param \Magento\View\Layout\File[] $files + * @param \Magento\View\Layout\File[] $filesOrigin + * @return \Magento\View\Layout\File[] + * @throws \LogicException + */ + public function collate($files, $filesOrigin) + { + foreach ($files as $file) { + $identifier = $file->getFileIdentifier(); + if (!array_key_exists($identifier, $filesOrigin)) { + throw new \LogicException( + "Overriding layout file '{$file->getFilename()}' does not match to any of the files." + ); + } + $filesOrigin[$identifier] = $file; + } + return $filesOrigin; + } +} diff --git a/lib/Magento/View/Layout/File/FileList/Factory.php b/lib/Magento/View/Layout/File/FileList/Factory.php index 4d0c952c145bc05f145495ceb69f833f6643d7eb..5f8857b75915581e96108505d5aaff3b3d19f63a 100644 --- a/lib/Magento/View/Layout/File/FileList/Factory.php +++ b/lib/Magento/View/Layout/File/FileList/Factory.php @@ -31,10 +31,15 @@ use Magento\ObjectManager; */ class Factory { + /** + * Default file list collator + */ + const FILE_LIST_COLLATOR = 'Magento\View\Layout\File\FileList\Collator'; + /** * @var ObjectManager */ - private $objectManager; + protected $objectManager; /** * @param ObjectManager $objectManager @@ -47,10 +52,14 @@ class Factory /** * Return newly created instance of a layout file list * + * @param string $collator * @return \Magento\View\Layout\File\FileList */ - public function create() + public function create($collator = self::FILE_LIST_COLLATOR) { - return $this->objectManager->create('Magento\View\Layout\File\FileList'); + return $this->objectManager->create( + 'Magento\View\Layout\File\FileList', + array('collator' => $this->objectManager->get($collator)) + ); } } diff --git a/lib/Magento/View/Layout/File/Source/Aggregated.php b/lib/Magento/View/Layout/File/Source/Aggregated.php index bb324e7e8d9503dd138f0a8de13191cf10c9a71c..f7c960ed10aad26ee4ea664265e698a7e50f61bd 100644 --- a/lib/Magento/View/Layout/File/Source/Aggregated.php +++ b/lib/Magento/View/Layout/File/Source/Aggregated.php @@ -36,27 +36,27 @@ class Aggregated implements SourceInterface /** * @var Factory */ - private $fileListFactory; + protected $fileListFactory; /** * @var SourceInterface */ - private $baseFiles; + protected $baseFiles; /** * @var SourceInterface */ - private $themeFiles; + protected $themeFiles; /** * @var SourceInterface */ - private $overrideBaseFiles; + protected $overrideBaseFiles; /** * @var SourceInterface */ - private $overrideThemeFiles; + protected $overrideThemeFiles; /** * @param Factory $fileListFactory @@ -93,27 +93,11 @@ class Aggregated implements SourceInterface $list = $this->fileListFactory->create(); $list->add($this->baseFiles->getFiles($theme, $filePath)); - foreach ($this->getInheritedThemes($theme) as $currentTheme) { + foreach ($theme->getInheritedThemes() as $currentTheme) { $list->add($this->themeFiles->getFiles($currentTheme, $filePath)); $list->replace($this->overrideBaseFiles->getFiles($currentTheme, $filePath)); $list->replace($this->overrideThemeFiles->getFiles($currentTheme, $filePath)); } return $list->getAll(); } - - /** - * Return the full theme inheritance sequence, from the root theme till a specified one - * - * @param ThemeInterface $theme - * @return Theme[] Format: array([<root_theme>, ..., <parent_theme>,] <current_theme>) - */ - protected function getInheritedThemes(ThemeInterface $theme) - { - $result = array(); - while ($theme) { - $result[] = $theme; - $theme = $theme->getParentTheme(); - } - return array_reverse($result); - } } diff --git a/lib/Magento/Xml/Generator.php b/lib/Magento/Xml/Generator.php index 77271ff8143c4c2ff9236dce5a53d55140b07d2d..4da87b191ace59d51ec935e8767224758fec4aa7 100644 --- a/lib/Magento/Xml/Generator.php +++ b/lib/Magento/Xml/Generator.php @@ -32,7 +32,10 @@ class Generator */ const DEFAULT_ENTITY_ITEM_NAME = 'item'; + /** @var \DOMDocument|null */ protected $_dom = null; + + /** @var \DOMDocument */ protected $_currentDom; /** @var string */ @@ -46,16 +49,26 @@ class Generator return $this; } + /** + * @return \DOMDocument|null + */ public function getDom() { return $this->_dom; } + /** + * @return \DOMDocument + */ protected function _getCurrentDom() { return $this->_currentDom; } + /** + * @param \DOMDocument $node + * @return $this + */ protected function _setCurrentDom($node) { $this->_currentDom = $node; @@ -63,8 +76,9 @@ class Generator } /** - * @param array $content - */ + * @param array $content + * @return $this + */ public function arrayToXml($content) { $parentNode = $this->_getCurrentDom(); @@ -110,11 +124,18 @@ class Generator return $this; } + /** + * @return string + */ public function __toString() { return $this->getDom()->saveXML(); } + /** + * @param string $file + * @return $this + */ public function save($file) { $this->getDom()->save($file); @@ -124,8 +145,8 @@ class Generator /** * Set xml node name to use instead of numeric index during numeric arrays conversion. * - * @param $name - * @return \Magento\Xml\Generator + * @param string $name + * @return $this */ public function setIndexedArrayItemName($name) { diff --git a/lib/Magento/Xml/Parser.php b/lib/Magento/Xml/Parser.php index e249d03f65c7d2918cad075bcc9625a3e42e05fc..1ad76b8dc8dc5ed8871faf85e90a4d746e0ba690 100644 --- a/lib/Magento/Xml/Parser.php +++ b/lib/Magento/Xml/Parser.php @@ -28,8 +28,13 @@ namespace Magento\Xml; class Parser { + /** @var \DOMDocument|null */ protected $_dom = null; + + /** @var \DOMDocument */ protected $_currentDom; + + /** @var array */ protected $_content = array(); public function __construct() @@ -39,28 +44,45 @@ class Parser return $this; } + /** + * @return \DOMDocument|null + */ public function getDom() { return $this->_dom; } + /** + * @return \DOMDocument + */ protected function _getCurrentDom() { return $this->_currentDom; } + /** + * @param \DOMDocument $node + * @return $this + */ protected function _setCurrentDom($node) { $this->_currentDom = $node; return $this; } + /** + * @return array + */ public function xmlToArray() { $this->_content = $this->_xmlToArray(); return $this->_content; } + /** + * @param bool $currentNode + * @return array + */ protected function _xmlToArray($currentNode=false) { if (!$currentNode) { @@ -103,12 +125,20 @@ class Parser return $content; } + /** + * @param string $file + * @return $this + */ public function load($file) { $this->getDom()->load($file); return $this; } + /** + * @param string $string + * @return $this + */ public function loadXML($string) { $this->getDom()->loadXML($string); diff --git a/pub/get.php b/pub/get.php index 08b92be30929ead964f18b73bc4d779220eb781e..e23bae7b7e630702a989b86ffe8e3f23bead67ba 100644 --- a/pub/get.php +++ b/pub/get.php @@ -77,7 +77,7 @@ if ($mediaDirectory) { $params = $_SERVER; if (empty($mediaDirectory)) { $params[\Magento\Core\Model\App::PARAM_ALLOWED_MODULES] = array('Magento_Core'); - $params[\Magento\Core\Model\App::PARAM_CACHE_OPTIONS]['frontend_options']['disable_save'] = true; + $params[\Magento\Core\Model\App::PARAM_CACHE_FORCED_OPTIONS]['frontend_options']['disable_save'] = true; } $entryPoint = new \Magento\App\EntryPoint\EntryPoint(dirname(__DIR__), $params);